Java Code Examples for org.eclipse.emf.common.notify.Notification#getOldValue()

The following examples show how to use org.eclipse.emf.common.notify.Notification#getOldValue() . 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: DerivedEObjectEList.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public E setUnique(int index, E object) {

	if (isNotificationRequired()) {
		boolean oldIsSet = isSet();
		Notification notification = createNotification(Notification.SET,
				super.set(index, validate(index, object)), object, index,
				oldIsSet);
		dispatchNotification(notification);
		@SuppressWarnings("unchecked")
		E oldValue = (E) notification.getOldValue();
		return oldValue;
	} else {
		return super.set(index, validate(index, object));
	}
}
 
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: PoolNotificationListener.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void notifyChanged(final Notification notification) {
    final ProcessConfigurationRepositoryStore processConfStore = RepositoryManager.getInstance().getRepositoryStore(
            ProcessConfigurationRepositoryStore.class);
    final DiagramRepositoryStore diagramStore = RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);

    // Listen for changes to features.
    switch (notification.getFeatureID(AbstractProcess.class)) {
        case ProcessPackage.ABSTRACT_PROCESS__ELEMENTS:
            if (NotificationUtil.isElementAddedToSlot(notification) || NotificationUtil.isElementRemovedFromSlot(notification)) {
                final Object newValue = notification.getNewValue();
                if (newValue instanceof Pool) { //Pool added
                    handlePoolAdded(notification, processConfStore);
                } else if (newValue == null && notification.getOldValue() instanceof Pool) {//Pool removed
                    handlePoolRemoved(processConfStore, diagramStore);
                }
            }
            break;
    }
}
 
Example 4
Source File: ScriptModuleImpl.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
protected void customENotify ( final Notification notification )
{
    if ( notification.getFeature ().equals ( ComponentPackage.Literals.SCRIPT_MODULE__INPUTS ) )
    {
        super.eNotify ( new org.eclipse.emf.ecore.impl.ENotificationImpl ( this, notification.getEventType (), ComponentPackage.SCRIPT_MODULE__KNOWN_INPUTS, notification.getOldValue (), notification.getNewValue (), notification.getPosition (), notification.wasSet () ) );
    }
    if ( notification.getFeature ().equals ( ComponentPackage.Literals.SCRIPT_MODULE__OUTPUTS ) )
    {
        super.eNotify ( new org.eclipse.emf.ecore.impl.ENotificationImpl ( this, notification.getEventType (), ComponentPackage.SCRIPT_MODULE__KNOWN_OUTPUTS, notification.getOldValue (), notification.getNewValue (), notification.getPosition (), notification.wasSet () ) );
    }
    super.eNotify ( notification );
}
 
Example 5
Source File: FormulaModuleImpl.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void customENotify ( final Notification notification )
{
    if ( notification.getFeature ().equals ( ComponentPackage.Literals.FORMULA_MODULE__INPUTS ) )
    {
        super.eNotify ( new org.eclipse.emf.ecore.impl.ENotificationImpl ( this, notification.getEventType (), ComponentPackage.CALCULATION_MODULE__KNOWN_INPUTS, notification.getOldValue (), notification.getNewValue () ) );
    }
    super.eNotify ( notification );
}
 
Example 6
Source File: XtextResourceSet.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void notifyChanged(Notification notification) {
	final Map<URI, Resource> map = getURIResourceMap();
	if (map != null && notification.getFeatureID(Resource.class) == Resource.RESOURCE__URI && notification.getNotifier() instanceof Resource) {
		URI oldOne = (URI) notification.getOldValue();
		Resource resource = (Resource) notification.getNotifier();
		updateURI(resource, oldOne, map);
	}
	super.notifyChanged(notification);
}
 
Example 7
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 8
Source File: JvmTypeChangeDispatcher.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isRemoveThis(Notification notification) {
	return notification.getEventType() == Notification.REMOVING_ADAPTER 
			&& notification.getOldValue() == this
			&& notification.getNotifier() == notifier;
}
 
Example 9
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 10
Source File: Notifications.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public boolean isDiagnosticChange(Notification notification) {
	return notification != null && (notification.getOldValue() instanceof Diagnostic || notification.getNewValue() instanceof Diagnostic);
}
 
Example 11
Source File: CustomMessageFlowEditPart.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void updateMessageFlow(Notification notification) {
	MessageFlow messageFlow = (MessageFlow)resolveSemanticElement();
	if(messageFlow==null){
		return ;
	}
	String messageFlowName = messageFlow.getName();

	// old CatchMessage
	Object object = notification.getOldValue();
	if(object instanceof CatchMessageEvent){
		CatchMessageEvent oldTarget = (CatchMessageEvent) object;
		oldTarget.setIncomingMessag(null);
		oldTarget.setEvent("");

	}

	// new CatchMessage
	object = notification.getNewValue();
	if(object instanceof CatchMessageEvent){

		// update CatchMessage
		CatchMessageEvent newTarget = (CatchMessageEvent) object;
		newTarget.setIncomingMessag(messageFlow);
		newTarget.setEvent(messageFlowName);

		// update messageFlow
		messageFlow.setTarget(newTarget);
		ThrowMessageEvent throwMessage = messageFlow.getSource();

		// update message
		for( Message message : throwMessage.getEvents()){
			if(message.getName().equals(messageFlowName)){

				// set CathMessageEvent in the Message
				Expression expr = ExpressionHelper.createConstantExpression(newTarget.getName(), String.class.getName() );
				message.setTargetElementExpression(expr);

				// set pool of the target in the Message
				expr = ExpressionHelper.createConstantExpression(ModelHelper.getParentProcess(newTarget).getName(), String.class.getName() );
				message.setTargetProcessExpression(expr);
				break;
			}
		}
	}
}