Interface DFUndoManager<T extends DFUndoableEdit>

  • Type Parameters:
    T - type of undoable edit

    public interface DFUndoManager<T extends DFUndoableEdit>
    The undo/redo manager for a single undo/redo queue.

    If you want to create a single undo/redo edit for multiple edit operations you can use "complex operations", like:

           DFEntityDataProvider edp = ...;
           DFView view = ...;
           DFUndoManager undoManager = view.getUndoManager();
           try {
               undoManager.startComplexUndo("Display name of undo", edp.getLockable(), env.getLock());
               Map<DFUpdateDescription, DFUpdateResult> results = edp.update(...);
               DFUpdateResult res = results.get(updateDesc);
               if (res.getException() != null) {
                   throw res.getException();
               }
           } finally {
               undoManager.stopComplexUndo(edp.getLockable());
           }
     

    If you want to create a single undo/redo edit for single form-designer operation:

           AbstractViewTopComponent tc = ...;
           DFUndoManager undoManager = tc.getUndoManager();
           AbstractUndoableEdit edit = new T();
           undoManager.addUndoableEdit(edit);
     
    Author:
    Petr Hamernik
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addChangeListener​(javax.swing.event.ChangeListener listener)  
      void addUndoableEdit​(T edit)
      Adds single edit into this undo manager as a single undo operation.
      boolean canRedo()  
      boolean canUndo()  
      void discardAllEdits()
      Empty the undo manager, sending each edit a die message in the process.
      java.lang.String getRedoPresentationName()
      Provides a localized, human readable description of the redoable form of this edit, e.g.
      java.lang.String getUndoPresentationName()
      Provides a localized, human readable description of the undoable form of this edit, e.g.
      void redo​(com.im.commons.progress.DFEnvironmentRO env)
      Re-apply the edit, assuming that it has been undone.
      void removeChangeListener​(javax.swing.event.ChangeListener listener)  
      void startComplexUndo​(java.lang.String presentationName, com.im.commons.progress.DFLockable lockable, com.im.commons.progress.DFLock lock)
      Start the complex operation like copy/paste multiple cells or delete more rows together.
      void stopComplexUndo​(com.im.commons.progress.DFLockable lockable)
      Notifies UndoManager that the complex undoable edit identified by this lockable is finished and can be closed.
      void undo​(com.im.commons.progress.DFEnvironmentRO env)
      Undo the edit that was made.
    • Method Detail

      • canUndo

        boolean canUndo()
        Returns:
        true if it is still possible to undo this operation.
      • redo

        void redo​(com.im.commons.progress.DFEnvironmentRO env)
           throws DFUndoRedoException
        Re-apply the edit, assuming that it has been undone.
        Parameters:
        env -
        Throws:
        DFUndoRedoException
      • canRedo

        boolean canRedo()
        Returns:
        true if it is still possible to redo this operation.
      • getUndoPresentationName

        java.lang.String getUndoPresentationName()
        Provides a localized, human readable description of the undoable form of this edit, e.g. for use as an Undo menu item. Typically derived from getDescription.
        Returns:
        undo description
      • discardAllEdits

        void discardAllEdits()
        Empty the undo manager, sending each edit a die message in the process.
      • startComplexUndo

        void startComplexUndo​(java.lang.String presentationName,
                              com.im.commons.progress.DFLockable lockable,
                              com.im.commons.progress.DFLock lock)
        Start the complex operation like copy/paste multiple cells or delete more rows together. Complex undo action is action which is undoable together despite it's multiple DIF DML edit calls. You should always finish such a complex operation with stopComplexUndo(DFLockable) call.
        Parameters:
        presentationName - The presentation name of the coplex undo operation
        lockable - The complex undoable operation is identified by lockable. It means all edits which happens under this lockable until it's closed will become part of this complex undo edit.
        lock - The lock for lockable
        Throws:
        java.lang.IllegalStateException - if lock is not valid and is not lock of lockable param.
      • stopComplexUndo

        void stopComplexUndo​(com.im.commons.progress.DFLockable lockable)
        Notifies UndoManager that the complex undoable edit identified by this lockable is finished and can be closed.
        Parameters:
        lockable - The lockable which identifies the complex undo operation
      • addUndoableEdit

        void addUndoableEdit​(T edit)
        Adds single edit into this undo manager as a single undo operation.
        Parameters:
        edit -
        Since:
        20.12.0
      • getRedoPresentationName

        java.lang.String getRedoPresentationName()
        Provides a localized, human readable description of the redoable form of this edit, e.g. for use as a Redo menu item. Typically derived from getPresentationName.
        Returns:
        redo description
      • addChangeListener

        void addChangeListener​(javax.swing.event.ChangeListener listener)
      • removeChangeListener

        void removeChangeListener​(javax.swing.event.ChangeListener listener)