Eclipse Platform
2.0

org.eclipse.jface.action
Class ContributionManager

java.lang.Object
  |
  +--org.eclipse.jface.action.ContributionManager
All Implemented Interfaces:
IContributionManager
Direct Known Subclasses:
MenuManager, StatusLineManager, ToolBarManager

public abstract class ContributionManager
extends Object
implements IContributionManager

Abstract base class for all contribution managers, and standard implementation of 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.


Constructor Summary
protected ContributionManager()
          Creates a new contribution manager.
 
Method Summary
 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.
 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 implemenatation of this method declared on IContributionManager returns the current overrides.
protected  boolean hasDynamicItems()
          Returns whether this contribution manager contains dynamic items.
 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 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.
protected  void setDirty(boolean d)
          Sets whether this manager is dirty.
 void setOverrides(IContributionManagerOverrides newOverrides)
          Sets the overrides for this contribution manager
 
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
update
 

Constructor Detail

ContributionManager

protected ContributionManager()
Creates a new contribution manager.

Method Detail

add

public void add(IAction action)
Description copied from interface: IContributionManager
Adds an action as a contribution item to this manager. Equivalent to add(new ActionContributionItem(action)).

Specified by:
add in interface IContributionManager
Parameters:
action - the action

add

public void add(IContributionItem item)
Description copied from interface: IContributionManager
Adds a contribution item to this manager.

Specified by:
add in interface IContributionManager
Parameters:
item - the contribution item

appendToGroup

public void appendToGroup(String groupName,
                          IAction action)
Description copied from interface: IContributionManager
Adds a contribution item for the given action at the end of the group with the given name. Equivalent to appendToGroup(groupName,new ActionContributionItem(action)).

Specified by:
appendToGroup in interface IContributionManager
Parameters:
groupName - the name of the group
action - the action

appendToGroup

public void appendToGroup(String groupName,
                          IContributionItem item)
Description copied from interface: IContributionManager
Adds a contribution item to this manager at the end of the group with the given name.

Specified by:
appendToGroup in interface IContributionManager
Parameters:
groupName - the name of the group
item - the contribution item

dumpStatistics

protected void dumpStatistics()
Internal debug method for printing statistics about this manager to System.out.


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
Parameters:
id - the contribution item id
Returns:
the contribution item, or null if no item with the given id can be found

getItems

public IContributionItem[] getItems()
Description copied from interface: IContributionManager
Returns all contribution items known to this manager.

Specified by:
getItems in interface IContributionManager
Returns:
a list of contribution items

getOverrides

public IContributionManagerOverrides getOverrides()
The ContributionManager implemenatation of this method declared on IContributionManager returns the current overrides. If there is no overrides it lazily creates one which overrides no item state.

Specified by:
getOverrides in interface IContributionManager
Returns:
the overrides for the items of this manager
Since:
2.0

hasDynamicItems

protected boolean hasDynamicItems()
Returns whether this contribution manager contains dynamic items. A dynamic contribution item contributes items conditionally, dependent on some internal state.

Returns:
true if this manager contains dynamic items, and false otherwise

insertAfter

public void insertAfter(String ID,
                        IAction action)
Description copied from interface: IContributionManager
Inserts a contribution item for the given action after the item with the given id. Equivalent to insertAfter(id,new ActionContributionItem(action)).

Specified by:
insertAfter in interface IContributionManager
Parameters:
ID - the contribution item id
action - the action to insert

insertAfter

public void insertAfter(String ID,
                        IContributionItem item)
Description copied from interface: IContributionManager
Inserts a contribution item after the item with the given id.

Specified by:
insertAfter in interface IContributionManager
Parameters:
item - the contribution item to insert

insertBefore

public void insertBefore(String ID,
                         IAction action)
Description copied from interface: IContributionManager
Inserts a contribution item for the given action before the item with the given id. Equivalent to insertBefore(id,new ActionContributionItem(action)).

Specified by:
insertBefore in interface IContributionManager
Parameters:
ID - the contribution item id
action - the action to insert

insertBefore

public void insertBefore(String ID,
                         IContributionItem item)
Description copied from interface: IContributionManager
Inserts a contribution item before the item with the given id.

Specified by:
insertBefore in interface IContributionManager
Parameters:
item - the contribution item to insert

isDirty

public boolean isDirty()
Description copied from interface: IContributionManager
Returns whether the list of contributions has recently changed and has yet to be reflected in the corresponding widgets.

Specified by:
isDirty in interface IContributionManager
Returns:
true if this manager is dirty, and false if it is up-to-date

isEmpty

public boolean isEmpty()
Description copied from interface: IContributionManager
Returns whether this manager has any contribution items.

Specified by:
isEmpty in interface IContributionManager
Returns:
true if there are no items, and false otherwise

markDirty

public void markDirty()
Description copied from interface: IContributionManager
Marks this contribution manager as dirty.

Specified by:
markDirty in interface IContributionManager

prependToGroup

public void prependToGroup(String groupName,
                           IAction action)
Description copied from interface: IContributionManager
Adds a contribution item for the given action at the beginning of the group with the given name. Equivalent to prependToGroup(groupName,new ActionContributionItem(action)).

Specified by:
prependToGroup in interface IContributionManager
Parameters:
groupName - the name of the group
action - the action

prependToGroup

public void prependToGroup(String groupName,
                           IContributionItem item)
Description copied from interface: IContributionManager
Adds a contribution item to this manager at the beginning of the group with the given name.

Specified by:
prependToGroup in interface IContributionManager
Parameters:
groupName - the name of the group
item - the contribution item

remove

public IContributionItem remove(String ID)
Description copied from interface: IContributionManager
Removes and returns the contribution item with the given id from this manager. Returns null if this manager has no contribution items with the given id.

Specified by:
remove in interface IContributionManager
Parameters:
ID - the contribution item id
Returns:
the item that was found and removed, or null if none

remove

public IContributionItem remove(IContributionItem item)
Description copied from interface: IContributionManager
Removes the given contribution item from the contribution items known to this manager.

Specified by:
remove in interface IContributionManager
Parameters:
item - the contribution item
Returns:
the item parameter if the item was removed, and null if it was not found

removeAll

public void removeAll()
Description copied from interface: IContributionManager
Removes all contribution items from this manager.

Specified by:
removeAll in interface IContributionManager

setDirty

protected void setDirty(boolean d)
Sets whether this manager is dirty. When dirty, the list of contributions is not accurately reflected in the corresponding widgets.


setOverrides

public void setOverrides(IContributionManagerOverrides newOverrides)
Sets the overrides for this contribution manager

Parameters:
newOverrides - the overrides for the items of this manager
Since:
2.0

Eclipse Platform
2.0

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