Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » code to test "objectClass" of object contribution of "popupMenus" extension-poin
code to test "objectClass" of object contribution of "popupMenus" extension-poin [message #330556] Fri, 01 August 2008 14:59 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
R3.3, WinXP

I am designing my own extension-point (done that lots), in which I wish
to imitate the effect of the "objectClass" in the "objectContribution"
element of the "org.eclipse.ui.popupMenus" extension-point (haven't done
that often, maybe only once).

I've debugged a lot through these three classes (watching as existing
object contributions are loaded), and I have not seen where the actual
test is performed:


Here's a guess:

Class desired = Class.forName(contribution.objectClass);
Class actual = selectedObject.getClass();
boolean ok = desired.isAssignableFrom(actual);

Re: code to test "objectClass" of object contribution of "popupMenus" extension- [message #330851 is a reply to message #330556] Thu, 14 August 2008 16:51 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

org.eclipse.ui.internal.ObjectActionContributorManager.contr ibuteObjectActions(IWorkbenchPart,
IMenuManager, ISelectionProvider)

That uses
org.eclipse.ui.internal.ObjectContributorManager.getContribu tors(List)
to get a list of IObjectActionContributors for the current selection.
It does most of the objectClass work.

org.eclipse.ui.internal.ObjectContributorManager.isApplicabl eTo(List,

org.eclipse.ui.internal.ObjectActionContributor.isApplicable To(Object)
is called for each selection object to possibly adapt it, and
org.eclipse.ui.internal.ObjectActionContributor.ObjectContri bution.isApplicableTo(Object)
is called to finish any expression processing ...

.... I think. This code is amongst the most complicated of the legacy
action framework code.

If you are writing your own extension point, you could also consider
core expressions. The IConfigurationElement expression ->
org.eclipse.core.expressions.Expression parser is already provided. The
IEvaluationContext also had an implementation.

In 3.4, it's also easy to use the IEvaluationService to plug your own
extension points core expressions into the main eclipse evaluation
engine (the same one used by the context, menu, and handler service).


Paul Webster platform.doc.isv/guide/workbench.htm

Previous Topic:Following upgrade "Error: no label provider for container"
Next Topic:problems in using a custom IApplication class : AssertionFailedException
Goto Forum:

Current Time: Sun May 20 16:06:51 GMT 2018

Powered by FUDForum. Page generated in 0.01221 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top