Skip to content

Instantly share code, notes, and snippets.

@mbarbero
Last active December 15, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbarbero/77c81a93b5f63c441207 to your computer and use it in GitHub Desktop.
Save mbarbero/77c81a93b5f63c441207 to your computer and use it in GitHub Desktop.
package fr.obeo.emf.edit.econ2013.live;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
import org.eclipse.emf.examples.extlibrary.Library;
public class CommandExample {
/**
* @param args
*/
public static void main(String[] args) {
BasicCommandStack commandStack = new BasicCommandStack();
EditingDomain domain = new AdapterFactoryEditingDomain(new ComposedAdapterFactory(), commandStack);
Library library = EXTLibraryFactory.eINSTANCE.createLibrary();
Command command = SetCommand.create(domain, library, EXTLibraryPackage.eINSTANCE.getLibrary_Name(), "My library");
commandStack.execute(command);
System.out.println(library.getName());
commandStack.undo();
System.out.println("library name: " + library.getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment