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 TypeMethodDescriptiondefault booleancanRedo()Determine whether this edit can be redone.default booleancanUndo()Determine whether this edit can be undone.default voiddiscard()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.voidredo()Re-do the edit.default booleantryMergeInto(UndoableEdit edit) Determine whether the given edit can be merged into this edit.voidundo()Undo the edit.
-
Method Details
-
undo
Undo the edit.- Throws:
CannotUndoException- if this edit can not be undone
-
canUndo
default boolean canUndo()Determine whether this edit can be undone.- Returns:
trueif this edit can be undone
-
redo
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:
trueif 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
Determine whether the given edit can be merged into this edit. If it can, merge the edit and returntrue, otherwise do nothing and returnfalse.- Parameters:
edit- the edit that should possible be merged into this edit- Returns:
trueif this edit could be merged,falseotherwise
-
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
-