UndoableEdit represents an edit. The edit may
be undone, or if already undone the edit may be redone.
UndoableEdit is designed to be used with the
UndoManager. As UndoableEdits are generated
by an UndoableEditListener they are typically added to
the UndoManager. When an UndoableEdit
is added to an UndoManager the following occurs (assuming
end has not been called on the UndoManager):
UndoManager contains edits it will call
addEdit on the current edit passing in the new edit
as the argument. If addEdit returns true the
new edit is assumed to have been incorporated into the current edit and
the new edit will not be added to the list of current edits.
Edits can use addEdit as a way for smaller edits to
be incorporated into a larger edit and treated as a single edit.
addEdit returns false replaceEdit
is called on the new edit with the current edit passed in as the
argument. This is the inverse of addEdit —
if the new edit returns true from replaceEdit, the new
edit replaces the current edit.
UndoManager makes use of
isSignificant to determine how many edits should be
undone or redone. The UndoManager will undo or redo
all insignificant edits (isSignificant returns false)
between the current edit and the last or
next significant edit. addEdit and
replaceEdit can be used to treat multiple edits as
a single edit, returning false from isSignificant
allows for treating can be used to
have many smaller edits undone or redone at once. Similar functionality
can also be done using the addEdit method.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true ifanEdit may be incorporated into this
editthe edit to be added anEdit)Adds an |
| public boolean | |
| public boolean | |
| public void | |
| public String | Returns: description of this editReturns a localized, human-readable description of this edit, suitable for use in a change log, for example. |
| public String | Returns: a description of the redoable form of this editReturns a localized, human-readable description of the redoable form of this edit, suitable for use as a Redo menu item, for example. |
| public String | Returns: a description of the undoable form of this editReturns a localized, human-readable description of the undoable form of this edit, suitable for use as an Undo menu item, for example. |
| public boolean | Returns: true if this edit is significantReturns true if this edit is considered significant. |
| public void | |
| public boolean | Returns: true if this edit should replaceanEditthe edit that replaces the current edit anEdit)Returns true if this |
| public void |
| addEdit | back to summary |
|---|---|
| public boolean addEdit(UndoableEdit anEdit) Adds an
A return value of true indicates Typically the receiver is already in the queue of a
If true is returned, from now on
| |
| canRedo | back to summary |
|---|---|
| public boolean canRedo() Returns true if this edit may be redone.
| |
| canUndo | back to summary |
|---|---|
| public boolean canUndo() Returns true if this edit may be undone.
| |
| die | back to summary |
|---|---|
| public void die() Informs the edit that it should no longer be used. Once an
This is a useful hook for cleaning up state no longer
needed once undoing or redoing is impossible--for example,
deleting file resources used by objects that can no longer be
undeleted. Note that this is a one-way operation. There is no "un-die" method.
| |
| getPresentationName | back to summary |
|---|---|
| public String getPresentationName() Returns a localized, human-readable description of this edit, suitable for use in a change log, for example.
| |
| getRedoPresentationName | back to summary |
|---|---|
| public String getRedoPresentationName() Returns a localized, human-readable description of the redoable form of
this edit, suitable for use as a Redo menu item, for example. This is
typically derived from
| |
| getUndoPresentationName | back to summary |
|---|---|
| public String getUndoPresentationName() Returns a localized, human-readable description of the undoable form of
this edit, suitable for use as an Undo menu item, for example.
This is typically derived from
| |
| isSignificant | back to summary |
|---|---|
| public boolean isSignificant() Returns true if this edit is considered significant. A significant
edit is typically an edit that should be presented to the user, perhaps
on a menu item or tooltip. The
| |
| redo | back to summary |
|---|---|
| public void redo() throws CannotRedoException Re-applies the edit.
| |
| replaceEdit | back to summary |
|---|---|
| public boolean replaceEdit(UndoableEdit anEdit) Returns true if this This method provides a way for an edit to replace an existing edit. This message is the opposite of addEdit--anEdit has typically
already been queued in an If true is returned, from now on anEdit must return false from canUndo() and canRedo(), and must throw the appropriate exception on undo() or redo().
| |
| undo | back to summary |
|---|---|
| public void undo() throws CannotUndoException Undo the edit.
| |