Class ContextualLaunchAction
- All Implemented Interfaces:
IMenuCreator
,IActionDelegate
,IObjectActionDelegate
This class can be sub-classed and contributed as an object contribution pop-up menu extension action. When invoked, it becomes a sub-menu that dynamically builds a list of applicable launch shortcuts for the current selection. Each launch shortcut may have optional information to support a context menu action.
Clients may subclass this class.
- Since:
- 3.0
-
Constructor Summary
ConstructorDescriptionContextualLaunchAction
(String mode) Constructs a contextual launch action for the given launch mode. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Disposes the menu returned bygetMenu
.protected void
Fills the menu with applicable launch shortcutsprotected ILaunchManager
Returns the launch managerReturns the SWT menu, created as a pop up menu parented by the given control.Returns an SWT menu created as a drop down menu parented by the given menu.void
Performs this action.void
selectionChanged
(IAction action, ISelection selection) Notifies this action delegate that the selection in the workbench has changed.void
setActivePart
(IAction action, IWorkbenchPart targetPart) Sets the active part for the delegate.
-
Constructor Details
-
ContextualLaunchAction
Constructs a contextual launch action for the given launch mode.- Parameters:
mode
- launch mode
-
-
Method Details
-
setActivePart
Description copied from interface:IObjectActionDelegate
Sets the active part for the delegate. The active part is commonly used to get a working context for the action, such as the shell for any dialog which is needed.This method will be called every time the action appears in a popup menu. The targetPart may change with each invocation.
- Specified by:
setActivePart
in interfaceIObjectActionDelegate
- Parameters:
action
- the action proxy that handles presentation portion of the action; must not benull
.targetPart
- the new part target; must not benull
.
-
dispose
public void dispose()Description copied from interface:IMenuCreator
Disposes the menu returned bygetMenu
. Does nothing if there is no menu. This method will be executed only when the parent of the menu is disposed.- Specified by:
dispose
in interfaceIMenuCreator
-
getMenu
Description copied from interface:IMenuCreator
Returns the SWT menu, created as a pop up menu parented by the given control. In most cases, this menu can be created once, cached and reused when the pop-up/drop-down action occurs. If the menu must be dynamically created (i.e., each time it is popped up or dropped down), the old menu should be disposed of before replacing it with the new menu.- Specified by:
getMenu
in interfaceIMenuCreator
- Parameters:
parent
- the parent control- Returns:
- the menu, or
null
if the menu could not be created
-
getMenu
Description copied from interface:IMenuCreator
Returns an SWT menu created as a drop down menu parented by the given menu. In most cases, this menu can be created once, cached and reused when the pop-up/drop-down action occurs. If the menu must be dynamically created (i.e., each time it is popped up or dropped down), the old menu should be disposed of before replacing it with the new menu.- Specified by:
getMenu
in interfaceIMenuCreator
- Parameters:
parent
- the parent menu- Returns:
- the menu, or
null
if the menu could not be created
-
run
Description copied from interface:IActionDelegate
Performs this action.This method is called by the proxy action when the action has been triggered. Implement this method to do the actual work.
Note: If the action delegate also implements
IActionDelegate2
, then this method is not invoked but instead therunWithEvent(IAction, Event)
method is called.- Specified by:
run
in interfaceIActionDelegate
- Parameters:
action
- the action proxy that handles the presentation portion of the action
-
selectionChanged
Description copied from interface:IActionDelegate
Notifies this action delegate that the selection in the workbench has changed.Implementers can use this opportunity to change the availability of the action or to modify other presentation properties.
When the selection changes, the action enablement state is updated based on the criteria specified in the plugin.xml file. Then the delegate is notified of the selection change regardless of whether the enablement criteria in the plugin.xml file is met.
- Specified by:
selectionChanged
in interfaceIActionDelegate
- Parameters:
action
- the action proxy that handles presentation portion of the actionselection
- the current selection, ornull
if there is no selection.
-
getLaunchManager
Returns the launch manager- Returns:
- the launch manager
- Since:
- 3.3
-
fillMenu
Fills the menu with applicable launch shortcuts- Parameters:
menu
- The menu to fill
-