public class UndoStateManager
extends Object
What constitutes a state is entirely the responsibility of the implementer of the Undoable interface. As much or as little of the object's state may be saved/restored as required by the application's interaction.
UndoableState
,
Undoable
Modifier and Type | Field and Description |
---|---|
protected boolean |
enabled
Whether to actually operate or not
|
Undoable |
stateSource
The object whose states are being managed.
|
protected UndoRedoList<UndoableState> |
urStack
Supports the undo/redo operations.
|
Constructor and Description |
---|
UndoStateManager(Undoable source,
int max)
Instantiates the manager, with an undo/redo maximum level.
|
Modifier and Type | Method and Description |
---|---|
void |
doRedo()
Restores the object's state from the state just forward of the current
one.
|
void |
doUndo()
Restores the object's state from the last saved state.
|
boolean |
isEnabled()
Whether this manager is enabled or not.
|
void |
markAfterUndoableStep()
Tells the state manager that we've just completed something undoable.
|
boolean |
redoAvailable()
Is there a future state to restore?
|
void |
reset()
Empties the undo redo lists.
|
void |
resetAndMark()
Forget all previous actions and mark the current state for further
possible undo.
|
void |
setEnabled(boolean enabled)
Disable the marking capability.
|
boolean |
undoAvailable()
Is there any previous state to restore?
|
protected UndoRedoList<UndoableState> urStack
public Undoable stateSource
protected boolean enabled
public UndoStateManager(Undoable source, int max)
max
- the most number of previous/future actions handled by "undo"
If max is reached, then old states are discarded.public void markAfterUndoableStep()
public void doUndo()
public void doRedo()
public boolean undoAvailable()
public boolean redoAvailable()
public void reset()
public void resetAndMark()
public void setEnabled(boolean enabled)
public boolean isEnabled()