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
Eclipse UserFriend
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:

PluginActionContributionItem
ObjectContributorManager
ObjectActionContributorManager

Here's a guess:

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

TIA,
-Paul
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
Eclipse UserFriend
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,
IObjectContributor)

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

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Previous Topic:Error on startup
Next Topic:Visibility of Menu Contributions - a suggestion
Goto Forum:
  


Current Time: Tue Feb 11 03:21:06 GMT 2025

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

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

Back to the top