Class MementoBasedUndoableEdit

java.lang.Object
com.levigo.jadice.web.client.undo.AbstractUndoableEdit
com.levigo.jadice.web.client.undo.MementoBasedUndoableEdit
All Implemented Interfaces:
UndoableEdit

public class MementoBasedUndoableEdit extends AbstractUndoableEdit
An UndoableEdit using two Memento, one from before and one after the edit.
  • Constructor Details

    • MementoBasedUndoableEdit

      public MementoBasedUndoableEdit(String description, Object mergeKey, org.jadice.util.base.Memento before, org.jadice.util.base.Memento after)
      Create a memento-based undoable edit from the given menentos and the description of the edit. If non-null, the merge key is used to determine mergeability of two memento-based undoable edits: if they have the same merge key, as merge is performed by replacing the old after-memento with the new after-memento.
      Parameters:
      description - the description of the edit
      mergeKey - the merge key or null if this edit can never be merged with another one
      before - the before memento (used for undo)
      after - the after memento (used for redo)
  • Method Details

    • tryMergeInto

      public boolean tryMergeInto(UndoableEdit anEdit)
      Description copied from interface: UndoableEdit
      Determine whether the given edit can be merged into this edit. If it can, merge the edit and return true, otherwise do nothing and return false.
      Parameters:
      anEdit - the edit that should possible be merged into this edit
      Returns:
      true if this edit could be merged, false otherwise
    • getDescription

      public String getDescription()
      Description copied from class: AbstractUndoableEdit
      Return a presentation name fragment suitable for use both in an "undo something" and "redo something" style phrase.
      Specified by:
      getDescription in class AbstractUndoableEdit
      Returns:
      a "something" fragment
    • undo

      public void undo() throws CannotUndoException
      Description copied from interface: UndoableEdit
      Undo the edit.
      Throws:
      CannotUndoException - if this edit can not be undone
    • redo

      public void redo() throws CannotRedoException
      Description copied from interface: UndoableEdit
      Re-do the edit.
      Throws:
      CannotRedoException - if this edit can not be re-done
    • updateAfterState

      protected void updateAfterState(MementoBasedUndoableEdit newEdit)