public abstract class ContextualLaunchAction extends Object implements IObjectActionDelegate, IMenuCreator
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.
Constructor and Description |
---|
ContextualLaunchAction(String mode)
Constructs a contextual launch action for the given launch mode.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes the menu returned by
getMenu . |
protected void |
fillMenu(Menu menu)
Fills the menu with applicable launch shortcuts
|
protected ILaunchManager |
getLaunchManager()
Returns the launch manager
|
Menu |
getMenu(Control parent)
Returns the SWT menu, created as a pop up menu parented by the
given control.
|
Menu |
getMenu(Menu parent)
Returns an SWT menu created as a drop down menu parented by the
given menu.
|
void |
run(IAction action)
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.
|
public ContextualLaunchAction(String mode)
mode
- launch modepublic void setActivePart(IAction action, IWorkbenchPart targetPart)
IObjectActionDelegate
This method will be called every time the action appears in a popup menu. The targetPart may change with each invocation.
setActivePart
in interface IObjectActionDelegate
action
- the action proxy that handles presentation portion of the
action; must not be null
.targetPart
- the new part target; must not be null
.public void dispose()
IMenuCreator
getMenu
. Does nothing
if there is no menu. This method will be executed only when the
parent of the menu is disposed.dispose
in interface IMenuCreator
public Menu getMenu(Control parent)
IMenuCreator
getMenu
in interface IMenuCreator
parent
- the parent controlnull
if the menu could not
be createdpublic Menu getMenu(Menu parent)
IMenuCreator
getMenu
in interface IMenuCreator
parent
- the parent menunull
if the menu could not
be createdpublic void run(IAction action)
IActionDelegate
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 the runWithEvent(IAction, Event)
method is called.
run
in interface IActionDelegate
action
- the action proxy that handles the presentation portion of the
actionpublic void selectionChanged(IAction action, ISelection selection)
IActionDelegate
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.
selectionChanged
in interface IActionDelegate
action
- the action proxy that handles presentation portion of
the actionselection
- the current selection, or null
if there
is no selection.protected ILaunchManager getLaunchManager()
protected void fillMenu(Menu menu)
menu
- The menu to fill
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.