Automatically add child-nodes upon creation [message #1053465] |
Mon, 06 May 2013 07:01 |
|
Hi all,
I was wondering if it is possible to when I create a node in the diagram I by default create a child-node as well?
The way it looks now I create an Object and I have to add a child-node ObjectData to it before saving (because of XText grammar require the child-node). But I was wondering if I can maybe type in the ECore2GMF file, the emf file or something similar that when I create a Object node it will also generate a ObjectData node inside it?
(The reason I have constructed it like this is so that I can minimize all the data and only show the Objects label for a better overview when I have many objects)
Thanks for any help
Write you later / Mårten
|
|
|
Re: Automatically add child-nodes upon creation [message #1053577 is a reply to message #1053465] |
Mon, 06 May 2013 15:07 |
|
Hi Marten,
Eugenia can only do what the GMF models can do, and I think they don't allow for this kind of customization.
You might want to customize the *CreateCommand for your model element type in the "edit.commands" subpackage of your ".diagram" plugin. I think the "doExecuteWithResult" method might be the right one.
No problem,
Antonio
|
|
|
Re: Automatically add child-nodes upon creation [message #1053647 is a reply to message #1053577] |
Tue, 07 May 2013 06:49 |
|
Hello Antonio
Ok, I thought it might be like that but it never hurts to ask
Will take a look at the files you recommended, although it might not be until next week because of school work popping up like crazy , but thanks for letting me know where to look.
Write you later / Mårten
|
|
|
|
Re: Automatically add child-nodes upon creation [message #1056056 is a reply to message #1053770] |
Wed, 08 May 2013 11:17 |
|
I found a solution to the problem, and it only needed two lines of code
In the class <YourParentObject>CreateCommand you go to the function doExecuteWithResult.
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
idainfront.iipax.dsl.iiDsl.ObjectDefinition newElement = idainfront.iipax.dsl.iiDsl.IiDslFactory.eINSTANCE
.createObjectDefinition();
idainfront.iipax.dsl.iiDsl.Objectbase owner = (idainfront.iipax.dsl.iiDsl.Objectbase) getElementToEdit();
owner.getObjectTypes().add(newElement);
// These are the two lines you need to add in the function
// IiDsl is my name for MyDsl
// Object is my child node and ObjectDefinition is my parent node so newObject will be placed in the newElement
idainfront.iipax.dsl.iiDsl.Object newObject = IiDslFactory.eINSTANCE.createObject();
newElement.setObject(newObject);
doConfigure(newElement, monitor, info);
((CreateElementRequest) getRequest()).setNewElement(newElement);
return CommandResult.newOKCommandResult(newElement);
}
I got the solution from this thread.
|
|
|
Powered by
FUDForum. Page generated in 0.03420 seconds