这是一个老问题,但我遇到了这个问题并这样做了:
我有一个编辑器(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();
}
}
}