Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Propertytester always executed
icon5.gif  Propertytester always executed [message #550701] Wed, 04 August 2010 07:45 Go to next message
T. Wilhelm is currently offline T. WilhelmFriend
Messages: 129
Registered: July 2009
Senior Member
Hey all,

i have a problem using my PropertyTester.I registered a popupmenu on my view in the plugin.xml. This popupmenu has a command, where i added a visibleWhen condition. Here is the expression definition:

<definition
            id="my.expression.definition">
         <with
               variable="selection">
            <iterate
                  operator="or">
               <not>
                  <test
                        property="com.test.my.property">
                  </test>
               </not>
            </iterate>
         </with>
      </definition>


Everything works fine, but now i recognized that the propertyTester is always executed when i select something, even if it is in another perspective and another view?

In my idea, i thought the propertyTester will only be called when i open the popup menu, in the view where i registiered my popup.

Regarding a scenario where i have Propertytester for about 100 properties and every time i open a popupmenu somewhere in the application all these properties will be unnecessarily checked, this would be awful. Is there a way to prevent this?

Thanks a lot,
Thomas
Re: Propertytester always executed [message #553157 is a reply to message #550701] Mon, 16 August 2010 15:03 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The short answer is no. it's the variables used in an expression that
determine when that expression will be re-evaluated. In this case, the
"selection" variable that determines when your expression is called, and
since selection (as seen from the application) changes all the time your
expression will be called all the time.

Optimizations. You can add <instanceof/> check before your property
tester, so that it won't try and test an object that's not of your
property tester type.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Propertytester always executed [message #554222 is a reply to message #550701] Fri, 20 August 2010 15:00 Go to previous messageGo to next message
Rainer is currently offline RainerFriend
Messages: 6
Registered: July 2010
Junior Member
I think I read somewhere that Eclipse expressions' AND doesn't evaluate its second argument if the first didn't succeed (though I can't find the source for that information now, so I might be wrong).

In that case, you could also restrict the propertyTester to your view:
<and>
      <with variable="activePartId">
          <equals value="YOUR_VIEW_ID"/>
       </with>

        <with
               variable="selection">
            <iterate
                  operator="or">
               <not>
                  <test
                        property="com.test.my.property">
                  </test>
               </not>
            </iterate>
         </with>
</and>

The PropertyTester should not be called if the selection was not in your view, if I am not mistaken. Maybe veterans like Paul can confirm or refute that one.
Re: Propertytester always executed [message #554431 is a reply to message #554222] Mon, 23 August 2010 06:50 Go to previous messageGo to next message
T. Wilhelm is currently offline T. WilhelmFriend
Messages: 129
Registered: July 2009
Senior Member
Hi Rainer,

i didn´t test your example yet, but if it works i´m wondering why i have to define a locationURI for the menuContribution with my view Id.

I registered the popup menu with following locationURI:

popup:my.View.id?after=additions


I assumed that if i define this locationURI all checks are only done if i´m within the defined view, or in other words, the system does the

 <with variable="activePartId">
          <equals value="YOUR_VIEW_ID"/>
 </with>


check for me. Otherwise i see no sense in using the view id in the locationURI.

Thanks alot + Greetings from germany

Thomas
Re: Propertytester always executed [message #554794 is a reply to message #554431] Tue, 24 August 2010 12:26 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The locationURI determines where the menu or toolbar model
(IContributionItems in 3.x) will be generated. They specify location.

Expressions for activeWhen, enabledWhen, and visibleWhen are given to
the IEvaluationService. As the source variables change, the consuming
expressions are updated. In the case of a menuContribution, that will
set the IContributionItem visible attribute to true or false.

Before a menu is shown, the IContributionItems are evaluated by the
MenuManager and SWT widgets are updated to reflect the model.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Propertytester always executed [message #555398 is a reply to message #550701] Thu, 26 August 2010 13:50 Go to previous message
Rainer is currently offline RainerFriend
Messages: 6
Registered: July 2010
Junior Member
To sum it up, the locationURI does not restrict the "selection" variable to your view or menu. The "selection" is global; it changes on about every click in any Eclipse editor or view.
Previous Topic:How to enable/disable a command on a view toolbar?
Next Topic:Action Set vs command Hdler for main menu.
Goto Forum:
  


Current Time: Tue Apr 23 12:09:49 GMT 2024

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

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

Back to the top