public class CompoundEdit extends AbstractUndoableEdit
UndoableEdits
.
The use of a CompoundEdit
is divided in two separate
phases.
CompoundEdit
is
initialized. After a new instance of CompoundEdit
has
been created, addEdit(UndoableEdit)
is called for each
element of the compound. To terminate the initialization phase,
call end()
.CompoundEdit
can be
used, typically by invoking undo()
and
redo()
.Modifier and Type | Field and Description |
---|---|
protected Vector<UndoableEdit> |
edits
The
UndoableEdit s being combined into a compound
editing action. |
RedoName, UndoName
Constructor and Description |
---|
CompoundEdit()
Constructs a new CompoundEdit.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addEdit(UndoableEdit edit)
Incorporates another editing action into this one, thus forming a
combined edit.
|
boolean |
canRedo()
Determines whether it would be possible to redo this editing
action.
|
boolean |
canUndo()
Determines whether it would be possible to undo this editing
action.
|
void |
die()
Informs this edit action, and all compound edits, that they will
no longer be used.
|
void |
end()
Informs this
CompoundEdit that its construction
phase has been completed. |
String |
getPresentationName()
Returns a human-readable, localized name that describes this
editing action and can be displayed to the user.
|
String |
getRedoPresentationName()
Calculates a localized message text for presenting the redo
action to the user.
|
String |
getUndoPresentationName()
Calculates a localized message text for presenting the undo
action to the user.
|
boolean |
isInProgress()
Determines whether the initial construction phase of this
CompoundEdit is still in progress. |
boolean |
isSignificant()
Determines whether this editing action is significant enough for
being seperately undoable by the user.
|
protected UndoableEdit |
lastEdit()
Returns the the
UndoableEdit that was last added to
this compound. |
void |
redo()
Redoes all edits that are part of of this
CompoundEdit . |
String |
toString()
Calculates a string that may be useful for debugging.
|
void |
undo()
Undoes all edits that are part of of this
CompoundEdit . |
replaceEdit
protected Vector<UndoableEdit> edits
UndoableEdit
s being combined into a compound
editing action.public CompoundEdit()
public void undo() throws CannotUndoException
CompoundEdit
. The compound elements will receive the
undo
message in the reverse order of addition.undo
in interface UndoableEdit
undo
in class AbstractUndoableEdit
CannotUndoException
- if canUndo()
returns
false
. This can happen if end()
has not
been called on this CompoundEdit
, or if this edit
has already been undone.canUndo()
,
redo()
public void redo() throws CannotRedoException
CompoundEdit
. The compound elements will receive the
undo
message in the same order as they were added.redo
in interface UndoableEdit
redo
in class AbstractUndoableEdit
CannotRedoException
- if canRedo()
returns
false
. This can happen if end()
has not
been called on this CompoundEdit
, or if this edit
has already been redone.canRedo()
,
undo()
protected UndoableEdit lastEdit()
UndoableEdit
that was last added to
this compound.public void die()
UndoManager
before this action is removed from the edit queue.
The compound elements will receive the
die
message in the reverse order of addition.
die
in interface UndoableEdit
die
in class AbstractUndoableEdit
public boolean addEdit(UndoableEdit edit)
If this edit’s end()
method has been called
before, false
is returned immediately. Otherwise,
the last added edit is given the
opportunity to incorporate edit
. If this fails, edit
is given the opportunity to replace the last added
edit. If this fails as well, edit
gets added as a
new compound to edits
.
addEdit
in interface UndoableEdit
addEdit
in class AbstractUndoableEdit
edit
- the editing action being added.true
if edit
could somehow be
incorporated; false
if edit
has not
been incorporated because end()
was called before.public void end()
CompoundEdit
that its construction
phase has been completed. After this method has been called,
undo()
and redo()
may be called, isInProgress()
will return false
, and all attempts
to add further edits will
fail.public boolean canUndo()
true
if end()
has been called on this CompoundEdit
, die()
has not yet been called, and the edit has not been undone
already.canUndo
in interface UndoableEdit
canUndo
in class AbstractUndoableEdit
true
to indicate that this action can be
undone; false
otherwise.undo()
,
canRedo()
public boolean canRedo()
true
if end()
has been called on this CompoundEdit
, die()
has not yet been called, and the edit has not been redone
already.canRedo
in interface UndoableEdit
canRedo
in class AbstractUndoableEdit
true
to indicate that this action can be
redone; false
otherwise.redo()
,
canUndo()
public boolean isInProgress()
CompoundEdit
is still in progress. During this
phase, edits may be
added. After initialization has been terminated by calling
end()
, undo()
and redo()
can be used.public boolean isSignificant()
A CompoundEdit
is significant if any of its
elements are significant.
isSignificant
in interface UndoableEdit
isSignificant
in class AbstractUndoableEdit
true
to indicate that the action is
significant enough for being separately undoable, or
false
otherwise.public String getPresentationName()
The implementation delegates the call to the last added edit action. If no edit has been added yet, the inherited implementation will be invoked, which always returns an empty string.
getPresentationName
in interface UndoableEdit
getPresentationName
in class AbstractUndoableEdit
public String getUndoPresentationName()
The implementation delegates the call to the last added edit action. If no edit has been added yet, the inherited implementation will be invoked.
getUndoPresentationName
in interface UndoableEdit
getUndoPresentationName
in class AbstractUndoableEdit
public String getRedoPresentationName()
The implementation delegates the call to the last added edit action. If no edit has been added yet, the inherited implementation will be invoked.
getRedoPresentationName
in interface UndoableEdit
getRedoPresentationName
in class AbstractUndoableEdit
public String toString()
toString
in class AbstractUndoableEdit
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)