Home » Modeling » GMF (Graphical Modeling Framework) » Undo / Redo for whole Commandstack
Undo / Redo for whole Commandstack [message #217674] |
Sat, 07 February 2009 19:28 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Thomas Schindl 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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #218485 is a reply to message #217819] |
Thu, 12 February 2009 13:16 |
Eclipse User |
|
|
|
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
>
>
|
|
| |
Goto Forum:
Current Time: Mon Sep 23 06:48:46 GMT 2024
Powered by FUDForum. Page generated in 0.04730 seconds
|