library providers enablement expressions [message #572445] |
Wed, 31 March 2010 06:21  |
Eclipse User |
|
|
|
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 16:32   |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06747 seconds