|
Eclipse Platform Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.text.source.AnnotationModel
Standard implementation of IAnnotationModel
and its extension
interfaces. This class can directly be used by clients. Subclasses may adapt
this annotation model to other existing annotation mechanisms. This class
also implements ISynchronizable
. All
modifications of the model's internal annotation map are synchronized using
the model's lock object.
Field Summary | |
protected ArrayList |
fAnnotationModelListeners
The list of annotation model listeners |
protected Map |
fAnnotations
Deprecated. since 3.0 use getAnnotationMap instead |
protected IDocument |
fDocument
The document connected with this model |
Constructor Summary | |
AnnotationModel()
Creates a new annotation model. |
Method Summary | |
void |
addAnnotation(Annotation annotation,
Position position)
Adds a annotation to this annotation model. |
protected void |
addAnnotation(Annotation annotation,
Position position,
boolean fireModelChanged)
Adds the given annotation to this model. |
void |
addAnnotationModel(Object key,
IAnnotationModel attachment)
Attaches attachment to the receiver. |
void |
addAnnotationModelListener(IAnnotationModelListener listener)
Registers the annotation model listener with this annotation model. |
protected void |
addPosition(IDocument document,
Position position)
Adds the given position to the default position category of the given document. |
protected void |
cleanup(boolean fireModelChanged)
Removes all annotations from the model whose associated positions have been deleted. |
void |
connect(IDocument document)
Connects the annotation model to a document. |
protected void |
connected()
Hook method. |
protected AnnotationModelEvent |
createAnnotationModelEvent()
Creates and returns a new annotation model event. |
void |
disconnect(IDocument document)
Disconnects this model from a document. |
protected void |
disconnected()
Hook method. |
protected void |
fireModelChanged()
Informs all annotation model listeners that this model has been changed. |
protected void |
fireModelChanged(AnnotationModelEvent event)
Informs all annotation model listeners that this model has been changed as described in the annotation model event. |
Iterator |
getAnnotationIterator()
Returns all annotations managed by this model. |
protected Iterator |
getAnnotationIterator(boolean cleanup)
Returns all annotations managed by this model. |
protected IAnnotationMap |
getAnnotationMap()
Returns the annotation map internally used by this annotation model. |
IAnnotationModel |
getAnnotationModel(Object key)
Returns the attached IAnnotationModel for key ,
or null if none is attached for key . |
protected AnnotationModelEvent |
getAnnotationModelEvent()
Returns the current annotation model event. |
Object |
getLockObject()
Returns the lock object or null if there is none. |
Object |
getModificationStamp()
Returns the modification stamp of this annotation model. |
Position |
getPosition(Annotation annotation)
Returns the position associated with the given annotation. |
protected void |
modifyAnnotation(Annotation annotation,
boolean fireModelChanged)
Modifies the given annotation if the annotation is managed by this annotation model. |
void |
modifyAnnotationPosition(Annotation annotation,
Position position)
Modifies the position associated with the given annotation to equal the given position. |
protected void |
modifyAnnotationPosition(Annotation annotation,
Position position,
boolean fireModelChanged)
Modifies the associated position of the given annotation to the given position. |
void |
removeAllAnnotations()
Removes all annotations from this annotation model. |
protected void |
removeAllAnnotations(boolean fireModelChanged)
Removes all annotations from the annotation model. |
void |
removeAnnotation(Annotation annotation)
Removes the given annotation from the model. |
protected void |
removeAnnotation(Annotation annotation,
boolean fireModelChanged)
Removes the given annotation from the annotation model. |
IAnnotationModel |
removeAnnotationModel(Object key)
Removes and returns the attached IAnnotationModel for
key . |
void |
removeAnnotationModelListener(IAnnotationModelListener listener)
Removes the listener from the model's list of annotation model listeners. |
protected void |
removeAnnotations(List annotations,
boolean fireModelChanged,
boolean modelInitiated)
Removes the given annotations from this model. |
protected void |
removePosition(IDocument document,
Position position)
Removes the given position from the default position category of the given document. |
void |
replaceAnnotations(Annotation[] annotationsToRemove,
Map annotationsToAdd)
Adds and removes annotations to/from this annotation model in a single step. |
protected void |
replaceAnnotations(Annotation[] annotationsToRemove,
Map annotationsToAdd,
boolean fireModelChanged)
Replaces the given annotations in this model and if advised fires a model change event. |
void |
setLockObject(Object lockObject)
Sets the lock object for this object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Map fAnnotations
getAnnotationMap
instead
protected ArrayList fAnnotationModelListeners
protected IDocument fDocument
Constructor Detail |
public AnnotationModel()
Method Detail |
protected IAnnotationMap getAnnotationMap()
public Object getLockObject()
ISynchronizable
null
if there is none. Clients
should use the lock object in order to synchronize concurrent access to
the implementer.
getLockObject
in interface ISynchronizable
null
public void setLockObject(Object lockObject)
ISynchronizable
null
subsequent calls to specified methods of this object
are synchronized on this lock object. Which methods are synchronized is
specified by the implementer.
setLockObject
in interface ISynchronizable
lockObject
- the lock object. May be null
.protected final AnnotationModelEvent getAnnotationModelEvent()
fireModelChanged
.
public void addAnnotation(Annotation annotation, Position position)
IAnnotationModel
addAnnotation
in interface IAnnotationModel
annotation
- the annotation to add, may not be null
position
- the position describing the range covered by this annotation,
may not be null
public void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd)
IAnnotationModelExtension
replaceAnnotations
in interface IAnnotationModelExtension
annotationsToRemove
- the annotations to be removed, may be
null
annotationsToAdd
- the annotations which will be added, may be
null
each map entry has an
Annotation
as key and a Position
as valueprotected void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd, boolean fireModelChanged) throws BadLocationException
annotationsToRemove
- the annotations to be removedannotationsToAdd
- the annotations to be addedfireModelChanged
- true
if a model change event
should be fired, false
otherwise
BadLocationException
- in case an annotation should be added at an
invalid positionprotected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException
annotation
- the annotation to addposition
- the associate positionfireModelChanged
- indicates whether to notify all model listeners
BadLocationException
- if the position is not a valid document positionpublic void addAnnotationModelListener(IAnnotationModelListener listener)
IAnnotationModel
addAnnotationModelListener
in interface IAnnotationModel
listener
- the listener to be registered, may not be null
protected void addPosition(IDocument document, Position position) throws BadLocationException
document
- the document to which to add the positionposition
- the position to add
BadLocationException
- if the position is not a valid document positionprotected void removePosition(IDocument document, Position position)
document
- the document to which to add the positionposition
- the position to addpublic void connect(IDocument document)
IAnnotationModel
connect
calls must mention the document the
model is already connected to. An annotation model primarily uses
connect
and disconnect
for reference counting
the document. Reference counting frees the clients from keeping tracker
whether a model has already been connected to a document.
connect
in interface IAnnotationModel
document
- the document the model gets connected to,
may not be null
IAnnotationModel.disconnect(IDocument)
protected void connected()
protected void disconnected()
public void disconnect(IDocument document)
IAnnotationModel
disconnect
in interface IAnnotationModel
document
- the document the model gets disconnected from,
may not be null
for further specification details
protected void fireModelChanged()
protected AnnotationModelEvent createAnnotationModelEvent()
protected void fireModelChanged(AnnotationModelEvent event)
IAnnotationModelListenerExtension
.
All other listeners are notified by just calling modelChanged(IAnnotationModel)
.
event
- the event to be sent out to the listenersprotected void removeAnnotations(List annotations, boolean fireModelChanged, boolean modelInitiated)
modelInitiated
indicates whether the deletion has
been initiated by this model or by one of its clients.
annotations
- the annotations to be removedfireModelChanged
- indicates whether to notify all model listenersmodelInitiated
- indicates whether this changes has been initiated by this modelprotected void cleanup(boolean fireModelChanged)
fireModelChanged
- indicates whether to notify all model listenerspublic Iterator getAnnotationIterator()
IAnnotationModel
getAnnotationIterator
in interface IAnnotationModel
protected Iterator getAnnotationIterator(boolean cleanup)
cleanup
indicates whether all annotations whose associated positions are
deleted should previously be removed from the model.
cleanup
- indicates whether annotations with deleted associated positions are removed
public Position getPosition(Annotation annotation)
IAnnotationModel
getPosition
in interface IAnnotationModel
annotation
- the annotation whose position should be returned
null
if no
associated annotation existspublic void removeAllAnnotations()
IAnnotationModelExtension
removeAllAnnotations
in interface IAnnotationModelExtension
protected void removeAllAnnotations(boolean fireModelChanged)
fireModelChanged
- indicates whether to notify all model listenerspublic void removeAnnotation(Annotation annotation)
IAnnotationModel
removeAnnotation
in interface IAnnotationModel
annotation
- the annotation to be removed from this model,
may not be null
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged)
annotation
- the annotation to be removedfireModelChanged
- indicates whether to notify all model listenerspublic void modifyAnnotationPosition(Annotation annotation, Position position)
IAnnotationModelExtension
null
the annotation is removed from the model. All
annotation model change listeners will be informed about the change.
modifyAnnotationPosition
in interface IAnnotationModelExtension
annotation
- the annotation whose associated position should be
modifiedposition
- the position to whose values the associated position
should be changedprotected void modifyAnnotationPosition(Annotation annotation, Position position, boolean fireModelChanged)
null
, the
annotation is removed from the model.
If requested, all annotation model change listeners will be informed about the change.
annotation
- the annotation whose associated position should be
modifiedposition
- the position to whose values the associated position
should be changedfireModelChanged
- indicates whether to notify all model listenersprotected void modifyAnnotation(Annotation annotation, boolean fireModelChanged)
If requested, all annotation model change listeners will be informed about the change.
annotation
- the annotation to be modifiedfireModelChanged
- indicates whether to notify all model listenerspublic void removeAnnotationModelListener(IAnnotationModelListener listener)
IAnnotationModel
removeAnnotationModelListener
in interface IAnnotationModel
listener
- the listener to be removed, may not be null
public void addAnnotationModel(Object key, IAnnotationModel attachment)
IAnnotationModelExtension
attachment
to the receiver. Connects
attachment
to the currently connected document. If
attachment
is already attached (even) under a different
key), it is not attached again.
addAnnotationModel
in interface IAnnotationModelExtension
key
- the key through which the attachment is identified.attachment
- the attached IAnnotationModel
public IAnnotationModel getAnnotationModel(Object key)
IAnnotationModelExtension
IAnnotationModel
for key
,
or null
if none is attached for key
.
getAnnotationModel
in interface IAnnotationModelExtension
key
- the key through which the attachment is identified.
IAnnotationModel
attached under
key
, or null
public IAnnotationModel removeAnnotationModel(Object key)
IAnnotationModelExtension
IAnnotationModel
for
key
.
removeAnnotationModel
in interface IAnnotationModelExtension
key
- the key through which the attachment is identified.
IAnnotationModel
attached under
key
, or null
public Object getModificationStamp()
IAnnotationModelExtension
getModificationStamp
in interface IAnnotationModelExtension
|
Eclipse Platform Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.