Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » EMF EditingDomain, Undo/Redo
EMF EditingDomain, Undo/Redo [message #742456] Thu, 20 October 2011 10:07 Go to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Hello,

i want to use EMF undo/redo in e4.

In 3.x code
	CommandStack commandStack = new BasicCommandStack();
		EditingDomain domain = new AdapterFactoryEditingDomain(new E4AdapterFactory(), commandStack);
		
		bindingContext = new EMFDataBindingContext();


and in the toolbar the command
org.eclipse.ui.edit.undo


Do in e4 exist a undo/redo command? Or i have to create a own command + handler?

And can i inject the EditingDomain?
Re: EMF EditingDomain, Undo/Redo [message #742473 is a reply to message #742456] Thu, 20 October 2011 10:26 Go to previous message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
I create a UndoHandler. Does anybody know a better solution?Or is this solution ok?

public class UndoHandler {

	@CanExecute
	public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart mPart) {
		if(mPart.getObject() instanceof IEditingDomainProvider){
			EditingDomain editingDomain = ((IEditingDomainProvider)mPart.getObject()).getEditingDomain();
			return editingDomain.getCommandStack().canUndo();
		}
		return false;
	}

	@Execute
	public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart mPart) {
		System.out.println("execute");
		if(mPart.getObject() instanceof IEditingDomainProvider){
			EditingDomain editingDomain = ((IEditingDomainProvider)mPart.getObject()).getEditingDomain();
			editingDomain.getCommandStack().undo();
		}
	}

}
Previous Topic:HowTo Display Validaton Status ICONS in a Form
Next Topic:Double invocation of a Login Dialog using LifeCyleHandler
Goto Forum:
  


Current Time: Tue Jul 22 13:44:55 EDT 2014

Powered by FUDForum. Page generated in 0.01686 seconds