Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Undo Operation on Editing domain's command stack(Undo does not undo all the commands in the command stack)
Undo Operation on Editing domain's command stack [message #557601] Wed, 08 September 2010 09:16 Go to next message
manasa  is currently offline manasa Friend
Messages: 3
Registered: September 2010
Junior Member
Hi,

I am a novice in EMF, and have a question regarding the undo operation on ediitng domain.

I see that calling an undo on the editing domain, i.e
EditingDomain.getCommandStack().undo(), internally calls an undo implementation (in this case, undo() in BasicCommandStack) , where only the topmost command of the commandstack is reverted back.

I was expecting the undo call on the editing domain, to undo all the commands in the command stack, but this is not the case.

Is there a way, how all the commands in the command stack could be reverted back at once?

Thanks,
Manasa
Re: Undo Operation on Editing domain's command stack [message #557693 is a reply to message #557601] Wed, 08 September 2010 14:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Manasa,

Comments below.

manasa wrote:
> Hi,
>
> I am a novice in EMF, and have a question regarding the undo operation
> on ediitng domain.
>
> I see that calling an undo on the editing domain, i.e
> EditingDomain.getCommandStack().undo(), internally calls an undo
> implementation (in this case, undo() in BasicCommandStack) , where
> only the topmost command of the commandstack is reverted back.
Yes, as the Javadoc says.
>
> I was expecting the undo call on the editing domain, to undo all the
> commands in the command stack, but this is not the case.
It would be hard to implement undo in the editor if that's the only
thing the command stack supported. How would one undo just one command
and have the command stack be updated to redo that command?
>
> Is there a way, how all the commands in the command stack could be
> reverted back at once?
You'd have to call undo repeatedly until the command stack can't be
undone anymore.
>
> Thanks,
> Manasa


Ed Merks
Professional Support: https://www.macromodeling.com/
icon6.gif  Re: Undo Operation on Editing domain's command stack [message #557805 is a reply to message #557693] Thu, 09 September 2010 03:48 Go to previous message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 18
Registered: September 2010
Location: Bangalore
Junior Member
Adding to the above reply by Ed Merks:
You can do it by checking whether the command stack is not empty in a loop and undoing a command each time its found that the command stack is "not empty". This can be done as follows :-

while (myCommandStack.canUndo()) {
myEditingDomain.getCommandStack().undo();
}

Smile


Regards,
Animesh

[Updated on: Thu, 09 September 2010 04:08]

Report message to a moderator

Previous Topic:Using EMF reflective APIs to add to a list of Objects
Next Topic:EMF.Edit: Override Copy/Paste to preserve bidirectional references
Goto Forum:
  


Current Time: Thu Sep 26 06:57:11 GMT 2024

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

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

Back to the top