Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352938 - [Commands] two propertyTester are crashing on selection with two different objects
Summary: [Commands] two propertyTester are crashing on selection with two different ob...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-23 13:38 EDT by Phil F. CLA
Modified: 2020-05-14 16:18 EDT (History)
2 users (show)

See Also:


Attachments
plugin project with example (340.34 KB, application/octet-stream)
2011-07-27 15:33 EDT, Paul Webster CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Phil F. CLA 2011-07-23 13:38:59 EDT
Build Identifier: 

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)

For me this loks strange and I suspect a bug.

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


Reproducible: Always
Comment 1 Remy Suen CLA 2011-07-23 22:07:09 EDT
Please attach the stack trace of the error.
Comment 2 Phil F. CLA 2011-07-25 01:58:20 EDT
(In reply to comment #1)
> Please attach the stack trace of the error.

There is no stack trace, since the error is caught internally in the core expressions code, and nothing is forwarded. I will check, if i can comeup with some little example code in the near future, if the current info is not enough.
Comment 3 Oleg Besedin CLA 2011-07-26 10:25:43 EDT
(In reply to comment #2)
> ... I will check, if i can comeup with
> some little example code in the near future, if the current info is not enough.

That would help a lot.
Comment 4 Paul Webster CLA 2011-07-27 15:33:59 EDT
Created attachment 200471 [details]
plugin project with example

I've added the example to this plugin (it's the RCP mail app, but that's not important).

The 2 testers:
z.ex.rcp.mail.PropertyTester1
z.ex.rcp.mail.PropertyTester2

            <visibleWhen
                  checkEnabled="false">
               <iterate
                     operator="or">
                  <or>
                     <test
                           forcePluginActivation="true"
                           property="z.ex.rcp.mail.propertyTester1.test">
                     </test>
                     <test
                           forcePluginActivation="true"
                           property="z.ex.rcp.mail.propertyTester2.test">
                     </test>
                  </or></iterate>
            </visibleWhen>

If the first tester doesn't apply to that resource type, the second is *not* applied.

PW
Comment 5 Eclipse Genie CLA 2020-05-14 16:18:02 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.