Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Faceted Project Framework » library providers enablement expressions
library providers enablement expressions [message #572445] Wed, 31 March 2010 10:21 Go to next message
Eric Peters is currently offline Eric PetersFriend
Messages: 27
Registered: July 2009
Junior Member
Hi,

I was trying to get a define complex enablement expression like below with 2 facet requirements , but seemed only the first requirement was being recognized. It is entirely possible my enablement expression is not correctly formed.

What we actually want though is support for e.g. a Project PropertyTester and associated class in our enablement expression , so the class would get called with a handle to the project to glean information like what runtime is it targeting, does that runtime support our library (having some logic in the class to determine that.

So, can you tell me if the extension point supports more or less an arbitrarily complex enablement expression with property testers etc like we are looking for?

Thanks in advance for your help,


<extension point="org.eclipse.jst.common.project.facet.core.libraryProviders ">
<provider id="com.library.id">
<enablement>
<and>
<with variable="requestingProjectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jaxrs:1.0" forcePluginActivation="true" />
</with>
<with variable="requestingProjectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jsf:" forcePluginActivation="true" />
</with>
</and>
</enablement>
<action type="INSTALL">
<config class="someclass"/>
<operation class="someclass"/>
</action>

<label>a library</label>
<priority>10000</priority>
</provider>
</extension>




org.eclipse.jst.common.project.facet.core.libprov.user.UserL ibraryProviderInstallOperationConfig
Re: library providers enablement expressions [message #572463 is a reply to message #572445] Thu, 01 April 2010 20:32 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
The library providers extension point supports arbitrary enablement expressions, but using the enablement expression language takes a little getting used to. The way property testers work is particularly tricky.

<enablement>
<and>
<with variable="requestingProjectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jaxrs:1.0" forcePluginActivation="true" />
</with>
<with variable="requestingProjectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jsf:" forcePluginActivation="true" />
</with>
</and>
</enablement>

You can write it simpler by pulling up with operator higher, but this should work too. Perhaps the property tester is getting confused by the trailing colon in "jst.jsf:". Try it just as "jst.jsf".

Regarding your question about using a custom property tester, could you show how you are defining the property tester? You must define the property tester for specific types for the expression evaluator to know about them. Based on how you wrote that enablement expression, your context variable is going to be IProjectFacetVersion. Judging by the exception you are getting, your property tester is not defined for this type.

It doesn't sound like IProjectFacetVersion is enough for what you are trying to test, anyway, so you have to pick a different variable to use. Here is the list of the available variables:

context - EvaluationContext (if your custom property tester needs access to variety of things)
requestingProjectFacet - IProjectFacetVersion (same as default variable)
projectFacets - Collection<IProjectFacetVersion>
targetedRuntimes - Collection<IRuntime>
provider - ILibraryProvider

Based on what you've said so far, try using "context" variable, which of type org.eclipse.jst.common.project.facet.core.libprov.Enablement ExpressionContext. This will give your property tester access to pretty much everything available. Remember that you have to register your property tester to work with EnablementExpressionContext type.

Hope this helps. Post further questions, if necessary.

- Konstantin
Re: library providers enablement expressions [message #572481 is a reply to message #572463] Tue, 06 April 2010 13:17 Go to previous messageGo to next message
Eric Peters is currently offline Eric PetersFriend
Messages: 27
Registered: July 2009
Junior Member
Thanks a lot Konstantin, using context variable did the trick. Is there any documentation on using the varaiables below? Indeed looking at the libraryProviders extension point definition in an editor the enablement attribute has a red x on it and no DTD, and I was not able to figure out how to use it.

Also. I was still not able to get something like below working... I expected as long as the project had the 2 facets below the library would show up in the jax-rs facet page but it did not. Tried several variations of below but nothing worked.



<with variable="requestingProjectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jaxrs:1.0" forcePluginActivation="true"/>
</with>
<with variable="requestingProjectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jsf" forcePluginActivation="true"/>
</with>
Re: library providers enablement expressions [message #572555 is a reply to message #572481] Tue, 06 April 2010 17:07 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Hi Eric,

There is a section on available variables in framework documentation:

http://www.eclipse.org/fproj/articles/libprov/1/index.html

You can find the link to this article from the main project page:

http://www.eclipse.org/fproj/

Getting xml syntax completion to work for expressions can be a bit of a pain in the behind. For reasons unknown, the platform team has chosen to only bundle the required schema in the SDK version of the platform. That means you have to have platform SDK in your target (i think) and maybe in your dev eclipse too.

I usually just Google for "Eclipse Core Expressions". There are documents like this one that will help you out:

http://wiki.eclipse.org/Command_Core_Expressions

Regarding your last remaining problem, now that I have my eyes fully open, you are correct, the problem is with the variable being used. It sounds like you are trying to test that the requesting project facet is jaxrs while the project also has jsf.

This is approx what you would need to write:

<with variable="requestingProjectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jaxrs:1.0" forcePluginActivation="true"/>
</with>
<with variable="projectFacets">
<count value="+"/>
<iterate operator="or">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet " value="jst.jsf" forcePluginActivation="true"/>
</iterate>
</with>

The second part says loop over the list of all facets, check each one if it's jsf, exactly one has to match the test (the combination of iterator "or" operator and could value of "+").

How is that for intuitive syntax?

Hope this helps,

- Konstantin
Re: library providers enablement expressions [message #572569 is a reply to message #572555] Tue, 06 April 2010 17:39 Go to previous message
Eric Peters is currently offline Eric PetersFriend
Messages: 27
Registered: July 2009
Junior Member
Worked beautifully! Thanks for the links and sample code.
Previous Topic:library providers enablement expressions
Next Topic:How to define implementation library programmatically for a facet?
Goto Forum:
  


Current Time: Thu Mar 28 17:08:31 GMT 2024

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

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

Back to the top