public abstract class AbstractMarkerAnnotationModel extends AnnotationModel implements IPersistableAnnotationModel
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:
retrieveMarkersisAcceptabledeleteMarkerslistenToMarkerChangesfAnnotationModelListeners, fAnnotations, fDocument| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMarkerAnnotationModel()
Creates a new annotation model.
|
| Modifier and Type | Method and Description |
|---|---|
protected 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 |
commit(IDocument document)
Transforms the current transient state of the annotation model into a
persistent state.
|
protected void |
connected()
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 |
disconnected()
Removes the marker change listener.
|
MarkerAnnotation |
getMarkerAnnotation(IMarker marker)
Returns this model's annotation for the given marker.
|
Position |
getMarkerPosition(IMarker marker)
Returns the position known to this annotation model for the given marker.
|
protected void |
handleCoreException(CoreException exception,
String message)
Handles an unanticipated
CoreException 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 annotations,
boolean fireModelChanged,
boolean modelInitiated)
Removes the given annotations from this model.
|
protected 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 |
resetMarkers()
Resets all the markers to their original state.
|
protected abstract IMarker[] |
retrieveMarkers()
Retrieves all markers from this model.
|
void |
revert(IDocument document)
Changes the current transient state of the annotation model to match the
last persisted state.
|
boolean |
updateMarker(IDocument document,
IMarker marker,
Position position)
Updates the given marker according to the given position in the given
document.
|
boolean |
updateMarker(IMarker marker,
IDocument document,
Position position)
Deprecated.
use
updateMarker(IDocument, IMarker, Position) instead. This method will be changed to protected. |
void |
updateMarkers(IDocument document)
Updates the markers managed by this annotation model by calling
all registered marker updaters (
IMarkerUpdater). |
addAnnotation, addAnnotation, addAnnotationModel, addAnnotationModelListener, addPosition, cleanup, connect, createAnnotationModelEvent, disconnect, fireModelChanged, fireModelChanged, getAnnotationIterator, getAnnotationIterator, getAnnotationMap, getAnnotationModel, getAnnotationModelEvent, getLockObject, getModificationStamp, getPosition, modifyAnnotation, modifyAnnotationPosition, modifyAnnotationPosition, removeAllAnnotations, removeAllAnnotations, removeAnnotation, removeAnnotation, removeAnnotationModel, removeAnnotationModelListener, removePosition, replaceAnnotations, replaceAnnotations, setLockObjectprotected AbstractMarkerAnnotationModel()
protected abstract IMarker[] retrieveMarkers() throws CoreException
Subclasses must implement this method.
CoreException - if there is a problem getting the markersprotected abstract void deleteMarkers(IMarker[] markers) throws CoreException
Subclasses must implement this method.
markers - the array of markersCoreException - if there are problems deleting the markersprotected abstract void listenToMarkerChanges(boolean listen)
Subclasses must implement this method.
listen - true if this model should listen, and
false otherwiseprotected abstract boolean isAcceptable(IMarker marker)
Subclasses must implement this method.
marker - the markertrue if the marker is acceptableprotected void addMarkerUpdater(IMarkerUpdater markerUpdater)
markerUpdater - the marker updater to be addedprotected void removeMarkerUpdater(IMarkerUpdater markerUpdater)
markerUpdater - the marker updater to be removedprotected MarkerAnnotation createMarkerAnnotation(IMarker marker)
Subclasses may override.
marker - the markerprotected void handleCoreException(CoreException exception, String message)
CoreException in
a standard manner.exception - the exceptionmessage - a message to aid debuggingprotected Position createPositionFromMarker(IMarker marker)
Subclasses may override.
marker - the markernull if the marker attributes do not specify a valid positionprotected final void addMarkerAnnotation(IMarker marker)
marker - the markerisAcceptable(IMarker)protected void connected()
connected in class AnnotationModelAnnotationModel.connected()protected void disconnected()
disconnected in class AnnotationModelAnnotationModel.disconnected()public Position getMarkerPosition(IMarker marker)
marker - the markernull if noneprotected void modifyMarkerAnnotation(IMarker marker)
Subclasses may override.
marker - the markerprotected void removeAnnotations(List annotations, boolean fireModelChanged, boolean modelInitiated)
AnnotationModelmodelInitiated indicates whether the deletion has
been initiated by this model or by one of its clients.removeAnnotations in class AnnotationModelannotations - the annotations to be removedfireModelChanged - indicates whether to notify all model listenersmodelInitiated - indicates whether this changes has been initiated by this modelprotected final void removeMarkerAnnotation(IMarker marker)
marker - the markerpublic final MarkerAnnotation getMarkerAnnotation(IMarker marker)
marker - the markernull if nonepublic boolean updateMarker(IMarker marker, IDocument document, Position position) throws CoreException
updateMarker(IDocument, IMarker, Position) instead. This method will be changed to protected.null, 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
returns false.marker - the marker to be updateddocument - the document into which the given position pointsposition - the current position of the marker inside the given documentfalse if the marker is invalidCoreException - if there is a problem updating the markerpublic boolean updateMarker(IDocument document, IMarker marker, Position position) throws CoreException
null, 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
returns false.marker - the marker to be updateddocument - the document into which the given position pointsposition - the current position of the marker inside the given documentfalse if the marker is invalidCoreException - if there is a problem updating the markerpublic void updateMarkers(IDocument document) throws CoreException
IMarkerUpdater).document - the document to which this model is currently connectedCoreException - if there is a problem updating the markerspublic void resetMarkers()
public void commit(IDocument document) throws CoreException
IPersistableAnnotationModelcommit in interface IPersistableAnnotationModeldocument - the document the annotation model is connected toCoreException - in case the transformation failspublic void revert(IDocument document)
IPersistableAnnotationModelrevert in interface IPersistableAnnotationModeldocument - the document the annotation model is connected topublic void reinitialize(IDocument document)
IPersistableAnnotationModelcommit or revert
operation.reinitialize in interface IPersistableAnnotationModeldocument - the document the annotation model is connected toGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.