Class AbstractMarkerAnnotationModel

    • 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)
      • 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<? extends Annotation> 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

        @Deprecated
        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.
      • 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