Class ContextualLaunchAction

  • All Implemented Interfaces:
    IMenuCreator, IActionDelegate, 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 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 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; must not be null.
        targetPart - the new part target; must not be null.
      • 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.
      • getLaunchManager

        protected ILaunchManager getLaunchManager()
        Returns the launch manager
        Returns:
        the launch manager
        Since:
        3.3
      • fillMenu

        protected void fillMenu​(Menu menu)
        Fills the menu with applicable launch shortcuts
        Parameters:
        menu - The menu to fill