Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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] Sun, 15 August 2010 03:05 Go to next message
Yu Sun is currently offline Yu SunFriend
Messages: 58
Registered: July 2009
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.

Re: How to create and excute a command manually [message #553071 is a reply to message #552948] Mon, 16 August 2010 10:27 Go to previous message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
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);


Previous Topic:Hiding GMF elements
Next Topic:Create notation-only edges
Goto Forum:

Current Time: Fri Jun 21 22:52:44 GMT 2024

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

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

Back to the top