Package org.eclipse.ui.internal
Class ObjectContributorManager
java.lang.Object
org.eclipse.ui.internal.ObjectContributorManager
- All Implemented Interfaces:
IExtensionChangeHandler
- Direct Known Subclasses:
ObjectActionContributorManager
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:
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map
Cache of adaptable class contributor search paths;null
if none.protected Set
protected Map
Table of contributors.protected Map
Cache of object class contributor search paths;null
if none.protected Map
Cache of resource adapter class contributor search paths;null
if none. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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 withextensibleClass
.protected List
computeCombinedOrder
(Class inputClass) Returns the class search order starting withextensibleClass
.protected final List
computeInterfaceOrder
(List classList) Returns the interface search order for the class hierarchy described byclassList
.void
dispose()
Remove listeners and dispose of this manager.void
Flushes the cache of contributor search paths.protected List
getAdaptableContributors
(String adapterType) Returns the contributions for the given type name.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
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 givenIResource
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 inresults
.void
removeExtension
(IExtension source, Object[] objects) This method is called after the removal of an extension.void
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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler
addExtension
-
Field Details
-
contributors
Table of contributors. -
objectLookup
Cache of object class contributor search paths;null
if none. -
resourceAdapterLookup
Cache of resource adapter class contributor search paths;null
if none. -
adaptableLookup
Cache of adaptable class contributor search paths;null
if none. -
contributorRecordSet
-
-
Constructor Details
-
ObjectContributorManager
public ObjectContributorManager()Constructs a new contributor manager.
-
-
Method Details
-
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
Returns the class search order starting withextensibleClass
. The search order is defined in this class' comment. -
computeInterfaceOrder
Returns the interface search order for the class hierarchy described byclassList
. 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
Get the contributions registered to this manager.- Returns:
- an unmodifiable
Collection
containing all registered contributions. The objects in thisCollection
will beList
s containing the actual contributions. - Since:
- 3.0
-
addContributorsFor
Return the list of contributors for the supplied class. -
hasContributorsFor
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
Return whether the given contributor is applicable to all elements in the selection.- Parameters:
selection
- the selectioncontributor
- the contributor- Returns:
- whether it is applicable
-
isApplicableTo
Return whether the given contributor is applicable to all elements in the list.- Parameters:
list
- the selectioncontributor
- the contributor- Returns:
- whether it is applicable
-
registerContributor
Register a contributor.- Parameters:
contributor
- the contributortargetType
- the target type
-
unregisterAllContributors
public void unregisterAllContributors()Unregister all contributors. -
unregisterContributor
Unregister a contributor from the target type.- Parameters:
contributor
- the contributortargetType
- the target type
-
unregisterContributors
Unregister all contributors for the target type.- Parameters:
targetType
- the target type
-
getContributors
-
getObjectContributors
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
Returns the contributions for the givenIResource
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
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
Prunes from the list of adapters type names that are in the class search order of every class inresults
.- Since:
- 3.1
-
computeCombinedOrder
Returns the class search order starting withextensibleClass
. The search order is defined in this class' comment. -
removeExtension
Description copied from interface:IExtensionChangeHandler
This method is called after the removal of an extension.- Specified by:
removeExtension
in interfaceIExtensionChangeHandler
- Parameters:
source
- the extension being removedobjects
- the objects that were associated with the removed extension
-
dispose
public void dispose()Remove listeners and dispose of this manager.- Since:
- 3.1
-
getContributors
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
)
-