Eclipse Platform
2.0

org.eclipse.ui.actions
Class RetargetAction

java.lang.Object
  |
  +--org.eclipse.jface.action.Action
        |
        +--org.eclipse.ui.actions.PartEventAction
              |
              +--org.eclipse.ui.actions.RetargetAction
All Implemented Interfaces:
IAction, IPartListener
Direct Known Subclasses:
LabelRetargetAction

public class RetargetAction
extends PartEventAction

A RetargetAction tracks the active part in the workbench. Each RetargetAction has an ID. If the active part provides an action handler for the ID the enable state of the RetargetAction is determined from the enable state of the handler. If the active part does not provide an action handler then this action is disabled.

Note: instances of this class add themselves as listeners to their action handler. It is important for the creator of a retarget action to call dispose when the action is no longer needed. This will ensure that the listener is removed.

This class may be instantiated. It is not intented to be subclassed.

Since:
2.0

Field Summary
 
Fields inherited from interface org.eclipse.jface.action.IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, CHECKED, DESCRIPTION, ENABLED, IMAGE, TEXT, TOOL_TIP_TEXT
 
Constructor Summary
RetargetAction(String actionID, String label)
          Constructs a RetargetAction.
 
Method Summary
 void dispose()
          Disposes of the action and any resources held.
 void enableAccelerator(boolean b)
          Enables the accelerator for this action.
 int getAccelerator()
          Returns the accelerator keycode for this action.
protected  IAction getActionHandler()
          Returns the action handler.
 void partActivated(IWorkbenchPart part)
          A workbench part has been activated.
 void partClosed(IWorkbenchPart part)
          A workbench part has been closed.
 void partDeactivated(IWorkbenchPart part)
          A workbench part has been deactivated.
protected  void propogateChange(PropertyChangeEvent event)
          Either the action handler itself has changed, or the configured action handlers on the action bars have changed.
 void run()
          Invoked when an action occurs.
 void runWithEvent(Event event)
          Invoked when an action occurs.
protected  void setActionHandler(IAction newHandler)
          Sets the action handler.
 void setHelpListener(HelpListener listener)
          The RetargetAction implementation of this method declared on IAction stores the help listener in a local field.
 
Methods inherited from class org.eclipse.ui.actions.PartEventAction
getActivePart, partBroughtToTop, partOpened
 
Methods inherited from class org.eclipse.jface.action.Action
addPropertyChangeListener, convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, firePropertyChange, firePropertyChange, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, removeAcceleratorText, removePropertyChangeListener, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetargetAction

public RetargetAction(String actionID,
                      String label)
Constructs a RetargetAction.

Method Detail

dispose

public void dispose()
Disposes of the action and any resources held.

Since:
2.0

enableAccelerator

public void enableAccelerator(boolean b)
Enables the accelerator for this action.


getAccelerator

public int getAccelerator()
Description copied from interface: IAction
Returns the accelerator keycode for this action. The result is the bit-wise OR of zero or more modifier masks and a key, as explained in MenuItem.getAccelerator.

Specified by:
getAccelerator in interface IAction
Overrides:
getAccelerator in class Action
Returns:
the accelerator keycode
See Also:
MenuItem.getAccelerator()

partActivated

public void partActivated(IWorkbenchPart part)
A workbench part has been activated. Try to connect to it.

Specified by:
partActivated in interface IPartListener
Overrides:
partActivated in class PartEventAction
Parameters:
part - the workbench part that has been activated
See Also:
IPerspective#activate

partClosed

public void partClosed(IWorkbenchPart part)
A workbench part has been closed.

Specified by:
partClosed in interface IPartListener
Overrides:
partClosed in class PartEventAction
Parameters:
part - the workbench part that has been closed
See Also:
IPerspective#close

partDeactivated

public void partDeactivated(IWorkbenchPart part)
A workbench part has been deactivated. Disconnect from it.

Specified by:
partDeactivated in interface IPartListener
Overrides:
partDeactivated in class PartEventAction
Parameters:
part - the workbench part that has been deactivated
See Also:
IPerspective#activate

propogateChange

protected void propogateChange(PropertyChangeEvent event)
Either the action handler itself has changed, or the configured action handlers on the action bars have changed. Update self.


run

public void run()
Invoked when an action occurs.

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

runWithEvent

public void runWithEvent(Event event)
Invoked when an action occurs.

Specified by:
runWithEvent in interface IAction
Overrides:
runWithEvent in class Action
Parameters:
event - the SWT event which triggered this action being run

getActionHandler

protected IAction getActionHandler()
Returns the action handler.


setActionHandler

protected void setActionHandler(IAction newHandler)
Sets the action handler.


setHelpListener

public void setHelpListener(HelpListener listener)
The RetargetAction implementation of this method declared on IAction stores the help listener in a local field. The supplied listener is only used if there is no hanlder.

Specified by:
setHelpListener in interface IAction
Overrides:
setHelpListener in class Action
Parameters:
listener - a help listener for this action

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.