日食标记是不可见的
我在添加自定义 Eclipse 标记时遇到一个奇怪的问题。场景是,在添加标记时,当资源(我需要添加标记)打开时,标记图标可见。但是,如果资源未打开,则会添加标记,但图标不可见。
这是我正在使用的代码片段
<extension
id="HighPriority"
name="High Priority problem"
point="org.eclipse.core.resources.markers">
<persistent value="true">
</persistent>
<super type="org.eclipse.core.resources.problemmarker"/>
<super type="org.eclipse.core.resources.textmarker"/>
</extension>
<extension point="org.eclipse.ui.editors.annotationTypes">
<type
name="X.X.X.HighPriorityAnnotation"
super="org.eclipse.ui.workbench.texteditor.warning"
markerType="X.X.X.HighPriority"/>
</extension>
<extension point="X.X.X.markerAnnotationSpecification">
<specification
annotationType="X.X.X.HighPriorityAnnotation"
icon="icons\img.gif"
/>
</extension>
,用于创建标记的代码是
IMarker marker = markerNode.getTargetFile().createMarker(markerNode.getPriority().getMarkerName());
Map<String, Object> attributes = new HashMap<String,Object>();
attributes.put(IMarker.LINE_NUMBER, markerNode.getLineNumber());
attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING));
attributes.put(IMarker.MESSAGE, markerNode.getMessage());
attributes.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_HIGH));
marker.setAttributes(attributes);
打开编辑器,我使用以下代码,
IDE.openEditor(this.getSite().getPage(), marker, OpenStrategy.activateOnOpen());
打开编辑器时我还需要执行其他操作吗?
有什么建议...???
I am facing a strange problem while adding custom eclipse marker. The scenario is that while adding marker, when a resource(To which I need to add marker) is open then Marker icon is visible. But if the resource is not open then marker is added but icon is not visible.
Here is a snippet of code I am using
<extension
id="HighPriority"
name="High Priority problem"
point="org.eclipse.core.resources.markers">
<persistent value="true">
</persistent>
<super type="org.eclipse.core.resources.problemmarker"/>
<super type="org.eclipse.core.resources.textmarker"/>
</extension>
<extension point="org.eclipse.ui.editors.annotationTypes">
<type
name="X.X.X.HighPriorityAnnotation"
super="org.eclipse.ui.workbench.texteditor.warning"
markerType="X.X.X.HighPriority"/>
</extension>
<extension point="X.X.X.markerAnnotationSpecification">
<specification
annotationType="X.X.X.HighPriorityAnnotation"
icon="icons\img.gif"
/>
</extension>
And code for creating marker is
IMarker marker = markerNode.getTargetFile().createMarker(markerNode.getPriority().getMarkerName());
Map<String, Object> attributes = new HashMap<String,Object>();
attributes.put(IMarker.LINE_NUMBER, markerNode.getLineNumber());
attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING));
attributes.put(IMarker.MESSAGE, markerNode.getMessage());
attributes.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_HIGH));
marker.setAttributes(attributes);
To open editor I using following code
IDE.openEditor(this.getSite().getPage(), marker, OpenStrategy.activateOnOpen());
Do I need to do anything else while opening editor??
Any Suggestions...???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将您的代码与应该正常工作的代码进行比较,如 中发布的错误 73420。
那个旧错误(eclipse 3.1)的上下文与您的不同,但可以为您提供一些关于尝试什么的线索或想法。
您使用的 Eclipse 和 Java 版本是什么?
该错误报告摘录:
You can compare your code with ones supposed to work fine, as posted in bug 73420.
The context of that old bug (eclipse 3.1) is not the same than yours, but can give you some clue or idea about what to try.
What Eclipse and Java version are you using?
Extract from that bug report:
早些时候我已经将我的代码付诸行动。但是在我用项目构建器替换它之后,它开始工作......
我不知道出了什么问题......:)
Earlier I have dumped my code into action. But after I have replaced it with a project builder it started working...
I dont have clue what went wrong.. :)