Class IzOperationHistoryActionHandler

  • All Implemented Interfaces:
    org.eclipse.core.runtime.IAdaptable, org.eclipse.jface.action.IAction, org.eclipse.ui.actions.ActionFactory.IWorkbenchAction
    Direct Known Subclasses:
    IzRedoActionHandler, IzUndoActionHandler

    public abstract class IzOperationHistoryActionHandler
    extends org.eclipse.jface.action.Action
    implements org.eclipse.ui.actions.ActionFactory.IWorkbenchAction, org.eclipse.core.runtime.IAdaptable
    OperationHistoryActionHandler implements common behavior for the undo and redo actions. It supports filtering of undo or redo on a particular undo context. If an undo context is not specified, or there has been no history available for the specified undo context, then the workbench undo context will be used.

    OperationHistoryActionHandler assumes a linear undo/redo model. When the handler is run, the operation history is asked to perform the most recent undo/redo for the handler's undo context. The handler can be configured (using #setPruneHistory(true)) to flush the operation undo or redo history for the handler's undo context when there is no valid operation on top of the history. This avoids keeping a stale history of invalid operations. By default, pruning does not occur and it is assumed that clients of the particular undo context are pruning the history when necessary.

    This class is virtually a copy of the Eclipse OperationHistoryActionHandler, with the workbench site requirement removed in order to accommodate a shell instead.

    Author:
    Christopher Mindus
    • Field Summary

      • Fields inherited from interface org.eclipse.jface.action.IAction

        AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voiddispose()
      Dispose of the action, clean up listener.
      <T> TgetAdapter​(java.lang.Class<T> adapter)
      Adapts...
      voidrun()
      The action run method.
      voidsetContext​(org.eclipse.core.commands.operations.IUndoContext context)
      Set the context shown by the handler.
      voidsetPruneHistory​(boolean prune)
      Specify whether the action handler should actively prune the operation history when invalid operations are encountered.
      voidupdate()
      Update enabling and labels according to the current status of the operation history.
      • Methods inherited from class org.eclipse.jface.action.Action

        convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
      • Methods inherited from class org.eclipse.jface.action.AbstractAction

        addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
      • Methods inherited from class org.eclipse.core.commands.common.EventManager

        addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.eclipse.jface.action.IAction

        addPropertyChangeListener, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, removePropertyChangeListener, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
    • Method Detail

      • dispose

        public void dispose()
        Dispose of the action, clean up listener.
        Specified by:
        dispose in interface org.eclipse.ui.actions.ActionFactory.IWorkbenchAction
      • run

        public final void run()
        The action run method.
        Specified by:
        run in interface org.eclipse.jface.action.IAction
        Overrides:
        run in class org.eclipse.jface.action.Action
      • getAdapter

        public <T> T getAdapter​(java.lang.Class<T> adapter)
        Adapts...
        Specified by:
        getAdapter in interface org.eclipse.core.runtime.IAdaptable
      • setContext

        public void setContext​(org.eclipse.core.commands.operations.IUndoContext context)
        Set the context shown by the handler. Normally the context is set up when the action handler is created, but the context can also be changed dynamically.
        Parameters:
        context - The context to be used for the undo history.
      • setPruneHistory

        public void setPruneHistory​(boolean prune)
        Specify whether the action handler should actively prune the operation history when invalid operations are encountered. The default value is false.
        Parameters:
        prune - true if the history should be pruned by the handler, and false if it should not.
      • update

        public void update()
        Update enabling and labels according to the current status of the operation history.