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: 2
Registered: February 2018
Junior 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 Damus is currently offline Christian DamusFriend
Messages: 1270
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: 2
Registered: February 2018
Junior 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: Thu Apr 18 12:24:20 GMT 2024

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

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

Back to the top