Package ca.odell.glazedlists.swing
Class UndoSupport<E>
- java.lang.Object
-
- ca.odell.glazedlists.swing.UndoSupport<E>
-
public final class UndoSupport<E> extends java.lang.Object
This class adapts the genericUndoRedoSupport
provided by Glazed Lists for specific use with Swing's nativeUndoManager
. EachUndoRedoSupport.Edit
produced by Glazed List'sUndoRedoSupport
is adapted to Swing'sUndoableEdit
interface and thenadded
into the given UndoManager.Fine grain control of the
UndoableEdit
that is ultimately added to theUndoableEdit
can be achieved by usingthis
install method and specifying a custom Function.- Author:
- James Lemieux
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> UndoSupport
install(javax.swing.undo.UndoManager undoManager, EventList<E> source)
Installs support for undoing/redoing edits on the givensource
.static <E> UndoSupport
install(javax.swing.undo.UndoManager undoManager, EventList<E> source, FunctionList.Function<UndoRedoSupport.Edit,javax.swing.undo.UndoableEdit> editAdapter)
Installs support for undoing/redoing edits on the givensource
.void
uninstall()
This method removes undo/redo support from theEventList
it was installed on.
-
-
-
Method Detail
-
install
public static <E> UndoSupport install(javax.swing.undo.UndoManager undoManager, EventList<E> source)
Installs support for undoing/redoing edits on the givensource
. Specifically,UndoableEdit
s are added to theundoManager
each time thesource
changes.Undoing
andredoing
these edits will unapply/reapply the corresponding changes to thesource
.This method uses a default strategy for mapping the GL-style edits to
UndoableEdit
s.- Parameters:
undoManager
- the manager of all undoable edits for the entire Swing applicationsource
- the EventList to watch for undoable edits- Returns:
- an instance of the support class providing undo/redo edit features
- Throws:
java.lang.IllegalStateException
- if this method is called from any Thread other than the Swing Event Dispatch Thread
-
install
public static <E> UndoSupport install(javax.swing.undo.UndoManager undoManager, EventList<E> source, FunctionList.Function<UndoRedoSupport.Edit,javax.swing.undo.UndoableEdit> editAdapter)
Installs support for undoing/redoing edits on the givensource
. Specifically,UndoableEdit
s are added to theundoManager
each time thesource
changes.Undoing
andredoing
these edits will unapply/reapply the corresponding changes to thesource
.This method uses the given
editAdapter
for mapping the GL-style edits toUndoableEdit
s.- Parameters:
undoManager
- the manager of all undoable edits for the entire Swing applicationsource
- the EventList to watch for undoable editseditAdapter
- the function that converts GL-style edits into Swing-style edits- Returns:
- an instance of the support class providing undo/redo edit features
- Throws:
java.lang.IllegalStateException
- if this method is called from any Thread other than the Swing Event Dispatch Thread
-
uninstall
public void uninstall()
This method removes undo/redo support from theEventList
it was installed on. This method is useful when theEventList
must outlive the undo/redo support itself. Calling this method will make this support object available for garbage collection independently of theEventList
of items.- Throws:
java.lang.IllegalStateException
- if this method is called from any Thread other than the Swing Event Dispatch Thread
-
-