Undo/Redo functionality with EMF resources [message #1010797] |
Mon, 18 February 2013 09:02 |
Bastian Wagenfeld Messages: 183 Registered: January 2013 |
Senior Member |
|
|
Hi,
I'm not sure, whether this is the right forum or the EMF forum is the better choice. But I thought, this could be more of an Eclipse 4 topic.
I'm creating a Eclipse 4 RCP that uses EMF resources as input. Now I want to implement undo/redo functionality. In Eclipse 3.x the EMF generated editor used an EditingDomain that includes a CommandStack. I thought maybe I could use this EditingDomain in the Eclipse 4 RCP, too. So I created the EditingDomain like in the EMF Editor:
adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory
.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory
.addAdapterFactory(new IdentifiableItemProviderAdapterFactory());
adapterFactory
.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
BasicCommandStack commandStack = new BasicCommandStack();
commandStack.addCommandStackListener(new CommandStackListener() {
@Override
public void commandStackChanged(EventObject event) {
eventBroker.post(UIEvents.Dirtyable.DIRTY, dirtyable);
}
});
editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
commandStack, new HashMap<Resource, Boolean>());
editingDomain.getResourceSet().getResources().add(resource);
Unfortunately the CommandStack is always empty. Does anabody have an idea what else I have to do, to get the CommandStack filled, if an action on the resource is permormed?
Best regards
Bastian
|
|
|
Re: Undo/Redo functionality with EMF resources [message #1010804 is a reply to message #1010797] |
Mon, 18 February 2013 09:11 |
|
Hi
I don't know about e4, but concerning the editing domain and the command
stack: are you using the same resource set of the editing domain to load
your EMF resource?
cheers
Lorenzo
On 02/18/2013 10:02 AM, Bastian Wagenfeld wrote:
> Hi,
>
> I'm not sure, whether this is the right forum or the EMF forum is the
> better choice. But I thought, this could be more of an Eclipse 4 topic.
> I'm creating a Eclipse 4 RCP that uses EMF resources as input. Now I
> want to implement undo/redo functionality. In Eclipse 3.x the EMF
> generated editor used an EditingDomain that includes a CommandStack. I
> thought maybe I could use this EditingDomain in the Eclipse 4 RCP, too.
> So I created the EditingDomain like in the EMF Editor:
> adapterFactory = new ComposedAdapterFactory(
> ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
> adapterFactory
> .addAdapterFactory(new
> ResourceItemProviderAdapterFactory());
> adapterFactory
> .addAdapterFactory(new
> IdentifiableItemProviderAdapterFactory());
> adapterFactory
> .addAdapterFactory(new
> ReflectiveItemProviderAdapterFactory());
>
> BasicCommandStack commandStack = new BasicCommandStack();
> commandStack.addCommandStackListener(new CommandStackListener() {
>
> @Override
> public void commandStackChanged(EventObject event) {
> eventBroker.post(UIEvents.Dirtyable.DIRTY, dirtyable);
>
> }
> });
>
> editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
> commandStack, new HashMap<Resource, Boolean>());
> editingDomain.getResourceSet().getResources().add(resource);
>
> Unfortunately the CommandStack is always empty. Does anabody have an
> idea what else I have to do, to get the CommandStack filled, if an
> action on the resource is permormed?
> Best regards
> Bastian
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03228 seconds