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.ObjectThis class adapts the genericUndoRedoSupportprovided by Glazed Lists for specific use with Swing's nativeUndoManager. EachUndoRedoSupport.Editproduced by Glazed List'sUndoRedoSupportis adapted to Swing'sUndoableEditinterface and thenaddedinto the given UndoManager.Fine grain control of the
UndoableEditthat is ultimately added to theUndoableEditcan be achieved by usingthisinstall 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> UndoSupportinstall(javax.swing.undo.UndoManager undoManager, EventList<E> source)Installs support for undoing/redoing edits on the givensource.static <E> UndoSupportinstall(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.voiduninstall()This method removes undo/redo support from theEventListit 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,UndoableEdits are added to theundoManagereach time thesourcechanges.Undoingandredoingthese edits will unapply/reapply the corresponding changes to thesource.This method uses a default strategy for mapping the GL-style edits to
UndoableEdits.- 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,UndoableEdits are added to theundoManagereach time thesourcechanges.Undoingandredoingthese edits will unapply/reapply the corresponding changes to thesource.This method uses the given
editAdapterfor mapping the GL-style edits toUndoableEdits.- 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 theEventListit was installed on. This method is useful when theEventListmust outlive the undo/redo support itself. Calling this method will make this support object available for garbage collection independently of theEventListof items.- Throws:
java.lang.IllegalStateException- if this method is called from any Thread other than the Swing Event Dispatch Thread
-
-