- 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
Fields Modifier and Type Field Description protected Vector<UndoableEdit>editsThe collection ofUndoableEdits undone/redone en masse by thisCompoundEdit.-
Fields declared in class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
-
-
Constructor Summary
Constructors Constructor Description CompoundEdit()Constructs aCompoundEdit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEdit(UndoableEdit anEdit)If this edit isinProgress, acceptsanEditand returns true.booleancanRedo()Returns false ifisInProgressor if super returns false.booleancanUndo()Returns false ifisInProgressor if super returns false.voiddie()Sendsdieto each subedit, in the reverse of the order that they were added.voidend()SetsinProgressto false.StringgetPresentationName()ReturnsgetPresentationNamefrom the lastUndoableEditadded toedits.StringgetRedoPresentationName()ReturnsgetRedoPresentationNamefrom the lastUndoableEditadded toedits.StringgetUndoPresentationName()ReturnsgetUndoPresentationNamefrom the lastUndoableEditadded toedits.booleanisInProgress()Returns true if this edit is in progress--that is, it has not received end.booleanisSignificant()Returns true if any of theUndoableEdits ineditsdo.protected UndoableEditlastEdit()Returns the lastUndoableEditinedits, ornullifeditsis empty.voidredo()Sendsredoto all containedUndoableEdits in the order in which they were added.StringtoString()Returns a string that displays and identifies this object's properties.voidundo()Sendsundoto all containedUndoableEditsin the reverse of the order in which they were added.-
Methods declared in class javax.swing.undo.AbstractUndoableEdit
replaceEdit
-
-
-
-
Field Detail
-
edits
protected Vector<UndoableEdit> edits
The collection ofUndoableEdits undone/redone en masse by thisCompoundEdit.
-
-
Method Detail
-
undo
public void undo() throws CannotUndoExceptionSendsundoto all containedUndoableEditsin the reverse of the order in which they were added.- Specified by:
undoin interfaceUndoableEdit- Overrides:
undoin classAbstractUndoableEdit- Throws:
CannotUndoException- ifcanUndoreturnsfalse- See Also:
AbstractUndoableEdit.canUndo()
-
redo
public void redo() throws CannotRedoExceptionSendsredoto all containedUndoableEdits in the order in which they were added.- Specified by:
redoin interfaceUndoableEdit- Overrides:
redoin classAbstractUndoableEdit- Throws:
CannotRedoException- ifcanRedoreturnsfalse- See Also:
AbstractUndoableEdit.canRedo()
-
lastEdit
protected UndoableEdit lastEdit()
Returns the lastUndoableEditinedits, ornullifeditsis empty.- Returns:
- the last
UndoableEditinedits, ornullifeditsis empty.
-
die
public void die()
Sendsdieto each subedit, in the reverse of the order that they were added.- Specified by:
diein interfaceUndoableEdit- Overrides:
diein classAbstractUndoableEdit- See Also:
die()
-
addEdit
public boolean addEdit(UndoableEdit anEdit)
If this edit isinProgress, acceptsanEditand returns true.The last edit added to this
CompoundEditis given a chance toaddEdit(anEdit). If it refuses (returns false),anEditis given a chance toreplaceEditthe last edit. IfanEditreturns false here, it is added toedits.- Specified by:
addEditin interfaceUndoableEdit- Overrides:
addEditin 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 ifisInProgressor if super returns false.- Specified by:
canUndoin interfaceUndoableEdit- Overrides:
canUndoin classAbstractUndoableEdit- Returns:
- true if this edit is
aliveandhasBeenDoneistrue - See Also:
isInProgress()
-
canRedo
public boolean canRedo()
Returns false ifisInProgressor if super returns false.- Specified by:
canRedoin interfaceUndoableEdit- Overrides:
canRedoin classAbstractUndoableEdit- Returns:
trueif this edit isaliveandhasBeenDoneisfalse- 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 theUndoableEdits ineditsdo. Returns false if they all return false.- Specified by:
isSignificantin interfaceUndoableEdit- Overrides:
isSignificantin classAbstractUndoableEdit- Returns:
- true
- See Also:
UndoableEdit.isSignificant()
-
getPresentationName
public String getPresentationName()
ReturnsgetPresentationNamefrom the lastUndoableEditadded toedits. Ifeditsis empty, calls super.- Specified by:
getPresentationNamein interfaceUndoableEdit- Overrides:
getPresentationNamein classAbstractUndoableEdit- Returns:
- the empty string ""
- See Also:
AbstractUndoableEdit.getUndoPresentationName(),AbstractUndoableEdit.getRedoPresentationName()
-
getUndoPresentationName
public String getUndoPresentationName()
ReturnsgetUndoPresentationNamefrom the lastUndoableEditadded toedits. Ifeditsis empty, calls super.- Specified by:
getUndoPresentationNamein interfaceUndoableEdit- Overrides:
getUndoPresentationNamein classAbstractUndoableEdit- Returns:
- the value from the defaults table with key
AbstractUndoableEdit.undoText, followed by a space, followed bygetPresentationNameunlessgetPresentationNameis "" in which case, the defaults value is returned alone. - See Also:
AbstractUndoableEdit.getPresentationName()
-
getRedoPresentationName
public String getRedoPresentationName()
ReturnsgetRedoPresentationNamefrom the lastUndoableEditadded toedits. Ifeditsis empty, calls super.- Specified by:
getRedoPresentationNamein interfaceUndoableEdit- Overrides:
getRedoPresentationNamein classAbstractUndoableEdit- Returns:
- the value from the defaults table with key
AbstractUndoableEdit.redoText, followed by a space, followed bygetPresentationNameunlessgetPresentationNameis "" 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:
toStringin classAbstractUndoableEdit- Returns:
- a String representation of this object
-
-