public class TLcdUndoManager extends Object implements ILcdUndoableListener
This class is a manager for classes that implement the ILcdUndoable
interface.
One can add ILcdUndoable
s to this manager which can then later be undone and redone
using the methods undo()
and redo()
.
For convenience, it implements ILcdUndoableListener
. This allows to add a
TLcdUndoManager
as a listener to any class that supports undo/redo (e.g. the TLcdGXYZoomController
). Any ILcdUndoable
s that are
emitted by this class will then be added to this manager.
The public methods of this class are synchronized, and should be safe to call from multiple
threads. This should make TLcdUndoManager
a convenient marshall for classes that
support the undo/redo mechanism.
ILcdUndoable
,
TLcdUndoAction
,
TLcdRedoAction
Constructor and Description |
---|
TLcdUndoManager()
Creates an undo manager with a default limit.
|
TLcdUndoManager(int aLimit)
Creates an undo manager with the specified limit.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ILcdChangeListener aChangeListener)
Adds a status listener to this manager that will be notified when anything about the undo
manager changes.
|
void |
addUndoable(ILcdUndoable aUndoable)
Adds an ILcdUndoable to this undo manager.
|
void |
discardAll()
Discards all
ILcdUndoable objects managed by this TLcdUndoManager . |
ILcdUndoable |
getCurrentRedo()
Returns the
ILcdUndoable that will be triggered upon the next redo. |
ILcdUndoable |
getCurrentUndo()
Returns the
ILcdUndoable that will be triggered upon the next undo. |
int |
getLimit()
Returns the limit that is set on this manager.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
redo()
Redoes the significant
ILcdUndoable that was undone last. |
void |
removeChangeListener(ILcdChangeListener aChangeListener)
Removes the specified change listener from this manager.
|
void |
removeStatusListener(ILcdChangeListener aChangeListener)
Deprecated.
The name of this method is wrong. Use
removeChangeListener instead. |
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setLimit(int aLimit)
Sets an upper limit for the amount of
ILcdUndoable s this
TLcdUndoManager can hold. |
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
undo()
Undoes the significant
ILcdUndoable that was added or redone last. |
void |
undoableHappened(TLcdUndoableEvent aEvent)
Implementation of
ILcdUndoableListener.undoableHappened(TLcdUndoableEvent) . |
public TLcdUndoManager()
public TLcdUndoManager(int aLimit)
aLimit
- The number of significant ILcdUndoable
s this manager should keep
track of.setLimit(int)
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.aTraceOn
- if true then all log messages are recorded for this
instance. If false, then only the informative, warning and
error log messages are recorded.public boolean isTraceOn()
true
if tracing is enabled for this class.public void addChangeListener(ILcdChangeListener aChangeListener)
aChangeListener
- The status listener that will be notified when the undo manager
changes.public void removeChangeListener(ILcdChangeListener aChangeListener)
aChangeListener
- The change listener that should no longer be notified of changes in the
undo manager.public void removeStatusListener(ILcdChangeListener aChangeListener)
removeChangeListener
instead.aChangeListener
- The change listener that should no longer be notified of changes in the
undo manager.public void undoableHappened(TLcdUndoableEvent aEvent)
ILcdUndoableListener.undoableHappened(TLcdUndoableEvent)
. Adds the
ILcdUndoable
contained in aEvent
to this manager.undoableHappened
in interface ILcdUndoableListener
aEvent
- The event describing the new ILcdUndoable
.public ILcdUndoable getCurrentUndo()
ILcdUndoable
that will be triggered upon the next undo.ILcdUndoable
that will be triggered upon the next undo.public ILcdUndoable getCurrentRedo()
ILcdUndoable
that will be triggered upon the next redo.ILcdUndoable
that will be triggered upon the next redo.public void undo()
ILcdUndoable
that was added or redone last.ILcdUndoable.isSignificant()
public void redo()
ILcdUndoable
that was undone last.ILcdUndoable.isSignificant()
public void addUndoable(ILcdUndoable aUndoable)
ILcdUndoable
s that
could be redone by invoking ILcdUndoable.die()
on them.aUndoable
- The undoable to add to the manager.public void discardAll()
ILcdUndoable
objects managed by this TLcdUndoManager
.public void setLimit(int aLimit)
ILcdUndoable
s this
TLcdUndoManager
can hold. Use -1 to indicate there is no upper limit. This limit
only applies to the number of significant undoables that can be held.aLimit
- The new upper limit, or -1 to disable the upper limit.public int getLimit()
ILcdUndoable
s this manager can hold.