Package org.eclipse.jface.text.source

# Class AnnotationModelEvent

java.lang.Object
org.eclipse.jface.text.source.AnnotationModelEvent

public class AnnotationModelEvent extends Object
Specification of changes applied to annotation models. The event carries the changed annotation model as well as added, removed, and modified annotations.

An event can be sealed. Afterwards it can not be modified. Thus, the normal process is that an empty event is created, filled with the changed information, and before it is sent to the listeners, the event is sealed.

Since:
  2.0
See Also:
  - `IAnnotationModel`
  - `IAnnotationModelListenerExtension`

## Constructor Summary

Constructors
Constructor
Description
`AnnotationModelEvent(IAnnotationModel model)`
Creates a new annotation model event for the given model.
`AnnotationModelEvent(IAnnotationModel model, boolean isWorldChange)`
Creates a new annotation model event for the given model.

## Method Summary

Modifier and Type
Method
Description
`void`
`annotationAdded(Annotation annotation)`
Adds the given annotation to the set of annotations that are reported as being added from the model.
`void`
`annotationChanged(Annotation annotation)`
Adds the given annotation to the set of annotations that are reported as being changed from the model.
`void`
`annotationRemoved(Annotation annotation)`
Adds the given annotation to the set of annotations that are reported as being removed from the model.
`void`
`annotationRemoved(Annotation annotation, Position position)`
Adds the given annotation to the set of annotations that are reported as being removed from the model.
`Annotation[]`
`getAddedAnnotations()`
Returns the added annotations.
`IAnnotationModel`
`getAnnotationModel()`
Returns the model this event refers to.
`Annotation[]`
`getChangedAnnotations()`
Returns the changed annotations.
`Position`
`getPositionOfRemovedAnnotation(Annotation annotation)`
Returns the position of the removed annotation at that point in time when the annotation has been removed.
`Annotation[]`
`getRemovedAnnotations()`
Returns the removed annotations.
`boolean`
`isEmpty()`
Returns whether this annotation model event is empty or not.
`boolean`
`isValid()`
Returns whether this annotation model event is still valid.
`boolean`
`isWorldChange()`
Returns whether this annotation model events contains detailed information about the modifications applied to the event annotation model or whether it represents a world change.
`void`
`markSealed()`
Seals this event.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AnnotationModelEvent

public AnnotationModelEvent(IAnnotationModel model)
Creates a new annotation model event for the given model.

Parameters:
  `model` - the model

### AnnotationModelEvent

public AnnotationModelEvent(IAnnotationModel model, boolean isWorldChange)
Creates a new annotation model event for the given model.

Parameters:
  `model` - the model
  `isWorldChange` - `true` if world change
Since:
  3.0

## Method Details

### getAnnotationModel

public IAnnotationModel getAnnotationModel()
Returns the model this event refers to.

Returns:
  the model this events belongs to

### annotationAdded

public void annotationAdded(Annotation annotation)
Adds the given annotation to the set of annotations that are reported as being added from the model. If this event is considered a world change, it is no longer so after this method has successfully finished.

Parameters:
  `annotation` - the added annotation
Since:
  3.0

### getAddedAnnotations

public Annotation[] getAddedAnnotations()
Returns the added annotations.

Returns:
  the added annotations
Since:
  3.0

### annotationRemoved

public void annotationRemoved(Annotation annotation)
Adds the given annotation to the set of annotations that are reported as being removed from the model. If this event is considered a world change, it is no longer so after this method has successfully finished.

Parameters:
  `annotation` - the removed annotation
Since:
  3.0

### annotationRemoved

public void annotationRemoved(Annotation annotation, Position position)
Adds the given annotation to the set of annotations that are reported as being removed from the model. If this event is considered a world change, it is no longer so after this method has successfully finished.

Parameters:
  `annotation` - the removed annotation
  `position` - the position of the removed annotation
Since:
  3.0

### getRemovedAnnotations

public Annotation[] getRemovedAnnotations()
Returns the removed annotations.

Returns:
  the removed annotations
Since:
  3.0

### getPositionOfRemovedAnnotation

public Position getPositionOfRemovedAnnotation(Annotation annotation)
Returns the position of the removed annotation at that point in time when the annotation has been removed.

Parameters:
  `annotation` - the removed annotation
Returns:
  the position of the removed annotation or `null`
Since:
  3.0

### annotationChanged

public void annotationChanged(Annotation annotation)
Adds the given annotation to the set of annotations that are reported as being changed from the model. If this event is considered a world change, it is no longer so after this method has successfully finished.

Parameters:
  `annotation` - the changed annotation
Since:
  3.0

### getChangedAnnotations

public Annotation[] getChangedAnnotations()
Returns the changed annotations.

Returns:
  the changed annotations
Since:
  3.0

### isEmpty

public boolean isEmpty()
Returns whether this annotation model event is empty or not. If this event represents a world change, this method returns `false` although the event does not carry any added, removed, or changed annotations.

Returns:
  `true` if this event is empty
Since:
  3.0

### isWorldChange

public boolean isWorldChange()
Returns whether this annotation model events contains detailed information about the modifications applied to the event annotation model or whether it represents a world change. I.e. everything in the model might have changed.

Returns:
  `true` if world change, `false` otherwise
Since:
  3.0

### isValid

public boolean isValid()
Returns whether this annotation model event is still valid.

Returns:
  `true` if this event is still valid, `false` otherwise
Since:
  3.0

### markSealed

public void markSealed()
Seals this event. Any direct modification to the annotation model after the event has been sealed invalidates this event.

Since:
  3.0