类org.eclipse.emf.ecore.util.EContentAdapter源码实例Demo

下面列出了怎么用org.eclipse.emf.ecore.util.EContentAdapter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: n4js   文件: N4JSResource.java
/**
 * 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);
			}
		}
	}
}
 
源代码2 项目: openhab1-addons   文件: TinkerforgeBinding.java
/**
 * 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);
}
 
源代码3 项目: xtext-core   文件: GenericUnloaderTest.java
@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());
}
 
源代码4 项目: bonita-studio   文件: ManageOrganizationWizard.java
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);
}
 
源代码5 项目: birt   文件: TaskSelectType.java
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 );
			}
		}
	}
}
 
源代码6 项目: birt   文件: ChartWizard.java
public EContentAdapter getAdapter( )
{
	return adapter;
}
 
 类所在包
 类方法
 同包方法