org.eclipse.emf.ecore.util.EContentAdapter Java Examples
The following examples show how to use
org.eclipse.emf.ecore.util.EContentAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4JSResource.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Creates a custom notification and sends it for proxy and loaded object. Registers adapters to loaded object. * * @param idx * index in the contents list (first or second slot) * @param oldProxy * the proxified object before being loaded */ protected void notifyProxyResolved(int idx, EObject oldProxy) { if (eNotificationRequired() && idx < contents.size()) { EObject newObject = contents.basicGet(idx); Notification notification = new NotificationImpl(Notification.RESOLVE, oldProxy, newObject) { @Override public Object getNotifier() { return N4JSResource.this; } @Override public int getFeatureID(Class<?> expectedClass) { return RESOURCE__CONTENTS; } }; eNotify(notification); for (Adapter adapter : eAdapters()) { if (adapter instanceof EContentAdapter && !newObject.eAdapters().contains(adapter)) { newObject.eAdapters().add(adapter); } } } }
Example #2
Source File: TinkerforgeBinding.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * 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); }
Example #3
Source File: GenericUnloaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example #4
Source File: ManageOrganizationWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void addActiveOrganizationAdapter(final Organization orga) { activeOrganization = orga; final EContentAdapter adapter = new EContentAdapter() { @Override public void notifyChanged(final Notification notification) { super.notifyChanged(notification); activeOrganizationHasBeenModified = true; if (notification.getFeatureID(Organization.class) == OrganizationPackage.ORGANIZATION__NAME) { newActiveOrganizationName = Optional.ofNullable((String) notification.getNewValue()); } } }; activeOrganization.eAdapters().add(adapter); }
Example #5
Source File: TaskSelectType.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void updateAdapters( ) { EObject model = getChartModelObject( ); if ( container instanceof ChartWizard ) { // Refresh all adapters EContentAdapter adapter = ( (ChartWizard) container ).getAdapter( ); model.eAdapters( ).remove( adapter ); TreeIterator<EObject> iterator = model.eAllContents( ); while ( iterator.hasNext( ) ) { EObject oModel = iterator.next( ); oModel.eAdapters( ).remove( adapter ); } model.eAdapters( ).add( adapter ); } else { // For extension case, create an adapter and add change listener EList<Adapter> adapters = model.eAdapters( ); if ( adapters.isEmpty( ) ) { // Get the previous adapter if existent if ( adapter == null ) { adapter = new ChartAdapter( container ); adapter.addListener( this ); } adapters.add( adapter ); } else { if ( adapters.get( 0 ) instanceof ChartAdapter ) { ( (ChartAdapter) adapters.get( 0 ) ).addListener( this ); } } } }
Example #6
Source File: ChartWizard.java From birt with Eclipse Public License 1.0 | 4 votes |
public EContentAdapter getAdapter( ) { return adapter; }