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()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
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
-