Artur,
Probably it's easier to look at using an AddCommand. If you look at
the Javadoc, it shows that an AddCommand will do the equivalent of this:
*
((EList)((EObject)owner).eGet((EStructuralFeature)feature)).addAll(index,
(Collection)collection);
Or in terms of generated code it's equivalent to
owner.getFoo().addAll(listOfFoos).
In the end, you do have to determine which object you're adding stuff
to (the owner), which feature you're adding it to (foo), and what's
being added...
Artur Kronenberg wrote:
Hi Ed,
thank you for your fast reply. I tried using the CreateChildrenCommand
by getting a command from the AdapterFactoryEditingDomain but it
somehow did not work out for me. I don't quite get how to use those
commands exactly to achieve what I need.
If I would use the
AdapterFactoryEditingDomain.createCinnabd(CreateChildCommand.class, new
CommandParameters(owner, feature, collection<?>) what would be
the parameters for the CommandParameters.
I have my Editor and therefor I could access everything in it. I still
couldn't figure out how to get the owner for my new object (i supposed
this should be the parent node?) If I thate the resourceset from my
editor and iterate through its contents then I can get my rootNodeImpl
and get all the childNodes and find out where to put my new created
node, but this seems to be kind of a weird way to achieve this?
Also, what would be the feature atribute I would have to set there?
>From debuggin I think the collection I have to pass the
commandParameters I can get by calling getNewChildDescriptors from my
editingDomain?
Thank you for your help.
Best regards,
Artur
Ed Merks wrote:
Artur,
You could use CreateChildCommand and execute
it on the command stack. Or just use an AddCommand directly (also
executing it on the command stack).
Artur Kronenberg wrote:
Hi,
I have the following problem:
I created an EMF editor that is handeling a specific task in itself. As
soon as the element is created (through mouseclicking) the editor
synchronizes perfectly and everything works just fine.
The problem is, that I need the Child created programmatically by a
right click on my gmf editor.
I have no problem getting the name for the child Element. I know I can
create a child element with my FactoryImpl.createChildElement() and set
the name on the returned object. But how can I add the element to the
model of the EMF editor so it gets updated, undo is supported and so
on..
basically I try to use the action that is give through the UI by
rightclicking on a node, creating a child but only programmatically.
Is there a way to do that?
Best regards,
Artur
|