propertyTester crashes on different objects [message #700381] |
Sat, 23 July 2011 10:07 |
|
Hi Everyone,
I am working on a RCP based on Eclipse 3.6. Within my RCP I am having selections of two different objects "ObjectA" and "ObjectB". A selection may contain both objects at a time. Furthermore I have a command for editing the selected object. In order to enable it I am providing a commandHandler with it the "enabledWhen" expression. This expression is iterating through the selection and uses two "propertyTester" to check the objects.
The problem i was facing that in case i have a selction with both objects contained. Only the first "propertyTester" in the "or" expression is evaluated. As soon as the second one is evaluated, the core expressions are bailöing out with a "SWTCoreException". Changing the order of the "propertyTester" makes the other one work but the first one fail. (see the first code block)
To work around this problem I added an "and" expression to the "propertyTester" having an "instanceOf" called before the tester. By this both "propertyTesters" are never getting called in the same expression. And everything works fine and the way i expected. (see the second code block)
Finally, is this expected behaviour? Is there something I am missing out? Or is it maybe a bug which should be failed? What is your experience with the propertyTesters?
Cheers
Phil
Code Block I (command, commandHandler and propertyTester):
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="org.phil.tester.test.propertyTester.PropertyTesterObjectA"
id="org.phil.tester.test.propertyTesterA"
namespace="org.phil.tester.test.objectA"
properties="test"
type="SelectionObjectA">
</propertyTester>
<propertyTester
class="org.phil.tester.test.propertyTester.PropertyTesterObjectB"
id="org.phil.tester.test.propertyTesterB"
namespace="org.phil.tester.test.objectB"
properties="test"
type="SelectionObjectB">
</propertyTester>
</extension>
<extension
id="org.phil.tester.test.command.editObject"
name="Edit Selection Object"
point="org.eclipse.ui.commands">
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.phil.tester.test.commandHandler.CommandHandlerEditObject"
commandId="org.phil.tester.test.command.editObject">
<enabledWhen>
<iterate
ifEmpty="false"
operator="or">
<or>
<test
forcePluginActivation="true"
property="org.phil.tester.test.propertyTesterA.test">
</test>
<test
forcePluginActivation="true"
property="org.phil.tester.test.propertyTesterB.test">
</test>
</or>
</iterate>
</enabledWhen>
</handler>
</extension>
</plugin>
Code Block II (the changed expression adding "and"):
...
<enabledWhen>
<iterate
ifEmpty="false"
operator="or">
<or>
<and>
<instanceof
value="ObjectA">
</instanceof>
<test
forcePluginActivation="true"
property="org.phil.tester.test.propertyTesterA.test">
</test>
</and>
<and>
<instanceof
value="ObjectA">
</instanceof>
<test
forcePluginActivation="true"
property="org.phil.tester.test.propertyTesterB.test">
</test>
</and>
</or>
</iterate>
</enabledWhen>
...
|
|
|
|
Powered by
FUDForum. Page generated in 0.03157 seconds