Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » StrictCompoundCommand
StrictCompoundCommand [message #425271] Fri, 21 November 2008 12:20 Go to next message
Eclipse UserFriend
Originally posted by: swt.magellium.fr

Hello all !

I want to create a CompoundCommand composed of two commands, where the
second command must wait for the result of the first command in order to
be executed.
I think this is achieved by using a StrictCompoundCommand
(non-pessimistic), and by wrapping the second command in a
CommandWrapper (the second command is then created when it's wrapper is
prepared). This works well, except for undo.

When the command is prepared, my first sub-command is executed, and the
wrapper of the second one is prepared, so the second command is created
and prepared.
When the command is executed, the second sub-command is executed (the
first was already executed during prepare).
That is ok.

But then, if I "undo" the command, only the last sub-command (the second
one) is undone !
This is logic regarding redo : it will only have to re-execute the last
sub-command. But I also need to undo the first sub-command to obtain the
real expected undo effect !

I imagine this is a well known problem. Can someone help me with this ??
Thanks in advance !

Stephane
Re: StrictCompoundCommand [message #425273 is a reply to message #425271] Fri, 21 November 2008 12:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: swt.magellium.fr

It seems that using pessimistic solves the undo problem. Is this the
right way to do it ?
And so, in which cases can non-pessimistic be useful ?

Thanks in advance again!


> Hello all !
>
> I want to create a CompoundCommand composed of two commands, where the
> second command must wait for the result of the first command in order to
> be executed.
> I think this is achieved by using a StrictCompoundCommand
> (non-pessimistic), and by wrapping the second command in a
> CommandWrapper (the second command is then created when it's wrapper is
> prepared). This works well, except for undo.
>
> When the command is prepared, my first sub-command is executed, and the
> wrapper of the second one is prepared, so the second command is created
> and prepared.
> When the command is executed, the second sub-command is executed (the
> first was already executed during prepare).
> That is ok.
>
> But then, if I "undo" the command, only the last sub-command (the second
> one) is undone !
> This is logic regarding redo : it will only have to re-execute the last
> sub-command. But I also need to undo the first sub-command to obtain the
> real expected undo effect !
>
> I imagine this is a well known problem. Can someone help me with this ??
> Thanks in advance !
>
> Stephane
Re: StrictCompoundCommand [message #425284 is a reply to message #425273] Fri, 21 November 2008 14:26 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30897
Registered: July 2009
Senior Member
SWT,

Comments below.

SWT wrote:
> It seems that using pessimistic solves the undo problem. Is this the
> right way to do it ?
It seems so.
> And so, in which cases can non-pessimistic be useful ?
When the enablement of commands does not depend on those before it.
>
> Thanks in advance again!
>
>
>> Hello all !
>>
>> I want to create a CompoundCommand composed of two commands, where
>> the second command must wait for the result of the first command in
>> order to be executed.
>> I think this is achieved by using a StrictCompoundCommand
>> (non-pessimistic), and by wrapping the second command in a
>> CommandWrapper (the second command is then created when it's wrapper
>> is prepared). This works well, except for undo.
>>
>> When the command is prepared, my first sub-command is executed, and
>> the wrapper of the second one is prepared, so the second command is
>> created and prepared.
>> When the command is executed, the second sub-command is executed (the
>> first was already executed during prepare).
>> That is ok.
>>
>> But then, if I "undo" the command, only the last sub-command (the
>> second one) is undone !
>> This is logic regarding redo : it will only have to re-execute the
>> last sub-command. But I also need to undo the first sub-command to
>> obtain the real expected undo effect !
>>
>> I imagine this is a well known problem. Can someone help me with this ??
Do all the comments in the Javadoc for StrictCompoundCommand apply for
your case?
>> Thanks in advance !
>>
>> Stephane
Previous Topic:EMF 2.5M3 with Eclipse SDK 3.5 M2
Next Topic:Auto unload - memory management
Goto Forum:
  


Current Time: Sun Feb 23 12:14:51 GMT 2020

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

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

Back to the top