Interface UndoManager
-
- All Known Implementing Classes:
BundleUndoManager,DefaultUndoManager
public interface UndoManagerManagesUndoableOperations. You add such an operation withaddOperation(UndoableOperation)and it is put on a stack. To perform the latest undo callundo(). The operation is then put on the re-do stack. To re-do the latest undone operation callredo().
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddOperation(UndoableOperation operation)Puts an UndoableOperation on the stack.booleancanRedo()Returns true if there's an re-do operation and if the current re-do operation can be performed i.e itsUndoableOperation.canRedo()returns true.booleancanUndo()Returns true if there's an undo operation and if the current undo operation can be performed, i.e itsUndoableOperation.canUndo()returns true.java.util.List<UndoableOperation>getRedoOperations()Returns the re-do operations in the stack's order with the most recent first.java.lang.StringgetRedoPresentationName()Returns a human readable description of the most recent re-do operationjava.util.List<UndoableOperation>getUndoOperations()Returns the undo operations in the stack's order with the most recent first.java.lang.StringgetUndoPresentationName()Returns a human readable description of the most recent undo operationUndoableOperationpeekRedoOperation()Returns the latest re-do operation without performing it.UndoableOperationpeekUndoOperation()Returns the latest undo operation without performing it.voidredo()Re-does the last undo operation, removes it from the re-do stack and puts it on the undo stack.voidundo()Undoes the latest operation.
-
-
-
Method Detail
-
undo
void undo() throws CannotUndoException
Undoes the latest operation. Puts the UndoOperation on the re-do stack.- Throws:
CannotUndoException- if there is no UndoOperation or if the latest operation cannot be undone
-
canUndo
boolean canUndo()
Returns true if there's an undo operation and if the current undo operation can be performed, i.e itsUndoableOperation.canUndo()returns true.- Returns:
- true if there's an undo operation and if the current undo operation can be performed, false otherwise
-
redo
void redo() throws CannotRedoException
Re-does the last undo operation, removes it from the re-do stack and puts it on the undo stack.- Throws:
CannotRedoException- if there is no re-do operation on the stack or the current re-do operation cannot be performed
-
canRedo
boolean canRedo()
Returns true if there's an re-do operation and if the current re-do operation can be performed i.e itsUndoableOperation.canRedo()returns true.- Returns:
- true if there's an re-do operation and if the current re-do operation can be performed, false otherwise
-
addOperation
void addOperation(UndoableOperation operation)
Puts an UndoableOperation on the stack. If the stack is full the oldest UndoableOperation is removed from the stack.- Parameters:
operation- the UndoableOperation operation to be put on the stack
-
peekUndoOperation
UndoableOperation peekUndoOperation()
Returns the latest undo operation without performing it.- Returns:
- latest undo operation without performing it
-
peekRedoOperation
UndoableOperation peekRedoOperation()
Returns the latest re-do operation without performing it.- Returns:
- latest re-do operation without performing it
-
getUndoOperations
java.util.List<UndoableOperation> getUndoOperations()
Returns the undo operations in the stack's order with the most recent first.- Returns:
- undo operations in the stack's order with the most recent first
-
getRedoOperations
java.util.List<UndoableOperation> getRedoOperations()
Returns the re-do operations in the stack's order with the most recent first.- Returns:
- re-do operations in the stack's order with the most recent first
-
getUndoPresentationName
java.lang.String getUndoPresentationName()
Returns a human readable description of the most recent undo operation- Returns:
- human readable description of the most recent undo operation
-
getRedoPresentationName
java.lang.String getRedoPresentationName()
Returns a human readable description of the most recent re-do operation- Returns:
- human readable description of the most recent re-do operation
-
-