public class RetargetAction extends PartEventAction implements ActionFactory.IWorkbenchAction
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.
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 and Description |
|---|
RetargetAction(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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
IAction |
getActionHandler()
Returns the action handler.
|
boolean |
isHandled()
Returns whether this action is handled.
|
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 |
propagateChange(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 |
setChecked(boolean checked)
Sets the checked status of this action.
|
void |
setHelpListener(HelpListener listener)
The
RetargetAction implementation of this method declared on
IAction stores the help listener in a local field. |
String |
toString()
Returns a string representation of this action.
|
getActivePart, partBroughtToTop, partOpenedconvertAccelerator, 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, setToolTipTextaddPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListeneraddListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddPropertyChangeListener, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, removePropertyChangeListener, setAccelerator, setActionDefinitionId, setDescription, setDisabledImageDescriptor, setEnabled, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipTextpublic RetargetAction(String actionID, String text)
actionID - the retargetable action idtext - the action's text, or null if there is no textpublic RetargetAction(String actionID, String text, int style)
actionID - the retargetable action idtext - the action's text, or null if there is no textstyle - one of AS_PUSH_BUTTON, AS_CHECK_BOX,
AS_DROP_DOWN_MENU, AS_RADIO_BUTTON, and
AS_UNSPECIFIEDpublic void dispose()
dispose in interface ActionFactory.IWorkbenchActionpublic void enableAccelerator(boolean b)
b - the new enable statepublic int getAccelerator()
IActionMenuItem.getAccelerator.getAccelerator in interface IActiongetAccelerator in class ActionMenuItem.getAccelerator()public void partActivated(IWorkbenchPart part)
partActivated in interface IPartListenerpartActivated in class PartEventActionpart - the workbench part that has been activatedIWorkbenchPage.activate(org.eclipse.ui.IWorkbenchPart)public void partClosed(IWorkbenchPart part)
partClosed in interface IPartListenerpartClosed in class PartEventActionpart - the workbench part that has been closedIWorkbenchPage.hideView(IViewPart)public void partDeactivated(IWorkbenchPart part)
partDeactivated in interface IPartListenerpartDeactivated in class PartEventActionpart - the workbench part that has been deactivatedIWorkbenchPage.activate(IWorkbenchPart)protected void propagateChange(PropertyChangeEvent event)
public void run()
public void runWithEvent(Event event)
runWithEvent in interface IActionrunWithEvent in class Actionevent - the SWT event which triggered this action being runpublic IAction getActionHandler()
null if there is no current
handler.public final boolean isHandled()
IActiontrue. 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.protected void setActionHandler(IAction newHandler)
public void setChecked(boolean checked)
IActionAS_CHECK_BOX or AS_RADIO_BUTTON.
Fires a property change event for the CHECKED property
if the checked status actually changes as a consequence.
setChecked in interface IActionsetChecked in class Actionchecked - the new checked statusIAction.CHECKEDpublic void setHelpListener(HelpListener listener)
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.setHelpListener in interface IActionsetHelpListener in class Actionlistener - a help listener for this actionGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.