Class UndoRedoSupport<E>
- java.lang.Object
-
- ca.odell.glazedlists.UndoRedoSupport<E>
-
public final class UndoRedoSupport<E> extends java.lang.ObjectUndoRedoSupport, 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
ObservableElementListwhich 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.Editobject. 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
BasicEventListor a trivial wrapper around a BasicEventList which does not affect the order or type of the elements, such as anObservableElementList. Advanced transformations, such asSortedListorFilterListwill not work as expected with this UndoRedoSupport class since their contents are controlled by information outside of themselves (Comparators andMatchers).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 interfaceUndoRedoSupport.EditProvides an easy interface to undo/redo a ListEvent in its entirety.static interfaceUndoRedoSupport.ListenerImplementations 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 voidaddUndoSupportListener(UndoRedoSupport.Listener l)Add aUndoRedoSupport.Listenerwhich will receive a callback when an undoable edit occurs on the given sourceEventList.static <E> UndoRedoSupportinstall(EventList<E> source)Installs support for undoing and redoing changes to the givensource.voidremoveUndoSupportListener(UndoRedoSupport.Listener l)Remove aUndoRedoSupport.Listenerfrom receiving a callback when an undoable edit occurs on the given sourceEventList.voiduninstall()This method removes undo/redo support from theEventListit was installed on.
-
-
-
Method Detail
-
addUndoSupportListener
public void addUndoSupportListener(UndoRedoSupport.Listener l)
Add aUndoRedoSupport.Listenerwhich will receive a callback when an undoable edit occurs on the given sourceEventList.
-
removeUndoSupportListener
public void removeUndoSupportListener(UndoRedoSupport.Listener l)
Remove aUndoRedoSupport.Listenerfrom 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.Listenermust be registered on the object that is returned by this method. That Listener object will typically add theUndoRedoSupport.Editit 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()
-
-