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:
retrieveMarkers
isAcceptable
deleteMarkers
listenToMarkerChanges
-
Field Summary
Fields inherited from class org.eclipse.jface.text.source.AnnotationModel
fAnnotationModelListeners, fAnnotations, fDocument
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a new annotation model. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addMarkerAnnotation
(IMarker marker) Creates an annotation for the given marker and adds it to this model.protected void
addMarkerUpdater
(IMarkerUpdater markerUpdater) Adds the given marker updater to this annotation model.void
Transforms the current transient state of the annotation model into a persistent state.protected void
Connects to the source of markers as marker change listener.protected MarkerAnnotation
createMarkerAnnotation
(IMarker marker) Creates a new annotation for the given marker.protected Position
createPositionFromMarker
(IMarker marker) Creates and returns the character position of the given marker based on its attributes.protected abstract void
deleteMarkers
(IMarker[] markers) Deletes the given markers from this model.protected void
Removes the marker change listener.final MarkerAnnotation
getMarkerAnnotation
(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 void
handleCoreException
(CoreException exception, String message) Handles an unanticipatedCoreException
in a standard manner.protected abstract boolean
isAcceptable
(IMarker marker) Determines whether the marker is acceptable as an addition to this model.protected abstract void
listenToMarkerChanges
(boolean listen) Tells the model whether it should listen for marker changes.protected void
modifyMarkerAnnotation
(IMarker marker) Updates the annotation corresponding to the given marker which has changed in some way.void
reinitialize
(IDocument document) Forces this annotation model to re-initialize from the persistent state.protected void
removeAnnotations
(List<? extends Annotation> annotations, boolean fireModelChanged, boolean modelInitiated) Removes the given annotations from this model.protected final void
removeMarkerAnnotation
(IMarker marker) Removes the annotation corresponding to the given marker.protected void
removeMarkerUpdater
(IMarkerUpdater markerUpdater) Removes the given marker updater from this annotation model.void
Resets all the markers to their original state.protected abstract IMarker[]
Retrieves all markers from this model.void
Changes the current transient state of the annotation model to match the last persisted state.boolean
updateMarker
(IMarker marker, IDocument document, Position position) Deprecated.boolean
updateMarker
(IDocument document, IMarker marker, Position position) Updates the given marker according to the given position in the given document.void
updateMarkers
(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
-true
if this model should listen, andfalse
otherwise
-
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:
true
if 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 unanticipatedCoreException
in 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
null
if 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:
connected
in classAnnotationModel
- See Also:
-
disconnected
protected void disconnected()Removes the marker change listener.- Overrides:
disconnected
in classAnnotationModel
- See Also:
-
getMarkerPosition
Returns the position known to this annotation model for the given marker.- Parameters:
marker
- the marker- Returns:
- the position, or
null
if 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:AnnotationModel
Removes the given annotations from this model. If requested all annotation model listeners will be informed about this change.modelInitiated
indicates whether the deletion has been initiated by this model or by one of its clients.- Overrides:
removeAnnotations
in 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
null
if 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
false
this 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:
false
if 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:
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:
false
if 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:IPersistableAnnotationModel
Transforms the current transient state of the annotation model into a persistent state.- Specified by:
commit
in interfaceIPersistableAnnotationModel
- Parameters:
document
- the document the annotation model is connected to- Throws:
CoreException
- in case the transformation fails
-
revert
Description copied from interface:IPersistableAnnotationModel
Changes the current transient state of the annotation model to match the last persisted state.- Specified by:
revert
in interfaceIPersistableAnnotationModel
- Parameters:
document
- the document the annotation model is connected to
-
reinitialize
Description copied from interface:IPersistableAnnotationModel
Forces 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 lastcommit
orrevert
operation.- Specified by:
reinitialize
in interfaceIPersistableAnnotationModel
- Parameters:
document
- the document the annotation model is connected to
-
updateMarker(IDocument, IMarker, Position)
instead.