Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EContentAdapter not fired for containment relation
EContentAdapter not fired for containment relation [message #991769] Thu, 20 December 2012 06:46 Go to next message
Deepak P is currently offline Deepak PFriend
Messages: 32
Registered: January 2012
Member
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 07:54 Go to previous messageGo to next message
Ruben Faelens is currently offline Ruben FaelensFriend
Messages: 3
Registered: December 2012
Junior Member
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 10:20 Go to previous messageGo to next message
Deepak P is currently offline Deepak PFriend
Messages: 32
Registered: January 2012
Member
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 19:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EContentAdapter not fired for containment relation [message #995857 is a reply to message #994237] Mon, 31 December 2012 10:07 Go to previous message
Deepak P is currently offline Deepak PFriend
Messages: 32
Registered: January 2012
Member
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: Thu Apr 25 00:04:38 GMT 2024

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

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

Back to the top