# Class ObjectContributorManager

java.lang.Object
org.eclipse.ui.internal.ObjectContributorManager

All Implemented Interfaces:
  `IExtensionChangeHandler`

Direct Known Subclasses:
  `ObjectActionContributorManager`

public abstract class ObjectContributorManager extends Object implements IExtensionChangeHandler
This class is a default implementation of `IObjectContributorManager`. It provides fast merging of contributions with the following semantics:

- All of the matching contributors will be invoked per property lookup
- The search order from a class with the definition
  `class X extends Y implements A, B`
  is as follows:
- - the target's class: X
  - X's superclasses in order to `Object`
  - a depth-first traversal of the target class's interfaces in the order returned by `getInterfaces()` (in the example, A and its superinterfaces then B and its superinterfaces)

See Also:
  - `IObjectContributor`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Map`
`adaptableLookup`
Cache of adaptable class contributor search paths; `null` if none.
`protected Set`
`contributorRecordSet`
`protected Map`
`contributors`
Table of contributors.
`protected Map`
`objectLookup`
Cache of object class contributor search paths; `null` if none.
`protected Map`
`resourceAdapterLookup`
Cache of resource adapter class contributor search paths; `null` if none.

## Constructor Summary

Constructors
Constructor
Description
`ObjectContributorManager()`
Constructs a new contributor manager.

## Method Summary

Modifier and Type
Method
Description
`protected List`
`addContributorsFor(Class objectClass)`
Return the list of contributors for the supplied class.
`protected final List`
`computeClassOrder(Class extensibleClass)`
Returns the class search order starting with `extensibleClass`.
`protected List`
`computeCombinedOrder(Class inputClass)`
Returns the class search order starting with `extensibleClass`.
`protected final List`
`computeInterfaceOrder(List classList)`
Returns the interface search order for the class hierarchy described by `classList`.
`void`
`dispose()`
Remove listeners and dispose of this manager.
`void`
`flushLookup()`
Flushes the cache of contributor search paths.
`protected List`
`getAdaptableContributors(String adapterType)`
Returns the contributions for the given type name.
`Collection`
`getContributors()`
Get the contributions registered to this manager.
`protected List`
`getContributors(Object object)`
`protected List`
`getContributors(List elements)`
Returns the list of contributors that are interested in the given list of model elements.
`protected String`
`getExtensionPointFilter()`
Return the extension point id (local to org.eclipse.ui) that this manager is associated with.
`protected List`
`getObjectContributors(Class objectClass)`
Returns the contributions for the given class.
`protected List`
`getResourceContributors(Class resourceClass)`
Returns the contributions for the given `IResource`class.
`boolean`
`hasContributorsFor(Object object)`
Returns true if contributors exist in the manager for this object and any of it's super classes, interfaces, or adapters.
`boolean`
`isApplicableTo(List list, IObjectContributor contributor)`
Return whether the given contributor is applicable to all elements in the list.
`boolean`
`isApplicableTo(IStructuredSelection selection, IObjectContributor contributor)`
Return whether the given contributor is applicable to all elements in the selection.
`void`
`registerContributor(IObjectContributor contributor, String targetType)`
Register a contributor.
`protected void`
`removeCommonAdapters(List adapters, List results)`
Prunes from the list of adapters type names that are in the class search order of every class in `results`.
`void`
`removeExtension(IExtension source, Object[] objects)`
This method is called after the removal of an extension.
`void`
`unregisterAllContributors()`
Unregister all contributors.
`void`
`unregisterContributor(IObjectContributor contributor, String targetType)`
Unregister a contributor from the target type.
`void`
`unregisterContributors(String targetType)`
Unregister all contributors for the target type.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface IExtensionChangeHandler

`addExtension`

## Field Details

### contributors

protected Map contributors
Table of contributors.

### objectLookup

protected Map objectLookup
Cache of object class contributor search paths; `null` if none.

### resourceAdapterLookup

protected Map resourceAdapterLookup
Cache of resource adapter class contributor search paths; `null` if none.

### adaptableLookup

protected Map adaptableLookup
Cache of adaptable class contributor search paths; `null` if none.

### contributorRecordSet

protected Set contributorRecordSet

## Constructor Details

### ObjectContributorManager

public ObjectContributorManager()
Constructs a new contributor manager.

## Method Details

### getExtensionPointFilter

protected String getExtensionPointFilter()
Return the extension point id (local to org.eclipse.ui) that this manager is associated with. Default implementation returns null, which implies no relationship with a particular extension.

Returns:
  the extension point id
Since:
  3.4

### computeClassOrder

protected final List computeClassOrder(Class extensibleClass)
Returns the class search order starting with `extensibleClass`. The search order is defined in this class' comment.

### computeInterfaceOrder

protected final List computeInterfaceOrder(List classList)
Returns the interface search order for the class hierarchy described by `classList`. The search order is defined in this class' comment.

### flushLookup

public void flushLookup()
Flushes the cache of contributor search paths. This is generally required whenever a contributor is added or removed.

It is likely easier to just toss the whole cache rather than trying to be smart and remove only those entries affected.

### getContributors

public Collection getContributors()
Get the contributions registered to this manager.

Returns:
  an unmodifiable `Collection` containing all registered contributions. The objects in this `Collection` will be `List`s containing the actual contributions.
Since:
  3.0

### addContributorsFor

protected List addContributorsFor(Class objectClass)
Return the list of contributors for the supplied class.

### hasContributorsFor

public boolean hasContributorsFor(Object object)
Returns true if contributors exist in the manager for this object and any of it's super classes, interfaces, or adapters.

Parameters:
  `object` - the object to test
Returns:
  whether the object has contributors

### isApplicableTo

public boolean isApplicableTo(IStructuredSelection selection, IObjectContributor contributor)
Return whether the given contributor is applicable to all elements in the selection.

Parameters:
  `selection` - the selection
  `contributor` - the contributor
Returns:
  whether it is applicable

### isApplicableTo

public boolean isApplicableTo(List list, IObjectContributor contributor)
Return whether the given contributor is applicable to all elements in the list.

Parameters:
  `list` - the selection
  `contributor` - the contributor
Returns:
  whether it is applicable

### registerContributor

public void registerContributor(IObjectContributor contributor, String targetType)
Register a contributor.

Parameters:
  `contributor` - the contributor
  `targetType` - the target type

### unregisterAllContributors

public void unregisterAllContributors()
Unregister all contributors.

### unregisterContributor

public void unregisterContributor(IObjectContributor contributor, String targetType)
Unregister a contributor from the target type.

Parameters:
  `contributor` - the contributor
  `targetType` - the target type

### unregisterContributors

public void unregisterContributors(String targetType)
Unregister all contributors for the target type.

Parameters:
  `targetType` - the target type

### getContributors

protected List getContributors(Object object)

### getObjectContributors

protected List getObjectContributors(Class objectClass)
Returns the contributions for the given class. This considers contributors on any super classes and interfaces.

Parameters:
  `objectClass` - the class to search for contributions.
Returns:
  the contributions for the given class. This considers contributors on any super classes and interfaces.
Since:
  3.1

### getResourceContributors

protected List getResourceContributors(Class resourceClass)
Returns the contributions for the given `IResource`class. This considers contributors on any super classes and interfaces. This will only return contributions that are adaptable.

Parameters:
  `resourceClass` - the class to search for contributions.
Returns:
  the contributions for the given class. This considers adaptable contributors on any super classes and interfaces.
Since:
  3.1

### getAdaptableContributors

protected List getAdaptableContributors(String adapterType)
Returns the contributions for the given type name.

Parameters:
  `adapterType` - the class to search for contributions.
Returns:
  the contributions for the given class. This considers contributors to this specific type.
Since:
  3.1

### removeCommonAdapters

protected void removeCommonAdapters(List adapters, List results)
Prunes from the list of adapters type names that are in the class search order of every class in `results`.

Since:
  3.1

### computeCombinedOrder

protected List computeCombinedOrder(Class inputClass)
Returns the class search order starting with `extensibleClass`. The search order is defined in this class' comment.

### removeExtension

public void removeExtension(IExtension source, Object[] objects)
Description copied from interface: `IExtensionChangeHandler`
This method is called after the removal of an extension.

Specified by:
  `removeExtension` in interface `IExtensionChangeHandler`
Parameters:
  `source` - the extension being removed
  `objects` - the objects that were associated with the removed extension

### dispose

public void dispose()
Remove listeners and dispose of this manager.

Since:
  3.1

### getContributors

protected List getContributors(List elements)
Returns the list of contributors that are interested in the given list of model elements.

Parameters:
  `elements` - a list of model elements (`Object`)
Returns:
  the list of interested contributors (`IObjectContributor`)