AffectedObjects in mostRecentCommand is always empty! [message #419242] |
Wed, 14 May 2008 14:19 |
Supreetha H R Messages: 24 Registered: July 2009 |
Junior Member |
|
|
Hello,
In our RCP application, we are providing Undo/Redo actions on few
operations like deletion of our model object. Here we cant just use EMF's
deletion command, as we have to do others operations like setting the
state and other tool related settings, for that we have our own command
class written which is extending ChangeCommand. And these commands are
executed when related action (simple jface actions) is run.
Everything works fine, except setting the selection after Undo/Redo is
done. getAffectedObjects from mostRecentCommand is always coming as empty
list.
When i looked into EMF generated code (which i always refer to as an
example), has a different type of actions, which is extending
CommandActionHandler class in which updateSelection is creating a command
with the collection of selected objects as command parameter, and wheni
checked the affected objects got from most recent command, after undo, it
had a proper list of objects.
I dont understand why it is not working with our own commands, are we
missing out something?
Regards,
Supreetha
|
|
|
Re: AffectedObjects in mostRecentCommand is always empty! [message #419243 is a reply to message #419242] |
Wed, 14 May 2008 14:56 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Supreetha,
Each command is carefully designed to return an appropriate result for
getAffectedObjects, but ChangeCommand just returns an empty list since
it's not obvious generically what it should return.
Supreetha H R wrote:
> Hello,
>
> In our RCP application, we are providing Undo/Redo actions on few
> operations like deletion of our model object. Here we cant just use
> EMF's deletion command, as we have to do others operations like
> setting the state and other tool related settings, for that we have
> our own command class written which is extending ChangeCommand. And
> these commands are executed when related action (simple jface actions)
> is run.
> Everything works fine, except setting the selection after Undo/Redo is
> done. getAffectedObjects from mostRecentCommand is always coming as
> empty list.
>
> When i looked into EMF generated code (which i always refer to as an
> example), has a different type of actions, which is extending
> CommandActionHandler class in which updateSelection is creating a
> command with the collection of selected objects as command parameter,
> and wheni checked the affected objects got from most recent command,
> after undo, it had a proper list of objects.
>
> I dont understand why it is not working with our own commands, are we
> missing out something?
>
> Regards,
> Supreetha
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: AffectedObjects in mostRecentCommand is always empty! [message #419245 is a reply to message #419244] |
Wed, 14 May 2008 15:24 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Supreetha,
If you look at things like AddCommand and RemoveCommand, you'll see they
carefully compute the contents of the "affectedObjects" fields as part
of doExecute, doUndo, and do Redo and return it as part of overriding
doGetAffectedObjects. If you want to influence what gets selected for
your specialized commands, you'll need to do this same kind of thing.
Supreetha H R wrote:
> Hello Ed Merks,
>
> As my English is not that good, i am not able to understand
> completely what you have written ;-) Could you please clear it
> little more?
>
>
> Regards,
> Supreetha
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 1.25460 seconds