Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.ui.texteditor
Class AbstractMarkerAnnotationModel

java.lang.Object
  extended by 

org.eclipse.jface.text.source.AnnotationModel
      extended by 
org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel
All Implemented Interfaces:
IPersistableAnnotationModel, ISynchronizable, IAnnotationModel, IAnnotationModelExtension, IAnnotationModelExtension2
Direct Known Subclasses:
ResourceMarkerAnnotationModel

public abstract class AbstractMarkerAnnotationModel
extends AnnotationModel
implements IPersistableAnnotationModel

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(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:

  • retrieveMarkers
  • isAcceptable
  • deleteMarkers
  • listenToMarkerChanges


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.
 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).
 
Methods inherited from class org.eclipse.jface.text.source. AnnotationModel
addAnnotation, addAnnotation, addAnnotationModel, addAnnotationModelListener, addPosition, cleanup, connect, createAnnotationModelEvent, disconnect, fireModelChanged, fireModelChanged, getAnnotationIterator, getAnnotationIterator, getAnnotationIterator, getAnnotationMap, getAnnotationModel, getAnnotationModelEvent, getLockObject, getModificationStamp, getPosition, modifyAnnotation, modifyAnnotationPosition, modifyAnnotationPosition, removeAllAnnotations, removeAllAnnotations, removeAnnotation, removeAnnotation, removeAnnotationModel, removeAnnotationModelListener, removePosition, replaceAnnotations, replaceAnnotations, setLockObject
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMarkerAnnotationModel

protected AbstractMarkerAnnotationModel()
Creates a new annotation model. The annotation model does not manage any annotations and is not connected to any document.

Method Detail

retrieveMarkers

protected abstract 
IMarker[] retrieveMarkers()
                                      throws 
CoreException
Retrieves all markers from this model.

Subclasses must implement this method.

Returns:
the list of markers
Throws:
CoreException - if there is a problem getting the markers

deleteMarkers

protected abstract void deleteMarkers(
IMarker[] markers)
                               throws 
CoreException
Deletes the given markers from this model.

Subclasses must implement this method.

Parameters:
markers - the array of markers
Throws:
CoreException - if there are problems deleting the markers

listenToMarkerChanges

protected abstract void listenToMarkerChanges(boolean listen)
Tells the model whether it should listen for marker changes.

Subclasses must implement this method.

Parameters:
listen - true if this model should listen, and false otherwise

isAcceptable

protected abstract boolean isAcceptable(
IMarker marker)
Determines whether the marker is acceptable as an addition to this model. If the marker, say, represents an aspect or range of no interest to this model, the marker is rejected.

Subclasses must implement this method.

Parameters:
marker - the marker
Returns:
true if the marker is acceptable

addMarkerUpdater

protected void addMarkerUpdater(
IMarkerUpdater markerUpdater)
Adds the given marker updater to this annotation model. It is the client's responsibility to ensure the consistency of the set of registered marker updaters.

Parameters:
markerUpdater - the marker updater to be added

removeMarkerUpdater

protected void removeMarkerUpdater(
IMarkerUpdater markerUpdater)
Removes the given marker updater from this annotation model.

Parameters:
markerUpdater - the marker updater to be removed

createMarkerAnnotation

protected 
MarkerAnnotation createMarkerAnnotation(
IMarker marker)
Creates a new annotation for the given marker.

Subclasses may override.

Parameters:
marker - the marker
Returns:
the new marker annotation

handleCoreException

protected void handleCoreException(
CoreException exception,
                                   
String message)
Handles an unanticipated CoreException in a standard manner.

Parameters:
exception - the exception
message - a message to aid debugging

createPositionFromMarker

protected 
Position createPositionFromMarker(
IMarker marker)
Creates and returns the character position of the given marker based on its attributes.

Subclasses may override.

Parameters:
marker - the marker
Returns:
the new position or null if the marker attributes do not specify a valid position

addMarkerAnnotation

protected final void addMarkerAnnotation(
IMarker marker)
Creates an annotation for the given marker and adds it to this model. Does nothing if the marker is not acceptable to this model.

Parameters:
marker - the marker
See Also:
isAcceptable(IMarker)

connected

protected void connected()
Connects to the source of markers as marker change listener.

Overrides:
connected in class AnnotationModel
See Also:
AnnotationModel.connected()

disconnected

protected void disconnected()
Removes the marker change listener.

Overrides:
disconnected in class AnnotationModel
See Also:
AnnotationModel.disconnected()

getMarkerPosition

public 
Position getMarkerPosition(
IMarker marker)
Returns the position known to this annotation model for the given marker.

Parameters:
marker - the marker
Returns:
the position, or null if none

modifyMarkerAnnotation

protected void modifyMarkerAnnotation(
IMarker marker)
Updates the annotation corresponding to the given marker which has changed in some way.

Subclasses may override.

Parameters:
marker - the marker

removeAnnotations

protected void removeAnnotations(
List annotations,
                                 boolean fireModelChanged,
                                 boolean modelInitiated)
Description copied from class: AnnotationModel
Removes the given annotations from this model. If requested all annotation model listeners will be informed about this change. modelInitiated indicates whether the deletion has been initiated by this model or by one of its clients.

Overrides:
removeAnnotations in class AnnotationModel
Parameters:
annotations - the annotations to be removed
fireModelChanged - indicates whether to notify all model listeners
modelInitiated - indicates whether this changes has been initiated by this model

removeMarkerAnnotation

protected final void removeMarkerAnnotation(
IMarker marker)
Removes the annotation corresponding to the given marker. Does nothing if there is no annotation for this marker.

Parameters:
marker - the marker

getMarkerAnnotation

public final 
MarkerAnnotation getMarkerAnnotation(
IMarker marker)
Returns this model's annotation for the given marker.

Parameters:
marker - the marker
Returns:
the annotation, or null if none

updateMarker

public boolean updateMarker(
IMarker marker,
                            
IDocument document,
                            
Position position)
                     throws 
CoreException
Deprecated. use updateMarker(IDocument, IMarker, Position) instead. This method will be changed to protected.

Updates the given marker according to the given position in the given document. If the given position is 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.

Note: This implementation queries the registered IMarkerUpdaters. If any of these updaters returns false this method also returns false.

Parameters:
marker - the marker to be updated
document - the document into which the given position points
position - the current position of the marker inside the given document
Returns:
false if the marker is invalid
Throws:
CoreException - if there is a problem updating the marker
Since:
2.0

updateMarker

public boolean updateMarker(
IDocument document,
                            
IMarker marker,
                            
Position position)
                     throws 
CoreException
Updates the given marker according to the given position in the given document. If the given position is 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.

Parameters:
marker - the marker to be updated
document - the document into which the given position points
position - the current position of the marker inside the given document
Returns:
false if the marker is invalid
Throws:
CoreException - if there is a problem updating the marker
Since:
3.0

updateMarkers

public void updateMarkers(
IDocument document)
                   throws 
CoreException
Updates the markers managed by this annotation model by calling all registered marker updaters (IMarkerUpdater).

Parameters:
document - the document to which this model is currently connected
Throws:
CoreException - if there is a problem updating the markers

resetMarkers

public void resetMarkers()
Resets all the markers to their original state.


commit

public void commit(
IDocument document)
            throws 
CoreException
Description copied from interface: IPersistableAnnotationModel
Transforms the current transient state of the annotation model into a persistent state.

Specified by:
commit in interface IPersistableAnnotationModel
Parameters:
document - the document the annotation model is connected to
Throws:
CoreException - in case the transformation fails

revert

public void revert(
IDocument document)
Description copied from interface: IPersistableAnnotationModel
Changes the current transient state of the annotation model to match the last persisted state.

Specified by:
revert in interface IPersistableAnnotationModel
Parameters:
document - the document the annotation model is connected to

reinitialize

public void reinitialize(
IDocument document)
Description copied from interface: IPersistableAnnotationModel
Forces this annotation model to re-initialize from the persistent state. The persistent state must not be the same as the last persisted state. I.e. external modification may have caused changes to the persistent state since the last commit or revert operation.

Specified by:
reinitialize in interface IPersistableAnnotationModel
Parameters:
document - the document the annotation model is connected to

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire