public abstract class ContributionManager extends Object implements IContributionManager
IContributionManager. This class provides functionality
common across the specific managers defined by this framework.
This class maintains a list of contribution items and a dirty flag, both as
internal state. In addition to providing implementations of most
IContributionManager methods, this class automatically
coalesces adjacent separators, hides beginning and ending separators,
and deals with dynamically changing sets of contributions. When the set
of contributions does change dynamically, the changes are propagated
to the control via the update method, which subclasses
must implement.
Note: A ContributionItem cannot be shared between different
ContributionManagers.
| Modifier | Constructor and Description |
|---|---|
protected |
ContributionManager()
Creates a new contribution manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(IAction action)
Adds an action as a contribution item to this manager.
|
void |
add(IContributionItem item)
Adds a contribution item to this manager.
|
protected boolean |
allowItem(IContributionItem itemToAdd)
This method allows subclasses of
ContributionManager to prevent
certain items in the contributions list. |
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.
|
protected void |
dumpStatistics()
Internal debug method for printing statistics about this manager
to
System.out. |
IContributionItem |
find(String id)
Finds the contribution item with the given id.
|
IContributionItem[] |
getItems()
Returns all contribution items known to this manager.
|
IContributionManagerOverrides |
getOverrides()
The
ContributionManager implementation of this
method declared on IContributionManager returns
the current overrides. |
protected boolean |
hasDynamicItems()
Returns whether this contribution manager contains dynamic items.
|
protected int |
indexOf(IContributionItem item)
Returns the index of the object in the internal structure.
|
int |
indexOf(String id)
Returns the index of the item with the given id.
|
void |
insert(int index,
IContributionItem item)
Insert the item at the given index.
|
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.
|
protected void |
internalSetItems(IContributionItem[] items)
An internal method for setting the order of the contribution items.
|
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.
|
protected void |
itemAdded(IContributionItem item)
The given item was added to the list of contributions.
|
protected void |
itemRemoved(IContributionItem item)
The given item was removed from the list of contributions.
|
void |
markDirty()
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.
|
IContributionItem |
remove(IContributionItem item)
Removes the given contribution item from the contribution items
known to this manager.
|
IContributionItem |
remove(String ID)
Removes and returns the contribution item with the given id from this manager.
|
void |
removeAll()
Removes all contribution items from this manager.
|
boolean |
replaceItem(String identifier,
IContributionItem replacementItem)
Replaces the item of the given identifier with another contribution item.
|
protected void |
setDirty(boolean dirty)
Sets whether this manager is dirty.
|
void |
setOverrides(IContributionManagerOverrides newOverrides)
Sets the overrides for this contribution manager
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitupdateprotected ContributionManager()
public void add(IAction action)
IContributionManageradd(new ActionContributionItem(action)).add in interface IContributionManageraction - the actionpublic void add(IContributionItem item)
IContributionManageradd in interface IContributionManageritem - the contribution itempublic void appendToGroup(String groupName, IAction action)
IContributionManagerappendToGroup(groupName,new ActionContributionItem(action)).appendToGroup in interface IContributionManagergroupName - the name of the groupaction - the actionpublic void appendToGroup(String groupName, IContributionItem item)
IContributionManagerappendToGroup in interface IContributionManagergroupName - the name of the groupitem - the contribution itemprotected boolean allowItem(IContributionItem itemToAdd)
ContributionManager to prevent
certain items in the contributions list. ContributionManager
will either block or allow an addition based on the result of this method
call. This can be used to prevent duplication, for example.itemToAdd - The contribution item to be added; may be null.true if the addition should be allowed;
false otherwise. The default implementation allows all items.protected void dumpStatistics()
System.out.public IContributionItem find(String id)
IContributionManagerfind in interface IContributionManagerid - the contribution item idnull if
no item with the given id can be foundpublic IContributionItem[] getItems()
IContributionManagergetItems in interface IContributionManagerpublic IContributionManagerOverrides getOverrides()
ContributionManager 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 IContributionManagerprotected boolean hasDynamicItems()
true if this manager contains dynamic items, and
false otherwisepublic int indexOf(String id)
id - The id of the item whose index is requested.int the index or -1 if the item is not foundprotected int indexOf(IContributionItem item)
indexOf(String id) since some contribution items may not have an id.item - The contribution itempublic void insert(int index,
IContributionItem item)
index - The index to be used for insertionitem - The item to be insertedpublic void insertAfter(String ID, IAction action)
IContributionManagerinsertAfter(id,new ActionContributionItem(action)).insertAfter in interface IContributionManagerID - the contribution item idaction - the action to insertpublic void insertAfter(String ID, IContributionItem item)
IContributionManagerinsertAfter in interface IContributionManagerID - the contribution item iditem - the contribution item to insertpublic void insertBefore(String ID, IAction action)
IContributionManagerinsertBefore(id,new ActionContributionItem(action)).insertBefore in interface IContributionManagerID - the contribution item idaction - the action to insertpublic void insertBefore(String ID, IContributionItem item)
IContributionManagerinsertBefore in interface IContributionManagerID - the contribution item iditem - the contribution item to insertpublic boolean isDirty()
IContributionManagerisDirty in interface IContributionManagertrue if this manager is dirty, and false
if it is up-to-datepublic boolean isEmpty()
IContributionManagerisEmpty in interface IContributionManagertrue if there are no items, and
false otherwiseprotected void itemAdded(IContributionItem item)
protected void itemRemoved(IContributionItem item)
public void markDirty()
IContributionManagermarkDirty in interface IContributionManagerpublic void prependToGroup(String groupName, IAction action)
IContributionManagerprependToGroup(groupName,new ActionContributionItem(action)).prependToGroup in interface IContributionManagergroupName - the name of the groupaction - the actionpublic void prependToGroup(String groupName, IContributionItem item)
IContributionManagerprependToGroup in interface IContributionManagergroupName - the name of the groupitem - the contribution itempublic IContributionItem remove(String ID)
IContributionManagernull if this manager has no contribution items
with the given id.remove in interface IContributionManagerID - the contribution item idnull if nonepublic IContributionItem remove(IContributionItem item)
IContributionManagerremove in interface IContributionManageritem - the contribution itemitem parameter if the item was removed,
and null if it was not foundpublic void removeAll()
IContributionManagerremoveAll in interface IContributionManagerpublic boolean replaceItem(String identifier, IContributionItem replacementItem)
identifier - The identifier to look for in the list of contributions;
should not be null.replacementItem - The contribution item to replace the old item; must
not be null. Use remove if that is what you want to do.true if the given identifier can be; protected void setDirty(boolean dirty)
dirty - true if this manager is dirty, and false
if it is up-to-datepublic void setOverrides(IContributionManagerOverrides newOverrides)
newOverrides - the overrides for the items of this managerprotected void internalSetItems(IContributionItem[] items)
items - the contribution items in the specified orderGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.