[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: What is the advantage of use AbstractTransactionalComman ?

Hi Christian,

Thanks for your reply. I still have some questions.

The WorkspaceCommandStackImpl implements a single, linear undo stack using
the operation history.  It is intended to provide the same behaviour as the
EMF CommandStack.

However, using AbstractEMFOperations (or GMF's
AbstractTransactionalCommands) with an operation history (not using the
WorkspaceCommandStackImpl), you can implement more interesting undo models. For example, you can have independent undo/redo stacks for different
Resources in the same ResourceSet, if these resources are not connected. Using EMF's CommandStack, you would actually need a separate ResourceSet
and EditingDomain for each resource.
At present I need single execution stack for my application. IOperationHistory and OperationHistoryFactory suits fine for this. But working with diagram editor in general I do not know what kind of CommandStack it is using and if that stack is backed by global IOperationHistory or not. At the same time I need to show some feedback when the command stack changes. Currently my application listens CommandStack that can be retrieved from the EditingDomain of DiagramEditor. If all modifications are performed using the CommandStack then I always know when to show feedback. If I execute a sort of AbstractEMFOperation in the global operation history the CommandStack does not trigger any events. If I understand correctly you suggest to support custom mapping from Resource to IOperationHistory instance (like the mapping Resource->ResourceSet->EditingDomain->CommandStack). In my case it is trivial:
Resource->global IOperationHistory. Everyone who modifies my model should use global history and feedback provider would listen to the IOperationHistory not to CommandStack. Am I right?


To answer your first question:  in a GMF application, you should probably
never execute commands in a CommandStack, because it will not be worth the
effort of coordinating the IUndoContexts applied to these commands and your
GMF AbstractTransactionalCommands to ensure that the Undo/Redo menus make
sense.
So if I want to implement a custom command which makes some changes with my EMF model I have to create a command inherited form AbstractEMFOperation and put all logic within it. Afterwards when I execute it in IOperationHistory I will get Undo/Redo functionality for free. Is it true?

Yury