Java Code Examples for org.eclipse.emf.common.notify.Notification#REMOVE

The following examples show how to use org.eclipse.emf.common.notify.Notification#REMOVE . 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: DefaultTextEditComposer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean doRecord(Notification notification) {
	if (!recording || notification.isTouch())
		return false;

	switch (notification.getEventType()) {
		case Notification.ADD:
		case Notification.ADD_MANY:
		case Notification.MOVE:
		case Notification.REMOVE:
		case Notification.REMOVE_MANY:
		case Notification.SET:
		case Notification.UNSET:
			return true;
		default:
			return false;
	}
}
 
Example 2
Source File: AbstractEReferenceChangedListener.java    From kieker with Apache License 2.0 6 votes vote down vote up
@Override
public final void notifyChanged(final Notification notification) {
	if (notification.getFeature() == this.listenedFeature) {
		switch (notification.getEventType()) {
		case Notification.ADD:
			this.notifyElementAddedIntern(notification.getNewValue());
			break;
		case Notification.ADD_MANY:
			final List<?> addedOperationTypes = (List<?>) notification.getNewValue();
			addedOperationTypes.forEach(o -> this.notifyElementAddedIntern(o));
			break;
		case Notification.REMOVE:
			this.notifyElementRemovedIntern(notification.getOldValue());
			break;
		case Notification.REMOVE_MANY:
			final List<?> removedOperationTypes = (List<?>) notification.getOldValue();
			removedOperationTypes.forEach(o -> this.notifyElementRemovedIntern(o));
			break;
		default:
			break;
		}
	}

	super.notifyChanged(notification);
}
 
Example 3
Source File: TinkerforgeBinding.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 4
Source File: DerivedAttributeAdapter.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void notifyChanged ( final Notification notification )
{
    if ( notification.getFeature () == null )
    {
        return;
    }

    if ( notification.getFeature ().equals ( this.navigationFeature ) )
    {
        switch ( notification.getEventType () )
        {
        // TODO support ADD_MANY/REMOVE_MANY?
            case Notification.ADD:
                final EObject added = (EObject)notification.getNewValue ();
                added.eAdapters ().add ( this.dependantAdapter );
                break;
            case Notification.SET:
                final EObject newValue = (EObject)notification.getNewValue ();
                final EObject oldValue = (EObject)notification.getOldValue ();
                if ( oldValue != null )
                {
                    oldValue.eAdapters ().remove ( this.dependantAdapter );
                }
                if ( newValue != null )
                {
                    newValue.eAdapters ().add ( this.dependantAdapter );
                }
                break;
            case Notification.REMOVE:
                final EObject removed = (EObject)notification.getOldValue ();
                removed.eAdapters ().remove ( this.dependantAdapter );
                break;
            default:
                return; // No notification
        }
        notifyDerivedAttributeChange ();
    }
    else if ( this.localFeatures.contains ( notification.getFeature () ) )
    {
        notifyDerivedAttributeChange ();
    }
}
 
Example 5
Source File: XtextLinker.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void notifyChanged(Notification msg) {
	super.notifyChanged(msg);
	if (!msg.isTouch() && msg.getOldValue() != null) {
		ResourceSet set;
		Resource notifyingResource;
		if (!(msg.getNotifier() instanceof Resource)) {
			Object feature = msg.getFeature();
			if (!(feature instanceof EReference))
				return;
			EReference ref = (EReference) feature;
			if (!ref.isContainment())
				return;
			notifyingResource = ((EObject) msg.getNotifier()).eResource();
		} else {
			notifyingResource = ((Resource) msg.getNotifier());
		}
		if (notifyingResource == null)
			return;
		set = notifyingResource.getResourceSet();
		if (set == null)
			return;
		switch (msg.getEventType()) {
			case Notification.REMOVE_MANY:
			case Notification.REMOVE:
			case Notification.SET:
				Object oldValue = msg.getOldValue();
				Collection<Resource> resourcesToRemove = Sets.newHashSet();
				Collection<Resource> resourcesToUnload = Sets.newHashSet();
				Collection<Resource> referencedResources = Sets.newHashSet(notifyingResource);
				if (oldValue instanceof Grammar) {
					processMetamodelDeclarations(((Grammar) oldValue).getMetamodelDeclarations(), set, resourcesToRemove,
							resourcesToUnload, referencedResources);
				} else if (oldValue instanceof AbstractMetamodelDeclaration) {
					processMetamodelDeclarations(Collections
							.singletonList((AbstractMetamodelDeclaration) oldValue), set, resourcesToRemove, resourcesToUnload, referencedResources);
				} else if (oldValue instanceof Collection<?>) {
					if (XtextPackage.Literals.GRAMMAR__METAMODEL_DECLARATIONS == msg.getFeature()) {
						Collection<AbstractMetamodelDeclaration> metamodelDeclarations = (Collection<AbstractMetamodelDeclaration>) oldValue;
						processMetamodelDeclarations(metamodelDeclarations, set, resourcesToRemove, resourcesToUnload, referencedResources);
					}
				}
				resourcesToRemove.removeAll(referencedResources);
				if (unloader != null) {
					resourcesToUnload.removeAll(referencedResources);
					for (Resource resource : resourcesToUnload) {
						if(resource.getResourceSet() == set) {
							for (EObject content : resource.getContents())
								unloader.unloadRoot(content);
						}
					}
				}
				set.getResources().removeAll(resourcesToRemove);
				break;
			default:
				break;
		}
	}
}
 
Example 6
Source File: TaskSelectData.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void changeTask( Notification notification )
{
	if ( previewPainter != null )
	{
		if ( notification == null )
		{
			if ( getChartModel( ) instanceof ChartWithAxes )
			{
				checkDataTypeForChartWithAxes( );
			}
			return;
		}

		// if remove the seriesDefition, remove the error messages
		// associated to it
		if ( notification.getEventType( ) == Notification.REMOVE
				&& notification.getNotifier( ) instanceof Axis )
		{
			ChartWizard.removeAllExceptions( "" + notification.getOldValue( ) //$NON-NLS-1$
					.hashCode( ) );
		}

		if ( ( notification.getNotifier( ) instanceof Query && ( (Query) notification.getNotifier( ) ).eContainer( ) instanceof Series ) )
		{
			checkDataType( (Query) notification.getNotifier( ),
					(Series) ( (Query) notification.getNotifier( ) ).eContainer( ) );
		}

		if ( notification.getNotifier( ) instanceof SeriesDefinition
				&& getChartModel( ) instanceof ChartWithAxes )
		{
			checkDataTypeForChartWithAxes( );
		}

		// Notify change to customize UI
		getCustomizeUI( ).notifyChange( notification );

		// Query and series change need to update Live Preview
		if ( notification.getNotifier( ) instanceof Query
				|| notification.getNotifier( ) instanceof Axis
				|| notification.getNotifier( ) instanceof SeriesDefinition
				|| notification.getNotifier( ) instanceof SeriesGrouping )
		{
			doPreview( );
		}
		else if ( ChartPreviewPainterBase.isLivePreviewActive( ) )
		{
			ChartAdapter.beginIgnoreNotifications( );
			ChartUIUtil.syncRuntimeSeries( getChartModel( ) );
			ChartAdapter.endIgnoreNotifications( );

			doPreview( );
		}
		else
		{
			doPreview( );
		}
	}
}