Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [newbee] Howto create children programmatically?
[newbee] Howto create children programmatically? [message #494384] Fri, 30 October 2009 13:55 Go to next message
Alex Schenkman is currently offline Alex SchenkmanFriend
Messages: 21
Registered: October 2009
Location: Sweden
Junior Member
Hi List:

I'm creating my model programatically with Java code. I do have an ecore model that generates a Factory for the classes in my model.

My problem is setting the relationships between my objects.
How do I define that an object is a child of another?

Is CreateChildCommand involved in this?
(org.eclipse.emf.edit.command.CreateChildCommand)

EditingDomain?

I do not need an editor nor GUI.

Thanks in advance!

Re: [newbee] Howto create children programmatically? [message #494394 is a reply to message #494384] Fri, 30 October 2009 14:04 Go to previous messageGo to next message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
Hello Alex,

an object being a child of an other object is defined at the meta level by
the ecore containment feature in your reference.

Create the Object with your factory and for ...
- a multivalued reference use the getter and then add your object.
- a singlevalued feature just set the reference target with the setter.

Regards

Enrico

"Alex Schenkman" <spam@schenkman.info> schrieb im Newsbeitrag
news:hcer8a$1nj$1@build.eclipse.org...
> Hi List:
>
> I'm creating my model programatically with Java code. I do have an ecore
> model that generates a Factory for the classes in my model.
>
> My problem is setting the relationships between my objects.
> How do I define that an object is a child of another?
>
> Is CreateChildCommand involved in this?
> (org.eclipse.emf.edit.command.CreateChildCommand)
>
> EditingDomain?
>
> I do not need an editor nor GUI.
>
> Thanks in advance!
>
>
Re: [newbee] Howto create children programmatically? [message #494395 is a reply to message #494394] Fri, 30 October 2009 14:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Hi,

AS for the CreateChildCommand, I don't remember the exact syntax but
commands are used when your model is under editor control that allows
undo/redo. If you are updating your model in conjunction with an editing
domain and a command stack then you must use commands to update the
model. It you updated directly then you would break the command stack
and you couldn't undo/redo the changes. If you are not maintaining your
model as an input to an editor then you would directly use the getters
and setters in the generated model.

--
Thanks,
Rich Kulp
Re: [newbee] Howto create children programmatically? [message #494417 is a reply to message #494394] Fri, 30 October 2009 14:57 Go to previous message
Alex Schenkman is currently offline Alex SchenkmanFriend
Messages: 21
Registered: October 2009
Location: Sweden
Junior Member
Thank you very much!
It was much easier than what I thought.
Previous Topic:Team revert causing undoing of EMF model changes
Next Topic:[CDO] CDO Explorer.
Goto Forum:
  


Current Time: Sat Apr 27 00:42:53 GMT 2024

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

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

Back to the top