use of org.eclipse.emf.ecore.util.EContentAdapter in project openhab1-addons by openhab.
the class TinkerforgeBinding method listen2Model.
/**
* Adds a listener {@link EContentAdapter} to the {@link Ecosystem}. The listener handles updated
* sensor values and posts them to the openhab eventbus by
* {@link #processTFDeviceValues(Notification) processTFDeviceValues}. Furthermore the addition
* and removal of devices is handled by {@link #initializeTFDevices(Notification)
* initializeTFDevices}.
*
* @param tinkerforgeEcosystem The EMF Ecosystem object.
*/
private void listen2Model(Ecosystem tinkerforgeEcosystem) {
EContentAdapter modelAdapter = new EContentAdapter() {
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
logger.debug("TinkerforgeNotifier was notified");
if (notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.ADD_MANY || notification.getEventType() == Notification.REMOVE || notification.getEventType() == Notification.REMOVE_MANY) {
initializeTFDevices(notification);
} else {
processTFDeviceValues(notification);
}
}
};
tinkerforgeEcosystem.eAdapters().add(modelAdapter);
}
use of org.eclipse.emf.ecore.util.EContentAdapter in project xtext-core by eclipse.
the class GenericUnloaderTest method testHandleContentAdapter.
@Test
public void testHandleContentAdapter() throws Exception {
EPackage root = createExample();
EContentAdapter eContentAdapter = new EContentAdapter();
root.eAdapters().add(eContentAdapter);
IReferableElementsUnloader.GenericUnloader genericUnloader = new IReferableElementsUnloader.GenericUnloader();
try {
genericUnloader.unloadRoot(root);
} catch (StackOverflowError e) {
e.printStackTrace();
fail("Unload does not cope with contentAdpaters");
}
// isEmtpy() does not work in EMF 3.5
assertEquals(0, root.eAdapters().size());
}
Aggregations