Ramg
Ramg

Reputation: 160

Eclipse Custom Marker View

I am trying to create a customized marker view. In this view I want to restrict/filter the resources to selected project only. This project name will be supplied dynamically.

For e.g, in the context menu from project explorer, the user will be given option to open the Custom Marker View.

If the user chooses the Custom Marker View from project1, the view should show only the markers of the project1.

Any suggestions?

Upvotes: 2

Views: 1653

Answers (1)

aphex
aphex

Reputation: 3412

I've done something similar. At first define a View in your plugin.xml the corresponding class must extend MarkerSupportView. Something like this:

public class MarkerView extends MarkerSupportView {

public MarkerView() {
    super("com.example.markerEventContentGenerator"); //$NON-NLS-1$

}
}

Then you need to define the columns in your new view and what kind of markers have to be shown. Here is an example from plugin.xml.

 <extension
   point="org.eclipse.ui.ide.markerSupport">
<markerContentGenerator
      id="com.example.markerEventContentGenerator"
      name="Custom Marker View">
    <markerTypeReference 
     id="com.example.myMarker"/>
</markerContentGenerator>
<markerField
      class="com.example.fields.NameMarkerField"
      id="com.example.field.name"
      name="Name">
</markerField>
</extension>

The NameMarkerField class must extend MarkerField. Another dummy example:

public class AnnotationNameMarkerField extends MarkerField {

public AnnotationNameMarkerField() {
    super();
}

@Override
public String getValue(final MarkerItem item) {
    return "Dummy Name";
}

/*
 * (non-Javadoc)
 *
 * @see
 * org.eclipse.ui.views.markers.MarkerField#getDefaultColumnWidth(org.eclipse
 * .swt.widgets.Control)
 */
@Override
public int getDefaultColumnWidth(final Control control) {
    return 400;
}
}

Now you have to decide how to create your project specific markers with id="com.example.myMarker".

Upvotes: 2

Related Questions