Class SaveableComparison

All Implemented Interfaces:
IAdaptable

public abstract class SaveableComparison extends Saveable
A saveable comparison is used to buffer changes made when comparing or merging model elements. A buffer can be shared between multiple typed elements within a comparison. The saveable is used by the comparison container in order to determine when a save is required.

Clients may subclass this class.

Since:
3.2
  • Field Details

    • PROP_DIRTY

      public static final int PROP_DIRTY
      The property id for isDirty.
      See Also:
  • Constructor Details

    • SaveableComparison

      public SaveableComparison()
  • Method Details

    • isDirty

      public boolean isDirty()
      Returns whether the contents of this saveable have changed since the last save operation.

      Note: this method is called frequently, for example by actions to determine their enabled status.

      Specified by:
      isDirty in class Saveable
      Returns:
      true if the contents have been modified and need saving, and false if they have not changed since the last save
    • doSave

      public void doSave(IProgressMonitor monitor) throws CoreException
      Saves the contents of this saveable.

      If the save is cancelled through user action, or for any other reason, the part should invoke setCancelled on the IProgressMonitor to inform the caller.

      This method is long-running; progress and cancellation are provided by the given progress monitor.

      Specified by:
      doSave in class Saveable
      Parameters:
      monitor - the progress monitor
      Throws:
      CoreException - if the save fails; it is the caller's responsibility to report the failure to the user
    • doRevert

      public void doRevert(IProgressMonitor monitor)
      Revert any changes in the buffer back to the last saved state.
      Parameters:
      monitor - a progress monitor on null if progress feedback is not required
    • addPropertyListener

      public void addPropertyListener(IPropertyListener listener)
      Add a property change listener. Adding a listener that is already registered has no effect.
      Parameters:
      listener - the listener
    • removePropertyListener

      public void removePropertyListener(IPropertyListener listener)
      Remove a property change listener. Removing a listener that is not registered has no effect.
      Parameters:
      listener - the listener
    • setDirty

      protected void setDirty(boolean dirty)
      Set the dirty state of this buffer. If the state has changed, a property change event will be fired.
      Parameters:
      dirty - the dirty state
    • firePropertyChange

      protected void firePropertyChange(int property)
      Fire a property change event for this buffer.
      Parameters:
      property - the property that changed
    • performSave

      protected abstract void performSave(IProgressMonitor monitor) throws CoreException
      Method invoked from doSave(IProgressMonitor) to write out the buffer. By default, this method invokes doSave on the buffers saveable model.
      Parameters:
      monitor - a progress monitor
      Throws:
      CoreException - if errors occur
    • performRevert

      protected abstract void performRevert(IProgressMonitor monitor)
      Method invoked from doRevert(IProgressMonitor) to discard the changes in the buffer.
      Parameters:
      monitor - a progress monitor