public class MenuManager extends ContributionManager implements IMenuManager
This class may be instantiated; it may also be subclassed.
| Constructor and Description |
|---|
MenuManager()
Creates a menu manager.
|
MenuManager(String text)
Creates a menu manager with the given text.
|
MenuManager(String text,
String id)
Creates a menu manager with the given text and id.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMenuListener(IMenuListener listener)
Adds a menu listener to this menu.
|
Menu |
createContextMenu(Control parent)
Creates and returns an SWT context menu control for this menu,
and installs all registered contributions.
|
Menu |
createMenuBar(Decorations parent)
Creates and returns an SWT menu bar control for this menu,
for use in the given
Decorations, and installs all registered
contributions. |
Menu |
createMenuBar(Shell parent)
Deprecated.
use
createMenuBar(Decorations) instead. |
void |
dispose()
Disposes of this menu manager and frees all allocated SWT resources.
|
void |
fill(Composite parent)
Fills the given composite control with controls representing this
contribution item.
|
void |
fill(CoolBar parent,
int index)
Fills the given cool bar 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.
|
IMenuManager |
findMenuUsingPath(String path)
Finds the manager for the menu at the given path.
|
IContributionItem |
findUsingPath(String path)
Finds the contribution item at the given path.
|
String |
getId()
Returns the menu id.
|
Menu |
getMenu()
Returns the SWT menu control for this menu manager.
|
String |
getMenuText()
Returns the text shown in the menu.
|
IContributionManagerOverrides |
getOverrides()
The
ContributionManager implementation of this
method declared on IContributionManager returns
the current overrides. |
IContributionManager |
getParent()
Returns the parent contribution manager of this manger.
|
boolean |
getRemoveAllWhenShown()
Returns whether all items should be removed when the menu is about to
show, but before notifying menu listeners.
|
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.
|
boolean |
isSubstituteFor(IContributionItem item)
Deprecated.
this method is no longer a part of the
IContributionItem API. |
boolean |
isVisible()
Returns whether this contribution item is visibile within its manager.
|
void |
markDirty()
The
MenuManager implementation of this ContributionManager method
also propagates the dirty flag up the parent chain. |
void |
removeMenuListener(IMenuListener listener)
Removes the given menu listener from this menu.
|
void |
saveWidgetState()
Saves any state information of the control(s) owned by this contribution item.
|
void |
setOverrides(IContributionManagerOverrides newOverrides)
Sets the overrides for this contribution manager
|
void |
setParent(IContributionManager manager)
Sets the parent manager of this item
|
void |
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 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)
The
MenuManager implementation of this IContributionManager
updates this menu, but not any of its submenus. |
protected void |
update(boolean force,
boolean recursive)
Incrementally builds the menu from the contribution items.
|
void |
update(String property)
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.
|
add, add, allowItem, appendToGroup, appendToGroup, dumpStatistics, find, getItems, hasDynamicItems, indexOf, indexOf, insert, insertAfter, insertAfter, insertBefore, insertBefore, internalSetItems, isDirty, isEmpty, itemAdded, itemRemoved, prependToGroup, prependToGroup, remove, remove, removeAll, replaceItem, setDirtyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, add, appendToGroup, appendToGroup, find, getItems, insertAfter, insertAfter, insertBefore, insertBefore, isDirty, isEmpty, prependToGroup, prependToGroup, remove, remove, removeAllisDirtypublic MenuManager()
null.
Typically used for creating a context menu, where it doesn't need to be referred to by id.public MenuManager(String text)
null.
Typically used for creating a sub-menu, where it doesn't need to be referred to by id.text - the text for the menu, or null if nonepublic void addMenuListener(IMenuListener listener)
IMenuManageraddMenuListener in interface IMenuManagerlistener - a menu listenerpublic Menu createContextMenu(Control parent)
Note that the menu is not expected to be dynamic.
parent - the parent controlpublic Menu createMenuBar(Decorations parent)
Decorations, and installs all registered
contributions. Does not create a new control if one already exists.parent - the parent decorationspublic Menu createMenuBar(Shell parent)
createMenuBar(Decorations) instead.Shell, and installs all registered contributions. Does not
create a new control if one already exists. This implementation simply calls
the createMenuBar(Decorations) methodparent - the parent decorationspublic void dispose()
removeAll for that purpose.dispose in interface IContributionItempublic void fill(Composite parent)
IContributionItemStatusLineManager.fill in interface IContributionItemparent - the parent controlpublic void fill(CoolBar parent, int index)
IContributionItemCoolBarManager.fill in interface IContributionItemparent - the parent cool barindex - the index where the controls are inserted,
or -1 to insert at the endpublic void fill(Menu parent, int index)
IContributionItemMenuManager.fill in interface IContributionItemparent - the parent menuindex - the index where the controls are inserted,
or -1 to insert at the endpublic void fill(ToolBar parent, int index)
IContributionItemToolBarManager.fill in interface IContributionItemparent - the parent tool barindex - the index where the controls are inserted,
or -1 to insert at the endpublic IMenuManager findMenuUsingPath(String path)
IMenuManager'/'.
Convenience for findUsingPath(path) which
extracts an IMenuManager if possible.
findMenuUsingPath in interface IMenuManagerpath - the path stringnull
if there is no such contribution item or if the item does
not have an associated menu managerpublic IContributionItem findUsingPath(String path)
IMenuManager'/'.findUsingPath in interface IMenuManagerpath - the path stringnull if there is no
such contribution itempublic String getId()
getId in interface IContributionItempublic Menu getMenu()
public String getMenuText()
public IContributionManagerOverrides getOverrides()
ContributionManagerContributionManager implementation of this
method declared on IContributionManager returns
the current overrides. If there is no overrides it lazily creates
one which overrides no item state.getOverrides in interface IContributionManagergetOverrides in class ContributionManagerpublic IContributionManager getParent()
public boolean getRemoveAllWhenShown()
IMenuManagerfalse.getRemoveAllWhenShown in interface IMenuManagertrue if all items should be removed when shown,
false if notpublic boolean isDynamic()
IContributionItemisDynamic in interface IContributionItemtrue if this item is dynamic, and
false for normal itemspublic boolean isEnabled()
The default implementation of this framework method
returns true. Subclasses may reimplement.
isEnabled in interface IContributionItemisEnabled in interface IMenuManagertrue if enabled, and
false if disabledpublic boolean isGroupMarker()
IContributionItemisGroupMarker in interface IContributionItemtrue if this item is a group marker, and
false for normal itemsGroupMarker,
IContributionManager.appendToGroup(String, IContributionItem),
IContributionManager.prependToGroup(String, IContributionItem)public boolean isSeparator()
IContributionItemisSeparator in interface IContributionItemtrue if this item is a separator, and
false for normal itemsSeparatorpublic boolean isSubstituteFor(IContributionItem item)
IContributionItem API.public boolean isVisible()
IContributionItemisVisible in interface IContributionItemtrue if this item is visible, and
false otherwisepublic void markDirty()
MenuManager implementation of this ContributionManager method
also propagates the dirty flag up the parent chain.markDirty in interface IContributionManagermarkDirty in class ContributionManagerpublic void removeMenuListener(IMenuListener listener)
IMenuManagerremoveMenuListener in interface IMenuManagerlistener - the menu listenerpublic void saveWidgetState()
IContributionItemsaveWidgetState in interface IContributionItempublic void setOverrides(IContributionManagerOverrides newOverrides)
setOverrides in class ContributionManagernewOverrides - the overrides for the items of this managerpublic void setParent(IContributionManager manager)
IContributionItemsetParent in interface IContributionItemmanager - the parent contribution managerpublic void setRemoveAllWhenShown(boolean removeAll)
IMenuManagersetRemoveAllWhenShown in interface IMenuManagerremoveAll - true if all items should be removed when shown,
false if notpublic void setVisible(boolean visible)
IContributionItemsetVisible in interface IContributionItemvisible - true if this item should be visible, and
false otherwisepublic void update()
IContributionItemupdate in interface IContributionItempublic void update(boolean force)
MenuManager implementation of this IContributionManager
updates this menu, but not any of its submenus.update in interface IContributionManagerforce - true means update even if not dirty,
and false for normal incremental updatingupdateAll(boolean)protected void update(boolean force,
boolean recursive)
force - true means update even if not dirty,
and false for normal incremental updatingrecursive - true means recursively update
all submenus, and false means just this menupublic void update(String property)
IContributionItemupdate in interface IContributionItemproperty - the id of the changed propertypublic void updateAll(boolean force)
IMenuManagerupdateAll in interface IMenuManagerforce - true means update even if not dirty,
and false for normal incremental updatingGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.