Class AbstractMarkerAnnotationModel
- All Implemented Interfaces:
IPersistableAnnotationModel,ISynchronizable,IAnnotationModel,IAnnotationModelExtension,IAnnotationModelExtension2
- Direct Known Subclasses:
ResourceMarkerAnnotationModel
Markers are provided by an underlying source (a subclass responsibility). Markers whose textual
range gets deleted during text editing are removed from the model on save. The
updateMarkers(IDocument) method can be used to force the model to update the source's
markers with any changes to their locations due to edits. Clients can register a
IMarkerUpdater objects in order to define the process of marker
updating. Registration can be done using the "org.eclipse.ui.markerUpdaters"
extension point.
Subclasses must implement the following methods:
retrieveMarkersisAcceptabledeleteMarkerslistenToMarkerChanges
-
Field Summary
Fields inherited from class org.eclipse.jface.text.source.AnnotationModel
fAnnotationModelListeners, fAnnotations, fDocument -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new annotation model. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddMarkerAnnotation(IMarker marker) Creates an annotation for the given marker and adds it to this model.protected voidaddMarkerUpdater(IMarkerUpdater markerUpdater) Adds the given marker updater to this annotation model.voidTransforms the current transient state of the annotation model into a persistent state.protected voidConnects to the source of markers as marker change listener.protected MarkerAnnotationcreateMarkerAnnotation(IMarker marker) Creates a new annotation for the given marker.protected PositioncreatePositionFromMarker(IMarker marker) Creates and returns the character position of the given marker based on its attributes.protected abstract voiddeleteMarkers(IMarker[] markers) Deletes the given markers from this model.protected voidRemoves the marker change listener.final MarkerAnnotationgetMarkerAnnotation(IMarker marker) Returns this model's annotation for the given marker.getMarkerPosition(IMarker marker) Returns the position known to this annotation model for the given marker.protected voidhandleCoreException(CoreException exception, String message) Handles an unanticipatedCoreExceptionin a standard manner.protected abstract booleanisAcceptable(IMarker marker) Determines whether the marker is acceptable as an addition to this model.protected abstract voidlistenToMarkerChanges(boolean listen) Tells the model whether it should listen for marker changes.protected voidmodifyMarkerAnnotation(IMarker marker) Updates the annotation corresponding to the given marker which has changed in some way.voidreinitialize(IDocument document) Forces this annotation model to re-initialize from the persistent state.protected voidremoveAnnotations(List<? extends Annotation> annotations, boolean fireModelChanged, boolean modelInitiated) Removes the given annotations from this model.protected final voidremoveMarkerAnnotation(IMarker marker) Removes the annotation corresponding to the given marker.protected voidremoveMarkerUpdater(IMarkerUpdater markerUpdater) Removes the given marker updater from this annotation model.voidResets all the markers to their original state.protected abstract IMarker[]Retrieves all markers from this model.voidChanges the current transient state of the annotation model to match the last persisted state.booleanupdateMarker(IMarker marker, IDocument document, Position position) Deprecated.booleanupdateMarker(IDocument document, IMarker marker, Position position) Updates the given marker according to the given position in the given document.voidupdateMarkers(IDocument document) Updates the markers managed by this annotation model by calling all registered marker updaters (IMarkerUpdater).Methods inherited from class org.eclipse.jface.text.source.AnnotationModel
addAnnotation, addAnnotation, addAnnotationModel, addAnnotationModelListener, addPosition, cleanup, connect, createAnnotationModelEvent, disconnect, fireModelChanged, fireModelChanged, getAnnotationIterator, getAnnotationIterator, getAnnotationIterator, getAnnotationMap, getAnnotationModel, getAnnotationModelEvent, getLockObject, getModificationStamp, getPosition, modifyAnnotation, modifyAnnotationPosition, modifyAnnotationPosition, removeAllAnnotations, removeAllAnnotations, removeAnnotation, removeAnnotation, removeAnnotationModel, removeAnnotationModelListener, removePosition, replaceAnnotations, replaceAnnotations, setLockObject
-
Constructor Details
-
AbstractMarkerAnnotationModel
protected AbstractMarkerAnnotationModel()Creates a new annotation model. The annotation model does not manage any annotations and is not connected to any document.
-
-
Method Details
-
retrieveMarkers
Retrieves all markers from this model.Subclasses must implement this method.
- Returns:
- the list of markers
- Throws:
CoreException- if there is a problem getting the markers
-
deleteMarkers
Deletes the given markers from this model.Subclasses must implement this method.
- Parameters:
markers- the array of markers- Throws:
CoreException- if there are problems deleting the markers
-
listenToMarkerChanges
protected abstract void listenToMarkerChanges(boolean listen) Tells the model whether it should listen for marker changes.Subclasses must implement this method.
- Parameters:
listen-trueif this model should listen, andfalseotherwise
-
isAcceptable
Determines whether the marker is acceptable as an addition to this model. If the marker, say, represents an aspect or range of no interest to this model, the marker is rejected.Subclasses must implement this method.
- Parameters:
marker- the marker- Returns:
trueif the marker is acceptable
-
addMarkerUpdater
Adds the given marker updater to this annotation model. It is the client's responsibility to ensure the consistency of the set of registered marker updaters.- Parameters:
markerUpdater- the marker updater to be added
-
removeMarkerUpdater
Removes the given marker updater from this annotation model.- Parameters:
markerUpdater- the marker updater to be removed
-
createMarkerAnnotation
Creates a new annotation for the given marker.Subclasses may override.
- Parameters:
marker- the marker- Returns:
- the new marker annotation
-
handleCoreException
Handles an unanticipatedCoreExceptionin a standard manner.- Parameters:
exception- the exceptionmessage- a message to aid debugging
-
createPositionFromMarker
Creates and returns the character position of the given marker based on its attributes.Subclasses may override.
- Parameters:
marker- the marker- Returns:
- the new position or
nullif the marker attributes do not specify a valid position
-
addMarkerAnnotation
Creates an annotation for the given marker and adds it to this model. Does nothing if the marker is not acceptable to this model.- Parameters:
marker- the marker- See Also:
-
connected
protected void connected()Connects to the source of markers as marker change listener.- Overrides:
connectedin classAnnotationModel- See Also:
-
disconnected
protected void disconnected()Removes the marker change listener.- Overrides:
disconnectedin classAnnotationModel- See Also:
-
getMarkerPosition
Returns the position known to this annotation model for the given marker.- Parameters:
marker- the marker- Returns:
- the position, or
nullif none
-
modifyMarkerAnnotation
Updates the annotation corresponding to the given marker which has changed in some way.Subclasses may override.
- Parameters:
marker- the marker
-
removeAnnotations
protected void removeAnnotations(List<? extends Annotation> annotations, boolean fireModelChanged, boolean modelInitiated) Description copied from class:AnnotationModelRemoves the given annotations from this model. If requested all annotation model listeners will be informed about this change.modelInitiatedindicates whether the deletion has been initiated by this model or by one of its clients.- Overrides:
removeAnnotationsin classAnnotationModel- Parameters:
annotations- the annotations to be removedfireModelChanged- indicates whether to notify all model listenersmodelInitiated- indicates whether this changes has been initiated by this model
-
removeMarkerAnnotation
Removes the annotation corresponding to the given marker. Does nothing if there is no annotation for this marker.- Parameters:
marker- the marker
-
getMarkerAnnotation
Returns this model's annotation for the given marker.- Parameters:
marker- the marker- Returns:
- the annotation, or
nullif none
-
updateMarker
@Deprecated public boolean updateMarker(IMarker marker, IDocument document, Position position) throws CoreException Deprecated.useupdateMarker(IDocument, IMarker, Position)instead. This method will be changed to protected.Updates the given marker according to the given position in the given document. If the given position isnull, the marker is assumed to carry the correct positional information. If it is detected that the marker is invalid and should thus be deleted, this method returnsfalse.Note: This implementation queries the registered IMarkerUpdaters. If any of these updaters returns
falsethis method also returnsfalse.- Parameters:
marker- the marker to be updateddocument- the document into which the given position pointsposition- the current position of the marker inside the given document- Returns:
falseif the marker is invalid- Throws:
CoreException- if there is a problem updating the marker- Since:
- 2.0
-
updateMarker
public boolean updateMarker(IDocument document, IMarker marker, Position position) throws CoreException Updates the given marker according to the given position in the given document. If the given position isnull, the marker is assumed to carry the correct positional information. If it is detected that the marker is invalid and should thus be deleted, this method returnsfalse.- Parameters:
document- the document into which the given position pointsmarker- the marker to be updatedposition- the current position of the marker inside the given document- Returns:
falseif the marker is invalid- Throws:
CoreException- if there is a problem updating the marker- Since:
- 3.0
-
updateMarkers
Updates the markers managed by this annotation model by calling all registered marker updaters (IMarkerUpdater).- Parameters:
document- the document to which this model is currently connected- Throws:
CoreException- if there is a problem updating the markers
-
resetMarkers
public void resetMarkers()Resets all the markers to their original state. -
commit
Description copied from interface:IPersistableAnnotationModelTransforms the current transient state of the annotation model into a persistent state.- Specified by:
commitin interfaceIPersistableAnnotationModel- Parameters:
document- the document the annotation model is connected to- Throws:
CoreException- in case the transformation fails
-
revert
Description copied from interface:IPersistableAnnotationModelChanges the current transient state of the annotation model to match the last persisted state.- Specified by:
revertin interfaceIPersistableAnnotationModel- Parameters:
document- the document the annotation model is connected to
-
reinitialize
Description copied from interface:IPersistableAnnotationModelForces this annotation model to re-initialize from the persistent state. The persistent state must not be the same as the last persisted state. I.e. external modification may have caused changes to the persistent state since the lastcommitorrevertoperation.- Specified by:
reinitializein interfaceIPersistableAnnotationModel- Parameters:
document- the document the annotation model is connected to
-
updateMarker(IDocument, IMarker, Position)instead.