com.levigo.util.swing.glazedlists
Class UndoSupport<E>

java.lang.Object
  extended by com.levigo.util.swing.glazedlists.UndoSupport<E>

public final class UndoSupport<E>
extends Object

This class adapts the generic UndoRedoSupport provided by Glazed Lists for specific use with Swing's native UndoManager. Each UndoRedoSupport.Edit produced by Glazed List's UndoRedoSupport is adapted to Swing's UndoableEdit interface and then added into the given UndoManager.

Fine grain control of the UndoableEdit that is ultimately added to the UndoableEdit can be achieved by using this install method and specifying a custom Function.

Author:
James Lemieux

Method Summary
static
<E> UndoSupport
install(UndoManager undoManager, EventList<E> source)
          Installs support for undoing/redoing edits on the given source.
static
<E> UndoSupport
install(UndoManager undoManager, EventList<E> source, FunctionList.Function<UndoRedoSupport.Edit,UndoableEdit> editAdapter)
          Installs support for undoing/redoing edits on the given source.
 void uninstall()
          This method removes undo/redo support from the EventList it was installed on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

install

public static <E> UndoSupport install(UndoManager undoManager,
                                      EventList<E> source)
Installs support for undoing/redoing edits on the given source. Specifically, UndoableEdits are added to the undoManager each time the source changes. Undoing and redoing these edits will unapply/reapply the corresponding changes to the source.

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 application
source - the EventList to watch for undoable edits
Returns:
an instance of the support class providing undo/redo edit features
Throws:
IllegalStateException - if this method is called from any Thread other than the Swing Event Dispatch Thread

install

public static <E> UndoSupport install(UndoManager undoManager,
                                      EventList<E> source,
                                      FunctionList.Function<UndoRedoSupport.Edit,UndoableEdit> editAdapter)
Installs support for undoing/redoing edits on the given source. Specifically, UndoableEdits are added to the undoManager each time the source changes. Undoing and redoing these edits will unapply/reapply the corresponding changes to the source.

This method uses the given editAdapter for mapping the GL-style edits to UndoableEdits.

Parameters:
undoManager - the manager of all undoable edits for the entire Swing application
source - the EventList to watch for undoable edits
editAdapter - the function that converts GL-style edits into Swing-style edits
Returns:
an instance of the support class providing undo/redo edit features
Throws:
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 the EventList it was installed on. This method is useful when the EventList must outlive the undo/redo support itself. Calling this method will make this support object available for garbage collection independently of the EventList of items.

Throws:
IllegalStateException - if this method is called from any Thread other than the Swing Event Dispatch Thread


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.