Class UndoRedoSupport<E>
- java.lang.Object
-
- ca.odell.glazedlists.UndoRedoSupport<E>
-
public final class UndoRedoSupport<E> extends java.lang.Object
UndoRedoSupport, as the name suggests, will provide generic support for undoing and redoing groups of changes to anEventList
. 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 toList.set(int, E)
with the same object at that index produce a ListEvent that does not have a correspondingUndoRedoSupport.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 anObservableElementList
. Advanced transformations, such asSortedList
orFilterList
will not work as expected with this UndoRedoSupport class since their contents are controlled by information outside of themselves (Comparator
s andMatcher
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.
- Author:
- James Lemieux
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 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 viaaddUndoSupportListener(ca.odell.glazedlists.UndoRedoSupport.Listener)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUndoSupportListener(UndoRedoSupport.Listener l)
Add aUndoRedoSupport.Listener
which will receive a callback when an undoable edit occurs on the given sourceEventList
.static <E> UndoRedoSupport
install(EventList<E> source)
Installs support for undoing and redoing changes to the givensource
.void
removeUndoSupportListener(UndoRedoSupport.Listener l)
Remove aUndoRedoSupport.Listener
from receiving a callback when an undoable edit occurs on the given sourceEventList
.void
uninstall()
This method removes undo/redo support from theEventList
it was installed on.
-
-
-
Method Detail
-
addUndoSupportListener
public void addUndoSupportListener(UndoRedoSupport.Listener l)
Add aUndoRedoSupport.Listener
which will receive a callback when an undoable edit occurs on the given sourceEventList
.
-
removeUndoSupportListener
public void removeUndoSupportListener(UndoRedoSupport.Listener l)
Remove aUndoRedoSupport.Listener
from receiving a callback when an undoable edit occurs on the given sourceEventList
.
-
install
public static <E> UndoRedoSupport install(EventList<E> source)
Installs support for undoing and redoing changes to the givensource
. To be notified of undoable changes, aUndoRedoSupport.Listener
must be registered on the object that is returned by this method. That Listener object will typically add theUndoRedoSupport.Edit
it is given over to whatever data structure is managing all undo/redo functions for the entire application.- Parameters:
source
- the EventList on which to provide undo/redo capabilities- Returns:
- an instance of UndoRedoSupport through which the undo/redo behaviour can be customized
-
uninstall
public void uninstall()
-
-