Plug-ins can also define marker resolutions, so that their markers can participate in the workbench Quick Fix... feature. Users can select a marker and choose Quick Fix... from the popup menu if there is a resolution contributed for the marker.
Marker resolutions are contributed using the org.eclipse.ui.markerResolution extension point. This extension point allows plug-ins to associate a class that implements IMarkerResolutionGenerator with a particular type of marker. The marker can be qualified by marker type only, or it can be further qualified by the value of one or more of its attributes. The readme tool declares several different marker resolutions:
<extension point="org.eclipse.ui.markerResolution"> <markerResolutionGenerator class="org.eclipse.ui.examples.readmetool.ReadmeMarkerResolutionGenerator" markerType="org.eclipse.ui.examples.readmetool.readmemarker"> <attribute name="org.eclipse.ui.examples.readmetool.id" value= "1234"/> </markerResolutionGenerator> <markerResolutionGenerator class="org.eclipse.ui.examples.readmetool.ReadmeMarkerResolutionGenerator" markerType="org.eclipse.ui.examples.readmetool.readmemarker"> <attribute name="org.eclipse.ui.examples.readmetool.level" value= "7"/> </markerResolutionGenerator> <markerResolutionGenerator class="org.eclipse.ui.examples.readmetool.ReadmeMarkerResolutionGenerator" markerType="org.eclipse.ui.examples.readmetool.readmemarker"> <attribute name="org.eclipse.ui.examples.readmetool.code" value= "red"/> <attribute name="org.eclipse.ui.examples.readmetool.language" value= "english"/> </markerResolutionGenerator> </extension>
Each marker resolution generator is defined for the readme marker type, but associated with a different combination of attribute values. The first marker resolution generator will be used for markers whose id attribute is set to "1234". In this particular example, the readme tool uses the same marker resolution generator for all cases. This is not typical, but makes sense in a case where there is only one resolution available for specific combinations of attribute values.
The marker resolution generator is responsible for returning an array of marker resolutions (IMarkerResolution) that will be shown in the Quick Fix... dialog. The resolution will be run() if the user selects it in the dialog. Here is the implementation from ReadmeMarkerResolutionGenerator:
public class ReadmeMarkerResolutionGenerator implements IMarkerResolutionGenerator { public IMarkerResolution[] getResolutions(IMarker marker) { return new IMarkerResolution[] {new AddSentenceResolution()}; } }
The AddSentenceResolution defines the resolution's dialog label and implements the resolution itself.