01: package newprocess.adapter;
02:
03: import newprocess.Expression;
04: import newprocess.NewprocessPackage;
05: import newprocess.OperatorTerm;
06:
07: import org.eclipse.emf.common.notify.Notification;
08: import org.eclipse.emf.common.notify.impl.SingletonAdapterImpl;
09:
10: /**
11: * @author ts
12: * listens on changes of the operator linkings to update the expression
13: *
14: */
15: public class OperatorAdapter extends SingletonAdapterImpl {
16:
17: // Singleton
18: public static OperatorAdapter INSTANCE = new OperatorAdapter();
19:
20: /**
21: * @author ts + sh
22: *
23: * @see org.eclipse.emf.common.notify.impl.SingletonAdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
24: */
25: @Override
26: public void notifyChanged(Notification msg) {
27: super .notifyChanged(msg);
28:
29: // react on Operator - Operator Link creations
30: if (msg.getEventType() == Notification.ADD
31: && msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.OPERATOR_TERM__SUB_TERM) {
32:
33: if (msg.getNotifier() instanceof OperatorTerm
34: && msg.getNewValue() instanceof OperatorTerm)
35: ((OperatorTerm) msg.getNotifier()).performUpdate();
36: }
37:
38: // react on Root - Operator Link creations
39: if (msg.getEventType() == Notification.ADD
40: && msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.ROOT__TERM) {
41:
42: if (msg.getNotifier() instanceof OperatorTerm) {
43: OperatorTerm op = (OperatorTerm) msg.getNotifier();
44: Expression expr = (Expression) op.eContainer();
45: expr.updateExpression();
46: }
47: }
48:
49: // react on Operator - Operator Link changes
50: if (msg.getEventType() == Notification.REMOVE
51: && msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.OPERATOR_TERM__SUB_TERM) {
52: ((OperatorTerm) msg.getNotifier()).performUpdate();
53: }
54: }
55: }
|