Eclipse Platform
2.0

org.eclipse.jface.text.source
Interface IAnnotationModel

All Known Implementing Classes:
AnnotationModel

public interface IAnnotationModel

This interface defines the model component for a vertical ruler. It maintains a set of annotations and notifies registered annotation model listeners about annotation model changes. It also provides methods for inquerying the current offset and length of an annotation managed by this model.

Clients may implement this interface or use the default implementation provided by AnnotationModel.

See Also:
IVerticalRuler, Annotation, IAnnotationModelListener

Method Summary
 void addAnnotation(Annotation annotation, Position position)
          Adds a annotation to this annotation model.
 void addAnnotationModelListener(IAnnotationModelListener listener)
          Registers the annotation model listener with this annotation model.
 void connect(IDocument document)
          Connects the annotation model to a document.
 void disconnect(IDocument document)
          Disconnects this model from a document.
 Iterator getAnnotationIterator()
          Returns all annotations managed by this model.
 Position getPosition(Annotation annotation)
          Returns the position associated with the given annotation.
 void removeAnnotation(Annotation annotation)
          Removes the given annotation from the model.
 void removeAnnotationModelListener(IAnnotationModelListener listener)
          Removes the listener from the model's list of annotation model listeners.
 

Method Detail

addAnnotationModelListener

public void addAnnotationModelListener(IAnnotationModelListener listener)
Registers the annotation model listener with this annotation model. After registration listener is informed about each change of this model. If the listener is already registered nothing happens.

Parameters:
listener - the listener to be registered, may not be null

removeAnnotationModelListener

public void removeAnnotationModelListener(IAnnotationModelListener listener)
Removes the listener from the model's list of annotation model listeners. If the listener is not registered with the model nothing happens.

Parameters:
listener - the listener to be removed, may not be null

connect

public void connect(IDocument document)
Connects the annotation model to a document. The annotations managed by this model must subsequently update according to the changes applied to the document. Once an annotation model is connected to a document, all further 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.

Parameters:
document - the document the model gets connected to, may not be null
See Also:
disconnect(org.eclipse.jface.text.IDocument)

disconnect

public void disconnect(IDocument document)
Disconnects this model from a document. After that, document changes no longer matter. An annotation model may only be disconnected from a document to which it has been connected before. If the model reference counts the connections to a document, the connection to the document may only be terminated if the reference count does down to 0.

Parameters:
document - the document the model gets disconnected from, may not be null
See Also:
for further specification details

addAnnotation

public void addAnnotation(Annotation annotation,
                          Position position)
Adds a annotation to this annotation model. The annotation is associated with with the given position which desscribes the range covered by the annotation. All registered annotation model listeners are informed about the change. If the model is connected to a document, the position is automatically updated on document changes. If the annotation is already managed by this annotation model nothing happens.

Parameters:
annotation - the annotation to add, may not be null
position - the position describing the range covered by this annotation, may not be null

removeAnnotation

public void removeAnnotation(Annotation annotation)
Removes the given annotation from the model. I.e. the annotation is no longer managed by this model. The position associated with the annotation is no longer updated on document changes. If the annotation is not managed by this model, nothing happens.

Parameters:
annotation - the annotation to be removed from this model, may not be null

getAnnotationIterator

public Iterator getAnnotationIterator()
Returns all annotations managed by this model.

Returns:
all annotations managed by this model

getPosition

public Position getPosition(Annotation annotation)
Returns the position associated with the given annotation.

Parameters:
annotation - the annotation whose position should be returned
Returns:
the position of the given annotation or null if no associated annotation exists

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.