01: package newprocess.adapter;
02:
03: import newprocess.ConditionProxy;
04: import newprocess.ConditionTerm;
05: import newprocess.Expression;
06: import newprocess.NewprocessPackage;
07: import newprocess.Root;
08:
09: import org.eclipse.emf.common.notify.Notification;
10: import org.eclipse.emf.common.notify.impl.SingletonAdapterImpl;
11: import org.eclipse.emf.ecore.EObject;
12:
13: /**
14: *
15: * listen for changes of the inverted flag, the condition and update if needed
16: *
17: * @author ts
18: *
19: */
20: public class ProxyAdapter extends SingletonAdapterImpl {
21:
22: // Singelton
23: public static ProxyAdapter INSTANCE = new ProxyAdapter();
24:
25: /**
26: *
27: * @author sh
28: *
29: * @see org.eclipse.emf.common.notify.impl.SingletonAdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
30: */
31: @Override
32: public void notifyChanged(Notification msg) {
33: super .notifyChanged(msg);
34:
35: // react on inverted flag changes
36: if (msg.getEventType() == Notification.SET
37: && msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__INVERTED) {
38: ((ConditionProxy) msg.getNotifier()).performUpdate();
39: }
40:
41: /*
42: // react on proxy name changes
43: else if(msg.getEventType() == Notification.SET &&
44: msg.getFeatureID(ProcessPackage.class) == ProcessPackage.ABSTRACT_PROXY__PROXY_NAME) {
45: ((AbstractProxy)msg.getNotifier()).performUpdate();
46: }
47: */
48: // react on proxy condition changes
49: else if (msg.getEventType() == Notification.SET
50: && msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__CONDITION) {
51: //((ConditionProxy)msg.getNotifier()).updateName();
52: ((ConditionProxy) msg.getNotifier()).performUpdate();
53: }
54:
55: // react on root connection changes
56: else if (msg.getEventType() == Notification.ADD
57: && msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__CONDITION_TERM) {
58: EObject newValue = (EObject) msg.getNewValue();
59: if (newValue instanceof ConditionTerm) {
60: ((Expression) newValue.eContainer()).updateExpression();
61: }
62: }
63:
64: // react on connection reoving
65: else if (msg.getEventType() == Notification.REMOVE
66: && msg.getFeatureID(NewprocessPackage.class) == NewprocessPackage.CONDITION_PROXY__CONDITION_TERM) {
67: EObject oldValue = (EObject) msg.getOldValue();
68: if (oldValue instanceof Root) {
69: Root root = (Root) oldValue;
70: ((Expression) root.eContainer()).updateExpression();
71: } else if (oldValue instanceof ConditionTerm) {
72: ConditionTerm conditinTerm = (ConditionTerm) oldValue;
73: ((Expression) conditinTerm.eContainer())
74: .updateExpression();
75: }
76: }
77: }
78: }
|