CompoundEdit (Java SE 15 & JDK 15) (original) (raw)
All Implemented Interfaces:
[Serializable](../../../../java.base/java/io/Serializable.html "interface in java.io")
, [UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Direct Known Subclasses:
[AbstractDocument.DefaultDocumentEvent](../text/AbstractDocument.DefaultDocumentEvent.html "class in javax.swing.text")
, [UndoManager](UndoManager.html "class in javax.swing.undo")
public class CompoundEdit extends AbstractUndoableEdit
A concrete subclass of AbstractUndoableEdit, used to assemble little UndoableEdits into great big ones.
Field Summary
Fields
Modifier and Type | Field | Description |
---|---|---|
protected Vector<UndoableEdit> | edits | The collection of UndoableEdits undone/redone en masse by this CompoundEdit. |
Constructor Summary
Constructors
Constructor | Description |
---|---|
CompoundEdit() | Constructs a CompoundEdit. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
boolean | addEdit(UndoableEdit anEdit) | If this edit is inProgress, accepts anEdit and returns true. |
boolean | canRedo() | Returns false if isInProgress or if super returns false. |
boolean | canUndo() | Returns false if isInProgress or if super returns false. |
void | die() | Sends die to each subedit, in the reverse of the order that they were added. |
void | end() | Sets inProgress to false. |
String | getPresentationName() | Returns getPresentationName from the last UndoableEdit added toedits. |
String | getRedoPresentationName() | Returns getRedoPresentationName from the last UndoableEdit added to edits. |
String | getUndoPresentationName() | Returns getUndoPresentationName from the last UndoableEdit added to edits. |
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 UndoableEdits in edits do. |
protected UndoableEdit | lastEdit() | Returns the last UndoableEdit inedits, or null if edits is empty. |
void | redo() | Sends redo to all containedUndoableEdits in the order in which they were added. |
String | toString() | Returns a string that displays and identifies this object's properties. |
void | undo() | Sends undo to all containedUndoableEdits in the reverse of the order in which they were added. |
Field Details
edits
The collection of
UndoableEdit
s undone/redone en masse by thisCompoundEdit
.Constructor Details
CompoundEdit
public CompoundEdit()
Constructs aCompoundEdit
.Method Details
undo
Sends
undo
to all containedUndoableEdits
in the reverse of the order in which they were added.
Specified by:
[undo](UndoableEdit.html#undo%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[undo](AbstractUndoableEdit.html#undo%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Throws:
[CannotUndoException](CannotUndoException.html "class in javax.swing.undo")
- ifcanUndo
returnsfalse
See Also:
AbstractUndoableEdit.canUndo()redo
Sends
redo
to all containedUndoableEdit
s in the order in which they were added.
Specified by:
[redo](UndoableEdit.html#redo%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[redo](AbstractUndoableEdit.html#redo%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Throws:
[CannotRedoException](CannotRedoException.html "class in javax.swing.undo")
- ifcanRedo
returnsfalse
See Also:
AbstractUndoableEdit.canRedo()lastEdit
Returns the last
UndoableEdit
inedits
, ornull
ifedits
is empty.
Returns:
the lastUndoableEdit
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](UndoableEdit.html#die%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[die](AbstractUndoableEdit.html#die%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
See Also:
die()addEdit
If this edit is
inProgress
, acceptsanEdit
and returns true.
The last edit added to thisCompoundEdit
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](UndoableEdit.html#addEdit%28javax.swing.undo.UndoableEdit%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[addEdit](AbstractUndoableEdit.html#addEdit%28javax.swing.undo.UndoableEdit%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Parameters:
anEdit
- the edit to be added
Returns:
true if the edit isinProgress
; otherwise returns false
See Also:
UndoableEdit.addEdit(javax.swing.undo.UndoableEdit)end
public void end()
SetsinProgress
to false.
See Also:
canUndo(), canRedo()canUndo
public boolean canUndo()
Returns false ifisInProgress
or if super returns false.
Specified by:
[canUndo](UndoableEdit.html#canUndo%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[canUndo](AbstractUndoableEdit.html#canUndo%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Returns:
true if this edit isalive
andhasBeenDone
istrue
See Also:
isInProgress()canRedo
public boolean canRedo()
Returns false ifisInProgress
or if super returns false.
Specified by:
[canRedo](UndoableEdit.html#canRedo%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[canRedo](AbstractUndoableEdit.html#canRedo%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
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](UndoableEdit.html#isSignificant%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[isSignificant](AbstractUndoableEdit.html#isSignificant%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Returns:
true
See Also:
UndoableEdit.isSignificant()getPresentationName
public String getPresentationName()
ReturnsgetPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.
Specified by:
[getPresentationName](UndoableEdit.html#getPresentationName%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[getPresentationName](AbstractUndoableEdit.html#getPresentationName%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Returns:
the empty string ""
See Also:
AbstractUndoableEdit.getUndoPresentationName(), AbstractUndoableEdit.getRedoPresentationName()getUndoPresentationName
public String getUndoPresentationName()
ReturnsgetUndoPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.
Specified by:
[getUndoPresentationName](UndoableEdit.html#getUndoPresentationName%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[getUndoPresentationName](AbstractUndoableEdit.html#getUndoPresentationName%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Returns:
the value from the defaults table with keyAbstractUndoableEdit.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()
ReturnsgetRedoPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.
Specified by:
[getRedoPresentationName](UndoableEdit.html#getRedoPresentationName%28%29)
in interface[UndoableEdit](UndoableEdit.html "interface in javax.swing.undo")
Overrides:
[getRedoPresentationName](AbstractUndoableEdit.html#getRedoPresentationName%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Returns:
the value from the defaults table with keyAbstractUndoableEdit.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](AbstractUndoableEdit.html#toString%28%29)
in class[AbstractUndoableEdit](AbstractUndoableEdit.html "class in javax.swing.undo")
Returns:
a String representation of this object