2013-03-04 51 views
2

我正在开发一个Eclipse插件,它在Eclipse自己的AbstractTextEditor中显示自定义多行标记。Eclipse:如何在VerticalRuler上自定义绘画标记

这是我到目前为止有:

  • 具有超强型 “org.eclipse.core.resources.textmarker”
  • 的annotationType(org.Eclipse.ui.editors的自定义标记。 annotationTypes)
  • 一个markerAnnotationSpecification(org.eclipse.ui.editors.markerAnnotationSpecification)

这一切运作良好,我的标记在编辑器中显示出来。但是我需要定制它们在VerticalRuler上绘制的方式,因此它们不仅显示为图标,而且显示为跨越受影响的源代码行的垂直线。

我知道,这可以通过实现IAnnotationPresentation和覆盖paint()与注释完成。

但是我怎样才能做到这一点的标记?

编辑:这里是什么,我想实现一个截图:

Red bars on the left

+0

“但是作为跨越受影响的源代码行的垂直线。”你什么意思?你能张贴描述你的问题的截图吗? – aphex 2013-03-05 07:55:23

回答

1

我解决了这个由贡献了RulerColumn(扩展点org.eclipse.ui.workbench.texteditor.rulerColumns)和配置markerAnnotationSpecification包括verticalRulerPreferenceKeyverticalRulerPreferenceValue(所以它不会显示在默认的AnnotationRulerColumn上)。

万一有人还发现,就如何最好地实现IContributedRulerColumn有点稀疏的文档:它似乎走的路是继承AbstractContributedRulerColumn并有方法委托的AbstractRulerColumn一个子类。

例如:

public class MyRulerColumn extends AbstractContributedRulerColumn { 
    private IVerticalRulerColumn delegate = new AbstractRulerColumn() { … } 
    public void setModel(IAnnotationModel model) { 
     delegate.setModel(model); 
    } 
    … 
} 

定制外观是那么容易,因为覆盖涂料的一个......在委托方法。