Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » AffectedObjects in mostRecentCommand is always empty!
AffectedObjects in mostRecentCommand is always empty! [message #419242] Wed, 14 May 2008 14:19 Go to next message
Supreetha H R is currently offline Supreetha H RFriend
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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
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 #419244 is a reply to message #419243] Wed, 14 May 2008 15:09 Go to previous messageGo to next message
Supreetha H R is currently offline Supreetha H RFriend
Messages: 24
Registered: July 2009
Junior Member
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
Re: AffectedObjects in mostRecentCommand is always empty! [message #419245 is a reply to message #419244] Wed, 14 May 2008 15:24 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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/
Previous Topic:Dynamic constraint in java
Next Topic:Ecore lower/upper bounds don't match XSD schema
Goto Forum:
  


Current Time: Wed Apr 24 14:23:48 GMT 2024

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

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

Back to the top