Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » how to create a custom IMarker with a custom icon?(org.eclipse.core.resources.IMarker)
how to create a custom IMarker with a custom icon? [message #1067043] Fri, 05 July 2013 15:05 Go to next message
John Smith is currently offline John SmithFriend
Messages: 3
Registered: July 2013
Junior Member
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 #1069142 is a reply to message #1067043] Mon, 15 July 2013 08:51 Go to previous messageGo to next message
Sumeet J is currently offline Sumeet JFriend
Messages: 2
Registered: July 2013
Junior Member
You should be able to make customizations using the IMarker interface . Ideally there are much more marker types than what you describe above . Maybe one of them will fit the type for which you need a marker . See here for all the categories http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fcore%2Fresources%2FIMarker.html

Regarding your question of whether it is possible to associate a different icon to a custom icon I think it may be possible(not 100% sure) . See the section ``Marker representation in the platform`` in the first link given below . However the exact way to do you will have to figure it out yourself Very Happy .

http://eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html

Note:
There is also blog which i am unable to post because i have less than 5 messages ( some forum restrcition) If you really need it let me know .

Re: how to create a custom IMarker with a custom icon? [message #1074956 is a reply to message #1067043] Sun, 28 July 2013 08:50 Go to previous messageGo to next message
Luke Swart is currently offline Luke SwartFriend
Messages: 1
Registered: June 2013
Junior Member
You will need to create a custom view that will be applied to your marker type. Example:

<extension
point="org.eclipse.ui.views">
<view
class="com.eclipse_tips.markers.MyCustomMarkersView"
icon="icons/sample.gif"
id="com.eclipse-tips.markers.customMarker"
name="My Custom Markers">
</view>
</extension>

As shown above, the "icon" is your custom icon image and "id" is your custom marker id.

You may find this blogpost helpful: (since I can't submit links due to low posts, google "prakash creating a custom marker view" and it should be the first one.

Check out custom view type here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fworkbench_basicext_views.htm[/url]


Another useful link about annotation types here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_editors_annotationTypes.html
Re: how to create a custom IMarker with a custom icon? [message #1092436 is a reply to message #1074956] Thu, 22 August 2013 20:00 Go to previous message
Kevin Regan is currently offline Kevin ReganFriend
Messages: 33
Registered: May 2013
Member
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 20:01]

Report message to a moderator

Previous Topic:UI not listing contents of Eclipse software site
Next Topic:Get File name or list of Files names as resources in plugin with specfic extension
Goto Forum:
  


Current Time: Fri Dec 19 01:47:40 GMT 2014

Powered by FUDForum. Page generated in 0.01585 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software