Class EventListUndoTracker<E>

java.lang.Object
com.levigo.jadice.web.client.undo.EventListUndoTracker<E>
Type Parameters:
E - the type of element in the EventList

public class EventListUndoTracker<E> extends Object
An EventListUndoTracker tracks changes to the contents of an EventList. UndoableEdits can be generated and fed into an DefaultUndoManager. Multiple event list edits can be collected into distinct logical edits. Usually, an EventListUndoTracker will not remain be attached to an EventList for a long time, if the life-cycle of the target list isn't closely managed. Instead, it should be attached before performing a set of operations and detached as soon as it is completed using done(), discard() or finish(String).
  • Method Details

    • startTracking

      public static <E> EventListUndoTracker<E> startTracking(org.jadice.util.glazedlists.EventList<E> list, UndoManager undoManager)
      Install an EventListUndoTracker on the given event list. Collected edits will be fed into the given undo manager. Once an operation to be tracked is completed, the undo tracker can be detached using done(), discard() or finish(String).
      Parameters:
      list - the list
      undoManager - the target undo manager
      Returns:
      an EventListUndoTracker
    • snapshot

      public void snapshot(String description)
      Create a snapshot of all pending edits and commit them into the UndoManager under the given human-readable edit description. If no edits are currently pending (no changes have been made since installation or the most recent snapshot(String)), nothing will happen.
      Parameters:
      description - the description of the edit
    • finish

      public void finish(String description)
      Finish tracking changes on the EventList. Takes all pending edits and commits them into the UndoManager under the given human-readable edit description. If no edits are currently pending (no changes have been made since installation or the most recent snapshot(String)) no Edit will be committed. This method is a shortcut for calling snapshot(String) and done() in sequence.
      Parameters:
      description - the description of the edit
    • discard

      public void discard()
      Finish tracking changes on the EventList and discard all edits (not only the pending ones!) captured by this tracker.
    • done

      public void done()
      Finish tracking changes on the EventList. If any pending edits remain, those are discarded and do not become part of an undoable edit.