Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » IUndoContext and Undo/Redo actions
IUndoContext and Undo/Redo actions [message #234185] Fri, 19 June 2009 07:26 Go to next message
Javier is currently offline JavierFriend
Messages: 57
Registered: July 2009
Member
Hello guys.

As far as I know, GMF commands implement the interface
IUndoableOperation, which includes the concept of IUndoContext. This
concept is also important in Undo/Redo action handlers, since we need to
tell those handlers which context to cover, it is, they will get from
the OperationHistory just those commands with the same UndoContext. At
least this is what I understand from what I read. Exactly as it says, if
I create a GMF command and I execute it this way:
DiagramEditor().getDiagramCommandStack().execute(command), that
DiagramCommandStack has a method to get the IUndoContext it is working with.

But then I find a problem with working with the
TransactionalEditingDomain.commandStack(). If I have an EMF command, and
I execute it this way:
editingDomain().getCommandStack().execute(command) I don't really know
which context it is operating under, since that CommandStack has no
UndoContext and EMF command have no UndoContext either. But when you are
working in the DigramaEditor and you execute a command this way, you do
get the possibility of Undoing that command from the edit menú. How is
this possible? Which undo context have those commands executed in the
TransactionalEditingDomain? I need to understand this because I'm trying
to make some modifications in the model when the diagram is closed and I
just have this EditingDomain CommandStack (not the DiagramCommandStack),
and I don't get to see my executed commands in the edit menú.

Does anyone have an idea about this? I would really appreciate any help..

Thank you!
Re: IUndoContext and Undo/Redo actions [message #234206 is a reply to message #234185] Fri, 19 June 2009 09:08 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Javier,

> But then I find a problem with working with the
> TransactionalEditingDomain.commandStack(). If I have an EMF command,
This will be an instance of org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.cre ateHistoryListener().


> and I execute it this way:
> editingDomain().getCommandStack().execute(command) I don't really know
> which context it is operating under, since that CommandStack has no
> UndoContext and EMF command have no UndoContext either. But when you
See WorkspaceCommandStackImpl.DomainListener + org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.
These two listeners will finally attach necessary undo context to each EMF
operation executed via EMF command stack, so each operation executed via
GMF/EMF command stack or just an AbstractEMFOperation executed on Operation
History finally will be associated with EditingDomainUndoContext (an instance
returned from DiagramEditor.getUndoContext()).

> How is this possible? Which undo context have those commands executed
> in the TransactionalEditingDomain? I need to understand this because
EditingDomainUndoContext (==DiagramEditor.getUndoContext())

-----------------
Alex Shatalin
Previous Topic:Outline, hierarchicaly, Diagram input a subelement
Next Topic:EditPart creation at compartement programmatially
Goto Forum:
  


Current Time: Fri Mar 29 07:41:35 GMT 2024

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

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

Back to the top