- 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.
-
-
Field Summary
Fields Modifier and Type Field and Description protected Vector<UndoableEdit>
edits
The collection ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.
-
Constructor Summary
Constructors Constructor and Description CompoundEdit()
-
Method Summary
Methods Modifier and Type Method and Description boolean
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.String
getPresentationName()
ReturnsgetPresentationName
from the lastUndoableEdit
added toedits
.String
getRedoPresentationName()
ReturnsgetRedoPresentationName
from the lastUndoableEdit
added toedits
.String
getUndoPresentationName()
ReturnsgetUndoPresentationName
from the lastUndoableEdit
added toedits
.boolean
isInProgress()
Returns true if this edit is in progress--that is, it has not received end.boolean
isSignificant()
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.String
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 inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
-
-
-
-
Field Detail
-
edits
protected Vector<UndoableEdit> edits
The collection ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.
-
-
Method Detail
-
undo
public void undo() throws CannotUndoException
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
public void redo() throws CannotRedoException
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
protected UndoableEdit lastEdit()
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
in interfaceUndoableEdit
- Overrides:
die
in classAbstractUndoableEdit
- See Also:
die()
-
addEdit
public boolean addEdit(UndoableEdit anEdit)
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)
-
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.- 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
public String 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
public String 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
public String 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
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
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/swing/undo/CompoundEdit.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.