Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
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()
.Field Summary | |
protected Vector |
|
Fields inherited from class javax.swing.undo.AbstractUndoableEdit | |
RedoName , UndoName |
Constructor Summary | |
|
Method Summary | |
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
String |
|
String |
|
String |
|
boolean |
|
boolean |
|
protected UndoableEdit |
|
void |
|
String |
|
void |
|
Methods inherited from class javax.swing.undo.AbstractUndoableEdit | |
addEdit , canRedo , canUndo , die , getPresentationName , getRedoPresentationName , getUndoPresentationName , isSignificant , redo , replaceEdit , toString , undo |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public boolean addEdit(UndoableEdit edit)
Incorporates another editing action into this one, thus forming a combined 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 incorporateedit
. 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 toedits
.
- Specified by:
- addEdit in interface UndoableEdit
- Overrides:
- addEdit in interface AbstractUndoableEdit
- Parameters:
edit
- the editing action being added.
- Returns:
true
ifedit
could somehow be incorporated;false
ifedit
has not been incorporated becauseend()
was called before.
public boolean canRedo()
Determines whether it would be possible to redo this editing action. The result will betrue
ifend()
has been called on thisCompoundEdit
,die()
has not yet been called, and the edit has not been redone already.
- Specified by:
- canRedo in interface UndoableEdit
- Overrides:
- canRedo in interface AbstractUndoableEdit
- Returns:
true
to indicate that this action can be redone;false
otherwise.
public boolean canUndo()
Determines whether it would be possible to undo this editing action. The result will betrue
ifend()
has been called on thisCompoundEdit
,die()
has not yet been called, and the edit has not been undone already.
- Specified by:
- canUndo in interface UndoableEdit
- Overrides:
- canUndo in interface AbstractUndoableEdit
- Returns:
true
to indicate that this action can be undone;false
otherwise.
public void die()
Informs this edit action, and all compound edits, that they will no longer be used. Some actions might use this information to release resources such as open files. Called byUndoManager
before this action is removed from the edit queue.The compound elements will receive the
die
message in the reverse order of addition.
- Specified by:
- die in interface UndoableEdit
- Overrides:
- die in interface AbstractUndoableEdit
public void end()
Informs thisCompoundEdit
that its construction phase has been completed. After this method has been called,undo()
andredo()
may be called,isInProgress()
will returnfalse
, and all attempts to add further edits will fail.
public String getPresentationName()
Returns a human-readable, localized name that describes this editing action and can be displayed to the user.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.
- Specified by:
- getPresentationName in interface UndoableEdit
- Overrides:
- getPresentationName in interface AbstractUndoableEdit
public String getRedoPresentationName()
Calculates a localized message text for presenting the redo action to the user.The implementation delegates the call to the last added edit action. If no edit has been added yet, the inherited implementation will be invoked.
- Specified by:
- getRedoPresentationName in interface UndoableEdit
- Overrides:
- getRedoPresentationName in interface AbstractUndoableEdit
public String getUndoPresentationName()
Calculates a localized message text for presenting the undo action to the user.The implementation delegates the call to the last added edit action. If no edit has been added yet, the inherited implementation will be invoked.
- Specified by:
- getUndoPresentationName in interface UndoableEdit
- Overrides:
- getUndoPresentationName in interface AbstractUndoableEdit
public boolean isInProgress()
Determines whether the initial construction phase of thisCompoundEdit
is still in progress. During this phase, edits may be added. After initialization has been terminated by callingend()
,undo()
andredo()
can be used.
- Returns:
true
if the initialization phase is still in progress;false
ifend()
has been called.
- See Also:
end()
public boolean isSignificant()
Determines whether this editing action is significant enough for being seperately undoable by the user. A typical significant action would be the resizing of an object. However, changing the selection in a text document would usually not be considered significant.A
CompoundEdit
is significant if any of its elements are significant.
- Specified by:
- isSignificant in interface UndoableEdit
- Overrides:
- isSignificant in interface AbstractUndoableEdit
protected UndoableEdit lastEdit()
Returns the theUndoableEdit
that was last added to this compound.
public void redo() throws CannotRedoException
Redoes all edits that are part of of thisCompoundEdit
. The compound elements will receive theundo
message in the same order as they were added.
- Specified by:
- redo in interface UndoableEdit
- Overrides:
- redo in interface AbstractUndoableEdit
- Throws:
CannotRedoException
- ifcanRedo()
returnsfalse
. This can happen ifend()
has not been called on thisCompoundEdit
, or if this edit has already been redone.
public String toString()
Calculates a string that may be useful for debugging.
- Overrides:
- toString in interface AbstractUndoableEdit
public void undo() throws CannotUndoException
Undoes all edits that are part of of thisCompoundEdit
. The compound elements will receive theundo
message in the reverse order of addition.
- Specified by:
- undo in interface UndoableEdit
- Overrides:
- undo in interface AbstractUndoableEdit
- Throws:
CannotUndoException
- ifcanUndo()
returnsfalse
. This can happen ifend()
has not been called on thisCompoundEdit
, or if this edit has already been undone.