java.lang.Object
javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
- All Implemented Interfaces:
Serializable
,UndoableEdit
- Direct Known Subclasses:
AbstractDocument.DefaultDocumentEvent
,UndoManager
A concrete subclass of AbstractUndoableEdit, used to assemble little
UndoableEdits into great big ones.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Vector<UndoableEdit>
The collection ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.Fields declared in class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addEdit(UndoableEdit anEdit)
If this edit isinProgress
, acceptsanEdit
and returns true.boolean
canRedo()
Returns false ifisInProgress
or if super returns false.boolean
canUndo()
Returns false ifisInProgress
or if super returns false.void
die()
Sendsdie
to each subedit, in the reverse of the order that they were added.void
end()
SetsinProgress
to false.ReturnsgetPresentationName
from the lastUndoableEdit
added toedits
.ReturnsgetRedoPresentationName
from the lastUndoableEdit
added toedits
.ReturnsgetUndoPresentationName
from the lastUndoableEdit
added toedits
.boolean
Returns true if this edit is in progress--that is, it has not received end.boolean
Returns true if any of theUndoableEdit
s inedits
do.protected UndoableEdit
lastEdit()
Returns the lastUndoableEdit
inedits
, ornull
ifedits
is empty.void
redo()
Sendsredo
to all containedUndoableEdit
s in the order in which they were added.toString()
Returns a string that displays and identifies this object's properties.void
undo()
Sendsundo
to all containedUndoableEdits
in the reverse of the order in which they were added.Methods declared in class javax.swing.undo.AbstractUndoableEdit
replaceEdit
-
Field Details
-
edits
The collection ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.
-
-
Constructor Details
-
CompoundEdit
public CompoundEdit()Constructs aCompoundEdit
.
-
-
Method Details
-
undo
Sendsundo
to all containedUndoableEdits
in the reverse of the order in which they were added.- Specified by:
undo
in interfaceUndoableEdit
- Overrides:
undo
in classAbstractUndoableEdit
- Throws:
CannotUndoException
- ifcanUndo
returnsfalse
- See Also:
AbstractUndoableEdit.canUndo()
-
redo
Sendsredo
to all containedUndoableEdit
s in the order in which they were added.- Specified by:
redo
in interfaceUndoableEdit
- Overrides:
redo
in classAbstractUndoableEdit
- Throws:
CannotRedoException
- ifcanRedo
returnsfalse
- See Also:
AbstractUndoableEdit.canRedo()
-
lastEdit
Returns the lastUndoableEdit
inedits
, ornull
ifedits
is empty.- Returns:
- the last
UndoableEdit
inedits
, ornull
ifedits
is empty.
-
die
public void die()Sendsdie
to each subedit, in the reverse of the order that they were added.- Specified by:
die
in interfaceUndoableEdit
- Overrides:
die
in classAbstractUndoableEdit
- See Also:
die()
-
addEdit
If this edit isinProgress
, acceptsanEdit
and returns true.The last edit added to this
CompoundEdit
is given a chance toaddEdit(anEdit)
. If it refuses (returns false),anEdit
is given a chance toreplaceEdit
the last edit. IfanEdit
returns false here, it is added toedits
.- Specified by:
addEdit
in interfaceUndoableEdit
- Overrides:
addEdit
in classAbstractUndoableEdit
- Parameters:
anEdit
- the edit to be added- Returns:
- true if the edit is
inProgress
; otherwise returns false - See Also:
UndoableEdit.addEdit(javax.swing.undo.UndoableEdit)
-
end
public void end()SetsinProgress
to false. -
canUndo
public boolean canUndo()Returns false ifisInProgress
or if super returns false.- Specified by:
canUndo
in interfaceUndoableEdit
- Overrides:
canUndo
in classAbstractUndoableEdit
- Returns:
- true if this edit is
alive
andhasBeenDone
istrue
- See Also:
isInProgress()
-
canRedo
public boolean canRedo()Returns false ifisInProgress
or if super returns false.- Specified by:
canRedo
in interfaceUndoableEdit
- Overrides:
canRedo
in classAbstractUndoableEdit
- Returns:
true
if this edit isalive
andhasBeenDone
isfalse
- See Also:
isInProgress()
-
isInProgress
public boolean isInProgress()Returns true if this edit is in progress--that is, it has not received end. This generally means that edits are still being added to it.- Returns:
- whether this edit is in progress
- See Also:
end()
-
isSignificant
public boolean isSignificant()Returns true if any of theUndoableEdit
s inedits
do. Returns false if they all return false.- Specified by:
isSignificant
in interfaceUndoableEdit
- Overrides:
isSignificant
in classAbstractUndoableEdit
- Returns:
- true
- See Also:
UndoableEdit.isSignificant()
-
getPresentationName
ReturnsgetPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.- Specified by:
getPresentationName
in interfaceUndoableEdit
- Overrides:
getPresentationName
in classAbstractUndoableEdit
- Returns:
- the empty string ""
- See Also:
AbstractUndoableEdit.getUndoPresentationName()
,AbstractUndoableEdit.getRedoPresentationName()
-
getUndoPresentationName
ReturnsgetUndoPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.- Specified by:
getUndoPresentationName
in interfaceUndoableEdit
- Overrides:
getUndoPresentationName
in classAbstractUndoableEdit
- Returns:
- the value from the defaults table with key
AbstractUndoableEdit.undoText
, followed by a space, followed bygetPresentationName
unlessgetPresentationName
is "" in which case, the defaults value is returned alone. - See Also:
AbstractUndoableEdit.getPresentationName()
-
getRedoPresentationName
ReturnsgetRedoPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.- Specified by:
getRedoPresentationName
in interfaceUndoableEdit
- Overrides:
getRedoPresentationName
in classAbstractUndoableEdit
- Returns:
- the value from the defaults table with key
AbstractUndoableEdit.redoText
, followed by a space, followed bygetPresentationName
unlessgetPresentationName
is "" in which case, the defaults value is returned alone. - See Also:
AbstractUndoableEdit.getPresentationName()
-
toString
Returns a string that displays and identifies this object's properties.- Overrides:
toString
in classAbstractUndoableEdit
- Returns:
- a String representation of this object
-