Interface IContributionManager
- All Known Subinterfaces:
ICoolBarManager
,IMenuManager
,IStatusLineManager
,IToolBarManager
- All Known Implementing Classes:
ActionSetMenuManager
,ContributionManager
,CoolBarManager
,CoolBarToTrimManager
,EditorMenuManager
,MenuManager
,StatusLineManager
,SubContributionManager
,SubCoolBarManager
,SubMenuManager
,SubStatusLineManager
,SubToolBarManager
,ToolBarManager
A contribution manager keeps track of a list of contribution items. Each contribution item may has an optional identifier, which can be used to retrieve items from a manager, and for positioning items relative to each other. The list of contribution items can be subdivided into named groups using special contribution items that serve as group markers.
The IContributionManager
interface provides general protocol for
adding, removing, and retrieving contribution items. It also provides
convenience methods that make it convenient to contribute actions. This
interface should be implemented by all objects that wish to manage
contributions.
There are several implementions of this interface in this package, including
ones for menus (MenuManager
), tool bars
(ToolBarManager
), and status lines
(StatusLineManager
).
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an action as a contribution item to this manager.void
add
(IContributionItem item) Adds a contribution item to this manager.void
appendToGroup
(String groupName, IAction action) Adds a contribution item for the given action at the end of the group with the given name.void
appendToGroup
(String groupName, IContributionItem item) Adds a contribution item to this manager at the end of the group with the given name.Finds the contribution item with the given id.getItems()
Returns all contribution items known to this manager.Returns the overrides for the items of this manager.void
insertAfter
(String id, IAction action) Inserts a contribution item for the given action after the item with the given id.void
insertAfter
(String id, IContributionItem item) Inserts a contribution item after the item with the given id.void
insertBefore
(String id, IAction action) Inserts a contribution item for the given action before the item with the given id.void
insertBefore
(String id, IContributionItem item) Inserts a contribution item before the item with the given id.boolean
isDirty()
Returns whether the list of contributions has recently changed and has yet to be reflected in the corresponding widgets.boolean
isEmpty()
Returns whether this manager has any contribution items.void
Marks this contribution manager as dirty.void
prependToGroup
(String groupName, IAction action) Adds a contribution item for the given action at the beginning of the group with the given name.void
prependToGroup
(String groupName, IContributionItem item) Adds a contribution item to this manager at the beginning of the group with the given name.Removes and returns the contribution item with the given id from this manager.remove
(IContributionItem item) Removes the given contribution item from the contribution items known to this manager.void
Removes all contribution items from this manager.void
update
(boolean force) Updates this manager's underlying widget(s) with any changes which have been made to it or its items.
-
Method Details
-
add
Adds an action as a contribution item to this manager. Equivalent toadd(new ActionContributionItem(action))
.- Parameters:
action
- the action, this cannot benull
-
add
Adds a contribution item to this manager.- Parameters:
item
- the contribution item, this cannot benull
-
appendToGroup
Adds a contribution item for the given action at the end of the group with the given name. Equivalent toappendToGroup(groupName,new ActionContributionItem(action))
.- Parameters:
groupName
- the name of the groupaction
- the action- Throws:
IllegalArgumentException
- if there is no group with the given name
-
appendToGroup
Adds a contribution item to this manager at the end of the group with the given name.- Parameters:
groupName
- the name of the groupitem
- the contribution item- Throws:
IllegalArgumentException
- if there is no group with the given name
-
find
Finds the contribution item with the given id.- Parameters:
id
- the contribution item id- Returns:
- the contribution item, or
null
if no item with the given id can be found
-
getItems
IContributionItem[] getItems()Returns all contribution items known to this manager.- Returns:
- a list of contribution items
-
getOverrides
IContributionManagerOverrides getOverrides()Returns the overrides for the items of this manager.- Returns:
- the overrides for the items of this manager
- Since:
- 2.0
-
insertAfter
Inserts a contribution item for the given action after the item with the given id. Equivalent toinsertAfter(id,new ActionContributionItem(action))
.- Parameters:
id
- the contribution item idaction
- the action to insert- Throws:
IllegalArgumentException
- if there is no item with the given id
-
insertAfter
Inserts a contribution item after the item with the given id.- Parameters:
id
- the contribution item iditem
- the contribution item to insert- Throws:
IllegalArgumentException
- if there is no item with the given id
-
insertBefore
Inserts a contribution item for the given action before the item with the given id. Equivalent toinsertBefore(id,new ActionContributionItem(action))
.- Parameters:
id
- the contribution item idaction
- the action to insert- Throws:
IllegalArgumentException
- if there is no item with the given id
-
insertBefore
Inserts a contribution item before the item with the given id.- Parameters:
id
- the contribution item iditem
- the contribution item to insert- Throws:
IllegalArgumentException
- if there is no item with the given id
-
isDirty
boolean isDirty()Returns whether the list of contributions has recently changed and has yet to be reflected in the corresponding widgets.- Returns:
true
if this manager is dirty, andfalse
if it is up-to-date
-
isEmpty
boolean isEmpty()Returns whether this manager has any contribution items.- Returns:
true
if there are no items, andfalse
otherwise
-
markDirty
void markDirty()Marks this contribution manager as dirty. -
prependToGroup
Adds a contribution item for the given action at the beginning of the group with the given name. Equivalent toprependToGroup(groupName,new ActionContributionItem(action))
.- Parameters:
groupName
- the name of the groupaction
- the action- Throws:
IllegalArgumentException
- if there is no group with the given name
-
prependToGroup
Adds a contribution item to this manager at the beginning of the group with the given name.- Parameters:
groupName
- the name of the groupitem
- the contribution item- Throws:
IllegalArgumentException
- if there is no group with the given name
-
remove
Removes and returns the contribution item with the given id from this manager. Returnsnull
if this manager has no contribution items with the given id.- Parameters:
id
- the contribution item id- Returns:
- the item that was found and removed, or
null
if none
-
remove
Removes the given contribution item from the contribution items known to this manager.- Parameters:
item
- the contribution item- Returns:
- the
item
parameter if the item was removed, andnull
if it was not found
-
removeAll
void removeAll()Removes all contribution items from this manager.Note: The items will not get disposed.
-
update
void update(boolean force) 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.- Parameters:
force
-true
means update even if not dirty, andfalse
for normal incremental updating
-