public class UndoableEdit
extends java.lang.Object
implements javax.swing.undo.UndoableEdit
Note that undo and redo operations rollback any updates in progress on the RuleDictionary that generated the UndoableEdit.
Modifier and Type | Method and Description |
---|---|
boolean |
addEdit(javax.swing.undo.UndoableEdit anEdit)
Adds an
UndoableEdit to this UndoableEdit . |
boolean |
canRedo()
True if it is still possible to redo this operation.
|
boolean |
canUndo()
True if it is still possible to undo this operation.
|
void |
die()
May be sent to inform an edit that it should no longer be
used.
|
java.lang.String |
getPresentationName()
Returns a localized, human-readable description of this edit, suitable
for use in a change log, for example.
|
java.lang.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.
|
java.lang.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.
|
boolean |
isSignificant()
Returns true if this edit is considered significant.
|
void |
redo()
Re-apply the edit, assuming that it has been undone.
|
boolean |
replaceEdit(javax.swing.undo.UndoableEdit anEdit)
Returns true if this
UndoableEdit should replace
anEdit . |
void |
setPresentationName(java.lang.String pn) |
void |
setRedoPresentationName(java.lang.String pn) |
void |
setUndoPresentationName(java.lang.String pn) |
void |
undo()
Undo the edit that was made.
|
public void undo() throws javax.swing.undo.CannotUndoException
undo
in interface javax.swing.undo.UndoableEdit
javax.swing.undo.CannotUndoException
- if this edit can not be undonepublic boolean canUndo()
canUndo
in interface javax.swing.undo.UndoableEdit
public void redo() throws javax.swing.undo.CannotRedoException
redo
in interface javax.swing.undo.UndoableEdit
javax.swing.undo.CannotRedoException
- if this edit can not be redonepublic boolean canRedo()
canRedo
in interface javax.swing.undo.UndoableEdit
public void die()
UndoManagercalls this before it dequeues edits. Note that this is a one-way operation. There is no "un-die" method.
die
in interface javax.swing.undo.UndoableEdit
CompoundEdit.die()
public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
javax.swing.undo.UndoableEdit
UndoableEdit
to this UndoableEdit
.
This method can be used to coalesce smaller edits into a larger
compound edit. For example, text editors typically allow
undo operations to apply to words or sentences. The text
editor may choose to generate edits on each key event, but allow
those edits to be coalesced into a more user-friendly unit, such as
a word. In this case, the UndoableEdit
would
override addEdit
to return true when the edits may
be coalesced.
A return value of true indicates anEdit
was incorporated
into this edit. A return value of false indicates anEdit
may not be incorporated into this edit.
Typically the receiver is already in the queue of a
UndoManager
(or other UndoableEditListener
),
and is being given a chance to incorporate anEdit
rather than letting it be added to the queue in turn.
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
.
addEdit
in interface javax.swing.undo.UndoableEdit
anEdit
- the edit to be addedanEdit
may be incorporated into this
editpublic boolean replaceEdit(javax.swing.undo.UndoableEdit anEdit)
javax.swing.undo.UndoableEdit
UndoableEdit
should replace
anEdit
. This method is used by CompoundEdit
and the UndoManager
; it is called if
anEdit
could not be added to the current edit
(addEdit
returns false).
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 UndoManager
(or other
UndoableEditListener), and the receiver is being given a chance
to take its place.
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().
replaceEdit
in interface javax.swing.undo.UndoableEdit
anEdit
- the edit that replaces the current editanEdit
public boolean isSignificant()
javax.swing.undo.UndoableEdit
UndoManager
will undo,
or redo, all insignificant edits to the next significant edit.isSignificant
in interface javax.swing.undo.UndoableEdit
public java.lang.String getPresentationName()
javax.swing.undo.UndoableEdit
getPresentationName
in interface javax.swing.undo.UndoableEdit
public void setPresentationName(java.lang.String pn)
public java.lang.String getUndoPresentationName()
javax.swing.undo.UndoableEdit
getPresentationName
.getUndoPresentationName
in interface javax.swing.undo.UndoableEdit
public void setUndoPresentationName(java.lang.String pn)
public java.lang.String getRedoPresentationName()
javax.swing.undo.UndoableEdit
getPresentationName
.getRedoPresentationName
in interface javax.swing.undo.UndoableEdit
public void setRedoPresentationName(java.lang.String pn)