Skip to main content



      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] Tue, 03 June 2014 22:13 Go to next message
Eclipse UserFriend
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 00:26 Go to previous messageGo to next message
Eclipse UserFriend
http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-met
amodel-inference-using-xtend2/
Re: Adding Property to EMF Objects Dynamically [message #1385054 is a reply to message #1385051] Wed, 04 June 2014 00:35 Go to previous messageGo to next message
Eclipse UserFriend
P.s. and for actually setting it you could use iderivedstatecomputer
BTW what is your actual/real usecase
Re: Adding Property to EMF Objects Dynamically [message #1385055 is a reply to message #1385054] Wed, 04 June 2014 01:02 Go to previous messageGo to next message
Eclipse UserFriend
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 03:12 Go to previous messageGo to next message
Eclipse UserFriend
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 05:34 Go to previous message
Eclipse UserFriend
Hi

the postprocessor can do the very same
Previous Topic:General scoping question regarding cross references
Next Topic:JvmModelInferrer and debug: skip steps?
Goto Forum:
  


Current Time: Wed Jul 23 01:50:43 EDT 2025

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

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

Back to the top