Class CompoundEdit
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
FieldsModifier and TypeFieldDescriptionprotected Vector<UndoableEdit> The collection ofUndoableEdits undone/redone en masse by thisCompoundEdit.Fields declared in class AbstractUndoableEdit
RedoName, UndoNameModifier and TypeFieldDescriptionprotected static final StringString returned bygetRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.protected static final StringString returned bygetUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEdit(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.ReturnsgetPresentationNamefrom the lastUndoableEditadded toedits.ReturnsgetRedoPresentationNamefrom the lastUndoableEditadded toedits.ReturnsgetUndoPresentationNamefrom the lastUndoableEditadded toedits.booleanReturns true if this edit is in progress--that is, it has not received end.booleanReturns 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.toString()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 AbstractUndoableEdit
replaceEditModifier and TypeMethodDescriptionbooleanreplaceEdit(UndoableEdit anEdit) This default implementation returns false.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Field Details
-
edits
The collection ofUndoableEdits undone/redone en masse by thisCompoundEdit.
-
-
Constructor Details
-
CompoundEdit
public CompoundEdit()Constructs aCompoundEdit.
-
-
Method Details
-
undo
Sendsundoto all containedUndoableEditsin the reverse of the order in which they were added.- Specified by:
undoin interfaceUndoableEdit- Overrides:
undoin classAbstractUndoableEdit- Throws:
CannotUndoException- ifcanUndoreturnsfalse- See Also:
-
redo
Sendsredoto all containedUndoableEdits in the order in which they were added.- Specified by:
redoin interfaceUndoableEdit- Overrides:
redoin classAbstractUndoableEdit- Throws:
CannotRedoException- ifcanRedoreturnsfalse- See Also:
-
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:
-
addEdit
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:
-
end
public void end()SetsinProgressto false.- See Also:
-
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:
-
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
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:
-
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:
-
getPresentationName
ReturnsgetPresentationNamefrom the lastUndoableEditadded toedits. Ifeditsis empty, calls super.- Specified by:
getPresentationNamein interfaceUndoableEdit- Overrides:
getPresentationNamein classAbstractUndoableEdit- Returns:
- the empty string ""
- See Also:
-
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:
-
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:
-
toString
Returns a string that displays and identifies this object's properties.- Overrides:
toStringin classAbstractUndoableEdit- Returns:
- a String representation of this object
-