How to create and excute a command manually [message #552948] |
Sat, 14 August 2010 23:05  |
Eclipse User |
|
|
|
Hi guys,
Could you please give me some hints on how to create and execute a command manually?
At a certain moment, I want to add some elements to my model by programming in the GMF editor. However, if I simply use the generated EMF APIs, the diagram cannot be updated accordingly (the new elements are added in the EMF model, but cannot be displayed in the diagram).
I checked some threads, and it seems that I can manually create a command and execute it by using getCommandStack or getDiagramCommandStack, in order to update and refresh the diagram automatically.
But I am not sure how to do this. Could you please give me some directions?
Thanks a lot.
Yu
|
|
|
Re: How to create and excute a command manually [message #553071 is a reply to message #552948] |
Mon, 16 August 2010 06:27  |
Eclipse User |
|
|
|
Hi Yu,
You can create and execute, for instance, a "set" command like this:
EObject model = .....;
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(model);
Command setVariable = SetCommand.create(
ted, model,
XXXPackage.Literals.NAME_OF_FEATURE_MODIFY, newValue);
ted.getCommandStack().execute(setVariable);
Cheers,
Emil
|
|
|
Powered by
FUDForum. Page generated in 0.99619 seconds