Filter elements according to an attribute [message #1695219] |
Tue, 12 May 2015 14:34  |
Eclipse User |
|
|
|
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 #1695955 is a reply to message #1695949] |
Wed, 20 May 2015 10:17  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04277 seconds