Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.jface.action
Class ContributionManager

java.lang.Object
  extended byorg.eclipse.jface.action.ContributionManager

All Implemented Interfaces:
IContributionManager

Direct Known Subclasses:
CoolBarManager, 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.
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
 
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


 

 

allowItem

protected boolean allowItem(IContributionItem itemToAdd)

This method allows subclasses of 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.

Parameters:
itemToAdd - The contribution item to be added; may be null.
Returns:
true if the addition should be allowed; false otherwise. The default implementation allows all items.
Since:
3.0


 

 

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 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.

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


 

 

indexOf

public int indexOf(String id)

Returns the index of the item with the given id.

Returns:
int the index or -1 if the item is not found


 

 

indexOf

protected int indexOf(IContributionItem item)

Returns the index of the object in the internal structure. This is different from indexOf(String id) since some contribution items may not have an id.

Parameters:
item - the contribution item
Returns:
the index, or -1 if the item is not found
Since:
3.0


 

 

insert

public void insert(int index,
                   IContributionItem item)

Insert the item at the given index.


 

 

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:
ID - the contribution item id
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:
ID - the contribution item id
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


 

 

itemAdded

protected void itemAdded(IContributionItem item)

The given item was added to the list of contributions. Marks the manager as dirty and updates the number of dynamic items, and the memento.


 

 

itemRemoved

protected void itemRemoved(IContributionItem item)

The given item was removed from the list of contributions. Marks the manager as dirty and updates the number of dynamic items.


 

 

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


 

 

replaceItem

public boolean replaceItem(String identifier,
                           IContributionItem replacementItem)

Replaces the item of the given identifier with another contribution item. This can be used, for example, to replace large contribution items with placeholders to avoid memory leaks. If the identifier cannot be found in the current list of items, then this does nothing. If multiple occurrences are found, then the replacement items is put in the first position and the other positions are removed.

Parameters:
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.
Returns:
true if the given identifier can be;
Since:
3.0


 

 

setDirty

protected void setDirty(boolean dirty)

Sets whether this manager is dirty. When dirty, the list of contributions is not accurately reflected in the corresponding widgets.

Parameters:
dirty - true if this manager is dirty, and false if it is up-to-date


 

 

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


 

 

internalSetItems

protected void internalSetItems(IContributionItem[] items)

An internal method for setting the order of the contribution items.

Parameters:
items - the contribution items in the specified order
Since:
3.0


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.