Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Undo / Redo for whole Commandstack
Undo / Redo for whole Commandstack [message #217674] Sat, 07 February 2009 19:28 Go to next message
Eclipse UserFriend
Originally posted by: Erazerx.gmx.de

Hi all,

i am trying to analyse how undo / redo works in GMF. Unfortunately i
wasn't very succesful. I just want to let undo / redo work on the whole
command stack of the editing domain, instead of just providing
funcionality for commands that are run on the graphical editor.

The situation is, that i got a multi tab editor with a tree viewer for
the model and a tab with a GMF created editor. When doing something in
the GMF-Tab on the model like creating a new elemnt, it can also be
undone in the viewer. However, changes that are made in the tree viewer
on the model can not be undone in the diagram editor tab. Well, is there
a way to let die diagram editor simply provide undo / redo for the whole
command stack?
Both tabs ware working with the same editing domain, of course.

I also made my own cut / copy / paste commands, that are wrapping the
EMF clipboard commands (to let the domain elements get copied instead of
just copying the visual parts). When these commands are executed, they
also can not be undone.

Thx in advance, Arne :)
Re: Undo / Redo for whole Commandstack [message #217701 is a reply to message #217674] Sun, 08 February 2009 08:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Erazerx.gmx.de

For my understanding now, undo / redo is only available when the command
was created by:
- first creating a Request
- let a EditPart create a command for the Request

Well, that mens the question is if there is a possibility to have
support for undo / red, regardless of if the command was created from a
edit part by a request?

thx in advance :)


Arne schrieb:
> Hi all,
>
> i am trying to analyse how undo / redo works in GMF. Unfortunately i
> wasn't very succesful. I just want to let undo / redo work on the whole
> command stack of the editing domain, instead of just providing
> funcionality for commands that are run on the graphical editor.
>
> The situation is, that i got a multi tab editor with a tree viewer for
> the model and a tab with a GMF created editor. When doing something in
> the GMF-Tab on the model like creating a new elemnt, it can also be
> undone in the viewer. However, changes that are made in the tree viewer
> on the model can not be undone in the diagram editor tab. Well, is there
> a way to let die diagram editor simply provide undo / redo for the whole
> command stack?
> Both tabs ware working with the same editing domain, of course.
>
> I also made my own cut / copy / paste commands, that are wrapping the
> EMF clipboard commands (to let the domain elements get copied instead of
> just copying the visual parts). When these commands are executed, they
> also can not be undone.
>
> Thx in advance, Arne :)
Re: Undo / Redo for whole Commandstack [message #217717 is a reply to message #217674] Sun, 08 February 2009 11:20 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
How are you executing the command? To make the command part of the
undo/redo stack you need to execute them like this:

----------8<----------
Command cmd = AddCommand.create(service.getEditingDomain(), parent,
EXTLibraryPackage.Literals.LIBRARY__WRITERS, w);

if( cmd.canExecute() ) {
editingDomain.getCommandStack().execute(cmd);
}
----------8<----------


Tom

Arne schrieb:
> Hi all,
>
> i am trying to analyse how undo / redo works in GMF. Unfortunately i
> wasn't very succesful. I just want to let undo / redo work on the whole
> command stack of the editing domain, instead of just providing
> funcionality for commands that are run on the graphical editor.
>
> The situation is, that i got a multi tab editor with a tree viewer for
> the model and a tab with a GMF created editor. When doing something in
> the GMF-Tab on the model like creating a new elemnt, it can also be
> undone in the viewer. However, changes that are made in the tree viewer
> on the model can not be undone in the diagram editor tab. Well, is there
> a way to let die diagram editor simply provide undo / redo for the whole
> command stack?
> Both tabs ware working with the same editing domain, of course.
>
> I also made my own cut / copy / paste commands, that are wrapping the
> EMF clipboard commands (to let the domain elements get copied instead of
> just copying the visual parts). When these commands are executed, they
> also can not be undone.
>
> Thx in advance, Arne :)


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Undo / Redo for whole Commandstack [message #217725 is a reply to message #217717] Sun, 08 February 2009 11:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Erazerx.gmx.de

Is the AddCommand from the package org.eclipse.emf.edit.command?
When executing EMF commands like this, i have only undo / redo support
for that specific Command in a EMF generated editor, not in the GMF editor.

I guess when it should be available for undo / redo in the GMF editor,
commands have to be created with requests on EditParts. Maybe i am
wrong, i do not know.

Arne


Tom Schindl schrieb:
> How are you executing the command? To make the command part of the
> undo/redo stack you need to execute them like this:
>
> ----------8<----------
> Command cmd = AddCommand.create(service.getEditingDomain(), parent,
> EXTLibraryPackage.Literals.LIBRARY__WRITERS, w);
>
> if( cmd.canExecute() ) {
> editingDomain.getCommandStack().execute(cmd);
> }
> ----------8<----------
>
>
> Tom
>
> Arne schrieb:
>> Hi all,
>>
>> i am trying to analyse how undo / redo works in GMF. Unfortunately i
>> wasn't very succesful. I just want to let undo / redo work on the whole
>> command stack of the editing domain, instead of just providing
>> funcionality for commands that are run on the graphical editor.
>>
>> The situation is, that i got a multi tab editor with a tree viewer for
>> the model and a tab with a GMF created editor. When doing something in
>> the GMF-Tab on the model like creating a new elemnt, it can also be
>> undone in the viewer. However, changes that are made in the tree viewer
>> on the model can not be undone in the diagram editor tab. Well, is there
>> a way to let die diagram editor simply provide undo / redo for the whole
>> command stack?
>> Both tabs ware working with the same editing domain, of course.
>>
>> I also made my own cut / copy / paste commands, that are wrapping the
>> EMF clipboard commands (to let the domain elements get copied instead of
>> just copying the visual parts). When these commands are executed, they
>> also can not be undone.
>>
>> Thx in advance, Arne :)
>
>
Re: Undo / Redo for whole Commandstack [message #217749 is a reply to message #217717] Sun, 08 February 2009 13:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Erazerx.gmx.de

I think the easiest way for me would be, just to implement my own undo /
redo actions and let them do sth. like this:

if (editingDomain.getCommandStack().canUndo()) {
editingDomain.getCommandStack().undo();
}

Well, but i do not know how to replace the undo / redo actions with my
own actions. Does anybody know how to do that?

Arne


Tom Schindl schrieb:
> How are you executing the command? To make the command part of the
> undo/redo stack you need to execute them like this:
>
> ----------8<----------
> Command cmd = AddCommand.create(service.getEditingDomain(), parent,
> EXTLibraryPackage.Literals.LIBRARY__WRITERS, w);
>
> if( cmd.canExecute() ) {
> editingDomain.getCommandStack().execute(cmd);
> }
> ----------8<----------
>
>
> Tom
>
> Arne schrieb:
>> Hi all,
>>
>> i am trying to analyse how undo / redo works in GMF. Unfortunately i
>> wasn't very succesful. I just want to let undo / redo work on the whole
>> command stack of the editing domain, instead of just providing
>> funcionality for commands that are run on the graphical editor.
>>
>> The situation is, that i got a multi tab editor with a tree viewer for
>> the model and a tab with a GMF created editor. When doing something in
>> the GMF-Tab on the model like creating a new elemnt, it can also be
>> undone in the viewer. However, changes that are made in the tree viewer
>> on the model can not be undone in the diagram editor tab. Well, is there
>> a way to let die diagram editor simply provide undo / redo for the whole
>> command stack?
>> Both tabs ware working with the same editing domain, of course.
>>
>> I also made my own cut / copy / paste commands, that are wrapping the
>> EMF clipboard commands (to let the domain elements get copied instead of
>> just copying the visual parts). When these commands are executed, they
>> also can not be undone.
>>
>> Thx in advance, Arne :)
>
>
Re: Undo / Redo for whole Commandstack [message #217819 is a reply to message #217749] Mon, 09 February 2009 08:02 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Arne,

All the commands in GMF (EMF-based or GEF-based) are executed through eclipse
command stack now. I think the problem is in incorrect “undo context” used
by some commands in your editor or Undo/redo actions. In general each IUndoableOperation
can have several IUndoContext attached, so there should be a code attaching
proper UndoContext to each command executed through GEF/EMF. I do not remember
then appropriate context will be attached to each command executed in GMF-generated
editor (this code is not so simple and spread around the GMF) but I know
there is such place(s) in code and I think you can try finding that by debugging.
AFAIR I was able to implement multipage editor with EMF/GMF pages and common
undo/redo stack and an idea was: attach appropriate undo context to each
executed command and then use this context in undo/redo actions.

-----------------
Alex Shatalin
Re: Undo / Redo for whole Commandstack [message #218485 is a reply to message #217819] Thu, 12 February 2009 13:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Erazerx.gmx.de

Hello Alex,

thank you very much! I really was doing it wrong with the IUndoContext.
You helped me a lot.

Arne

Alex Shatalin schrieb:
> Hello Arne,
>
> All the commands in GMF (EMF-based or GEF-based) are executed through
> eclipse command stack now. I think the problem is in incorrect “undo
> context” used by some commands in your editor or Undo/redo actions. In
> general each IUndoableOperation can have several IUndoContext attached,
> so there should be a code attaching proper UndoContext to each command
> executed through GEF/EMF. I do not remember then appropriate context
> will be attached to each command executed in GMF-generated editor (this
> code is not so simple and spread around the GMF) but I know there is
> such place(s) in code and I think you can try finding that by debugging.
> AFAIR I was able to implement multipage editor with EMF/GMF pages and
> common undo/redo stack and an idea was: attach appropriate undo context
> to each executed command and then use this context in undo/redo actions.
>
> -----------------
> Alex Shatalin
>
>
Re: Undo / Redo for whole Commandstack [message #220054 is a reply to message #218485] Thu, 26 February 2009 09:31 Go to previous message
Javier is currently offline JavierFriend
Messages: 57
Registered: July 2009
Member
Hello Alex & Arne!

Arne, I've had the same problem but I'm stuck at that point.
Could you give me a hint on how to solve this problem and where to look
at in the code to fix the issue of the UndoContext?

Thanks!



> Hello Alex,
>
> thank you very much! I really was doing it wrong with the IUndoContext.
> You helped me a lot.
>
> Arne
>
> Alex Shatalin schrieb:
>> Hello Arne,
>>
>> All the commands in GMF (EMF-based or GEF-based) are executed through
>> eclipse command stack now. I think the problem is in incorrect “undo
>> context” used by some commands in your editor or Undo/redo actions. In
>> general each IUndoableOperation can have several IUndoContext attached,
>> so there should be a code attaching proper UndoContext to each command
>> executed through GEF/EMF. I do not remember then appropriate context
>> will be attached to each command executed in GMF-generated editor (this
>> code is not so simple and spread around the GMF) but I know there is
>> such place(s) in code and I think you can try finding that by debugging.
>> AFAIR I was able to implement multipage editor with EMF/GMF pages and
>> common undo/redo stack and an idea was: attach appropriate undo context
>> to each executed command and then use this context in undo/redo actions.
>>
>> -----------------
>> Alex Shatalin
>>
>>
Previous Topic:A visual hierarchal layout for nodes
Next Topic:Changing between different Figures
Goto Forum:
  


Current Time: Tue Apr 23 06:11:59 GMT 2024

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

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

Back to the top