Search code examples
eclipseeclipse-plugineclipse-pde

How to set custom markers to custom view?


I have created eclipse plugin where I am in need of Custom marker view. I have created a view and created a my own markers and I need to have 4 columns in my view named location,resource, value,method name .I Don't get the custom fields like value and method name in the output view onlu default columns like location resource are comming.

Plugin.xml:

<extension
     id="com.test.plugin.markers"
     name="Test Markers"
     point="org.eclipse.core.resources.markers">
  <persistent
        value="true">
  </persistent>
  <super
        type="org.eclipse.core.resources.textmarker">
  </super>
  <attribute
        name="Name">
  </attribute>
  </extension>

  <!--creating new view for displaying the markers --> 
  <extension 
   point="org.eclipse.ui.views"> 
  <view 
     class="marker.handlers.CustomMarkerView" 
     icon="icons/sample.gif" 
     id="com.test.customMarker" 
     name="Test Markers View"> 
  </view> 
 </extension >

  <extension  point="org.eclipse.ui.ide.markerSupport"> 
  <markerContentGenerator 
   id="com.test.customMarkerGenerator" name="Custom Marker View">      
  <markerTypeReference 
     id="com.test.plugin.markers"/>   
 <markerFieldReference 
     id="org.eclipse.ui.ide.locationField"/>  
  <markerFieldReference 
     id="org.eclipse.ui.ide.resourceField"/>
<markerFieldReference 
     id="com.test.value"/> <markerFieldReference 
     id="com.test.methodname"/> 
 </markerContentGenerator>

 <markerField
  class="marker.handlers.MethodName"
  id="com.test.methodname"
  name="Method Name">
</markerField>

 <markerField
  class="marker.test.Value"
  id="com.test.value"
  name="Value">
 </markerField>
</extension>

CustomMarkerView.java :

public class CustomMarkerView extends MarkerSupportView {

public CustomMarkerView() {
    super("com.testcustomMarkerGenerator");

}
}

MethodName.java

 public class Names extends MarkerField {

  public Names() {
    super();
  }

  public String getValue(MarkerItem item) { 
     return item.getMarker().getResource().getProject().getName(); 
  }
}

But the methodname and values are not comming in the display and how can i add my custom marker into teh custom view?


Solution

  • Finally I found the problem, Its with my code. I created the Custom Field

    <markerField
      class="marker.handlers.MethodName"
      id="com.test.methodname"
      name="Method Name">
    

    after the markerContentGenerator If we put the markerField before the markerContentGenerator the custom fields displays in the view.

    Thanks.