|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.util.base.glazedlists.UndoRedoSupport<E>
public final class UndoRedoSupport<E>
UndoRedoSupport, as the name suggests, will provide generic support for undoing and redoing
groups of changes to an EventList
. The granularity of each undoable edit is determined by
the ListEvent from which it was generated.
Not every change described in a ListEvent results in an undoable edit. Specifically, a
mutation of a list element IN PLACE does not produce an undoable edit. For
example, an ObservableElementList
which observes a change of an element, or a call to
List.set(int, E)
with the same object at that index produce a ListEvent that does not have a
corresponding UndoRedoSupport.Edit
object. These ListEvents are ignored because they lack sufficient
information to undo or redo the change.
In general UndoRedoSupport only makes sense for use with a BasicEventList
or a trivial
wrapper around a BasicEventList which does not affect the order or type of the elements, such as
an ObservableElementList
. Advanced transformations, such as SortedList
or
FilterList
will not work as expected with this UndoRedoSupport class since their contents
are controlled by information outside of themselves (Comparator
s and
Matcher
s).
This class is agnostic to any particular GUI toolkit. As such it may be used in a headless environment or can also be bound to a specific toolkit.
Nested Class Summary | |
---|---|
static interface |
UndoRedoSupport.Edit
Provides an easy interface to undo/redo a ListEvent in its entirety. |
static interface |
UndoRedoSupport.Listener
Implementations of this Listener interface should be registered with an UndoRedoSupport object via addUndoSupportListener(com.levigo.util.base.glazedlists.UndoRedoSupport.Listener) . |
Method Summary | ||
---|---|---|
void |
addUndoSupportListener(UndoRedoSupport.Listener l)
Add a UndoRedoSupport.Listener which will receive a callback when an undoable edit occurs on the given
source EventList . |
|
static
|
install(EventList<E> source)
Installs support for undoing and redoing changes to the given source . |
|
void |
removeUndoSupportListener(UndoRedoSupport.Listener l)
Remove a UndoRedoSupport.Listener from receiving a callback when an undoable edit occurs on the given
source EventList . |
|
void |
uninstall()
This method removes undo/redo support from the EventList it was installed on. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void addUndoSupportListener(UndoRedoSupport.Listener l)
UndoRedoSupport.Listener
which will receive a callback when an undoable edit occurs on the given
source EventList
.
public void removeUndoSupportListener(UndoRedoSupport.Listener l)
UndoRedoSupport.Listener
from receiving a callback when an undoable edit occurs on the given
source EventList
.
public static <E> UndoRedoSupport<E> install(EventList<E> source)
source
. To be
notified of undoable changes, a UndoRedoSupport.Listener
must be registered on the object that is
returned by this method. That Listener object will typically add the UndoRedoSupport.Edit
it is given
over to whatever data structure is managing all undo/redo functions for the entire application.
source
- the EventList on which to provide undo/redo capabilities
public void uninstall()
EventList
it was installed on. This
method is useful when the EventList
must outlive the UndoRedoSupport object itself. The
UndoRedoSupport object will become available for garbage collection independently of the
EventList
it decorated with behaviour.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |