Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » A Creation Tool for every model/figure?
A Creation Tool for every model/figure? [message #657121] Tue, 01 March 2011 16:24 Go to next message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
Do I need a Creation Tool for every model respectively figure?

I only want a creation tool for one figure. Because the other figure are depending on the values of the first figure and should be created with the first Figure.

I try to explain this via code:

protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
			IAdaptable info) throws ExecutionException {
        Element newElement = ModelFactory.eINSTANCE.createElement();
        newElement.setValue(SOMEVALUE);

        Diagram owner = (Diagram) getElementToEdit();
        owner.getElements1().add(newElement);

        // this is what I meant - createing the other element in here or is there something else needed?
        // or can I just use my other creationtools here, but make the invisible in the editor?
        Element2 newElement2 = ModelFactory.eINSTANCE.createElement2();
        newElement2.setAttribute(newElement.getInformation());
        owner.getElements2().add(newElement2);
        doConfigure(newElement, monitor, info);

		((CreateElementRequest) getRequest()).setNewElement(newElement);
		return CommandResult.newOKCommandResult(newElement);
	}


[Updated on: Tue, 01 March 2011 16:27]

Report message to a moderator

Re: A Creation Tool for every model/figure? [message #657789 is a reply to message #657121] Fri, 04 March 2011 04:42 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Your code should work and if there is the correct mapping for Element2 in map model, then diagram update will (eventually) create node for an Element2.

If you want to have exact control on when and where the node for Element2 is created, you may implement a custom editpolicy that responds to CreateViewAndElementRequest filtered by semantic hint of Element1 type

The new policy will return the command which:
* accesses the just created newElement1 from the request.getNewObject()
* navigates to just created newElement2 (specific to your "main" command)
* calls the ViewService directly to create the node for newElement2, similar to the code in CreateCommand
* sets the positions / size of the new node by using ViewUtil.setStructuralFeatureValue(...) similar to the code in SetBoundsCommand, based on the original request location / size

Make sure that the custom editpolicy is registered for the same container (diagram) and that it is registered AFTER the default CreationEditPolicy which will guarantee that the additional command will be executed after the main one.

Hope this helps,
Regards,
Michael
Re: A Creation Tool for every model/figure? [message #657837 is a reply to message #657789] Fri, 04 March 2011 09:57 Go to previous messageGo to next message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
Thanks for your reply.

So I don't need the Creation Tools for the other Elements?
But I need the Create Command for the Element is that correct?

So when I delete the Creation Tools from my *.gmftool, will the Commands also be deleted, or will they be untouched?
Re: A Creation Tool for every model/figure? [message #657843 is a reply to message #657837] Fri, 04 March 2011 10:21 Go to previous message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Quote:
So I don't need the Creation Tools for the other Elements?

Correct

Quote:
So when I delete the Creation Tools from my *.gmftool, will the Commands also be deleted, or will they be untouched?

The latter

You may ignore the existing command for Element2, modify command for Element1 as in your sample, and follow steps from my prev reply.

Regards,
Michael
Previous Topic:The code of method getNodeVisualID(View, EObject) is exceeding the 65535 bytes limit
Next Topic:menu command not working when launched in exe . works when launched from product file
Goto Forum:
  


Current Time: Wed Apr 24 21:04:04 GMT 2024

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

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

Back to the top