Skip to main content



      Home
Home » Modeling » EMF » EContentAdapter not fired for containment relation
EContentAdapter not fired for containment relation [message #991769] Thu, 20 December 2012 01:46 Go to next message
Eclipse UserFriend
Hello All,
I am very much new to EMF concepts. So i have a doubt regarding adding an EContentAdapter.

We have "MySystem" object in the Ecore. And "MySystem" has a containment relationship to "MyElements". So when i add a EContentAdapter to "MySystem", If there are any changes in "MyElements" , the notifier should be notified right ?

The code snippet is as given below

public class MySystemCreator {

private void create() {
mySystem = myFactory.createMySystem();
MySystemChangeContentAdapter mySystemChangeContentAdapter = new MySystemChangeContentAdapter();
mySystem.eAdapters().add(mySystemChangeContentAdapter );
}
}

public class MySystemChangeContentAdapter extends EContentAdapter {

@Override
public void notifyChanged(final Notification notification) {
super.notifyChanged(notification);
System.out.println("Executed");
}
}

public class CreateMyElements {

public Object[] create(){

...
mySystem.getElements().add(myElement);
}
}

So when we add "myElement" to "mySystem", the notifier is not fired.

Is it the correct way of writing a EcontentAdapter ?


Re: EContentAdapter not fired for containment relation [message #991791 is a reply to message #991769] Thu, 20 December 2012 02:54 Go to previous messageGo to next message
Eclipse UserFriend
The notifier should really be fired. Your usage is correct.

* Check whether the mySystem element is the same in both cases (adding the eAdapter, adding the child)
* Check whether the eAdapters field of mySystem contains your custom adapter.
* Is the elements list an EList / NotifyingList? Debug inside to see whether events get fired due to an element being added.
Re: EContentAdapter not fired for containment relation [message #994077 is a reply to message #991791] Wed, 26 December 2012 05:20 Go to previous messageGo to next message
Eclipse UserFriend
Hello Ruben,
Thanks for your reply.

The problem was that "mySystem" object were different.
Because of which even though custom adapter was added to "mySystem" it was not getting fired.

Regarding "elements", Yes it is a EList.

Regards,
Deepak P
Re: EContentAdapter not fired for containment relation [message #994237 is a reply to message #994077] Wed, 26 December 2012 14:58 Go to previous messageGo to next message
Eclipse UserFriend
Deepak,

Nothing looks wrong from what you described so use the debugger to see
what's actually happening.


On 26/12/2012 11:20 AM, Deepak P wrote:
> Hello Ruben,
> Thanks for your reply.
>
> The problem was that "mySystem" object were different.
> Because of which even though custom adapter was added to "mySystem" it
> was not getting fired.
>
> Regarding "elements", Yes it is a EList.
>
> Regards,
> Deepak P
Re: EContentAdapter not fired for containment relation [message #995857 is a reply to message #994237] Mon, 31 December 2012 05:07 Go to previous message
Eclipse UserFriend
Hello Ed Merks,

Actually the object "mySystem" used in the class "MySystemCreator" and the one used in "CreateMyElements" are different instances.
Hence the notifier wasn't getting fired.

Thanks for your reply

Regards,
Deepak P
Previous Topic:Locking Mechanism in CDO
Next Topic:[XCore] Generating artifacts
Goto Forum:
  


Current Time: Wed Jul 23 02:26:41 EDT 2025

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

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

Back to the top