Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Adding Property to EMF Objects Dynamically(Adding Property to EMF Objects Dynamically)
Adding Property to EMF Objects Dynamically [message #1385051] Wed, 04 June 2014 02:13 Go to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Hi,

I want to add a property to EMF Object Dynamically for eg, if we have a grammar below :

Model:
greetings+=Greeting*;
Greeting:
'Hello' name=ID '!';


After EMF classes is generated, I want to add another property lets say greetingID to
Greeting Class at runtime. Is there any way to do achieve this ?

Cheers

Kunal
Re: Adding Property to EMF Objects Dynamically [message #1385053 is a reply to message #1385051] Wed, 04 June 2014 04:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13469
Registered: July 2009
Senior Member
http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-met
amodel-inference-using-xtend2/


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding Property to EMF Objects Dynamically [message #1385054 is a reply to message #1385051] Wed, 04 June 2014 04:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13469
Registered: July 2009
Senior Member
P.s. and for actually setting it you could use iderivedstatecomputer
BTW what is your actual/real usecase


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding Property to EMF Objects Dynamically [message #1385055 is a reply to message #1385054] Wed, 04 June 2014 05:02 Go to previous messageGo to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Hi Christian,
Thanks for the reply. My Actual/Real Use Case is I want to assign a property Id to each of my EMF Classes and that property should not be part of grammar ie it should not be displayed in Xtext editor . In other sense, I want a variable in Xtext Grammar and it should not be accessible in Xtext Editor but it can be accessed via generated EMF Classes.


Cheers

Kunal
Re: Adding Property to EMF Objects Dynamically [message #1385064 is a reply to message #1385055] Wed, 04 June 2014 07:12 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1762
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 04/06/2014 07:02, Kunal Khaware wrote:
> Hi Christian,
> Thanks for the reply. My Actual/Real Use Case is I want to assign a
> property Id to each of my EMF Classes and that property should not be
> part of grammar ie it should not be displayed in Xtext editor . In other
> sense, I want a variable in Xtext Grammar and it should not be
> accessible in Xtext Editor but it can be accessed via generated EMF
> Classes.

Hi

you need to swtich to a custom Ecore first (see, e.g.,
http://www.lorenzobettini.it/2014/02/switching-from-an-inferred-ecore-model-to-an-imported-one-in-your-xtext-grammar/
) and then you can add the additional field as "transient" so that it
won't be serialized when you save the file (it won't be shown in the
editor either).

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: Adding Property to EMF Objects Dynamically [message #1385088 is a reply to message #1385064] Wed, 04 June 2014 09:34 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13469
Registered: July 2009
Senior Member
Hi

the postprocessor can do the very same


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:General scoping question regarding cross references
Next Topic:JvmModelInferrer and debug: skip steps?
Goto Forum:
  


Current Time: Thu Jun 04 21:54:26 GMT 2020

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

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

Back to the top