Skip to content

Instantly share code, notes, and snippets.

@mbarbero mbarbero/CommandExample.java Secret
Last active Dec 15, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.