Eclipse Platform
Release 3.0

org.eclipse.debug.ui.actions
Class ContextualLaunchAction

java.lang.Object
  extended byorg.eclipse.debug.ui.actions.ContextualLaunchAction
All Implemented Interfaces:
IActionDelegate, IMenuCreator, IObjectActionDelegate

public abstract class ContextualLaunchAction
extends Object
implements IObjectActionDelegate, IMenuCreator

An action delegate that builds a context menu with applicable launch shortcuts for a specific launch mode.

This class can be subclassed 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. The extra

Clients may subclass this class.

Since:
3.0

Constructor Summary
ContextualLaunchAction(String mode)
          Constructs a contextual launch action for the given launch mode.
 
Method Summary
 void dispose()
          Disposes the menu returned by getMenu.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextualLaunchAction

public ContextualLaunchAction(String mode)
Constructs a contextual launch action for the given launch mode.

Parameters:
mode - launch mode
Method Detail

setActivePart

public void setActivePart(IAction action,
                          IWorkbenchPart targetPart)
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 interface IObjectActionDelegate
Parameters:
action - the action proxy that handles presentation portion of the action
targetPart - the new part target

dispose

public void dispose()
Description copied from interface: IMenuCreator
Disposes the menu returned by getMenu. 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 interface IMenuCreator

getMenu

public Menu getMenu(Control parent)
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 interface IMenuCreator
Parameters:
parent - the parent control
Returns:
the menu, or null if the menu could not be created

getMenu

public Menu getMenu(Menu parent)
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 interface IMenuCreator
Parameters:
parent - the parent menu
Returns:
the menu, or null if the menu could not be created

run

public void run(IAction action)
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 the runWithEvent(IAction, Event) method is called.

Specified by:
run in interface IActionDelegate
Parameters:
action - the action proxy that handles the presentation portion of the action

selectionChanged

public void selectionChanged(IAction action,
                             ISelection selection)
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 interface IActionDelegate
Parameters:
action - the action proxy that handles presentation portion of the action
selection - the current selection, or null if there is no selection.

Eclipse Platform
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.