how to create a custom IMarker with a custom icon? [message #1067043] |
Fri, 05 July 2013 11:05  |
Eclipse User |
|
|
|
I understand that the org.eclipse.core.resources.markers extension point will allow me to create a custom marker, which I can then instantiate as follows:
IMarker marker = resource.createMarker("com.my.custom.marker");
marker.setAttribute("myAttribute", "x");
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
marker.setAttribute(IMarker.LOCATION, "1");
marker.setAttribute(IMarker.LINE_NUMBER, 1);
marker.setAttribute(IMarker.DONE, true);
That works great, with the exception that the only "custom" markers I know how to create would be either custom "problem", "bookmark", "task" or "text" markers, which would then inherit the corresponding icons.
My objective is to create markers with custom icons.
Is there a simple way to do accomplish this or would it be a major hack probably not worth the trouble?
|
|
|
|
|
Re: how to create a custom IMarker with a custom icon? [message #1092436 is a reply to message #1074956] |
Thu, 22 August 2013 16:00  |
Eclipse User |
|
|
|
This may not be the only way to do it, but I added a custom icon to my marker by using the markerAnnotationSpecification extension point:
<extension
id="my.marker"
name="Testing Marker"
point="org.eclipse.core.resources.markers">
<super type="org.eclipse.core.resources.textmarker"/>
<persistent value="true"/>
</extension>
<extension
id="my.annotationType"
name="Testing Marker Annotation"
point="org.eclipse.ui.editors.annotationTypes">
<type
markerType="my.marker"
name="my.annotationType">
</type>
</extension>
<extension
point="org.eclipse.ui.editors.markerAnnotationSpecification"
id="my.annotationSpec">
<specification
annotationType="my.annotationType"
includeOnPreferencePage="true"
overviewRulerPreferenceKey="clruler"
label="Testing"
icon="lib/mycustomicon.ico"
overviewRulerPreferenceValue="true"
highlightPreferenceKey="highlight.background"
highlightPreferenceValue="true"
colorPreferenceKey="clcolor"
colorPreferenceValue="0,255,0"
textPreferenceKey="cltext"
textPreferenceValue="true"
presentationLayer="0"
verticalRulerPreferenceKey="clvertical"
verticalRulerPreferenceValue="true"
textStylePreferenceKey="clstyle"
textStylePreferenceValue="BOX">
</specification>
</extension>
Hope this helps.
[Updated on: Thu, 22 August 2013 16:01] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.24795 seconds