Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to use an Adapter to get all the notifications in a EMF model?(Search for a "best practice" to attach Adapters such that can process notifications from all the elements in a EMF model.)
How to use an Adapter to get all the notifications in a EMF model? [message #1803038] Thu, 21 February 2019 10:55 Go to next message
Patrik Suzzi is currently offline Patrik SuzziFriend
Messages: 91
Registered: June 2010
Location: Urdorf, Switzerland
Member

Hi All,

I am writing to ask if someone knows a way to get notifications for all the events triggered in a model.

In details:
I am working on a EMF model where I need to receive the RESOLVE changes in all the EObjects in the model.
So far, I can receive notifications for changes of a single object, by attaching an adapter to such object after creation, for example:

EObject aObject = instantiateElementA();

// here I attach the adapter to the specific object
aObject.eAdapters().add(new AdapterImpl() {

    @Override
    public void notifyChanged(final Notification msg) {
        if ((msg.getEventType() == Notification.RESOLVE)) {
        // here I handle the event 
        // ...
        }
        super.notifyChanged(msg);
    }

});


I think there should be a way to attach the same Adapter to all the obejcts instantiated in the model, and I guess this should be done either by accessing a global notifier, or by accessing the Factory that instantiates the EObjects.

Is there anybody who can suggest me which is the "best practice way" to attach such adapters to listen to all the notifications ?

Thanks for the time spent on this.
Best Regards,
Patrik
Re: How to use an Adapter to get all the notifications in a EMF model? [message #1803042 is a reply to message #1803038] Thu, 21 February 2019 12:23 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1195
Registered: July 2009
Location: Canada
Senior Member

Hi, Patrik,

Have a look at the EContentAdapter class. If you attach it to a ResourceSet, it will propagate itself to absolutely everything that is loaded within it, and will receive all Notifications.

HTH,

Christian
Re: How to use an Adapter to get all the notifications in a EMF model? [message #1803062 is a reply to message #1803042] Thu, 21 February 2019 14:55 Go to previous message
Patrik Suzzi is currently offline Patrik SuzziFriend
Messages: 91
Registered: June 2010
Location: Urdorf, Switzerland
Member

Thanks Christian,

This is exactly the solution I was searching for.

Best Regards,
Patrik
Previous Topic:issue with EMF proxy, EOpposite, and Adapters
Next Topic:Merging resources that share the same root node.
Goto Forum:
  


Current Time: Tue Jun 18 00:50:04 GMT 2019

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

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

Back to the top