public final class UndoRedoSupport<E> extends Object
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.
Modifier and Type | Class and Description |
---|---|
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(org.jadice.util.glazedlists.UndoRedoSupport.Listener) . |
Modifier and Type | Method and Description |
---|---|
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 <E> UndoRedoSupport |
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. |
public static <E> UndoRedoSupport 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 capabilitiespublic 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 void uninstall()
Copyright © 2024 levigo holding gmbh. All rights reserved.