StrictCompoundCommand [message #425271] |
Fri, 21 November 2008 12:20 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Ed Merks Messages: 33146 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
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03772 seconds