Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Can it has bidirectionl sychronization?(When we change the ecore model, we can generate new Java code template. If we rename certain methods in the Java template code,can changes be reflected to the ecore model?)
Can it has bidirectionl sychronization? [message #1004565] Wed, 23 January 2013 13:14 Go to next message
Lucy Chan is currently offline Lucy ChanFriend
Messages: 29
Registered: March 2012
Junior Member
Assume we use the EMF to model a simple class diagram. It has a class named "Example" with an attribute named "name" which is EString type.

Example
name: EString

With EMF, we will generate methods "setName()" and "getName()" in the code template Example.java.

I just wonder if I change methods "setName()" and "getName()" to "setDescription()" and "getDescription()", can the ecore model will change the attribute name from "name" to "description" automatically?

Thanks for your attention.
Best Regards,

Lucy Chan
Re: Can it has bidirectionl sychronization? [message #1004569 is a reply to message #1004565] Wed, 23 January 2013 13:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Lucy,

No, there's no automatic reverse engineering from generated code to the
Ecore model. But, if you define your model with Xcore, you can refactor
the "name" feature in the Xcore source and it will invoke Java
refactoring on the generated code and that refactoring will also rename
all the hand written uses of all the renamed things, including the use
of constants in the generated package. Xcore supports refactoring of
all named elements.

http://wiki.eclipse.org/Xcore

If you don't use Xcore, you should refactor your Java code to rename the
getter and setter (that's important only if you have hand written code
that uses the old name), rename the feature in Ecore, and then
regenerate the model.


On 23/01/2013 2:14 PM, Lucy Chan wrote:
> Assume we use the EMF to model a simple class diagram. It has a class
> named "Example" with an attribute named "name" which is EString type.
>
> Example
> name: EString
>
> With EMF, we will generate methods "setName()" and "getName()" in the
> code template Example.java.
>
> I just wonder if I change methods "setName()" and "getName()" to
> "setDescription()" and "getDescription()", can the ecore model will
> change the attribute name from "name" to "description" automatically?
>
> Thanks for your attention.
> Best Regards,
>
> Lucy Chan


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Can it has bidirectionl sychronization? [message #1004871 is a reply to message #1004569] Thu, 24 January 2013 03:17 Go to previous message
Lucy Chan is currently offline Lucy ChanFriend
Messages: 29
Registered: March 2012
Junior Member
Dear Ed,

Thanks for your reply. I will use the link as you recommended to me.

Cheers,

Lucy
Previous Topic:[CDO] Show Progress Monitor on commit
Next Topic:EMF Maven archetype?
Goto Forum:
  


Current Time: Fri Apr 26 11:35:48 GMT 2024

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

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

Back to the top