CompoundEdit (Java Platform SE 6) (original) (raw)



javax.swing.undo

Class CompoundEdit

java.lang.Object extended by javax.swing.undo.AbstractUndoableEdit extended by 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
protected Vector<UndoableEdit> edits The collection of UndoableEdits undone/redone en masse by this CompoundEdit.
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
Constructor Summary
CompoundEdit()
Method Summary
boolean addEdit(UndoableEdit anEdit) If this edit is inProgress, accepts anEdit and returns true.
boolean canRedo() Returns false if isInProgress or if super returns false.
boolean canUndo() Returns false if isInProgress or if super returns false.
void die() Sends die to each subedit, in the reverse of the order that they were added.
void end() Sets inProgress to false.
String getPresentationName() Returns getPresentationName from the last UndoableEdit added toedits.
String getRedoPresentationName() Returns getRedoPresentationName from the last UndoableEdit added to edits.
String getUndoPresentationName() Returns getUndoPresentationName from the last UndoableEdit added to edits.
boolean isInProgress() Returns true if this edit is in progress--that is, it has not received end.
boolean isSignificant() Returns true if any of the UndoableEdits in edits do.
protected UndoableEdit lastEdit() Returns the last UndoableEdit in edits, or null if edits is empty.
void redo() Sends redo to all containedUndoableEdits in the order in which they were added.
String toString() Returns a string that displays and identifies this object's properties.
void undo() Sends undo to all containedUndoableEdits in the reverse of the order in which they were added.
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../../java/lang/Object.html#wait%28long, int%29)
Field Detail

edits

protected Vector<UndoableEdit> edits

The collection of UndoableEdits undone/redone en masse by this CompoundEdit.

Constructor Detail

CompoundEdit

public CompoundEdit()

Method Detail

undo

public void undo() throws CannotUndoException

Sends undo to all containedUndoableEdits in the reverse of the order in which they were added.

Specified by:

[undo](../../../javax/swing/undo/UndoableEdit.html#undo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[undo](../../../javax/swing/undo/AbstractUndoableEdit.html#undo%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Throws:

[CannotUndoException](../../../javax/swing/undo/CannotUndoException.html "class in javax.swing.undo") - if canUndo returns false

See Also:

AbstractUndoableEdit.canUndo()


redo

public void redo() throws CannotRedoException

Sends redo to all containedUndoableEdits in the order in which they were added.

Specified by:

[redo](../../../javax/swing/undo/UndoableEdit.html#redo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[redo](../../../javax/swing/undo/AbstractUndoableEdit.html#redo%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Throws:

[CannotRedoException](../../../javax/swing/undo/CannotRedoException.html "class in javax.swing.undo") - if canRedo returns false

See Also:

AbstractUndoableEdit.canRedo()


lastEdit

protected UndoableEdit lastEdit()

Returns the last UndoableEdit in edits, or null if edits is empty.


die

public void die()

Sends die to each subedit, in the reverse of the order that they were added.

Specified by:

[die](../../../javax/swing/undo/UndoableEdit.html#die%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[die](../../../javax/swing/undo/AbstractUndoableEdit.html#die%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

See Also:

die()


addEdit

public boolean addEdit(UndoableEdit anEdit)

If this edit is inProgress, accepts anEdit and returns true.

The last edit added to this CompoundEdit is given a chance to addEdit(anEdit). If it refuses (returns false), anEdit is given a chance to replaceEdit the last edit. If anEdit returns false here, it is added to edits.

Specified by:

[addEdit](../../../javax/swing/undo/UndoableEdit.html#addEdit%28javax.swing.undo.UndoableEdit%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[addEdit](../../../javax/swing/undo/AbstractUndoableEdit.html#addEdit%28javax.swing.undo.UndoableEdit%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

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)


end

public void end()

Sets inProgress to false.

See Also:

canUndo(), canRedo()


canUndo

public boolean canUndo()

Returns false if isInProgress or if super returns false.

Specified by:

[canUndo](../../../javax/swing/undo/UndoableEdit.html#canUndo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[canUndo](../../../javax/swing/undo/AbstractUndoableEdit.html#canUndo%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Returns:

true if this edit is alive and hasBeenDone is true

See Also:

isInProgress()


canRedo

public boolean canRedo()

Returns false if isInProgress or if super returns false.

Specified by:

[canRedo](../../../javax/swing/undo/UndoableEdit.html#canRedo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[canRedo](../../../javax/swing/undo/AbstractUndoableEdit.html#canRedo%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Returns:

true if this edit is alive and hasBeenDone is false

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 the UndoableEdits in edits do. Returns false if they all return false.

Specified by:

[isSignificant](../../../javax/swing/undo/UndoableEdit.html#isSignificant%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[isSignificant](../../../javax/swing/undo/AbstractUndoableEdit.html#isSignificant%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Returns:

true

See Also:

UndoableEdit.isSignificant()


getPresentationName

public String getPresentationName()

Returns getPresentationName from the last UndoableEdit added toedits. If edits is empty, calls super.

Specified by:

[getPresentationName](../../../javax/swing/undo/UndoableEdit.html#getPresentationName%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[getPresentationName](../../../javax/swing/undo/AbstractUndoableEdit.html#getPresentationName%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Returns:

the empty string ""

See Also:

AbstractUndoableEdit.getUndoPresentationName(), AbstractUndoableEdit.getRedoPresentationName()


getUndoPresentationName

public String getUndoPresentationName()

Returns getUndoPresentationName from the last UndoableEdit added to edits. If edits is empty, calls super.

Specified by:

[getUndoPresentationName](../../../javax/swing/undo/UndoableEdit.html#getUndoPresentationName%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[getUndoPresentationName](../../../javax/swing/undo/AbstractUndoableEdit.html#getUndoPresentationName%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Returns:

the value from the defaults table with keyAbstractUndoableEdit.undoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.

See Also:

AbstractUndoableEdit.getPresentationName()


getRedoPresentationName

public String getRedoPresentationName()

Returns getRedoPresentationName from the last UndoableEdit added to edits. If edits is empty, calls super.

Specified by:

[getRedoPresentationName](../../../javax/swing/undo/UndoableEdit.html#getRedoPresentationName%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Overrides:

[getRedoPresentationName](../../../javax/swing/undo/AbstractUndoableEdit.html#getRedoPresentationName%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Returns:

the value from the defaults table with keyAbstractUndoableEdit.redoText, followed by a space, followed by getPresentationName unless getPresentationName 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](../../../javax/swing/undo/AbstractUndoableEdit.html#toString%28%29) in class [AbstractUndoableEdit](../../../javax/swing/undo/AbstractUndoableEdit.html "class in javax.swing.undo")

Returns:

a String representation of this object



Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Scripting on this page tracks web page traffic, but does not change the content in any way.