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 ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.Fields declared in class AbstractUndoableEdit
RedoName, UndoName
Modifier and TypeFieldDescriptionprotected static final String
String returned bygetRedoPresentationName
; as of Java 2 platform v1.3.1 this field is no longer used.protected static final String
String returned bygetUndoPresentationName
; as of Java 2 platform v1.3.1 this field is no longer used. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.ReturnsgetPresentationName
from the lastUndoableEdit
added toedits
.ReturnsgetRedoPresentationName
from the lastUndoableEdit
added toedits
.ReturnsgetUndoPresentationName
from the lastUndoableEdit
added toedits
.boolean
Returns true if this edit is in progress--that is, it has not received end.boolean
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.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 declared in class AbstractUndoableEdit
replaceEdit
Modifier and TypeMethodDescriptionboolean
replaceEdit
(UndoableEdit anEdit) This default implementation returns false.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
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
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(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 void
wait
(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 ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.
-
-
Constructor Details
-
CompoundEdit
public CompoundEdit()Constructs aCompoundEdit
.
-
-
Method Details
-
undo
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:
-
redo
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:
-
lastEdit
Returns the lastUndoableEdit
inedits
, ornull
ifedits
is empty.- Returns:
- the last
UndoableEdit
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:
-
addEdit
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:
-
end
public void end()SetsinProgress
to false.- See Also:
-
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:
-
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
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 theUndoableEdit
s inedits
do. Returns false if they all return false.- Specified by:
isSignificant
in interfaceUndoableEdit
- Overrides:
isSignificant
in classAbstractUndoableEdit
- Returns:
- true
- See Also:
-
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:
-
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:
-
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:
-
toString
Returns a string that displays and identifies this object's properties.- Overrides:
toString
in classAbstractUndoableEdit
- Returns:
- a String representation of this object
-