Class CompoundEdit
- java.lang.Object
-
- javax.swing.undo.AbstractUndoableEdit
-
- javax.swing.undo.CompoundEdit
- All Implemented Interfaces:
-
Serializable
,UndoableEdit
- Direct Known Subclasses:
-
AbstractDocument.DefaultDocumentEvent
,UndoManager
public class CompoundEdit extends AbstractUndoableEdit
A concrete subclass of AbstractUndoableEdit, used to assemble little UndoableEdits into great big ones.
- See Also:
- Serialized Form
Field Summary
Modifier and Type | Field | Description |
---|---|---|
protected Vector<UndoableEdit> | edits | The collection of |
Fields declared in class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
Constructor Summary
Constructor | Description |
---|---|
CompoundEdit() | Constructs a |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
boolean | addEdit(UndoableEdit anEdit) | If this edit is |
boolean | canRedo() | Returns false if |
boolean | canUndo() | Returns false if |
void | die() | Sends |
void | end() | Sets |
String | getPresentationName() | Returns |
String | getRedoPresentationName() | Returns |
String | getUndoPresentationName() | Returns |
boolean | isInProgress() | Returns true if this edit is in progress--that is, it has not received end. |
boolean | isSignificant() | Returns true if any of the |
protected UndoableEdit | lastEdit() | Returns the last |
void | redo() | Sends |
String | toString() | Returns a string that displays and identifies this object's properties. |
void | undo() | Sends |
Methods declared in class javax.swing.undo.AbstractUndoableEdit
replaceEdit
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
edits
protected Vector<UndoableEdit> edits
The collection of UndoableEdit
s undone/redone en masse by this CompoundEdit
.
Constructor Detail
CompoundEdit
public CompoundEdit()
Constructs a CompoundEdit
.
Method Detail
undo
public void undo() throws CannotUndoException
Sends undo
to all contained UndoableEdits
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
public void redo() throws CannotRedoException
Sends redo
to all contained UndoableEdit
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
protected UndoableEdit lastEdit()
Returns the last UndoableEdit
in edits
, or null
if edits
is empty.
- Returns:
- the last
UndoableEdit
inedits
, ornull
ifedits
is empty.
die
public void die()
Sends die
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
public boolean addEdit(UndoableEdit anEdit)
If this edit is inProgress
, accepts anEdit
and returns true.
The last edit added to this CompoundEdit
is given a chance to addEdit(anEdit)
. If it refuses (returns false), anEdit
is given a chance to replaceEdit
the last edit. If anEdit
returns false here, it is added to edits
.
- 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()
Sets inProgress
to false.
canUndo
public boolean canUndo()
Returns false if isInProgress
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 if isInProgress
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 the UndoableEdit
s in edits
do. Returns false if they all return false.
- Specified by:
-
isSignificant
in interfaceUndoableEdit
- Overrides:
-
isSignificant
in classAbstractUndoableEdit
- Returns:
- true
- See Also:
UndoableEdit.isSignificant()
getPresentationName
public String getPresentationName()
Returns getPresentationName
from the last UndoableEdit
added to edits
. If edits
is empty, calls super.
- Specified by:
-
getPresentationName
in interfaceUndoableEdit
- Overrides:
-
getPresentationName
in classAbstractUndoableEdit
- Returns:
- the empty string ""
- See Also:
-
AbstractUndoableEdit.getUndoPresentationName()
,AbstractUndoableEdit.getRedoPresentationName()
getUndoPresentationName
public String getUndoPresentationName()
Returns getUndoPresentationName
from the last UndoableEdit
added to edits
. If edits
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
public String getRedoPresentationName()
Returns getRedoPresentationName
from the last UndoableEdit
added to edits
. If edits
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
public String toString()
Returns a string that displays and identifies this object's properties.
- Overrides:
-
toString
in classAbstractUndoableEdit
- Returns:
- a String representation of this object