Class CompoundEdit
java.lang.Object 
 
javax.swing.undo.AbstractUndoableEdit 
 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
| Modifier and Type | Field | Description | 
|---|---|---|
protected Vector<UndoableEdit> | 
edits | 
  The collection of   UndoableEdits undone/redone en masse by this CompoundEdit. | 
Fields declared in class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
Constructor Summary
| Constructor | Description | 
|---|---|
CompoundEdit() | 
  Constructs a   CompoundEdit. | 
Method Summary
| Modifier and Type | Method | Description | 
|---|---|---|
boolean | 
addEdit | 
  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 to edits. | 
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 contained UndoableEdits 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 contained UndoableEdits in the reverse of the order in which they were added. | 
Methods declared in class javax.swing.undo.AbstractUndoableEdit
replaceEdit
Field Details
edits
protected Vector<UndoableEdit> edits
The collection of 
 UndoableEdits undone/redone en masse by this CompoundEdit.Constructor Details
CompoundEdit
public CompoundEdit()
Constructs a 
 CompoundEdit.Method Details
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:
 - 
undoin interfaceUndoableEdit - Overrides:
 - 
undoin classAbstractUndoableEdit - Throws:
 - 
CannotUndoException- ifcanUndoreturnsfalse - See Also:
 
redo
public void redo() throws CannotRedoException
Sends 
 redo to all contained UndoableEdits in the order in which they were added.- Specified by:
 - 
redoin interfaceUndoableEdit - Overrides:
 - 
redoin classAbstractUndoableEdit - Throws:
 - 
CannotRedoException- ifcanRedoreturnsfalse - See Also:
 
lastEdit
protected UndoableEdit lastEdit()
Returns the last 
 UndoableEdit in edits, or null if edits is empty.- Returns:
 - the last 
UndoableEditinedits, ornullifeditsis empty. 
die
public void die()
Sends 
 die to each subedit, in the reverse of the order that they were added.- Specified by:
 - 
diein interfaceUndoableEdit - Overrides:
 - 
diein classAbstractUndoableEdit - See Also:
 
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:
 - 
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()
Sets 
  inProgress to false.canUndo
public boolean canUndo()
Returns false if 
 isInProgress or 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 if 
 isInProgress or 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 the 
 UndoableEdits in edits do. Returns false if they all return false.- Specified by:
 - 
isSignificantin interfaceUndoableEdit - Overrides:
 - 
isSignificantin classAbstractUndoableEdit - Returns:
 - true
 - See Also:
 
getPresentationName
public String getPresentationName()
Returns 
 getPresentationName from the last UndoableEdit added to edits. If edits is empty, calls super.- Specified by:
 - 
getPresentationNamein interfaceUndoableEdit - Overrides:
 - 
getPresentationNamein classAbstractUndoableEdit - Returns:
 - the empty string ""
 - See Also:
 
getUndoPresentationName
public String getUndoPresentationName()
Returns 
 getUndoPresentationName from the last UndoableEdit added to edits. If edits is 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
public String getRedoPresentationName()
Returns 
 getRedoPresentationName from the last UndoableEdit added to edits. If edits is 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
public String toString()
Returns a string that displays and identifies this object's properties.
 - Overrides:
 - 
toStringin classAbstractUndoableEdit - Returns:
 - a String representation of this object
 
    © 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/undo/CompoundEdit.html