Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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: Wed Jul 02 19:06:20 EDT 2025

Powered by FUDForum. Page generated in 0.03447 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top