|
Re: How can I add nodes with the CreateElementRequest [message #853967 is a reply to message #848723] |
Mon, 23 April 2012 14:15 |
Michael Golubev Messages: 383 Registered: July 2009 |
Senior Member |
|
|
Hello,
You should not create the CreateElementCommand directly, its just a helper for editpolicies that handles creation.
The good news is that the code that manipulates with CreateElementCommands is already in place, so you need only to find a way to delegate to policies.
If you want to follow what is done from the creation tools the code will look like:
List types = Collections.singletonList(ActivityElementTypes.Action_2001);
CreateUnspecifiedTypeRequest gefRequest = new CreateUnspecifiedTypeRequest(types, PreferencesHint.USE_DEFAULTS);
gefRequest.setLocation(...);
gefRequest.setSize(...);
EditPart containerEP = .... //find EP that should host the new element, DiagramEditPart for top-level elements.
Command gefCommand = containerEP.getCommand(gefRequest);
if (gefCommand.canExecute()) {
//execute
}
Hope that helps,
Regards,
Michael "Borlander" Golubev
at Montages Think Tank, Prague, Czech Republic
Montages AG, Zürich, Switzerland
|
|
|
Powered by
FUDForum. Page generated in 0.03646 seconds