Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.

JSR-209 (Final Approval Ballot)

javax.swing.undo
Class CompoundEdit

java.lang.Object
  extended byjavax.swing.undo.AbstractUndoableEdit
      extended byjavax.swing.undo.CompoundEdit
All Implemented Interfaces:
java.io.Serializable, UndoableEdit
Direct Known Subclasses:
AbstractDocument.DefaultDocumentEvent

public class CompoundEdit
extends AbstractUndoableEdit

A concrete subclass of AbstractUndoableEdit, used to assemble little UndoableEdits into great big ones.


Field Summary
protected  java.util.Vector edits
          The collection of UndoableEdits undone/redone en masse by this CompoundEdit.
 
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.
 java.lang.String getPresentationName()
          Returns getPresentationName 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 contained UndoableEdits in the order in which they were added.
 java.lang.String toString()
          Returns a string that displays and identifies this object's properties.
 void undo()
          Sends undo to all contained UndoableEdits 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
 

Field Detail

edits

protected java.util.Vector 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 contained UndoableEdits in the reverse of the order in which they were added.

Specified by:
undo in interface UndoableEdit
Overrides:
undo in class AbstractUndoableEdit
Throws:
CannotUndoException - if canUndo returns false
See Also:
AbstractUndoableEdit.canUndo()

redo

public void redo()
          throws CannotRedoException
Sends redo to all contained UndoableEdits in the order in which they were added.

Specified by:
redo in interface UndoableEdit
Overrides:
redo in class AbstractUndoableEdit
Throws:
CannotRedoException - 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 in interface UndoableEdit
Overrides:
die in class AbstractUndoableEdit

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 in interface UndoableEdit
Overrides:
addEdit in class AbstractUndoableEdit
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 in interface UndoableEdit
Overrides:
canUndo in class AbstractUndoableEdit
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 in interface UndoableEdit
Overrides:
canRedo in class AbstractUndoableEdit
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 in interface UndoableEdit
Overrides:
isSignificant in class AbstractUndoableEdit
Returns:
true
See Also:
UndoableEdit.isSignificant()

getPresentationName

public java.lang.String getPresentationName()
Returns getPresentationName from the last UndoableEdit added to edits. If edits is empty, calls super.

Specified by:
getPresentationName in interface UndoableEdit
Overrides:
getPresentationName in class AbstractUndoableEdit
Returns:
the empty string ""

toString

public java.lang.String toString()
Returns a string that displays and identifies this object's properties.

Overrides:
toString in class AbstractUndoableEdit
Returns:
a String representation of this object

JSR-209 (Final Approval Ballot)

Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 209 specification.
ing HTML relocated from here