Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Expressions definition iterate/or condition
Expressions definition iterate/or condition [message #328026] Mon, 12 May 2008 18:03 Go to next message
Eclipse UserFriend
Originally posted by: clea.mittag.gmail.com

Hi,

I am trying to create an expression definition to work for
enabling/disabling a context menu. I have a tree viewer that contains a
number of different object types. I need to write a test that will return
true if the active menu selection is either object type A or object type
B, but returns false for all other types that may be in the tree.

My expression definition is using the activeMenuSelection(with) variable
test, then iterate, then an insteanceof test and a custom property tester
(for object B, we need to check another property, not just the class
type). Given the iterate documentation, my assumption was that I would
select the OR operator, and then nest the instanceof and property test
items under the iterate tag. The expressions framework would then return
true if either the instanceof test OR the property test returned true. But
it doesn't seem to work. I can get it working using (and) (not)
combinations, but that's kind of painful as I have to list a whole bunch
of tests. Am I not using the correct syntax for OR?

Here's what I have:

<handler class="MyHandler" commandId="AddTask">
<enabledWhen>
<with variable="activeMenuSelection">
<iterate operator="or">
<instanceof value="ObjectA"></instanceof>
<test property="ObjectBPropertyTester"></test>
</iterate>
</with>
</enabledWhen>
</handler>

I've also tried nesting OR tags after the iterate tag:

<handler class="MyHandler" commandId="AddTask">
<enabledWhen>
<with variable="activeMenuSelection">
<iterate operator="or">
<instanceof value="ObjectA"></instanceof>
<or>
<test property="ObjectBPropertyTester"></test>
</or>
</iterate>
</with>
</enabledWhen>
</handler>

... but that doesn't work either. Can someone point me in the right
direction for using an OR condition in an iterate tag?

Thanks in advance!
Re: Expressions definition iterate/or condition [message #328099 is a reply to message #328026] Wed, 14 May 2008 03:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ronbermejo.nospamm.com

CM wrote:

> Hi,

> I've also tried nesting OR tags after the iterate tag:

> <handler class="MyHandler" commandId="AddTask">
> <enabledWhen>
> <with variable="activeMenuSelection">
> <iterate operator="or">
> <instanceof value="ObjectA"></instanceof>
> <or>
> <test property="ObjectBPropertyTester"></test>
> </or>
> </iterate>
> </with>
> </enabledWhen>
> </handler>

> ... but that doesn't work either. Can someone point me in the right
> direction for using an OR condition in an iterate tag?

Hi,

How about nesting both conditions inside the <or> element? eg,

<or>
<instanceof value="ObjectA"></instanceof>
<test property="ObjectBPropertyTester"></test>
</or>

Hth,
Ron
Re: Expressions definition iterate/or condition [message #328663 is a reply to message #328026] Fri, 30 May 2008 16:44 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

the iterate "and/or" apply to the results of the loop, not the contained
expression. i.e. iterate with "and" means the expression must evaluate
true for all items in the collection and iterate with "or" means that
the expression must be true for one item in the list.

As Ron mentioned, you probably want:

<iterate>
<or>
<instanceof value="ObjectA"></instanceof>
<test property="ObjectBPropertyTester"></test>
</or>
</iterate>
[/xml]




--
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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:How to show view in Action.run( )
Next Topic:Changing bgcolor in Section title bars...
Goto Forum:
  


Current Time: Thu Dec 26 23:23:30 GMT 2024

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

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

Back to the top