繁体   English   中英

Eclipse插件:标记的自定义图标

[英]Eclipse plugin: Custom icon for a Marker

我想为标记指定自定义图标。 可悲的是,我没有显示我选择的图标。

这是plugin.xml文件的相关部分(项目ID“x”):

<extension
      id="xmlProblem"
      name="XML Problem"
      point="org.eclipse.core.resources.markers">
   <super type="org.eclipse.core.resources.problemmarker"/>
   <persistent
         value="true">
   </persistent>
</extension>

<extension
      point="org.eclipse.ui.ide.markerImageProviders">
   <imageprovider
         markertype="x.xmlProblem"
         icon="icons/marker.png"
         id="xmlProblemImageProvider">
   </imageprovider>
</extension>

我也尝试指定一个类(实现IMarkerImageProvider )而不是图标,但是不会调用该类的getImagePath()方法。

有关如何使自定义标记图标工作的任何想法?

绝望地,你的。

-Itay

更新

VonC的解决方案非常正确,除了您不能org.eclipse.core.resources.problemmarker指定为标记的超类型。 它只在我使用org.eclipse.core.resources.textmarker作为唯一的超类型时才有用。

请参阅错误260909 “markerImageProviders扩展点无法正常工作”(在阅读此主题后找到)

Tod Creasey 2009-01-21 07:32:38 EST

我们从来没有努力制作这个API,因为它有一些不灵活性,使它通常不会消耗 - 它是早期编写的,为我们使用的3个严重性启用第一个标记视图,因此markerSupport没有使用它它不是API。

令人困惑的是,我们有一个内部扩展点(我们通常不这样做),但删除它可能会在没有警告的情况下打破某人。

[由Itay编辑]

根据Vonc的指示,我最终成功地完成了这项工作。 以下是我的plugin.xml中的相关片段(假设插件名称为abc

  <extension point="org.eclipse.core.resources.markers"   
        id="myMarker">
     <super type="org.eclipse.core.resources.textmarker"/>         
     <persistent value="true"/>
  </extension>

  <extension point="org.eclipse.ui.editors.annotationTypes">
     <type
        super="org.eclipse.ui.workbench.texteditor.warning"
        markerType="a.b.c.myMarker"
        name="a.b.c.myAnnotation"
        markerSeverity="1"/>
  </extension>

  <extension point="org.eclipse.ui.editors.markerAnnotationSpecification">
     <specification
        annotationType="a.b.c.myAnnotation"
        icon="icons/marker.png"
        verticalRulerPreferenceKey="myMarkerIndicationInVerticalRuler"
        verticalRulerPreferenceValue="true"/>
  </extension>

陷阱

  • 必须将标记的超类型设置为org.eclipse.core.resources.textmarker 任何其他值都将阻止您使用自定义图标。
  • 在代码中创建标记时,请确保其严重性与org.eclipse.ui.editors.annotationTypes扩展点的markerSeverity属性中指定的严重性值相匹配。 1表示警告等
  • 确保在build.properties文件中指定了icons文件夹(或插件编辑器中的“build”选项卡)
  • 上面的声明只会指定一个自定义图标。 如果您想自定义其他属性(在概述标尺显示的颜色等)遵循从样品这里上该解决方案为基础的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM