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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMenuListener
(IMenuListener listener) Adds a menu listener to this menu.void
dispose()
The default implementation of thisIContributionItem
method does nothing.void
Disposes this sub contribution manager, removing all its items and cleaning up any other resources allocated by it.void
Fills the given composite control with controls representing this contribution item.void
Fills the given cool bar with controls representing this contribution item.void
Fills the given menu with controls representing this contribution item.void
Fills the given tool bar with controls representing this contribution item.Method declared on IContributionManager.findMenuUsingPath
(String path) The menu returned is wrapped within aSubMenuManager
to monitor additions and removals.findUsingPath
(String path) Method declared on IMenuManager.getId()
Returns the identifier of this contribution item.protected final IMenuManager
boolean
Returns whether all items should be removed when the menu is about to show, but before notifying menu listeners.protected IMenuManager
getWrapper
(IMenuManager mgr) Returns the menu wrapper for a menu manager.boolean
Returns whether this contribution item is dynamic.boolean
Returns whether this menu should be enabled or not.boolean
Returns whether this contribution item is a group marker.boolean
Returns whether this contribution item is a separator.void
Remove all contribution items.void
removeMenuListener
(IMenuListener listener) Removes the given menu listener from this menu.void
Saves any state information of the control(s) owned by this contribution item.void
setParent
(IContributionManager parent) Sets the parent manager of this itemvoid
setRemoveAllWhenShown
(boolean removeAll) Sets whether all items should be removed when the menu is about to show, but before notifying menu listeners.void
setVisible
(boolean visible) Sets the visibility of the manager.void
update()
Updates any SWT controls cached by this contribution item with any changes which have been made to this contribution item since the last update.void
update
(boolean force) Updates this manager's underlying widget(s) with any changes which have been made to it or its items.void
Updates any SWT controls cached by this contribution item with changes for the the given property.void
updateAll
(boolean force) Incrementally builds the menu from the contribution items, and does so recursively for all submenus.protected SubMenuManager
wrapMenu
(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, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jface.action.IContributionItem
isDirty, isVisible
Methods 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 theSubMenuManager
are forwarded and appear in the parent manager.
-
-
Method Details
-
addMenuListener
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 interfaceIMenuManager
- Parameters:
listener
- a menu listener
-
dispose
public void dispose()The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
dispose
in interfaceIContributionItem
-
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 classSubContributionManager
-
fill
Description copied from interface:IContributionItem
Fills the given composite control with controls representing this contribution item. Used byStatusLineManager
.- Specified by:
fill
in interfaceIContributionItem
- Parameters:
parent
- the parent control
-
fill
Description copied from interface:IContributionItem
Fills the given cool bar with controls representing this contribution item. Used byCoolBarManager
.- Specified by:
fill
in interfaceIContributionItem
- Parameters:
parent
- the parent cool barindex
- the index where the controls are inserted, or-1
to insert at the end
-
fill
Description copied from interface:IContributionItem
Fills the given menu with controls representing this contribution item. Used byMenuManager
.- Specified by:
fill
in interfaceIContributionItem
- Parameters:
parent
- the parent menuindex
- the index where the controls are inserted, or-1
to insert at the end
-
fill
Description copied from interface:IContributionItem
Fills the given tool bar with controls representing this contribution item. Used byToolBarManager
.- Specified by:
fill
in interfaceIContributionItem
- Parameters:
parent
- the parent tool barindex
- the index where the controls are inserted, or-1
to 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:
find
in interfaceIContributionManager
- Overrides:
find
in classSubContributionManager
- Parameters:
id
- of theIContributionItem
- Returns:
- the contribution item, or
null
if no item with the given id can be found
-
findMenuUsingPath
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 interfaceIMenuManager
- 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
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 interfaceIMenuManager
- Parameters:
path
- which allows to find anIContributionItem
through the menu structure.- Returns:
- the contribution item, or
null
if there is no such contribution item
-
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 interfaceIContributionItem
- Returns:
- the contribution item identifier, or
null
if none
-
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 isfalse
.- Specified by:
getRemoveAllWhenShown
in interfaceIMenuManager
- Returns:
true
if all items should be removed when shown,false
if not
-
getWrapper
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 interfaceIContributionItem
- Returns:
true
if this item is dynamic, andfalse
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 interfaceIContributionItem
- Specified by:
isEnabled
in interfaceIMenuManager
- Returns:
true
if enabled, andfalse
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 interfaceIContributionItem
- Returns:
true
if this item is a group marker, andfalse
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 interfaceIContributionItem
- Returns:
true
if this item is a separator, andfalse
for normal items- See Also:
-
removeAll
public void removeAll()Remove all contribution items.- Specified by:
removeAll
in interfaceIContributionManager
- Overrides:
removeAll
in classSubContributionManager
-
removeMenuListener
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 interfaceIMenuManager
- 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 interfaceIContributionItem
-
setParent
Description copied from interface:IContributionItem
Sets the parent manager of this item- Specified by:
setParent
in interfaceIContributionItem
- 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 interfaceIMenuManager
- 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 istrue
then each item within the manager appears within the parent manager. Otherwise, the items are not visible.- Specified by:
setVisible
in interfaceIContributionItem
- Overrides:
setVisible
in classSubContributionManager
- 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 interfaceIContributionItem
-
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 interfaceIContributionManager
- Parameters:
force
-true
means update even if not dirty, andfalse
for normal incremental updating
-
update
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 interfaceIContributionItem
- 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 interfaceIMenuManager
- Parameters:
force
-true
means update even if not dirty, andfalse
for 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
-