Package org.eclipse.jface.action
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
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMenuListener(IMenuListener listener) Adds a menu listener to this menu.voiddispose()The default implementation of thisIContributionItemmethod does nothing.voidDisposes this sub contribution manager, removing all its items and cleaning up any other resources allocated by it.voidFills the given composite control with controls representing this contribution item.voidFills the given cool bar with controls representing this contribution item.voidFills the given menu with controls representing this contribution item.voidFills the given tool bar with controls representing this contribution item.Method declared on IContributionManager.findMenuUsingPath(String path) The menu returned is wrapped within aSubMenuManagerto monitor additions and removals.findUsingPath(String path) Method declared on IMenuManager.getId()Returns the identifier of this contribution item.protected final IMenuManagerbooleanReturns whether all items should be removed when the menu is about to show, but before notifying menu listeners.protected IMenuManagergetWrapper(IMenuManager mgr) Returns the menu wrapper for a menu manager.booleanReturns whether this contribution item is dynamic.booleanReturns whether this menu should be enabled or not.booleanReturns whether this contribution item is a group marker.booleanReturns whether this contribution item is a separator.voidRemove all contribution items.voidremoveMenuListener(IMenuListener listener) Removes the given menu listener from this menu.voidSaves any state information of the control(s) owned by this contribution item.voidsetParent(IContributionManager parent) Sets the parent manager of this itemvoidsetRemoveAllWhenShown(boolean removeAll) Sets whether all items should be removed when the menu is about to show, but before notifying menu listeners.voidsetVisible(boolean visible) Sets the visibility of the manager.voidupdate()Updates any SWT controls cached by this contribution item with any changes which have been made to this contribution item since the last update.voidupdate(boolean force) Updates this manager's underlying widget(s) with any changes which have been made to it or its items.voidUpdates any SWT controls cached by this contribution item with changes for the the given property.voidupdateAll(boolean force) Incrementally builds the menu from the contribution items, and does so recursively for all submenus.protected SubMenuManagerwrapMenu(IMenuManager menu) Wraps a menu manager in a sub menu manager, and returns the new wrapper.Methods inherited from class org.eclipse.jface.action.SubContributionManager
add, add, appendToGroup, appendToGroup, getItems, getOverrides, getParent, insertAfter, insertAfter, insertBefore, insertBefore, isDirty, isEmpty, isVisible, itemAdded, itemRemoved, items, markDirty, prependToGroup, prependToGroup, remove, remove, unwrap, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jface.action.IContributionItem
isDirty, isVisibleMethods inherited from interface org.eclipse.jface.action.IContributionManager
add, add, appendToGroup, appendToGroup, getItems, getOverrides, insertAfter, insertAfter, insertBefore, insertBefore, isDirty, isEmpty, markDirty, prependToGroup, prependToGroup, remove, remove
-
Constructor Details
-
SubMenuManager
Constructs a new manager.- Parameters:
mgr- the parent manager. All contributions made to theSubMenuManagerare forwarded and appear in the parent manager.
-
-
Method Details
-
addMenuListener
Description copied from interface:IMenuManagerAdds a menu listener to this menu. Has no effect if an identical listener is already registered.- Specified by:
addMenuListenerin interfaceIMenuManager- Parameters:
listener- a menu listener
-
dispose
public void dispose()The default implementation of thisIContributionItemmethod does nothing. Subclasses may override.- Specified by:
disposein interfaceIContributionItem
-
disposeManager
public void disposeManager()Description copied from class:SubContributionManagerDisposes 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:
disposeManagerin classSubContributionManager
-
fill
Description copied from interface:IContributionItemFills the given composite control with controls representing this contribution item. Used byStatusLineManager.- Specified by:
fillin interfaceIContributionItem- Parameters:
parent- the parent control
-
fill
Description copied from interface:IContributionItemFills the given cool bar with controls representing this contribution item. Used byCoolBarManager.- Specified by:
fillin interfaceIContributionItem- Parameters:
parent- the parent cool barindex- the index where the controls are inserted, or-1to insert at the end
-
fill
Description copied from interface:IContributionItemFills the given menu with controls representing this contribution item. Used byMenuManager.- Specified by:
fillin interfaceIContributionItem- Parameters:
parent- the parent menuindex- the index where the controls are inserted, or-1to insert at the end
-
fill
Description copied from interface:IContributionItemFills the given tool bar with controls representing this contribution item. Used byToolBarManager.- Specified by:
fillin interfaceIContributionItem- Parameters:
parent- the parent tool barindex- the index where the controls are inserted, or-1to insert at the end
-
find
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:
findin interfaceIContributionManager- Overrides:
findin classSubContributionManager- Parameters:
id- of theIContributionItem- Returns:
- the contribution item, or
nullif no item with the given id can be found
-
findMenuUsingPath
The menu returned is wrapped within a
SubMenuManagerto monitor additions and removals. If the visibility of this menu is modified the visibility of the submenus is also modified.- Specified by:
findMenuUsingPathin interfaceIMenuManager- Parameters:
path- the path string- Returns:
- the menu contribution item, or
nullif there is no such contribution item or if the item does not have an associated menu manager
-
findUsingPath
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:
findUsingPathin interfaceIMenuManager- Parameters:
path- which allows to find anIContributionItemthrough the menu structure.- Returns:
- the contribution item, or
nullif there is no such contribution item
-
getId
Description copied from interface:IContributionItemReturns the identifier of this contribution item. The id is used for retrieving an item from its manager.- Specified by:
getIdin interfaceIContributionItem- Returns:
- the contribution item identifier, or
nullif none
-
getParentMenuManager
- Returns:
- the parent menu manager that this sub-manager contributes to.
-
getRemoveAllWhenShown
public boolean getRemoveAllWhenShown()Description copied from interface:IMenuManagerReturns whether all items should be removed when the menu is about to show, but before notifying menu listeners. The default isfalse.- Specified by:
getRemoveAllWhenShownin interfaceIMenuManager- Returns:
trueif all items should be removed when shown,falseif not
-
getWrapper
Returns the menu wrapper for a menu manager.The sub menus within this menu are wrapped within a
SubMenuManagerto 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:IContributionItemReturns whether this contribution item is dynamic. A dynamic contribution item contributes items conditionally, dependent on some internal state.- Specified by:
isDynamicin interfaceIContributionItem- Returns:
trueif this item is dynamic, andfalsefor normal items
-
isEnabled
public boolean isEnabled()Description copied from interface:IMenuManagerReturns whether this menu should be enabled or not.- Specified by:
isEnabledin interfaceIContributionItem- Specified by:
isEnabledin interfaceIMenuManager- Returns:
trueif enabled, andfalseif disabled
-
isGroupMarker
public boolean isGroupMarker()Description copied from interface:IContributionItemReturns whether this contribution item is a group marker. This information is used when adding items to a group.- Specified by:
isGroupMarkerin interfaceIContributionItem- Returns:
trueif this item is a group marker, andfalsefor normal items- See Also:
-
isSeparator
public boolean isSeparator()Description copied from interface:IContributionItemReturns whether this contribution item is a separator. This information is used to enable hiding of unnecessary separators.- Specified by:
isSeparatorin interfaceIContributionItem- Returns:
trueif this item is a separator, andfalsefor normal items- See Also:
-
removeAll
public void removeAll()Remove all contribution items.- Specified by:
removeAllin interfaceIContributionManager- Overrides:
removeAllin classSubContributionManager
-
removeMenuListener
Description copied from interface:IMenuManagerRemoves the given menu listener from this menu. Has no effect if an identical listener is not registered.- Specified by:
removeMenuListenerin interfaceIMenuManager- Parameters:
listener- the menu listener
-
saveWidgetState
public void saveWidgetState()Description copied from interface:IContributionItemSaves 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:
saveWidgetStatein interfaceIContributionItem
-
setParent
Description copied from interface:IContributionItemSets the parent manager of this item- Specified by:
setParentin interfaceIContributionItem- Parameters:
parent- the parent contribution manager
-
setRemoveAllWhenShown
public void setRemoveAllWhenShown(boolean removeAll) Description copied from interface:IMenuManagerSets whether all items should be removed when the menu is about to show, but before notifying menu listeners.- Specified by:
setRemoveAllWhenShownin interfaceIMenuManager- Parameters:
removeAll-trueif all items should be removed when shown,falseif not
-
setVisible
public void setVisible(boolean visible) Description copied from class:SubContributionManagerSets the visibility of the manager. If the visibility istruethen each item within the manager appears within the parent manager. Otherwise, the items are not visible.- Specified by:
setVisiblein interfaceIContributionItem- Overrides:
setVisiblein classSubContributionManager- Parameters:
visible- the new visibility
-
update
public void update()Description copied from interface:IContributionItemUpdates 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:
updatein interfaceIContributionItem
-
update
public void update(boolean force) Description copied from interface:IContributionManagerUpdates 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:
updatein interfaceIContributionManager- Parameters:
force-truemeans update even if not dirty, andfalsefor normal incremental updating
-
update
Description copied from interface:IContributionItemUpdates any SWT controls cached by this contribution item with changes for the the given property.- Specified by:
updatein interfaceIContributionItem- Parameters:
id- the id of the changed property
-
updateAll
public void updateAll(boolean force) Description copied from interface:IMenuManagerIncrementally builds the menu from the contribution items, and does so recursively for all submenus.- Specified by:
updateAllin interfaceIMenuManager- Parameters:
force-truemeans update even if not dirty, andfalsefor normal incremental updating
-
wrapMenu
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
-