2013-04-15 56 views
1

我想在我创建的新编辑器上切换断点。我有一个新的编辑器和一个新的LineBreakpoint实施和运行。 >运行 - - >切换行断点我已经可以用按Ctrl ++或主菜单切换这些断点。我希望能够在我的自定义Eclipse应用程序的垂直标尺栏中添加Java编辑器中相同的切换行为。也就是说,双击创建/切换给定线位置的断点。然后右键点击切换断点菜单上下文(在垂直标尺栏上)。也完成线切换图像标签。在Eclipse RCP中切换自定义编辑器的断点?

我假设有一个简单的方法来做到这一点,而不是实现每个菜单和动作。如果不是,我该如何将这些双击和上下文菜单添加到自定义编辑器的垂直标尺中?

回答

0

我期待着做同样的事情。到目前为止,我发现扩展AbstractDecoratedTextEditor将为您提供执行此操作的平台。我将在工作时更新。

0

这是一个老问题,但我有这个问题,这样做:

我有一个编辑器(org.eclipse.ui.texteditor.AbstractDecoratedTextEditor)。在此编辑器类我实现了这个方法:

@Override 
protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler) { 
    AnnotationRulerColumn column = new MyAnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess(), this); 
    return column; 
} 

和类MyAnnotationRulerColumn被有些人认为这样的:

import org.eclipse.debug.ui.actions.ToggleBreakpointAction; 
import org.eclipse.jface.text.source.AnnotationRulerColumn; 
import org.eclipse.jface.text.source.IAnnotationAccess; 
import org.eclipse.jface.text.source.IVerticalRulerInfo; 

public class MyAnnotationRulerColumn extends AnnotationRulerColumn { 

    private MyEditor editor; 

    public MyAnnotationRulerColumn(int width, IAnnotationAccess annotationAccess, MyEditor part) { 
     super(width, annotationAccess); 
     this.editor = part; 
    } 

    @Override 
    protected void mouseDoubleClicked(int rulerLine) { 
     if (editor != null) { 
      IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) editor.getAdapter(IVerticalRulerInfo.class); 
      ToggleBreakpointAction action = new ToggleBreakpointAction(editor, null, rulerInfo); 
      action.update(); 
      action.run(); 
     } 
    } 

} 
相关问题