Skip to main content



      Home
Home » Eclipse Projects » Sirius » Filter elements according to an attribute
Filter elements according to an attribute [message #1695219] Tue, 12 May 2015 14:34 Go to next message
Eclipse UserFriend
Hi,

I have Class called Gate with a property/attribute called type. The type is an enumeration (GateType) which value is either AND, OR or XOR.

When I display the gate, I want to display a different figure according to the type: I want to have a different figure for an OR gate, another different for an AND gate, etc, etc.

I tried to make a conditional Style but it does not seem to work. I tried to put an conditional expression in the conditionalstyle but I have a hard time to access the eobject directly. I tried something like [thisEObject.type = GateType.AND/]

But it seems that thisEObject returns the conditional element and not the eobject. So, I am wondering how can I filter only the Gate object that has the type attribute set to AND or OR. Also, how can I use enumeration values in Accelero expression.

Thanks for any help/hint.
Re: Filter elements according to an attribute [message #1695237 is a reply to message #1695219] Tue, 12 May 2015 21:05 Go to previous messageGo to next message
Eclipse UserFriend
Making progress. Thanks to http://melb.enix.org/sirius/artificial-container/ I am trying to filter with this expression
[self.eContents()->select(p|p.oclAsType(Gate).type = 0)/]

However, instead of zero, i would then need to find it according my enumeration. So, using something like GateType.OR instead of 0. Any idea how to do it?
Re: Filter elements according to an attribute [message #1695949 is a reply to message #1695237] Wed, 20 May 2015 09:41 Go to previous messageGo to next message
Eclipse UserFriend
Le 13/05/2015 03:05, Julien Delange a écrit :
> Making progress. Thanks to
> http://melb.enix.org/sirius/artificial-container/ I am trying to filter
> with this expression
> [self.eContents()->select(p|p.oclAsType(Gate).type = 0)/]
>
> However, instead of zero, i would then need to find it according my
> enumeration. So, using something like GateType.OR instead of 0. Any idea
> how to do it?

Hi

The concept of OclLitteral does not exist. [1]
But you can manage to do what you want using string comparison.

[self.eContents()->select(p|p.oclAsType(Gate).type.toString() = 'OR ')/]

[1]
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.acceleo.doc%2Fpages%2Freference%2Foperations.html&cp=0_3_2
Re: Filter elements according to an attribute [message #1695955 is a reply to message #1695949] Wed, 20 May 2015 10:17 Go to previous message
Eclipse UserFriend
Hi Julien,


Le 20/05/2015 15:41, Laurent Fasani a écrit :
> Le 13/05/2015 03:05, Julien Delange a écrit :
>> Making progress. Thanks to
>> http://melb.enix.org/sirius/artificial-container/ I am trying to filter
>> with this expression
>> [self.eContents()->select(p|p.oclAsType(Gate).type = 0)/]
>>
>> However, instead of zero, i would then need to find it according my
>> enumeration. So, using something like GateType.OR instead of 0. Any idea
>> how to do it?
>
> Hi
>
> The concept of OclLitteral does not exist.
> But you can manage to do what you want using string comparison.
>
> [self.eContents()->select(p|p.oclAsType(Gate).type.toString() = 'OR ')/]

The qualifier separator in Acceleo MTL is "::" and not "." so the good
way to use the enum literal define in your ecore model is GateType::OR
GateType::AND as you can see on the wiki [1]

[self.eContents()->select(p|p.oclAsType(Gate).type = GateType::OR)/]


You should also use the qualified name of your EClass in your
expressions and domain class: yourpackagename::Gate and
yourpackagename::GateType::OR



Regards

--
Maxime - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
--
[1]
https://wiki.eclipse.org/Acceleo/FAQ#How_do_I_compare_data_to_an_enumeration_value.3F
Previous Topic:Get selected element in a diagram/table
Next Topic:Eclipse Sirius: How to access ancestors of the EObject of a line mapping?
Goto Forum:
  


Current Time: Thu May 22 03:52:08 EDT 2025

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

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

Back to the top