Tuesday, March 31, 2009

Using the EditingDomain to modify Ecore models

EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(eClass);
...
Command cmd = AddCommand.create(editingDomain, eClass, null, eOper);

editingDomain.getCommandStack().execute(cmd);


The above code snippet shows an improvement over the modifications done to the Ecore model in the posting about creating new actions for the Ecore Editor. The previous version had the drawback, that the changes to the model couldn't be undone. That is going to change now forever, just by exploiting the EditingDomain which is provided by EMF.

In order for this code to run, you will need to add org.eclipse.emf.ecore.edit to your list of plugin dependencies. I will continue to post some examples and make the editor available on sourceforge.net. Keep listening for more information.

1 comment: