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

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default boolean canRedo()
      Determine whether this edit can be redone.
      default boolean canUndo()
      Determine whether this edit can be undone.
      default void discard()
      Discard the edit by freeing any resources held by it beyond simple references that are disposed of by garbage collection.
      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.
      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.
      void redo()
      Re-do the edit.
      default boolean tryMergeInto​(UndoableEdit edit)
      Determine whether the given edit can be merged into this edit.
      void undo()
      Undo the edit.
    • Method Detail

      • canUndo

        default boolean canUndo()
        Determine whether this edit can be undone.
        Returns:
        true if this edit can be undone
      • 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