|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.jface.action.ContributionManager
org.eclipse.jface.action.MenuManager
public class MenuManager
A menu manager is a contribution manager which realizes itself and its items in a menu control; either as a menu bar, a sub-menu, or a context menu.
This class may be instantiated; it may also be subclassed.
| Field Summary | |
|---|---|
protected boolean |
visible
Indicates this item is visible in its manager; true
by default. |
| Constructor Summary | |
|---|---|
MenuManager()
Creates a menu manager. |
|
MenuManager(java.lang.String text)
Creates a menu manager with the given text. |
|
MenuManager(java.lang.String text,
ImageDescriptor image,
java.lang.String id)
Creates a menu manager with the given text, image, and id. |
|
MenuManager(java.lang.String text,
java.lang.String id)
Creates a menu manager with the given text and id. |
|
| Method Summary | |
|---|---|
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. |
protected void |
doItemFill(IContributionItem ci,
int index)
Call an IContributionItem's fill method with the
implementation's widget. |
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(java.lang.String path)
Finds the manager for the menu at the given path. |
IContributionItem |
findUsingPath(java.lang.String path)
Finds the contribution item at the given path. |
java.lang.String |
getId()
Returns the menu id. |
ImageDescriptor |
getImageDescriptor()
Returns the image for this menu as an image descriptor. |
Menu |
getMenu()
Returns the SWT menu control for this menu manager. |
protected Item |
getMenuItem(int index)
Get an item from the implementation's widget. |
protected int |
getMenuItemCount()
Get the menu item count for the implementation's widget. |
protected Item[] |
getMenuItems()
Get all the items from the implementation's widget. |
java.lang.String |
getMenuText()
Returns the text shown in the menu, potentially with a shortcut appended. |
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. |
protected boolean |
menuExist()
Returns whether the menu control is created and not disposed. |
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 |
setActionDefinitionId(java.lang.String definitionId)
Sets the action definition id of this action. |
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(java.lang.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. |
| Methods inherited from class org.eclipse.jface.action.ContributionManager |
|---|
add, add, allowItem, appendToGroup, appendToGroup, dumpStatistics, find, getItems, getSize, hasDynamicItems, indexOf, indexOf, insert, insertAfter, insertAfter, insertBefore, insertBefore, internalSetItems, isDirty, isEmpty, itemAdded, itemRemoved, prependToGroup, prependToGroup, remove, remove, removeAll, replaceItem, setDirty |
| 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, find, getItems, insertAfter, insertAfter, insertBefore, insertBefore, isDirty, isEmpty, prependToGroup, prependToGroup, remove, remove, removeAll |
| Methods inherited from interface org.eclipse.jface.action.IContributionItem |
|---|
isDirty |
| Field Detail |
|---|
protected boolean visible
true
by default.
| Constructor Detail |
|---|
public MenuManager()
null.
Typically used for creating a context menu, where it doesn't need to be referred to by id.
public MenuManager(java.lang.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 none
public MenuManager(java.lang.String text,
java.lang.String id)
text - the text for the menu, or null if noneid - the menu id, or null if it is to have no id
public MenuManager(java.lang.String text,
ImageDescriptor image,
java.lang.String id)
text - the text for the menu, or null if noneimage - the image for the menu, or null if noneid - the menu id, or null if it is to have no id| Method Detail |
|---|
public void addMenuListener(IMenuListener listener)
IMenuManager
addMenuListener in interface IMenuManagerlistener - a menu listenerpublic Menu createContextMenu(Control parent)
Note that the menu is not expected to be dynamic.
parent - the parent control
public Menu createMenuBar(Decorations parent)
Decorations, and installs all registered
contributions. Does not create a new control if one already exists.
parent - the parent decorations
public 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) method
parent - the parent decorations
public void dispose()
removeAll for that purpose.
dispose in interface IContributionItempublic void fill(Composite parent)
IContributionItemStatusLineManager.
fill in interface IContributionItemparent - the parent control
public 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 end
public 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 end
public 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(java.lang.String path)
IMenuManager'/'.
Convenience for findUsingPath(path) which
extracts an IMenuManager if possible.
findMenuUsingPath in interface IMenuManagerpath - the path string
null
if there is no such contribution item or if the item does
not have an associated menu managerpublic IContributionItem findUsingPath(java.lang.String path)
IMenuManager'/'.
findUsingPath in interface IMenuManagerpath - the path string
null if there is no
such contribution itempublic java.lang.String getId()
getId in interface IContributionItempublic Menu getMenu()
public java.lang.String getMenuText()
public ImageDescriptor getImageDescriptor()
null if this menu has no imagepublic 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()
IContributionItem
isDynamic 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()
IContributionItem
isGroupMarker 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()
IContributionItem
isSeparator in interface IContributionItemtrue if this item is a separator, and
false for normal itemsSeparatorpublic boolean isSubstituteFor(IContributionItem item)
IContributionItem API.
item - the contribution item
true if give item is a substitution for ourselvespublic boolean isVisible()
IContributionItem
isVisible 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 ContributionManagerprotected boolean menuExist()
true if the control is created
and not disposed, false otherwisepublic void removeMenuListener(IMenuListener listener)
IMenuManager
removeMenuListener in interface IMenuManagerlistener - the menu listenerpublic void saveWidgetState()
IContributionItem
saveWidgetState in interface IContributionItempublic void setOverrides(IContributionManagerOverrides newOverrides)
setOverrides in class ContributionManagernewOverrides - the overrides for the items of this managerpublic void setParent(IContributionManager manager)
IContributionItem
setParent in interface IContributionItemmanager - the parent contribution managerpublic void setRemoveAllWhenShown(boolean removeAll)
IMenuManager
setRemoveAllWhenShown in interface IMenuManagerremoveAll - true if all items should be removed when shown,
false if notpublic void setVisible(boolean visible)
IContributionItem
setVisible in interface IContributionItemvisible - true if this item should be visible, and
false otherwisepublic void setActionDefinitionId(java.lang.String definitionId)
definitionId - the command definition idpublic void update()
IContributionItem
update 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 Item[] getMenuItems()
protected Item getMenuItem(int index)
index - of the item
protected int getMenuItemCount()
protected void doItemFill(IContributionItem ci,
int index)
IContributionItem's fill method with the
implementation's widget. The default is to use the Menu
widget.fill(Menu menu, int index)
ci - An IContributionItem whose fill()
method should be called.index - The position the fill() method should start
inserting at.
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(java.lang.String property)
IContributionItem
update in interface IContributionItemproperty - the id of the changed propertypublic void updateAll(boolean force)
IMenuManager
updateAll in interface IMenuManagerforce - true means update even if not dirty,
and false for normal incremental updating
|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.