Class PopupMenuExtender

java.lang.Object
org.eclipse.ui.internal.PopupMenuExtender
All Implemented Interfaces:
EventListener, IRegistryChangeListener, IMenuListener, IMenuListener2

public class PopupMenuExtender extends Object implements IMenuListener2, IRegistryChangeListener
This class extends a single popup menu
  • Constructor Details

    • PopupMenuExtender

      public PopupMenuExtender(String id, MenuManager menu, ISelectionProvider prov, IWorkbenchPart part, IEclipseContext context)
      Construct a new menu extender.
      Parameters:
      id - the menu id
      menu - the menu to extend
      prov - the selection provider
      part - the part to extend
      context - the context to create the child popup menu context under
    • PopupMenuExtender

      public PopupMenuExtender(String id, MenuManager menu, ISelectionProvider prov, IWorkbenchPart part, IEclipseContext context, boolean includeEditorInput)
      Construct a new menu extender.
      Parameters:
      id - the menu id
      menu - the menu to extend
      prov - the selection provider
      part - the part to extend
      context - the context to create the child popup menu context under
      includeEditorInput - Whether the editor input should be included when adding object contributions to this context menu.
  • Method Details

    • getMenuIds

      public Set<String> getMenuIds()
      Return the menu identifiers for this extender.
      Returns:
      The set of all identifiers that represent this extender.
    • addMenuId

      public final void addMenuId(String menuId)

      Adds another menu identifier to this extender. An extender can represent many menu identifiers. These identifiers should represent the same menu manager, selection provider and part. Duplicate identifiers are automatically ignored.

      For example, it is necessary to filter out duplicate identifiers for CompilationUnitEditor instances, as these define both "#CompilationUnitEditorContext" and "org.eclipse.jdt.ui.CompilationUnitEditor.EditorContext" as menu identifier for the same pop-up menu. We don't want to contribute duplicate items in this case.

      Parameters:
      menuId - The menu identifier to add to this extender; should not be null.
    • matches

      public final boolean matches(MenuManager menuManager, ISelectionProvider selectionProvider, IWorkbenchPart part)
      Determines whether this extender would be the same as another extender created with the given values. Two extenders are equivalent if they have the same menu manager, selection provider and part (i.e., if the menu they represent is about to show, they would populate it with duplicate values).
      Parameters:
      menuManager - The menu manager with which to compare; may be null.
      selectionProvider - The selection provider with which to compare; may be null.
      part - The part with which to compare; may be null.
      Returns:
      true if the menu manager, selection provider and part are all the same.
    • dispose

      public void dispose()
      Dispose of the menu extender. Should only be called when the part is disposed.
    • registryChanged

      public void registryChanged(IRegistryChangeEvent event)
      Description copied from interface: IRegistryChangeListener
      Notifies this listener that some registry changes are happening, or have already happened.

      The supplied event gives details. This event object (and the deltas in it) is valid only for the duration of the invocation of this method.

      Note: This method is called by the platform; it is not intended to be called directly by clients.

      Specified by:
      registryChanged in interface IRegistryChangeListener
      Parameters:
      event - the registry change event
      See Also:
    • getManager

      public MenuManager getManager()