Interface ISaveableEditor

All Known Implementing Classes:
CaptureEditor

public interface ISaveableEditor
Interface implemented by an Editor part that holds data the property framework cannot see, and that must therefore track that data's dirty state itself.

When to implement this, and when not to. The framework already tracks everything held in the property tree: a change there raises an event, the file container compares the tree against the snapshot taken at load, and the part is marked dirty. Data in the tree needs nothing from this interface. Implement it only for data the tree does not hold — an edited capture, a database connection, anything the editor keeps beside the properties.

Both methods are consulted by FilePropSaveable, whose dirty computation asks every attached editor before answering: the part is dirty when the property tree differs from its snapshot or when any attached editor reports additional data dirty.

Author:
Christopher Mindus
  • Method Details

    • isAdditionalDataDirty

      boolean isAdditionalDataDirty()
      Checks the dirty state of the additional data this editor holds.

      Called whenever the part's dirty state is computed, which is often: any property event in the file's tree triggers it. Keep it cheap, and keep it free of side effects.

      Returns:
      true if the additional data has changed since it was last saved, false otherwise.
    • saveAdditionalData

      void saveAdditionalData(IProgressMonitor monitor) throws CoreException
      Saves the additional data.

      This is called BEFORE the property file itself is written, so a failure to write the file can still follow a successful call to this method.

      It follows that this method must not record the additional data as saved. Clear the editor's own dirty state only once the write it depends on has succeeded — inside doSave after the save call returns, so that an exception leaves the state set and the part correctly still dirty. An editor that marks itself clean here loses the user's change silently when the file write then fails: the part reads unchanged, closes without a prompt, and the data is gone.

      An editor whose additional data needs no separate write may leave this method empty.

      Parameters:
      monitor - The progress monitor.
      Throws:
      CoreException - For saving and I/O errors.