Problems with restricting property tester by using the type attribute [message #698521] |
Tue, 19 July 2011 15:33 |
Tam Gom Messages: 36 Registered: July 2011 |
Member |
|
|
I posted this issue in the PDE subforums but I noticed that this one is more active. Sorry if I did something wrong with re-posting it here.
My main problem is that in the Package Explorer projects can be either IProject or IJavaProject objects. I know that programmatically the IProject -> IJavaProject conversion is possible through the IAdaptable interface. But sometimes you just can't use this.
In my case I created my own PropertyTester. Here's how I defined it in my plugin.xml:
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
id="my.plugin.MyPropertyTester"
type="org.eclipse.core.resources.IProject"
namespace="my.plugin"
properties="isProject"
class="my.plugin.MyPropertyTester">
</propertyTester>
</extension>
The problem here is that the type attribute restricts when the property tester is called. So if a project in the package explorer is an IProject object there's no problem but my property tester is not called when it's an IJavaProject. I could use java.lang.Object instead of org.eclipse.core.resources.IProject but the property tester would run on every object in the UI that way.
I can't find a way to define two different types as restriction for a property tester or any other solution.
Any ideas or do somebody know how to do this properly?
Thank you.
[Updated on: Tue, 19 July 2011 15:35] Report message to a moderator
|
|
|
|
Re: Problems with restricting property tester by using the type attribute [message #699240 is a reply to message #698589] |
Thu, 21 July 2011 07:25 |
Tam Gom Messages: 36 Registered: July 2011 |
Member |
|
|
Hi Paul!
I've read about the solution you mentioned but it doesn't work in my case.
Here's the situation in details:
I have 4 plug-ins. 3 of them do different tasks and the last one is a menu extension which implements a submenu for the first 3 in the Package Exlporer's context menu. The menu plug-in contains my property tester (whose XML code is in my first post). Properties are tested in the 3 separate plug-ins.
If I modify the definition of the property tester in my menu plug-in like this:
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
id="my.plugin.MyPropertyTester"
type="org.eclipse.core.resources.IProject"
namespace="my.plugin"
properties="isProject"
class="my.plugin.MyPropertyTester">
</propertyTester>
</extension> and use the <adapt> tag in the others' plugin.xml like this:
<adapt type="org.eclipse.core.resources.IProject">
<test
property="my.plugin.isProject">
</test>
</adapt> the adaptation is not performed and my property tester is not called.
Is it a problem that testing against the property and the property's definiton are in different plug-ins? It wouldn't seem too logical to me if I had to define the same property tester in each plug-in.
UPDATE: I put my property tester class, the property tester definiton and the actual testing into the same plug-in but it's still no good. When I use java.lang.Object for the type attribute my tester is called but when I use org.eclipse.core.resources.IProject instead it doesn't work with IJavaProject objects even if I use the adapt element.
UPDATE #2: I also tried with java.lang.Object as type restriction and the adapt element but again the property tester is not called. If I remove the adapt tag it's OK, however this way I return to where I started.
[Updated on: Thu, 21 July 2011 10:01] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02304 seconds