Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to create and excute a command manually
How to create and excute a command manually [message #552948] Sat, 14 August 2010 23:05 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Hiding GMF elements
Next Topic:Create notation-only edges
Goto Forum:
  


Current Time: Fri Apr 18 02:54:43 EDT 2025

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

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

Back to the top