capint
7/10/2016 - 8:17 PM

EMF >> Adapter / Resource listener)

EMF >> Adapter / Resource listener)

ModelFactory factory = ModelFactory.eINSTANCE;
persons = factory.createIPersonList();

//Listen to changes of items in the lists plus their attributes
EContentAdapter adapter = new EContentAdapter() {
  public void notifyChanged(Notification notification) {
    super.notifyChanged(notification);
    System.out
        .println("Notfication received from the data model. Data model has changed!!!");
  }
};
persons.eAdapters().add(adapter);
ModelFactory factory = ModelFactory.eINSTANCE;
persons = factory.createIPersonList();

//Listen to changes of items in the list (add, remove)
Adapter adapter = new AdapterImpl() {
  public void notifyChanged(Notification notification) {
    System.out
        .println("Notfication received from the data model. Data model has changed!!!");
  }
};
persons.eAdapters().add(adapter);
EMF has the possibility to inform observers / listeners about changes in the model via Adapters
Source: http://www.vogella.com/tutorials/EclipseEMFNotification/article.htm