Eclipse plugin: Custom icon for a Marker(Eclipse 插件:标记的自定义图标)
问题描述
我想为标记指定一个自定义图标.很遗憾,我选择的图标没有显示出来.
I want to specify a custom icon for a marker. Sadly, the icon that I chose is not displayed.
这里是 plugin.xml 文件的相关部分(项目 id x"):
Here's the relevant parts of the plugin.xml file (the project 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()
方法没有被调用.
I also tried specifying a class (implementing IMarkerImageProvider
) instead of an icon, but that getImagePath()
method of the class does not get called.
对如何使自定义标记图标起作用有什么想法吗?
Any thoughts on how to make custom marker icons work?
非常感谢,你的.
-伊泰
更新
VonC 的解决方案非常正确,除了您必须不 指定 org.eclipse.core.resources.problemmarker
作为标记的超类型.它仅在我使用 org.eclipse.core.resources.textmarker
作为 only 超类型时才有效.
VonC's solution is pretty much correct, except that you must not specify org.eclipse.core.resources.problemmarker
as a supertype of your marker. It worked only when I used org.eclipse.core.resources.textmarker
as the only supertype.
推荐答案
参见错误 260909 markerImageProviders 扩展点不起作用"(在阅读this thread后发现)
See bug 260909 "markerImageProviders extension point does not work" (found after reading this thread)
Tod Creasey 2009-01-21 07:32:38 EST
Tod Creasey 2009-01-21 07:32:38 EST
我们从来没有推动过制作这个 API,因为它有一些不灵活,使其通常不能使用 - 它是早期编写的,用于为我们使用的 3 个严重性启用第一个标记视图,因此未被markerSupport 因为它不是 API.
We have never had the push to make this API because it has some inflexibility that made it generally not consumable - it was written early on to enable the first marker views for the 3 severities we use and as a result was not used by the markerSupport as it was not API.
令人困惑的是我们有一个内部扩展点(我们通常不这样做那)但删除它可能会在没有警告的情况下破坏某人.
It is confusing that we have an internal extension point (we don't generally do that) but removing it would likely break someone without warning.
[Itay 编辑]
按照 Vonc 的指示,我最终设法使这件事发挥作用.以下是我的 plugin.xml
中的相关片段(假设插件名称为 a.b.c
)
Following on Vonc's pointers, I eventually managed to make this thing work.
Here are the relevant fragments from my plugin.xml
(assuming the plugin name is a.b.c
)
<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 文件(或插件编辑器的build"选项卡)中指定了图标文件夹
- 上面的声明只会指定一个自定义图标.如果您想自定义其他属性(概览标尺上的指示颜色等),请遵循 here 此解决方案所基于的.
- The super type of the marker must be set to
org.eclipse.core.resources.textmarker
. Any other value will prevent your custom icon from being used. - When you create a marker in your code make sure its severity matches the severity value specified in the
markerSeverity
attribute at theorg.eclipse.ui.editors.annotationTypes
extension point.1
means warning, etc. - Make sure the icons folder is specified in your build.properties file (or the "build" tab at the plugin editor)
- The declaration above will only specify a custom icon. If you want to customize other attributes (color of indication at the overview ruler, etc.) follow the sample from here on which this solution is based.
这篇关于Eclipse 插件:标记的自定义图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Eclipse 插件:标记的自定义图标
基础教程推荐
- 降序排序:Java Map 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01