Class SubMenuManager

java.lang.Object
org.eclipse.jface.action.SubContributionManager
org.eclipse.jface.action.SubMenuManager
All Implemented Interfaces:
IContributionItem, IContributionManager, IMenuManager
Direct Known Subclasses:
ActionSetMenuManager, EditorMenuManager

public class SubMenuManager extends SubContributionManager implements IMenuManager
A SubMenuManager is used to define a set of contribution items within a parent manager. Once defined, the visibility of the entire set can be changed as a unit.

A client may ask for and make additions to a submenu. The visibility of these items is also controlled by the visibility of the SubMenuManager.

  • Constructor Details

    • SubMenuManager

      public SubMenuManager(IMenuManager mgr)
      Constructs a new manager.
      Parameters:
      mgr - the parent manager. All contributions made to the SubMenuManager are forwarded and appear in the parent manager.
  • Method Details

    • addMenuListener

      public void addMenuListener(IMenuListener listener)
      Description copied from interface: IMenuManager
      Adds a menu listener to this menu. Has no effect if an identical listener is already registered.
      Specified by:
      addMenuListener in interface IMenuManager
      Parameters:
      listener - a menu listener
    • dispose

      public void dispose()
      The default implementation of this IContributionItem method does nothing. Subclasses may override.
      Specified by:
      dispose in interface IContributionItem
    • disposeManager

      public void disposeManager()
      Description copied from class: SubContributionManager
      Disposes this sub contribution manager, removing all its items and cleaning up any other resources allocated by it. This must leave no trace of this sub contribution manager in the parent manager. Subclasses may extend.
      Overrides:
      disposeManager in class SubContributionManager
    • fill

      public void fill(Composite parent)
      Description copied from interface: IContributionItem
      Fills the given composite control with controls representing this contribution item. Used by StatusLineManager.
      Specified by:
      fill in interface IContributionItem
      Parameters:
      parent - the parent control
    • fill

      public void fill(CoolBar parent, int index)
      Description copied from interface: IContributionItem
      Fills the given cool bar with controls representing this contribution item. Used by CoolBarManager.
      Specified by:
      fill in interface IContributionItem
      Parameters:
      parent - the parent cool bar
      index - the index where the controls are inserted, or -1 to insert at the end
    • fill

      public void fill(Menu parent, int index)
      Description copied from interface: IContributionItem
      Fills the given menu with controls representing this contribution item. Used by MenuManager.
      Specified by:
      fill in interface IContributionItem
      Parameters:
      parent - the parent menu
      index - the index where the controls are inserted, or -1 to insert at the end
    • fill

      public void fill(ToolBar parent, int index)
      Description copied from interface: IContributionItem
      Fills the given tool bar with controls representing this contribution item. Used by ToolBarManager.
      Specified by:
      fill in interface IContributionItem
      Parameters:
      parent - the parent tool bar
      index - the index where the controls are inserted, or -1 to insert at the end
    • find

      public IContributionItem find(String id)
      Method declared on IContributionManager. Returns the item passed to us, not the wrapper. In the case of menu's not added by this manager, ensure that we return a wrapper for the menu.
      Specified by:
      find in interface IContributionManager
      Overrides:
      find in class SubContributionManager
      Parameters:
      id - of the IContributionItem
      Returns:
      the contribution item, or null if no item with the given id can be found
    • findMenuUsingPath

      public IMenuManager findMenuUsingPath(String path)

      The menu returned is wrapped within a SubMenuManager to monitor additions and removals. If the visibility of this menu is modified the visibility of the submenus is also modified.

      Specified by:
      findMenuUsingPath in interface IMenuManager
      Parameters:
      path - the path string
      Returns:
      the menu contribution item, or null if there is no such contribution item or if the item does not have an associated menu manager
    • findUsingPath

      public IContributionItem findUsingPath(String path)
      Method declared on IMenuManager. Returns the item passed to us, not the wrapper. We use use the same algorithm as MenuManager.findUsingPath, but unwrap submenus along so that SubMenuManagers are visible.
      Specified by:
      findUsingPath in interface IMenuManager
      Parameters:
      path - which allows to find an IContributionItem through the menu structure.
      Returns:
      the contribution item, or null if there is no such contribution item
    • getId

      public String getId()
      Description copied from interface: IContributionItem
      Returns the identifier of this contribution item. The id is used for retrieving an item from its manager.
      Specified by:
      getId in interface IContributionItem
      Returns:
      the contribution item identifier, or null if none
    • getParentMenuManager

      protected final IMenuManager getParentMenuManager()
      Returns:
      the parent menu manager that this sub-manager contributes to.
    • getRemoveAllWhenShown

      public boolean getRemoveAllWhenShown()
      Description copied from interface: IMenuManager
      Returns whether all items should be removed when the menu is about to show, but before notifying menu listeners. The default is false.
      Specified by:
      getRemoveAllWhenShown in interface IMenuManager
      Returns:
      true if all items should be removed when shown, false if not
    • getWrapper

      protected IMenuManager getWrapper(IMenuManager mgr)
      Returns the menu wrapper for a menu manager.

      The sub menus within this menu are wrapped within a SubMenuManager to monitor additions and removals. If the visibility of this menu is modified the visibility of the sub menus is also modified.

      Parameters:
      mgr - the menu manager to be wrapped
      Returns:
      the menu wrapper
    • isDynamic

      public boolean isDynamic()
      Description copied from interface: IContributionItem
      Returns whether this contribution item is dynamic. A dynamic contribution item contributes items conditionally, dependent on some internal state.
      Specified by:
      isDynamic in interface IContributionItem
      Returns:
      true if this item is dynamic, and false for normal items
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: IMenuManager
      Returns whether this menu should be enabled or not.
      Specified by:
      isEnabled in interface IContributionItem
      Specified by:
      isEnabled in interface IMenuManager
      Returns:
      true if enabled, and false if disabled
    • isGroupMarker

      public boolean isGroupMarker()
      Description copied from interface: IContributionItem
      Returns whether this contribution item is a group marker. This information is used when adding items to a group.
      Specified by:
      isGroupMarker in interface IContributionItem
      Returns:
      true if this item is a group marker, and false for normal items
      See Also:
    • isSeparator

      public boolean isSeparator()
      Description copied from interface: IContributionItem
      Returns whether this contribution item is a separator. This information is used to enable hiding of unnecessary separators.
      Specified by:
      isSeparator in interface IContributionItem
      Returns:
      true if this item is a separator, and false for normal items
      See Also:
    • removeAll

      public void removeAll()
      Remove all contribution items.
      Specified by:
      removeAll in interface IContributionManager
      Overrides:
      removeAll in class SubContributionManager
    • removeMenuListener

      public void removeMenuListener(IMenuListener listener)
      Description copied from interface: IMenuManager
      Removes the given menu listener from this menu. Has no effect if an identical listener is not registered.
      Specified by:
      removeMenuListener in interface IMenuManager
      Parameters:
      listener - the menu listener
    • saveWidgetState

      public void saveWidgetState()
      Description copied from interface: IContributionItem
      Saves any state information of the control(s) owned by this contribution item. The contribution manager calls this method before disposing of the controls.
      Specified by:
      saveWidgetState in interface IContributionItem
    • setParent

      public void setParent(IContributionManager parent)
      Description copied from interface: IContributionItem
      Sets the parent manager of this item
      Specified by:
      setParent in interface IContributionItem
      Parameters:
      parent - the parent contribution manager
    • setRemoveAllWhenShown

      public void setRemoveAllWhenShown(boolean removeAll)
      Description copied from interface: IMenuManager
      Sets whether all items should be removed when the menu is about to show, but before notifying menu listeners.
      Specified by:
      setRemoveAllWhenShown in interface IMenuManager
      Parameters:
      removeAll - true if all items should be removed when shown, false if not
    • setVisible

      public void setVisible(boolean visible)
      Description copied from class: SubContributionManager
      Sets the visibility of the manager. If the visibility is true then each item within the manager appears within the parent manager. Otherwise, the items are not visible.
      Specified by:
      setVisible in interface IContributionItem
      Overrides:
      setVisible in class SubContributionManager
      Parameters:
      visible - the new visibility
    • update

      public void update()
      Description copied from interface: IContributionItem
      Updates any SWT controls cached by this contribution item with any changes which have been made to this contribution item since the last update. Called by contribution manager update methods.
      Specified by:
      update in interface IContributionItem
    • update

      public void update(boolean force)
      Description copied from interface: IContributionManager
      Updates this manager's underlying widget(s) with any changes which have been made to it or its items. Normally changes to a contribution manager merely mark it as dirty, without updating the underlying widgets. This brings the underlying widgets up to date with any changes.
      Specified by:
      update in interface IContributionManager
      Parameters:
      force - true means update even if not dirty, and false for normal incremental updating
    • update

      public void update(String id)
      Description copied from interface: IContributionItem
      Updates any SWT controls cached by this contribution item with changes for the the given property.
      Specified by:
      update in interface IContributionItem
      Parameters:
      id - the id of the changed property
    • updateAll

      public void updateAll(boolean force)
      Description copied from interface: IMenuManager
      Incrementally builds the menu from the contribution items, and does so recursively for all submenus.
      Specified by:
      updateAll in interface IMenuManager
      Parameters:
      force - true means update even if not dirty, and false for normal incremental updating
    • wrapMenu

      protected SubMenuManager wrapMenu(IMenuManager menu)
      Wraps a menu manager in a sub menu manager, and returns the new wrapper.
      Parameters:
      menu - the menu manager to wrap
      Returns:
      the new wrapped menu manager