package newprocess.adapter;
import newprocess.ConditionProxy;
import newprocess.ConditionTerm;
import newprocess.Expression;
import newprocess.NewprocessPackage;
import newprocess.Root;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.SingletonAdapterImpl;
import org.eclipse.emf.ecore.EObject;
/**
*
* listen for changes of the inverted flag, the condition and update if needed
*
* @author ts
*
*/
public class ProxyAdapter extends SingletonAdapterImpl {
// Singelton
public static ProxyAdapter INSTANCE = new ProxyAdapter();
/**
*
* @author sh
*
* @see org.eclipse.emf.common.notify.impl.SingletonAdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
*/
@Override
public void notifyChanged(Notification msg) {
super.notifyChanged(msg);
// react on inverted flag changes
if(msg.getEventType() == Notification.SET &&
msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__INVERTED) {
((ConditionProxy)msg.getNotifier()).performUpdate();
}
/*
// react on proxy name changes
else if(msg.getEventType() == Notification.SET &&
msg.getFeatureID(ProcessPackage.class) == ProcessPackage.ABSTRACT_PROXY__PROXY_NAME) {
((AbstractProxy)msg.getNotifier()).performUpdate();
}
*/
// react on proxy condition changes
else if(msg.getEventType() == Notification.SET &&
msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__CONDITION) {
//((ConditionProxy)msg.getNotifier()).updateName();
((ConditionProxy)msg.getNotifier()).performUpdate();
}
// react on root connection changes
else if(msg.getEventType() == Notification.ADD &&
msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__CONDITION_TERM) {
EObject newValue = (EObject)msg.getNewValue();
if(newValue instanceof ConditionTerm) {
((Expression)newValue.eContainer()).updateExpression();
}
}
// react on connection reoving
else if(msg.getEventType() == Notification.REMOVE &&
msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__CONDITION_TERM) {
EObject oldValue = (EObject)msg.getOldValue();
if(oldValue instanceof Root) {
Root root = (Root)oldValue;
((Expression)root.eContainer()).updateExpression();
}
else if(oldValue instanceof ConditionTerm) {
ConditionTerm conditinTerm = (ConditionTerm)oldValue;
((Expression)conditinTerm.eContainer()).updateExpression();
}
}
}
}
|