Package org.eclipse.ui.internal
Class PluginAction
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.action.AbstractAction
org.eclipse.jface.action.Action
org.eclipse.ui.internal.PluginAction
- All Implemented Interfaces:
- EventListener,- IAction,- ISelectionChangedListener,- INullSelectionListener,- IPluginContribution,- ISelectionListener
- Direct Known Subclasses:
- ObjectPluginAction,- PartPluginAction,- WWinPluginAction
public abstract class PluginAction
extends Action
implements ISelectionListener, ISelectionChangedListener, INullSelectionListener, IPluginContribution
A PluginAction is a proxy for an action extension.
 At startup we read the registry and create a PluginAction for each action
 extension. This plugin action looks like the real action ( label, icon, etc )
 and acts as a proxy for the action until invoked. At that point the proxy
 will instantiate the real action and delegate the run method to the real
 action. This makes it possible to load the action extension lazily.
 Occasionally the class will ask if it is OK to load the delegate (on
 selection changes). If the plugin containing the action extension has been
 loaded then the action extension itself will be instantiated.
- 
Field SummaryFields inherited from interface org.eclipse.jface.action.IActionAS_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 SummaryConstructorsConstructorDescriptionPluginAction(IConfigurationElement actionElement, String id, int style) PluginAction constructor.
- 
Method SummaryModifier and TypeMethodDescriptionprotected final voidCreates the delegate and refreshes its enablement.voiddispose()Disposes this plugin action.voidDisposes the delegate, if created.protected IConfigurationElementprotected IActionDelegateReturns the action delegate if created.Returns the menu creator for this action.Returns the action identifier this action overrides.For testing purposes only.protected voidInitialize the action delegate by calling its lifecycle method.protected booleanReturns true if the declaring plugin has been loaded and there is no need to delay creating the delegate any more.protected voidRefresh the action enablement.voidrun()The default implementation of thisIActionmethod does nothing.voidrunWithEvent(Event event) The default implementation of thisIActionmethod ignores the event argument, and simply callsrun().voidselectionChanged(ISelection newSelection) Handles selection change.voidTheSelectionChangedEventActionimplementation of thisISelectionChangedListenermethod callsselectionChanged(IStructuredSelection)when the selection is a structured one.voidselectionChanged(IWorkbenchPart part, ISelection sel) TheSelectionChangedEventActionimplementation of thisISelectionListenermethod callsselectionChanged(IStructuredSelection)when the selection is a structured one.protected IActionDelegatevalidateDelegate(Object obj) Validates the object is a delegate of the expected type.Methods inherited from class org.eclipse.jface.action.ActionconvertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipTextMethods inherited from class org.eclipse.jface.action.AbstractActionaddPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListenerMethods inherited from class org.eclipse.core.commands.common.EventManageraddListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
- 
Constructor Details- 
PluginActionPluginAction constructor.- Parameters:
- actionElement- the element
- id- the identifier
- style- the style bits
 
 
- 
- 
Method Details- 
createDelegateprotected final void createDelegate()Creates the delegate and refreshes its enablement.
- 
validateDelegateValidates the object is a delegate of the expected type. Subclasses can override to check for specific delegate types.Note: Calls to the object are not allowed during this method. - Parameters:
- obj- a possible action delegate implementation
- Returns:
- the IActionDelegateimplementation for the object
- Throws:
- WorkbenchException- if not of the expected delegate type
 
- 
initDelegateprotected void initDelegate()Initialize the action delegate by calling its lifecycle method. Subclasses may override but must call this implementation first.
- 
getDelegateReturns the action delegate if created. Can benullif the delegate is not created yet or if previous delegate creation failed.
- 
isOkToCreateDelegateprotected boolean isOkToCreateDelegate()Returns true if the declaring plugin has been loaded and there is no need to delay creating the delegate any more.
- 
refreshEnablementprotected void refreshEnablement()Refresh the action enablement.
- 
runpublic void run()Description copied from class:ActionThe default implementation of thisIActionmethod does nothing. Subclasses should override this method if they do not need information from the triggering event, or overriderunWithEvent(Event)if they do.
- 
runWithEventDescription copied from class:ActionThe default implementation of thisIActionmethod ignores the event argument, and simply callsrun(). Subclasses should override this method if they need information from the triggering event, or overriderun()if not.- Specified by:
- runWithEventin interface- IAction
- Overrides:
- runWithEventin class- Action
- Parameters:
- event- the SWT event which triggered this action being run
- See Also:
 
- 
selectionChangedHandles selection change. If rule-based enabled is defined, it will be first to call it. If the delegate is loaded, it will also be given a chance.- Parameters:
- newSelection- the new selection
 
- 
selectionChangedTheSelectionChangedEventActionimplementation of thisISelectionChangedListenermethod callsselectionChanged(IStructuredSelection)when the selection is a structured one.- Specified by:
- selectionChangedin interface- ISelectionChangedListener
- Parameters:
- event- event object describing the change
 
- 
selectionChangedTheSelectionChangedEventActionimplementation of thisISelectionListenermethod callsselectionChanged(IStructuredSelection)when the selection is a structured one. Subclasses may extend this method to react to the change.- Specified by:
- selectionChangedin interface- ISelectionListener
- Parameters:
- part- the workbench part containing the selection
- sel- the current selection. This may be- nullif- INullSelectionListeneris implemented.
- See Also:
 
- 
getSelectionFor testing purposes only.- Returns:
- the selection
- Since:
- 3.1
 
- 
getOverrideActionIdReturns the action identifier this action overrides. Default implementation returnsnull.- Returns:
- the action identifier to override or null
 
- 
getConfigElement- Returns:
- the IConfigurationElement used to create this PluginAction.
- Since:
- 3.0
 
- 
getLocalId- Specified by:
- getLocalIdin interface- IPluginContribution
- Returns:
- the local id of the contribution. Must not be null. This should correspond to the extension-specific identifier for a given contribution.
 
- 
getPluginId- Specified by:
- getPluginIdin interface- IPluginContribution
- Returns:
- the id of the originating plugin. Can be nullif this contribution did not originate from a plugin.
 
- 
disposeDelegatepublic void disposeDelegate()Disposes the delegate, if created.- Since:
- 3.1
 
- 
disposepublic void dispose()Disposes this plugin action.- Since:
- 3.1
 
- 
getMenuCreatorDescription copied from interface:IActionReturns the menu creator for this action.- Specified by:
- getMenuCreatorin interface- IAction
- Overrides:
- getMenuCreatorin class- Action
- Returns:
- the menu creator, or nullif none
 
 
-