Skip to content

Instantly share code, notes, and snippets.

@mbarbero mbarbero/NotifyExample.java Secret
Last active Dec 15, 2015

Embed
What would you like to do?
package fr.obeo.emf.edit.econ2013.live;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.emf.examples.extlibrary.Book;
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
import org.eclipse.emf.examples.extlibrary.Library;
import org.eclipse.emf.examples.extlibrary.Writer;
public class NotifyExample {
public static void main(String[] args) {
Library library = EXTLibraryFactory.eINSTANCE.createLibrary();
library.eAdapters().add(new AdapterImpl() {
@Override
public void notifyChanged(Notification msg) {
super.notifyChanged(msg);
System.out.println(msg);
}
});
library.setName("My library");
Book book = EXTLibraryFactory.eINSTANCE.createBook();
library.getBooks().add(book);
book.setTitle("The two towers");
Writer writer = EXTLibraryFactory.eINSTANCE.createWriter();
library.getWriters().add(writer);
writer.setName("JRR Tolkien");
book.setAuthor(writer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.