Eclipse Platform
2.0

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

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 Summary
SubMenuManager(IMenuManager mgr)
          Constructs a new manager.
 
Method Summary
 void addMenuListener(IMenuListener listener)
          Adds a menu listener to this menu.
 void fill(Composite parent)
          Fills the given composite control with controls representing this contribution item.
 void fill(Menu parent, int index)
          Fills the given menu with controls representing this contribution item.
 void fill(ToolBar parent, int index)
          Fills the given tool bar with controls representing this contribution item.
 IContributionItem find(String id)
          Finds the contribution item with the given id.
 IMenuManager findMenuUsingPath(String path)
           The menu returned is wrapped within a SubMenuManager to monitor additions and removals.
 IContributionItem findUsingPath(String path)
          Finds the contribution item at the given path.
 String getId()
          Returns the identifier of this contribution item.
 boolean getRemoveAllWhenShown()
          Returns whether all items should be removed when the menu is first shown, but before notifying menu listeners.
protected  IMenuManager getWrapper(IMenuManager mgr)
          Returns the menu wrapper for a menu manager.
 boolean isDynamic()
          Returns whether this contribution item is dynamic.
 boolean isEnabled()
          Returns whether this menu should be enabled or not.
 boolean isGroupMarker()
          Returns whether this contribution item is a group marker.
 boolean isSeparator()
          Returns whether this contribution item is a separator.
 void removeAll()
          Remove all contribution items.
 void removeMenuListener(IMenuListener listener)
          Removes the given menu listener from this menu.
 void setParent(IContributionManager parent)
          Sets the parent manager of this item
 void setRemoveAllWhenShown(boolean removeAll)
          Sets whether all items should be removed when the menu is first shown, but before notifying menu listeners.
 void setVisible(boolean visible)
          Sets whether this contribution item is visibile within its 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 update(String id)
          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.IContributionManager
add, add, appendToGroup, appendToGroup, getItems, getOverrides, insertAfter, insertAfter, insertBefore, insertBefore, isDirty, isEmpty, markDirty, prependToGroup, prependToGroup, remove, remove
 
Methods inherited from interface org.eclipse.jface.action.IContributionItem
isVisible
 

Constructor Detail

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 Detail

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

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(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

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)
Description copied from interface: IMenuManager
Finds the contribution item at the given path. A path consists of contribution item ids separated by the separator character. The path separator character is '/'.

Specified by:
findUsingPath in interface IMenuManager
Parameters:
path - the path string
Returns:
the contribution item, or null if there is no such contribution item

find

public IContributionItem find(String id)
Description copied from interface: IContributionManager
Finds the contribution item with the given id.

Specified by:
find in interface IContributionManager
Overrides:
find in class SubContributionManager
Parameters:
id - the contribution item id
Returns:
the contribution item, or null if no item with the given id can be found

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

getRemoveAllWhenShown

public boolean getRemoveAllWhenShown()
Description copied from interface: IMenuManager
Returns whether all items should be removed when the menu is first shown, 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.

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 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:
GroupMarker, IContributionManager.appendToGroup(java.lang.String, org.eclipse.jface.action.IAction), IContributionManager.prependToGroup(java.lang.String, org.eclipse.jface.action.IAction)

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:
Separator

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

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 first shown, 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 interface: IContributionItem
Sets whether this contribution item is visibile within its manager.

Specified by:
setVisible in interface IContributionItem
Overrides:
setVisible in class SubContributionManager
Parameters:
visible - true if this item should be visible, and false otherwise

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

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

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

wrapMenu

protected SubMenuManager wrapMenu(IMenuManager menu)
Wraps a menu manager in a sub menu manager, and returns the new wrapper.


Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.