Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Automatically add child-nodes upon creation
Automatically add child-nodes upon creation [message #1053465] Mon, 06 May 2013 07:01 Go to next message
Mårten Carlzon is currently offline Mårten CarlzonFriend
Messages: 60
Registered: March 2013
Location: Sweden
Member

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 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

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 Go to previous messageGo to next message
Mårten Carlzon is currently offline Mårten CarlzonFriend
Messages: 60
Registered: March 2013
Location: Sweden
Member

Hello Antonio

Ok, I thought it might be like that but it never hurts to ask Smile

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 Smile, but thanks for letting me know where to look.

Write you later / Mårten
Re: Automatically add child-nodes upon creation [message #1053770 is a reply to message #1053647] Tue, 07 May 2013 14:28 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

No problem Smile. If you get it to work, it'd be great if you could post how you did it here, for future reference.
Re: Automatically add child-nodes upon creation [message #1056056 is a reply to message #1053770] Wed, 08 May 2013 11:17 Go to previous message
Mårten Carlzon is currently offline Mårten CarlzonFriend
Messages: 60
Registered: March 2013
Location: Sweden
Member

I found a solution to the problem, and it only needed two lines of code Smile

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.
Previous Topic:Illegal Name of EWL
Next Topic:Epsilon Validation Language
Goto Forum:
  


Current Time: Fri Apr 19 20:34:57 GMT 2024

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

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

Back to the top