Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Accessing attributes to set up pre/post-conditions
Accessing attributes to set up pre/post-conditions [message #1834525] Wed, 11 November 2020 18:18 Go to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 53
Registered: March 2020
Member
Hi,

I have classes in my metamodel with several boolean attributes. This is because based on how they are set in sirius, I may want to change how the object looks or behaves. The first thing that I am doing to figure out how to create the condition for the conditional style is by using the interpreter on the model element to access the attribute and see its return value. At this point however I am unable to find the syntax for Acceleo that would allow me to do so. I figured all I would have to do is click on the attribute and then in the interpreter window have [self.attribute/] to have it return the value I set for the attribute; in this case true or false.

I have not found the tutorials to be very helpful when describing how to do this and pressing 'ctrl+spcbar' hasn't shown me the commands that I would think I need to do it. Any helps?
Re: Accessing attributes to set up pre/post-conditions [message #1834550 is a reply to message #1834525] Thu, 12 November 2020 09:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7127
Registered: July 2009
Senior Member
Hi

There is nothing very special about Boolean attributes, so it is hard to see why you are having a problem. Since you provide no example of your best failing endeavour, I can only guess that you are trying to use the Java API where EMF wraps Boolean attributes in an isXXX() getter rather than the much simpler direct XXX model feature access.

Regards

Ed Willink
Re: Accessing attributes to set up pre/post-conditions [message #1834551 is a reply to message #1834525] Thu, 12 November 2020 10:03 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 265
Registered: August 2010
Senior Member
Hi,

If I understand, you want to define a conditional style according to an attribute boolean value ?
Generally, I would suggest you to use AQL expressions. The documentation about queries in Sirius: https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html.
The detailed documentation for AQL is available here: https://www.eclipse.org/acceleo/documentation/aql.html
But for simple cases like get an attribute (or reference) value you can use the feature interpreter. Your conditional expression will look like "feature:yourBooleanAttributeName".
You can have a look on the Ecore tools modeler based on Sirius if you want an advanced example: https://github.com/eclipse/ecoretools. The odesign is defined in org.eclipse.emf.ecoretools.design/description/

Regards,

Florian
Re: Accessing attributes to set up pre/post-conditions [message #1834570 is a reply to message #1834551] Thu, 12 November 2020 15:02 Go to previous message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 53
Registered: March 2020
Member
I was overthinking things and didn't realize that I could simply use feature:booleanAttribute. I thought I needed to do some query in AQL thanks!
Previous Topic:What happens after DiagramDialectUIServices.openEditor?
Next Topic:Delete root element of diagram does not delete the diagram from aird file
Goto Forum:
  


Current Time: Sun May 09 20:48:26 GMT 2021

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

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

Back to the top