Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.ui.internal
Class PluginAction  view PluginAction download PluginAction.java

java.lang.Object
  extended byorg.eclipse.jface.action.Action
      extended byorg.eclipse.ui.internal.PluginAction
All Implemented Interfaces:
org.eclipse.jface.action.IAction, org.eclipse.ui.INullSelectionListener, org.eclipse.ui.IPluginContribution, org.eclipse.jface.viewers.ISelectionChangedListener, org.eclipse.ui.ISelectionListener
Direct Known Subclasses:
ObjectPluginAction, PartPluginAction, WWinPluginAction

public abstract class PluginAction
extends org.eclipse.jface.action.Action
implements org.eclipse.ui.ISelectionListener, org.eclipse.jface.viewers.ISelectionChangedListener, org.eclipse.ui.INullSelectionListener, org.eclipse.ui.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 Summary
private static int actionCount
           
(package private)  boolean adaptableNotChecked
           
private  org.eclipse.core.runtime.IConfigurationElement configElement
           
private  org.eclipse.ui.IActionDelegate delegate
           
private  org.eclipse.ui.SelectionEnabler enabler
           
(package private)  boolean isAdaptableAction
           
private  java.lang.String pluginId
           
private  java.lang.String runAttribute
           
private  org.eclipse.jface.viewers.ISelection selection
           
 
Fields inherited from class org.eclipse.jface.action.Action
 
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, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
 
Constructor Summary
PluginAction(org.eclipse.core.runtime.IConfigurationElement actionElement, java.lang.String id, int style)
          PluginAction constructor.
 
Method Summary
protected  void createDelegate()
          Creates the delegate and refreshes its enablement.
protected  org.eclipse.core.runtime.IConfigurationElement getConfigElement()
           
protected  org.eclipse.ui.IActionDelegate getDelegate()
          Returns the action delegate if created.
 java.lang.String getLocalId()
           
 java.lang.String getOverrideActionId()
          Returns the action identifier this action overrides.
 java.lang.String getPluginId()
           
private  org.eclipse.jface.viewers.ISelection getResourceAdapters(org.eclipse.jface.viewers.ISelection sel)
          Get a new selection with the resource adaptable version of this selection
private  boolean hasAdaptableType()
          Return whether or not this action could have been registered due to an adaptable - i.e.
protected  void initDelegate()
          Initialize the action delegate by calling its lifecycle method.
protected  boolean isOkToCreateDelegate()
          Returns true if the declaring plugin has been loaded and there is no need to delay creating the delegate any more.
protected  void refreshEnablement()
          Refresh the action enablement.
 void run()
          The default implementation of this IAction method does nothing.
 void runWithEvent(org.eclipse.swt.widgets.Event event)
          The default implementation of this IAction method ignores the event argument, and simply calls run().
 void selectionChanged(org.eclipse.jface.viewers.ISelection newSelection)
          Handles selection change.
 void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection sel)
          The SelectionChangedEventAction implementation of this ISelectionListener method calls selectionChanged(IStructuredSelection) when the selection is a structured one.
 void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
          The SelectionChangedEventAction implementation of this ISelectionChangedListener method calls selectionChanged(IStructuredSelection) when the selection is a structured one.
protected  org.eclipse.ui.IActionDelegate validateDelegate(java.lang.Object obj)
          Validates the object is a delegate of the expected type.
 
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, notifyResult, removeAcceleratorText, removeMnemonics, removePropertyChangeListener, 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
 

Field Detail

delegate

private org.eclipse.ui.IActionDelegate delegate

enabler

private org.eclipse.ui.SelectionEnabler enabler

selection

private org.eclipse.jface.viewers.ISelection selection

configElement

private org.eclipse.core.runtime.IConfigurationElement configElement

pluginId

private java.lang.String pluginId

runAttribute

private java.lang.String runAttribute

actionCount

private static int actionCount

isAdaptableAction

boolean isAdaptableAction

adaptableNotChecked

boolean adaptableNotChecked
Constructor Detail

PluginAction

public PluginAction(org.eclipse.core.runtime.IConfigurationElement actionElement,
                    java.lang.String id,
                    int style)
PluginAction constructor.

Method Detail

createDelegate

protected final void createDelegate()
Creates the delegate and refreshes its enablement.


validateDelegate

protected org.eclipse.ui.IActionDelegate validateDelegate(java.lang.Object obj)
                                                   throws org.eclipse.ui.WorkbenchException
Validates 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.


initDelegate

protected void initDelegate()
Initialize the action delegate by calling its lifecycle method. Subclasses may override but must call this implementation first.


getDelegate

protected org.eclipse.ui.IActionDelegate getDelegate()
Returns the action delegate if created. Can be null if the delegate is not created yet or if previous delegate creation failed.


isOkToCreateDelegate

protected boolean isOkToCreateDelegate()
Returns true if the declaring plugin has been loaded and there is no need to delay creating the delegate any more.


hasAdaptableType

private boolean hasAdaptableType()
Return whether or not this action could have been registered due to an adaptable - i.e. it is a resource type.


refreshEnablement

protected void refreshEnablement()
Refresh the action enablement.


run

public void run()
Description copied from class: org.eclipse.jface.action.Action
The default implementation of this IAction method does nothing. Subclasses should override this method if they do not need information from the triggering event, or override runWithEvent(Event) if they do.

Specified by:
run in interface org.eclipse.jface.action.IAction

runWithEvent

public void runWithEvent(org.eclipse.swt.widgets.Event event)
Description copied from class: org.eclipse.jface.action.Action
The default implementation of this IAction method ignores the event argument, and simply calls run(). Subclasses should override this method if they need information from the triggering event, or override run() if not.

Specified by:
runWithEvent in interface org.eclipse.jface.action.IAction

selectionChanged

public void selectionChanged(org.eclipse.jface.viewers.ISelection newSelection)
Handles 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.


selectionChanged

public void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
The SelectionChangedEventAction implementation of this ISelectionChangedListener method calls selectionChanged(IStructuredSelection) when the selection is a structured one.

Specified by:
selectionChanged in interface org.eclipse.jface.viewers.ISelectionChangedListener

selectionChanged

public void selectionChanged(org.eclipse.ui.IWorkbenchPart part,
                             org.eclipse.jface.viewers.ISelection sel)
The SelectionChangedEventAction implementation of this ISelectionListener method calls selectionChanged(IStructuredSelection) when the selection is a structured one. Subclasses may extend this method to react to the change.

Specified by:
selectionChanged in interface org.eclipse.ui.ISelectionListener

getResourceAdapters

private org.eclipse.jface.viewers.ISelection getResourceAdapters(org.eclipse.jface.viewers.ISelection sel)
Get a new selection with the resource adaptable version of this selection


getOverrideActionId

public java.lang.String getOverrideActionId()
Returns the action identifier this action overrides. Default implementation returns null.


getConfigElement

protected org.eclipse.core.runtime.IConfigurationElement getConfigElement()
Since:
3.0

getLocalId

public java.lang.String getLocalId()
Specified by:
getLocalId in interface org.eclipse.ui.IPluginContribution

getPluginId

public java.lang.String getPluginId()
Specified by:
getPluginId in interface org.eclipse.ui.IPluginContribution