Interface UndoableEdit

All Known Implementing Classes:
AbstractUndoableEdit, MementoBasedUndoableEdit, RemoveListElementsUndoableEdit

public interface UndoableEdit
An undoable edit encapsulates some form of mutating action taken by a user in a user interface, that should be able to be un-done (and later on possibly re-done) at some future time.

An action can be small in effect e.g. typing a single letter or rather large, e.g. modifying some property of a large number of objects. It is up to the implementor to manage the granularity of an edit. In general, it is desirable to neither make them too fine-grained (don't undo every single key-press for some typed text) nor too coarse, so that an undo loses a large amount of work. tryMergeInto(UndoableEdit) can be used to manage the granularity of several subsequent edits.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Determine whether this edit can be redone.
    default boolean
    Determine whether this edit can be undone.
    default void
    Discard the edit by freeing any resources held by it beyond simple references that are disposed of by garbage collection.
    Returns a localized, human-readable description of the redoable form of this edit, suitable for use as a Redo menu item, for example.
    Returns a localized, human-readable description of the undoable form of this edit, suitable for use as an Undo menu item, for example.
    void
    Re-do the edit.
    default boolean
    Determine whether the given edit can be merged into this edit.
    void
    Undo the edit.
  • Method Details

    • undo

      void undo() throws CannotUndoException
      Undo the edit.
      Throws:
      CannotUndoException - if this edit can not be undone
    • canUndo

      default boolean canUndo()
      Determine whether this edit can be undone.
      Returns:
      true if this edit can be undone
    • redo

      void redo() throws CannotRedoException
      Re-do the edit.
      Throws:
      CannotRedoException - if this edit can not be re-done
    • canRedo

      default boolean canRedo()
      Determine whether this edit can be redone.
      Returns:
      true if this edit can be redone
    • discard

      default void discard()
      Discard the edit by freeing any resources held by it beyond simple references that are disposed of by garbage collection. Most implementations don't need to do anything here.
    • tryMergeInto

      default boolean tryMergeInto(UndoableEdit edit)
      Determine whether the given edit can be merged into this edit. If it can, merge the edit and return true, otherwise do nothing and return false.
      Parameters:
      edit - the edit that should possible be merged into this edit
      Returns:
      true if this edit could be merged, false otherwise
    • getUndoDescription

      String getUndoDescription()
      Returns a localized, human-readable description of the undoable form of this edit, suitable for use as an Undo menu item, for example.
      Returns:
      a description of the undoable form of this edit
    • getRedoDescription

      String getRedoDescription()
      Returns a localized, human-readable description of the redoable form of this edit, suitable for use as a Redo menu item, for example.
      Returns:
      a description of the redoable form of this edit