Package org.eclipse.ui.actions
Class RetargetAction
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.action.AbstractAction
org.eclipse.jface.action.Action
org.eclipse.ui.actions.PartEventAction
org.eclipse.ui.actions.RetargetAction
- All Implemented Interfaces:
IAction,ActionFactory.IWorkbenchAction,IPartListener
- Direct Known Subclasses:
LabelRetargetAction
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 and check state of the RetargetAction is determined from
the enable and check 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
- Restriction:
- This class is not intended to be subclassed by clients.
-
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 -
Constructor Summary
ConstructorsConstructorDescriptionRetargetAction(String actionID, String text) Constructs a RetargetAction with the given action id and text.RetargetAction(String actionID, String text, int style) Constructs a RetargetAction with the given action id, text and style. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Disposes of the action and any resources held.voidenableAccelerator(boolean b) Enables the accelerator for this action.intReturns the accelerator keycode for this action.Returns the action handler.final booleanReturns whether this action is handled.voidpartActivated(IWorkbenchPart part) A workbench part has been activated.voidpartClosed(IWorkbenchPart part) A workbench part has been closed.voidA workbench part has been deactivated.protected voidEither the action handler itself has changed, or the configured action handlers on the action bars have changed.voidrun()Invoked when an action occurs.voidrunWithEvent(Event event) Invoked when an action occurs.protected voidsetActionHandler(IAction newHandler) Sets the action handler.voidsetChecked(boolean checked) Sets the checked status of this action.voidsetHelpListener(HelpListener listener) TheRetargetActionimplementation of this method declared onIActionstores the help listener in a local field.final StringtoString()Returns a string representation of this action.Methods inherited from class org.eclipse.ui.actions.PartEventAction
getActivePart, partBroughtToTop, partOpenedMethods inherited from class org.eclipse.jface.action.Action
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, notifyResult, removeAcceleratorText, removeMnemonics, setAccelerator, setActionDefinitionId, setDescription, setDisabledImageDescriptor, setEnabled, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipTextMethods inherited from class org.eclipse.jface.action.AbstractAction
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListenerMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jface.action.IAction
addPropertyChangeListener, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, removePropertyChangeListener, setAccelerator, setActionDefinitionId, setDescription, setDisabledImageDescriptor, setEnabled, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
-
Constructor Details
-
RetargetAction
Constructs a RetargetAction with the given action id and text.- Parameters:
actionID- the retargetable action idtext- the action's text, ornullif there is no text
-
RetargetAction
Constructs a RetargetAction with the given action id, text and style.- Parameters:
actionID- the retargetable action idtext- the action's text, ornullif there is no textstyle- one ofAS_PUSH_BUTTON,AS_CHECK_BOX,AS_DROP_DOWN_MENU,AS_RADIO_BUTTON, andAS_UNSPECIFIED- Since:
- 3.0
-
-
Method Details
-
dispose
public void dispose()Disposes of the action and any resources held.- Specified by:
disposein interfaceActionFactory.IWorkbenchAction
-
enableAccelerator
public void enableAccelerator(boolean b) Enables the accelerator for this action.- Parameters:
b- the new enable state
-
getAccelerator
public int getAccelerator()Description copied from interface:IActionReturns the accelerator keycode for this action. The result is the bit-wise OR of zero or more modifier masks and a key, as explained inMenuItem.getAccelerator.- Specified by:
getAcceleratorin interfaceIAction- Overrides:
getAcceleratorin classAction- Returns:
- the accelerator keycode
- See Also:
-
partActivated
A workbench part has been activated. Try to connect to it.- Specified by:
partActivatedin interfaceIPartListener- Overrides:
partActivatedin classPartEventAction- Parameters:
part- the workbench part that has been activated- See Also:
-
partClosed
A workbench part has been closed.- Specified by:
partClosedin interfaceIPartListener- Overrides:
partClosedin classPartEventAction- Parameters:
part- the workbench part that has been closed- See Also:
-
partDeactivated
A workbench part has been deactivated. Disconnect from it.- Specified by:
partDeactivatedin interfaceIPartListener- Overrides:
partDeactivatedin classPartEventAction- Parameters:
part- the workbench part that has been deactivated- See Also:
-
propagateChange
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. -
runWithEvent
Invoked when an action occurs.- Specified by:
runWithEventin interfaceIAction- Overrides:
runWithEventin classAction- Parameters:
event- the SWT event which triggered this action being run- See Also:
-
getActionHandler
Returns the action handler. This method was made public in 3.0.- Returns:
- The current action handling this retargettable action. This handler
will be
nullif there is no current handler.
-
isHandled
public final boolean isHandled()Description copied from interface:IActionReturns whether this action is handled. In the default case, this is alwaystrue. However, if the action delegates some of its behaviour to some other object, then this method should answer whether such an object is currently available. -
setActionHandler
Sets the action handler. -
setChecked
public void setChecked(boolean checked) Description copied from interface:IActionSets the checked status of this action. Applicable for the stylesAS_CHECK_BOXorAS_RADIO_BUTTON.Fires a property change event for the
CHECKEDproperty if the checked status actually changes as a consequence.- Specified by:
setCheckedin interfaceIAction- Overrides:
setCheckedin classAction- Parameters:
checked- the new checked status- See Also:
-
setHelpListener
TheRetargetActionimplementation of this method declared onIActionstores the help listener in a local field. The supplied listener is only used if there is no hanlder.- Specified by:
setHelpListenerin interfaceIAction- Overrides:
setHelpListenerin classAction- Parameters:
listener- a help listener for this action
-
toString
Returns a string representation of this action.
-