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 #524245] 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>

Also, was trying to use a project property tester like below but was getting exceptions...
<extension
point="org.eclipse.jst.common.project.facet.core.libraryProviders ">
<provider id="com.ibm.ast.ws.jaxrs.v61.stub.library">
<label>MyLib</label>
<enablement>
<test
property=" org.eclipse.wst.ws.service.ws.service.policy.projectHasWSDLf iles "/>
</enablement>

(the project property tester above is defined in org.eclipse.wst.ws so should
be able to quickly try it out).

When using a project property tester like above getting exception below....

!MESSAGE No property tester contributes a property
org.eclipse.wst.ws.service.ws.service.policy.projectHasWSDLf iles to type class
org.eclipse.wst.common.project.facet.core.internal.ProjectFa cetVersion
!STACK 1
org.eclipse.core.runtime.CoreException: No property tester contributes a
property org.eclipse.wst.ws.service.ws.service.policy.projectHasWSDLf iles to
type class
org.eclipse.wst.common.project.facet.core.internal.ProjectFa cetVersion
at
org.eclipse.core.internal.expressions.TypeExtensionManager.g etProperty(TypeExtensionManager.java:123)
at
org.eclipse.core.internal.expressions.TestExpression.evaluat e(TestExpression.java:96)
at
org.eclipse.core.internal.expressions.CompositeExpression.ev aluateAnd(CompositeExpression.java:53)
at
org.eclipse.core.internal.expressions.EnablementExpression.e valuate(EnablementExpression.java:53)
at
org.eclipse.jst.common.project.facet.core.libprov.internal.L ibraryProvider.isEnabledFor(LibraryProvider.java:287)
at
org.eclipse.jst.common.project.facet.core.libprov.LibraryIns tallDelegate.refresh(LibraryInstallDelegate.java:359)
at
org.eclipse.jst.common.project.facet.core.libprov.LibraryIns tallDelegate.reset(LibraryInstallDelegate.java:445)
at
org.eclipse.jst.common.project.facet.core.libprov.LibraryIns tallDelegate. <init>(LibraryInstallDelegate.java:138)


[Updated on: Thu, 01 April 2010 20:04]

Report message to a moderator

Re: library providers enablement expressions [message #524698 is a reply to message #524245] 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 #525392 is a reply to message #524698] 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. Maybe I should try using variable projectFacets - Collection<IProjectFacetVersion> instead? If so can you provide an example of how to use?



<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>

[Updated on: Tue, 06 April 2010 13:31]

Report message to a moderator

Re: library providers enablement expressions [message #525487 is a reply to message #525392] 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 count value of "+").

How is that for intuitive syntax?

Hope this helps,

- Konstantin

[Updated on: Tue, 06 April 2010 17:14]

Report message to a moderator

icon6.gif  Re: library providers enablement expressions [message #525514 is a reply to message #525487] 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.

[Updated on: Tue, 06 April 2010 17:40]

Report message to a moderator

Previous Topic:LibraryProviderFrameworkUi API question
Next Topic:library providers enablement expressions
Goto Forum:
  


Current Time: Mon Dec 30 16:23:53 GMT 2024

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

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

Back to the top