Eclipse Platform
Release 3.1

org.eclipse.ui.operations
Class OperationHistoryActionHandler

java.lang.Object
  extended byorg.eclipse.jface.action.Action
      extended byorg.eclipse.ui.operations.OperationHistoryActionHandler
All Implemented Interfaces:
ActionFactory.IWorkbenchAction, IAction, IAdaptable
Direct Known Subclasses:
RedoActionHandler, UndoActionHandler

public abstract class OperationHistoryActionHandler
extends Action
implements ActionFactory.IWorkbenchAction, IAdaptable

OperationHistoryActionHandler implements common behavior for the undo and redo actions. It supports filtering of undo or redo on a particular undo context. (A null undo context will cause undo and redo to be disabled.)

OperationHistoryActionHandler provides an adapter in the info parameter of the IOperationHistory undo and redo methods that is used to get UI info for prompting the user during operations or operation approval. Adapters are provided for org.eclipse.ui.IWorkbenchWindow, org.eclipse.swt.widgets.Shell, org.eclipse.ui.IWorkbenchPart, org.eclipse.core.commands.IUndoContext, and org.eclipse.runtime.IProgressMonitor.

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.

Since:
3.1

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
 void dispose()
          Disposes of this action.
 Object getAdapter(Class adapter)
          Returns an object which is an instance of the given class associated with this object.
 void run()
          Runs this action.
 void setContext(IUndoContext context)
          Set the context shown by the handler.
 void setPruneHistory(boolean prune)
          Specify whether the action handler should actively prune the operation history when invalid operations are encountered.
 void update()
          Update enabling and labels according to the current status of the operation history.
 
Methods inherited from class org.eclipse.jface.action.Action
addPropertyChangeListener, convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, firePropertyChange, firePropertyChange, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, removePropertyChangeListener, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
 
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()
Description copied from interface: ActionFactory.IWorkbenchAction
Disposes of this action. Once disposed, this action cannot be used. This operation has no effect if the action has already been disposed.

Specified by:
dispose in interface ActionFactory.IWorkbenchAction

run

public final void run()
Description copied from interface: IAction
Runs this action. Each action implementation must define the steps needed to carry out this action. The default implementation of this method in Action does nothing.

Specified by:
run in interface IAction
Overrides:
run in class Action

getAdapter

public Object getAdapter(Class adapter)
Description copied from interface: IAdaptable
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

Specified by:
getAdapter in interface IAdaptable
Parameters:
adapter - the adapter class to look up
Returns:
a object castable to the given class, or null if this object does not have an adapter for the given class

setContext

public void setContext(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.


Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.