Eclipse icon

Working with Markers

You can choose to reuse the markers defined as part of Eclipse or define your own. New marker types can either build on existing maker definitions and behavior, or be implemented as specialized markers where all behavior is implemented as part of your tool logic.

This marker example defines a new marker type (com.ibm.lab.soln.resource.recentEdits) that builds on both the existing Eclipse bookmark and problem marker types. This means that this kind of marker will automatically be visible in the Bookmarks and Tasks views. The recentEdit markers are created for resources that have been recently modified.

The plug-in also extends the org.eclipse.ui.startup extension point so that it may add the resource change listener used to create recent edit markers.

The plugin.xml defines the marker extensions and the code is provided in the com.ibm.lab.soln.resources.markers package.

Running the Solution

To run the example, launch the run-time instance of Eclipse (Run > Run As > Run-time Workbench).

  1. The recentEdits marker logic has default processing rules, but if the com.ibm.lab.soln.dialogs project is available, these rules can be modified. If you have the com.ibm.lab.soln.dialogs project loaded, you can open the Soln: Basic Preference Page and view or modify the setting that determines how many recentEdits markers to keep active and if these recentEdits markers should be saved in the workspace (custom logic will use the IMarker.TRANSIENT attribute to override the <persistent value="true" /> setting in the marker extension):


    If the com.ibm.lab.soln.dialogs plug-in is not available, a hard-coded value of four is used as the recentEdits marker limit and the marker extension definition is used to determine if the marker is persistent.

  2. The com.ibm.lab.soln.resources plug-in includes an org.eclipse.ui.startup extension, this means the plug-in starts when Eclipse starts. Because of this you may already have recentEdits markers showing in the Bookmarks and Tasks views:


    Note: If the display of the recentEdits markers in the Tasks view is bothersome, you have two choices:

    This change will remove the recentEdit markers from the Tasks view. They will only be shown in the Bookmarks view.

  3. If you do not have any recentEdits markers showing, then open a file in your workspace and then edit/save the file. If you open/save enough files, you will reach the maximum number of recentEdits markers that can be saved. The oldest marker is deleted to make room for a new marker.

    A resource change listener (RecentEditsRCL) is used to detect file modifications and the RecentEdits class manages the recentEdits markers.

  4. The recentEdit marker support can also be disabled for individual files. If you have the com.ibm.lab.soln.dialogs project loaded, you can open the properties page Soln: File Properties, and view or modify the setting that determines if a recentEdits marker will be created for the file:

    When selected, the exclude setting will cause the recent edits listener to ignore this file during add marker processing.

Roadmap to the Solution

This example includes a marker extension and several pop-up action contributions that demonstrate how natures and builders can be used to customize projects and process resources. the use of the workspace API. The extension definition can be found in the plugin.xml. The classes that use this extension are shown below.

Extension / Object Implementation
Marker extension:
recentEdits
A marker is defined; there is no implementation class.
Resource Change Listener The resource change listener is implemented by the RecentEditsRCL class.
Recent Edits Manager The recent edits manager is implemented by the RecentEdits class.

When the nature is configured as part of a project it adds the builder. The builder implements a simple resource transformation by reacting to new or modified .readme files and creating associated .html files. This processing is implemented by the ReadmeVisitor class.

© Copyright International Business Machines Corporation, 2003.
All rights reserved.