|
Eclipse Platform 2.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.eclipse.jface.text.source.AnnotationModel
|
+--org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel
Abstract implementation of a marker-based annotation model.
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 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 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 | |
protected |
AbstractMarkerAnnotationModel()
Creates a new annotation model. |
| Method Summary | |
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. |
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. |
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. |
boolean |
updateMarker(IMarker marker,
IDocument document,
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, addAnnotationModelListener, addPosition, cleanup, connect, disconnect, fireModelChanged, fireModelChanged, getAnnotationIterator, getAnnotationIterator, getPosition, removeAllAnnotations, removeAllAnnotations, removeAnnotation, removeAnnotation, removeAnnotationModelListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected AbstractMarkerAnnotationModel()
| Method Detail |
protected abstract IMarker[] retrieveMarkers()
throws CoreException
Subclasses must implement this method.
CoreException - if there is a problem getting the markers
protected abstract void deleteMarkers(IMarker[] markers)
throws CoreException
Subclasses must implement this method.
markers - the array of markers
CoreException - 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 marker
true 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 marker
protected 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 marker
null 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 marker
null if noneprotected void modifyMarkerAnnotation(IMarker marker)
Subclasses may override.
marker - the marker
protected 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 marker
null if none
public boolean updateMarker(IMarker marker,
IDocument document,
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 document
CoreException - if there is a problem updating the marker
public void updateMarkers(IDocument document)
throws CoreException
IMarkerUpdater).
document - the document to which this model is currently connected
CoreException - if there is a problem updating the markerspublic void resetMarkers()
|
Eclipse Platform 2.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||