Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EContentAdapter does not always see map values changes
EContentAdapter does not always see map values changes [message #1053559] Mon, 06 May 2013 14:20 Go to next message
David Michonneau is currently offline David MichonneauFriend
Messages: 85
Registered: July 2009
Member
I have an issue with EContentAdapter. When I have maps with lists as values, it does not detect that new list instances are added as values. And so no notification is triggered when the list changes. Here is an example that demonstrates it:

Note that if the EContentAdapter is registered after the new BasicEList() is added to the map, it gets the notification correctly

Any idea if this is a bug, or there is a way to do it that would work?

---- xcore
package test

class A {
contains TestMap[] items
}
class ItemValue {}
class TestMap wraps java.util.Map$Entry{
String key
contains ItemValue [0..*] value
}

---- test
A a = TestFactory.eINSTANCE.createA();
Adapter listener = new EContentAdapter() {
@Override
public void notifyChanged(Notification notification) {
System.out.println(notification);
}
};
a.eAdapters().add(listener);
a.getItems().put("key" , new BasicEList<ItemValue>()); // this seems to go unnoticed by EContentAdapter
ItemValue value = TestFactory.eINSTANCE.createItemValue();
a.getItems().get("key").add(value ); // EContentAdapter not notified

[Updated on: Mon, 06 May 2013 14:21]

Report message to a moderator

Re: EContentAdapter does not always see map values changes [message #1053565 is a reply to message #1053559] Mon, 06 May 2013 14:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
David,

Comments below.

On 06/05/2013 4:20 PM, David Michonneau wrote:
> I have an issue with EContentAdapter. When I have maps with lists as
> values, it does not detect that new list instances are added as values.
I think that's not true. When I run your test case there is one
notification, i.e., for the map entry being added to the items list...
> And so no notification is triggered when the list changes. Here is an
> example that demonstrates it:
>
> Note that if the EContentAdapter is registered after the new
> BasicEList() is added to the map, it gets the notification correctly
>
> Any idea if this is a bug, or there is a way to do it that would work?
>
> ---- xcore
> package test
>
> class A {
> contains TestMap[] items
> }
> class ItemValue {}
> class TestMap wraps java.util.Map$Entry{
> String key
> contains ItemValue [0..*] value
> }
>
> ---- test
> A a = TestFactory.eINSTANCE.createA();
> Adapter listener = new EContentAdapter() {
> @Override
> public void notifyChanged(Notification notification) {
> System.out.println(notification);
You're not calling super, so the content adapter doesn't attach itself
to the newly added map entry...
> }
> };
> a.eAdapters().add(listener); a.getItems().put("key" , new
> BasicEList<ItemValue>()); // this seems to go unnoticed by
> EContentAdapter
> ItemValue value = TestFactory.eINSTANCE.createItemValue();
> a.getItems().get("key").add(value ); // EContentAdapter not notified


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EContentAdapter does not always see map values changes [message #1053566 is a reply to message #1053565] Mon, 06 May 2013 14:43 Go to previous messageGo to next message
David Michonneau is currently offline David MichonneauFriend
Messages: 85
Registered: July 2009
Member
No Message Body
Re: EContentAdapter does not always see map values changes [message #1053567 is a reply to message #1053566] Mon, 06 May 2013 14:44 Go to previous message
David Michonneau is currently offline David MichonneauFriend
Messages: 85
Registered: July 2009
Member
Yes I just realised that too...

Thanks,

David
Previous Topic:Backslashes and spaces in EMF URI's
Next Topic:[Teneo] Using ChangeRecorder and persisting ChangeDescription models
Goto Forum:
  


Current Time: Fri Apr 26 02:51:13 GMT 2024

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

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

Back to the top