-
-
Save mbarbero/77c81a93b5f63c441207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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