Class ShowInMenu

All Implemented Interfaces:
IContributionItem, IWorkbenchContribution

public class ShowInMenu extends ContributionItem implements IWorkbenchContribution
A ShowInMenu is used to populate a menu manager with Show In actions. The items to show are determined from the active perspective and active part.
  • Constructor Details

    • ShowInMenu

      public ShowInMenu()
    • ShowInMenu

      public ShowInMenu(IWorkbenchWindow window, String id)
      Creates a Show In menu.
      Parameters:
      window - the window containing the menu
      id - The ID for this contribution
  • Method Details

    • isDirty

      public boolean isDirty()
      Description copied from class: ContributionItem
      The default implementation of this IContributionItem method returns false. Subclasses may override.
      Specified by:
      isDirty in interface IContributionItem
      Overrides:
      isDirty in class ContributionItem
      Returns:
      true if this item is dirty
    • isDynamic

      public boolean isDynamic()
      Overridden to always return true and force dynamic menu building.
      Specified by:
      isDynamic in interface IContributionItem
      Overrides:
      isDynamic in class ContributionItem
      Returns:
      true if this item is dynamic, and false for normal items
    • fill

      public void fill(Menu menu, int index)
      Description copied from class: ContributionItem
      The default implementation of this IContributionItem method does nothing. Subclasses may override.
      Specified by:
      fill in interface IContributionItem
      Overrides:
      fill in class ContributionItem
      Parameters:
      menu - the parent menu
      index - the index where the controls are inserted, or -1 to insert at the end
    • getContributionItem

      protected IContributionItem getContributionItem(IViewDescriptor viewDescriptor)
      Return the appropriate command contribution item for the parameter.
      Returns:
      the show in command contribution item
    • getSourcePart

      protected IWorkbenchPart getSourcePart()
      Returns the source part, or null if there is no applicable source part

      This implementation returns the current part in the window. Subclasses may extend or reimplement.

      Returns:
      the source part or null
    • getContext

      protected ShowInContext getContext(IWorkbenchPart sourcePart)
      Returns the ShowInContext to show in the selected target, or null if there is no valid context to show.

      This implementation obtains the context from the IShowInSource of the source part (if provided), or, if the source part is an editor, it creates the context from the editor's input and selection.

      Subclasses may extend or reimplement.

      Returns:
      the ShowInContext to show or null
    • initialize

      public void initialize(IServiceLocator serviceLocator)
      Description copied from interface: IWorkbenchContribution
      The service locator for this contribution. It will potentially exist longer than the lifecycle of this specific contribution, so ContributionItems should remove themselves from any listeners or services in their dispose() calls.
      Specified by:
      initialize in interface IWorkbenchContribution
      Parameters:
      serviceLocator - the locator which services can be retrieved. Will not be null
    • getWindow

      protected IWorkbenchWindow getWindow()
    • dispose

      public void dispose()
      Description copied from class: ContributionItem
      The default implementation of this IContributionItem method does nothing. Subclasses may override.
      Specified by:
      dispose in interface IContributionItem
      Overrides:
      dispose in class ContributionItem