On this page
Class AbstractUndoableEdit
- All Implemented Interfaces:
Serializable,UndoableEdit
- Direct Known Subclasses:
AbstractDocument.ElementEdit,CompoundEdit,DefaultStyledDocument.AttributeUndoableEdit,StateEdit
public class AbstractUndoableEdit extends Object implements UndoableEdit, Serializable
UndoableEdit, implementing simple responses to all boolean methods in that interface.
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
protected static final String |
RedoName |
String returned by getRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.
|
protected static final String |
UndoName |
String returned by getUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.
|
Constructor Summary
| Constructor | Description |
|---|---|
AbstractUndoableEdit() |
Creates an AbstractUndoableEdit which defaults hasBeenDone and alive to true.
|
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
addEdit |
This default implementation returns false.
|
boolean |
canRedo() |
Returns true if this edit is alive and hasBeenDone is false.
|
boolean |
canUndo() |
Returns true if this edit is alive and hasBeenDone is true.
|
void |
die() |
Sets alive to false.
|
String |
getPresentationName() |
This default implementation returns "".
|
String |
getRedoPresentationName() |
Retrieves the value from the defaults table with key AbstractUndoableEdit.redoText and returns that value followed by a space, followed by getPresentationName.
|
String |
getUndoPresentationName() |
Retrieves the value from the defaults table with key AbstractUndoableEdit.undoText and returns that value followed by a space, followed by getPresentationName.
|
boolean |
isSignificant() |
This default implementation returns true.
|
void |
redo() |
Throws CannotRedoException if canRedo returns false.
|
boolean |
replaceEdit |
This default implementation returns false.
|
String |
toString() |
Returns a string that displays and identifies this object's properties.
|
void |
undo() |
Throws CannotUndoException if canUndo returns false.
|
Field Details
UndoName
protected static final String UndoName
getUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used. This value is now localized and comes from the defaults table with key AbstractUndoableEdit.undoText.
- See Also:
RedoName
protected static final String RedoName
getRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used. This value is now localized and comes from the defaults table with key AbstractUndoableEdit.redoText.
- See Also:
Constructor Details
AbstractUndoableEdit
public AbstractUndoableEdit()
AbstractUndoableEdit which defaults hasBeenDone and alive to true.
Method Details
die
public void die()
alive to false. Note that this is a one way operation; dead edits cannot be resurrected. Sending undo or redo to a dead edit results in an exception being thrown.
Typically an edit is killed when it is consolidated by another edit's addEdit or replaceEdit method, or when it is dequeued from an UndoManager.
- Specified by:
diein interfaceUndoableEdit- See Also:
undo
public void undo() throws CannotUndoException
CannotUndoException if canUndo returns false. Sets hasBeenDone to false. Subclasses should override to undo the operation represented by this edit. Override should begin with a call to super.
- Specified by:
undoin interfaceUndoableEdit- Throws:
CannotUndoException- ifcanUndoreturnsfalse- See Also:
canUndo
public boolean canUndo()
alive and hasBeenDone is true.
- Specified by:
canUndoin interfaceUndoableEdit- Returns:
-
true if this edit is
aliveandhasBeenDoneistrue - See Also:
redo
public void redo() throws CannotRedoException
CannotRedoException if canRedo returns false. Sets hasBeenDone to true. Subclasses should override to redo the operation represented by this edit. Override should begin with a call to super.
- Specified by:
redoin interfaceUndoableEdit- Throws:
CannotRedoException- ifcanRedoreturnsfalse- See Also:
canRedo
public boolean canRedo()
true if this edit is alive and hasBeenDone is false.
- Specified by:
canRedoin interfaceUndoableEdit- Returns:
trueif this edit isaliveandhasBeenDoneisfalse- See Also:
addEdit
public boolean addEdit(UndoableEdit anEdit)
- Specified by:
addEditin interfaceUndoableEdit- Parameters:
anEdit- the edit to be added- Returns:
- false
- See Also:
replaceEdit
public boolean replaceEdit(UndoableEdit anEdit)
- Specified by:
replaceEditin interfaceUndoableEdit- Parameters:
anEdit- the edit to replace- Returns:
- false
- See Also:
isSignificant
public boolean isSignificant()
- Specified by:
isSignificantin interfaceUndoableEdit- Returns:
- true
- See Also:
getPresentationName
public String getPresentationName()
getUndoPresentationName and getRedoPresentationName to construct the strings they return. Subclasses should override to return an appropriate description of the operation this edit represents.
- Specified by:
getPresentationNamein interfaceUndoableEdit- Returns:
- the empty string ""
- See Also:
getUndoPresentationName
public String getUndoPresentationName()
AbstractUndoableEdit.undoText and returns that value followed by a space, followed by getPresentationName. If getPresentationName returns "", then the defaults value is returned alone.
- Specified by:
getUndoPresentationNamein interfaceUndoableEdit- 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()
AbstractUndoableEdit.redoText and returns that value followed by a space, followed by getPresentationName. If getPresentationName returns "", then the defaults value is returned alone.
- Specified by:
getRedoPresentationNamein interfaceUndoableEdit- 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()
© 1993, 2023, 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/21/docs/api/java.desktop/javax/swing/undo/AbstractUndoableEdit.html