Skip to main content



      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 08:14 Go to next message
Eclipse UserFriend
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 08:25 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Can it has bidirectionl sychronization? [message #1004871 is a reply to message #1004569] Wed, 23 January 2013 22:17 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 01:02:08 EDT 2025

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

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

Back to the top