Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ChangeCommand.getAffectedObjects()
ChangeCommand.getAffectedObjects() [message #1706808] Mon, 31 August 2015 10:21 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I've just noted that ChangeCommand does not implement
getAffectedObjects, so it will always return an empty list (the default
implementation).

I would have expected an implementation like, e.g.,

@Override
public Collection<?> getAffectedObjects() {
Set<EObject> changeDescriptionObjects =
changeDescription.getObjectChanges().keySet();

return changeDescriptionObjects;
}

so I was wondering why it is not implemented at all...

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: ChangeCommand.getAffectedObjects() [message #1706976 is a reply to message #1706808] Tue, 01 September 2015 09:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Lorenzo,

It's not so clear that this would produce the desired selection
behavior. I.e., when you add an object via an AddCommand, the added
object is the affected object, and after your undo, it's the parent.
When doing this with a change recorder, the changed object is likely
always the parent. It's probably better the client spend some time
thinking about what selection behavior they'd like to see...


On 31/08/2015 12:21 PM, Lorenzo Bettini wrote:
> Hi
>
> I've just noted that ChangeCommand does not implement
> getAffectedObjects, so it will always return an empty list (the default
> implementation).
>
> I would have expected an implementation like, e.g.,
>
> @Override
> public Collection<?> getAffectedObjects() {
> Set<EObject> changeDescriptionObjects =
> changeDescription.getObjectChanges().keySet();
>
> return changeDescriptionObjects;
> }
>
> so I was wondering why it is not implemented at all...
>
> cheers
> Lorenzo
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ChangeCommand.getAffectedObjects() [message #1707015 is a reply to message #1706976] Tue, 01 September 2015 13:58 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 01/09/2015 11:18, Ed Merks wrote:
> Lorenzo,
>
> It's not so clear that this would produce the desired selection
> behavior. I.e., when you add an object via an AddCommand, the added
> object is the affected object, and after your undo, it's the parent.
> When doing this with a change recorder, the changed object is likely
> always the parent. It's probably better the client spend some time
> thinking about what selection behavior they'd like to see...

OK, I see.

But in a ChangeCommand, by parent you mean the object you pass to the
ChangeCommand constructor, for instance?

Thank you Ed.

cheers
Lorenzo

>
>
> On 31/08/2015 12:21 PM, Lorenzo Bettini wrote:
>> Hi
>>
>> I've just noted that ChangeCommand does not implement
>> getAffectedObjects, so it will always return an empty list (the default
>> implementation).
>>
>> I would have expected an implementation like, e.g.,
>>
>> @Override
>> public Collection<?> getAffectedObjects() {
>> Set<EObject> changeDescriptionObjects =
>> changeDescription.getObjectChanges().keySet();
>>
>> return changeDescriptionObjects;
>> }
>>
>> so I was wondering why it is not implemented at all...
>>
>> cheers
>> Lorenzo
>>
>


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: ChangeCommand.getAffectedObjects() [message #1707069 is a reply to message #1707015] Wed, 02 September 2015 04:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
I mean the changed object is the object that was added to not the object
that was added. The object passed in the constructor might not even be
objects that are changed, but rather some deeply nested descendant,
i.e., you could pass in the whole resource set on the constructor and
change anything.

On 01/09/2015 3:58 PM, Lorenzo Bettini wrote:
> OK, I see.
>
> But in a ChangeCommand, by parent you mean the object you pass to the
> ChangeCommand constructor, for instance?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:<appinfo> tag not generated during model export to XSD
Next Topic:Metamodel registration
Goto Forum:
  


Current Time: Thu Mar 28 18:50:02 GMT 2024

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

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

Back to the top