1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
package org.argouml.notation.providers; |
15 | |
|
16 | |
import java.util.Collection; |
17 | |
import java.util.Iterator; |
18 | |
|
19 | |
import org.argouml.model.Model; |
20 | |
import org.argouml.notation.NotationProvider; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | 0 | class NotationUtilityProviders { |
28 | |
|
29 | |
|
30 | |
static void addListenersForTransition(NotationProvider np, |
31 | |
Object transition) { |
32 | 0 | np.addElementListener(transition, |
33 | |
new String[] {"guard", "trigger", "effect"}); |
34 | |
|
35 | 0 | Object guard = Model.getFacade().getGuard(transition); |
36 | 0 | if (guard != null) { |
37 | 0 | np.addElementListener(guard, "expression"); |
38 | |
|
39 | |
} |
40 | |
|
41 | 0 | Object trigger = Model.getFacade().getTrigger(transition); |
42 | 0 | addListenersForEvent(np, trigger); |
43 | |
|
44 | 0 | Object effect = Model.getFacade().getEffect(transition); |
45 | 0 | addListenersForAction(np, effect); |
46 | 0 | } |
47 | |
|
48 | |
static private void addListenersForEvent(NotationProvider np, |
49 | |
Object event) { |
50 | 0 | if (event != null) { |
51 | 0 | if (Model.getFacade().isAEvent(event)) { |
52 | 0 | np.addElementListener(event, |
53 | |
new String[] { |
54 | |
"parameter", "name"}); |
55 | |
} |
56 | 0 | if (Model.getFacade().isATimeEvent(event)) { |
57 | 0 | np.addElementListener(event, new String[] {"when"}); |
58 | |
} |
59 | 0 | if (Model.getFacade().isAChangeEvent(event)) { |
60 | 0 | np.addElementListener(event, |
61 | |
new String[] {"changeExpression"}); |
62 | |
} |
63 | |
|
64 | 0 | Collection prms = Model.getFacade().getParameters(event); |
65 | 0 | Iterator i = prms.iterator(); |
66 | 0 | while (i.hasNext()) { |
67 | 0 | Object parameter = i.next(); |
68 | 0 | np.addElementListener(parameter, |
69 | |
new String[] {"defaultValue", "name", "type", "kind"}); |
70 | 0 | } |
71 | |
} |
72 | 0 | } |
73 | |
|
74 | |
static void addListenersForAction(NotationProvider np, |
75 | |
Object action) { |
76 | 0 | if (action != null) { |
77 | 0 | np.addElementListener(action, |
78 | |
new String[] { |
79 | |
"script", "actualArgument", "action" |
80 | |
}); |
81 | |
|
82 | 0 | Collection args = Model.getFacade().getActualArguments(action); |
83 | 0 | Iterator i = args.iterator(); |
84 | 0 | while (i.hasNext()) { |
85 | 0 | Object argument = i.next(); |
86 | 0 | np.addElementListener(argument, "value"); |
87 | 0 | } |
88 | 0 | if (Model.getFacade().isAActionSequence(action)) { |
89 | 0 | Collection subactions = Model.getFacade().getActions(action); |
90 | 0 | i = subactions.iterator(); |
91 | 0 | while (i.hasNext()) { |
92 | 0 | Object a = i.next(); |
93 | 0 | addListenersForAction(np, a); |
94 | 0 | } |
95 | |
} |
96 | |
} |
97 | 0 | } |
98 | |
|
99 | |
} |