1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
package org.argouml.model.mdr; |
41 | |
|
42 | |
import java.util.ArrayList; |
43 | |
import java.util.Collection; |
44 | |
import java.util.Iterator; |
45 | |
import java.util.List; |
46 | |
|
47 | |
import javax.jmi.reflect.InvalidObjectException; |
48 | |
|
49 | |
import org.argouml.model.CommonBehaviorHelper; |
50 | |
import org.argouml.model.InvalidElementException; |
51 | |
import org.argouml.model.Model; |
52 | |
import org.omg.uml.behavioralelements.collaborations.ClassifierRole; |
53 | |
import org.omg.uml.behavioralelements.collaborations.Message; |
54 | |
import org.omg.uml.behavioralelements.commonbehavior.Action; |
55 | |
import org.omg.uml.behavioralelements.commonbehavior.ActionSequence; |
56 | |
import org.omg.uml.behavioralelements.commonbehavior.Argument; |
57 | |
import org.omg.uml.behavioralelements.commonbehavior.AttributeLink; |
58 | |
import org.omg.uml.behavioralelements.commonbehavior.CallAction; |
59 | |
import org.omg.uml.behavioralelements.commonbehavior.ComponentInstance; |
60 | |
import org.omg.uml.behavioralelements.commonbehavior.CreateAction; |
61 | |
import org.omg.uml.behavioralelements.commonbehavior.Instance; |
62 | |
import org.omg.uml.behavioralelements.commonbehavior.Link; |
63 | |
import org.omg.uml.behavioralelements.commonbehavior.LinkEnd; |
64 | |
import org.omg.uml.behavioralelements.commonbehavior.NodeInstance; |
65 | |
import org.omg.uml.behavioralelements.commonbehavior.Reception; |
66 | |
import org.omg.uml.behavioralelements.commonbehavior.SendAction; |
67 | |
import org.omg.uml.behavioralelements.commonbehavior.Signal; |
68 | |
import org.omg.uml.behavioralelements.commonbehavior.Stimulus; |
69 | |
import org.omg.uml.behavioralelements.statemachines.CallEvent; |
70 | |
import org.omg.uml.behavioralelements.statemachines.Guard; |
71 | |
import org.omg.uml.behavioralelements.statemachines.SignalEvent; |
72 | |
import org.omg.uml.behavioralelements.statemachines.StateVertex; |
73 | |
import org.omg.uml.behavioralelements.statemachines.Transition; |
74 | |
import org.omg.uml.foundation.core.BehavioralFeature; |
75 | |
import org.omg.uml.foundation.core.Classifier; |
76 | |
import org.omg.uml.foundation.core.Operation; |
77 | |
import org.omg.uml.foundation.core.TaggedValue; |
78 | |
import org.omg.uml.foundation.datatypes.ActionExpression; |
79 | |
import org.omg.uml.foundation.datatypes.Expression; |
80 | |
import org.omg.uml.foundation.datatypes.IterationExpression; |
81 | |
import org.omg.uml.foundation.datatypes.ObjectSetExpression; |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | 0 | class CommonBehaviorHelperMDRImpl implements CommonBehaviorHelper { |
92 | |
|
93 | |
private MDRModelImplementation modelImpl; |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | 900 | public CommonBehaviorHelperMDRImpl(MDRModelImplementation implementation) { |
102 | 900 | this.modelImpl = implementation; |
103 | 900 | } |
104 | |
|
105 | |
|
106 | |
public Object getSource(Object link) { |
107 | |
try { |
108 | 0 | if (link instanceof Link) { |
109 | 0 | return modelImpl.getCoreHelper().getSource(link); |
110 | |
} |
111 | 0 | } catch (InvalidObjectException e) { |
112 | 0 | throw new InvalidElementException(e); |
113 | 0 | } |
114 | 0 | throw new IllegalArgumentException("Argument is not a link"); |
115 | |
} |
116 | |
|
117 | |
|
118 | |
public Object getDestination(Object link) { |
119 | |
try { |
120 | 0 | if (link instanceof Link) { |
121 | 0 | return modelImpl.getCoreHelper().getDestination(link); |
122 | |
} |
123 | 0 | } catch (InvalidObjectException e) { |
124 | 0 | throw new InvalidElementException(e); |
125 | 0 | } |
126 | 0 | throw new IllegalArgumentException("Argument is not a link"); |
127 | |
} |
128 | |
|
129 | |
|
130 | |
public void removeActualArgument(Object handle, Object argument) { |
131 | |
try { |
132 | 0 | if (handle instanceof Action && argument instanceof Argument) { |
133 | 0 | ((Action) handle).getActualArgument().remove(argument); |
134 | 0 | return; |
135 | |
} |
136 | 0 | } catch (InvalidObjectException e) { |
137 | 0 | throw new InvalidElementException(e); |
138 | 0 | } |
139 | 0 | throw new IllegalArgumentException("Unrecognized object " + handle |
140 | |
+ " or " + argument); |
141 | |
} |
142 | |
|
143 | |
|
144 | |
public void setActualArguments(Object action, List arguments) { |
145 | |
try { |
146 | 0 | if (action instanceof Action) { |
147 | 0 | ((Action) action).getActualArgument().clear(); |
148 | 0 | ((Action) action).getActualArgument().addAll(arguments); |
149 | 0 | return; |
150 | |
} |
151 | 0 | } catch (InvalidObjectException e) { |
152 | 0 | throw new InvalidElementException(e); |
153 | 0 | } |
154 | 0 | throw new IllegalArgumentException("Unrecognized object " + action |
155 | |
+ " or " + arguments); |
156 | |
} |
157 | |
|
158 | |
|
159 | |
public void removeClassifier(Object handle, Object classifier) { |
160 | |
try { |
161 | 0 | if (handle instanceof Instance |
162 | |
&& classifier instanceof Classifier) { |
163 | 0 | ((Instance) handle).getClassifier().remove(classifier); |
164 | 0 | return; |
165 | |
} |
166 | 0 | } catch (InvalidObjectException e) { |
167 | 0 | throw new InvalidElementException(e); |
168 | 0 | } |
169 | 0 | throw new IllegalArgumentException("Unrecognized object " + handle |
170 | |
+ " or " + classifier); |
171 | |
} |
172 | |
|
173 | |
|
174 | |
public void removeContext(Object handle, Object context) { |
175 | |
try { |
176 | 0 | if (handle instanceof Signal |
177 | |
&& context instanceof BehavioralFeature) { |
178 | 0 | ((org.omg.uml.UmlPackage) ((Signal) handle) |
179 | |
.refOutermostPackage()).getCommonBehavior() |
180 | |
.getAContextRaisedSignal().remove( |
181 | |
(BehavioralFeature) context, (Signal) handle); |
182 | 0 | return; |
183 | |
} |
184 | 0 | } catch (InvalidObjectException e) { |
185 | 0 | throw new InvalidElementException(e); |
186 | 0 | } |
187 | 0 | throw new IllegalArgumentException("Unrecognized object " + handle |
188 | |
+ " or " + context); |
189 | |
} |
190 | |
|
191 | |
|
192 | |
public void removeReception(Object handle, Object reception) { |
193 | |
try { |
194 | 0 | if (handle instanceof Signal && reception instanceof Reception) { |
195 | |
|
196 | |
|
197 | 0 | ((Reception) reception).setSignal(null); |
198 | 0 | return; |
199 | |
} |
200 | 0 | } catch (InvalidObjectException e) { |
201 | 0 | throw new InvalidElementException(e); |
202 | 0 | } |
203 | 0 | throw new IllegalArgumentException("Unrecognized object " + handle |
204 | |
+ " or " + reception); |
205 | |
} |
206 | |
|
207 | |
|
208 | |
public void addActualArgument(Object handle, Object argument) { |
209 | 0 | if (handle instanceof Action && argument instanceof Argument) { |
210 | 0 | ((Action) handle).getActualArgument().add((Argument) argument); |
211 | 0 | return; |
212 | |
} |
213 | 0 | throw new IllegalArgumentException("Unrecognized object " + handle |
214 | |
+ " or " + argument); |
215 | |
} |
216 | |
|
217 | |
|
218 | |
public void addActualArgument(Object handle, int position, |
219 | |
Object argument) { |
220 | 0 | if (handle instanceof Action && argument instanceof Argument) { |
221 | |
try { |
222 | 0 | ((Action) handle).getActualArgument().add(position, |
223 | |
(Argument) argument); |
224 | 0 | } catch (InvalidObjectException e) { |
225 | 0 | throw new InvalidElementException(e); |
226 | 0 | } |
227 | |
} else { |
228 | 0 | throw new IllegalArgumentException(); |
229 | |
} |
230 | 0 | } |
231 | |
|
232 | |
|
233 | |
public void addClassifier(Object handle, Object classifier) { |
234 | 0 | if (handle instanceof Instance && classifier instanceof Classifier) { |
235 | 0 | ((Instance) handle).getClassifier().add((Classifier) classifier); |
236 | 0 | return; |
237 | |
} |
238 | 0 | throw new IllegalArgumentException("Unrecognized object " + handle |
239 | |
+ " or " + classifier); |
240 | |
} |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
private void addContext(Object handle, Object behavorialFeature) { |
249 | 0 | if (handle instanceof Signal |
250 | |
&& behavorialFeature instanceof BehavioralFeature) { |
251 | 0 | ((org.omg.uml.UmlPackage) ((Signal) handle).refOutermostPackage()) |
252 | |
.getCommonBehavior().getAContextRaisedSignal().add( |
253 | |
(BehavioralFeature) behavorialFeature, |
254 | |
(Signal) handle); |
255 | 0 | return; |
256 | |
} |
257 | 0 | } |
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
private void addReception(Object handle, Object rec) { |
266 | 0 | if (handle instanceof Signal |
267 | |
&& rec instanceof Reception) { |
268 | 0 | ((Reception) rec).setSignal((Signal) handle); |
269 | 0 | return; |
270 | |
} |
271 | 0 | } |
272 | |
|
273 | |
|
274 | |
public void addStimulus(Object handle, Object stimulus) { |
275 | 0 | if (handle != null && stimulus != null |
276 | |
&& stimulus instanceof Stimulus) { |
277 | 0 | if (handle instanceof Action) { |
278 | 0 | ((Stimulus) stimulus).setDispatchAction((Action) handle); |
279 | 0 | return; |
280 | |
} |
281 | 0 | if (handle instanceof Link) { |
282 | 0 | ((Stimulus) stimulus).setCommunicationLink((Link) handle); |
283 | 0 | return; |
284 | |
} |
285 | |
} |
286 | 0 | throw new IllegalArgumentException("handle: " + handle |
287 | |
+ " or stimulus: " + stimulus); |
288 | |
} |
289 | |
|
290 | |
|
291 | |
public void setAsynchronous(Object handle, boolean value) { |
292 | 0 | if (handle instanceof Action) { |
293 | 0 | ((Action) handle).setAsynchronous(value); |
294 | 0 | return; |
295 | |
} |
296 | 0 | throw new IllegalArgumentException("handle: " + handle); |
297 | |
} |
298 | |
|
299 | |
|
300 | |
public void setOperation(Object handle, Object operation) { |
301 | 0 | if (handle instanceof CallAction |
302 | |
&& (operation == null || operation instanceof Operation)) { |
303 | 0 | ((CallAction) handle).setOperation((Operation) operation); |
304 | 0 | return; |
305 | |
} |
306 | 0 | if (handle instanceof CallEvent |
307 | |
&& (operation == null || operation instanceof Operation)) { |
308 | 0 | ((CallEvent) handle).setOperation((Operation) operation); |
309 | 0 | return; |
310 | |
} |
311 | 0 | throw new IllegalArgumentException("handle: " + handle |
312 | |
+ " or operation: " + operation); |
313 | |
} |
314 | |
|
315 | |
|
316 | |
public void setClassifiers(Object handle, Collection classifiers) { |
317 | 0 | if (handle instanceof Instance) { |
318 | 0 | ((Instance) handle).getClassifier().retainAll(classifiers); |
319 | 0 | ((Instance) handle).getClassifier().addAll(classifiers); |
320 | 0 | return; |
321 | |
} |
322 | 0 | throw new IllegalArgumentException("handle: " + handle); |
323 | |
} |
324 | |
|
325 | |
|
326 | |
public void setCommunicationLink(Object handle, Object c) { |
327 | 0 | if (handle instanceof Stimulus && c instanceof Link) { |
328 | 0 | ((Stimulus) handle).setCommunicationLink((Link) c); |
329 | 0 | return; |
330 | |
} |
331 | 0 | throw new IllegalArgumentException("handle: " + handle + " or c: " + c); |
332 | |
} |
333 | |
|
334 | |
|
335 | |
public void setComponentInstance(Object handle, Object c) { |
336 | 0 | if (handle instanceof Instance |
337 | |
&& (c == null || c instanceof ComponentInstance)) { |
338 | 0 | ((Instance) handle).setComponentInstance((ComponentInstance) c); |
339 | 0 | return; |
340 | |
} |
341 | 0 | throw new IllegalArgumentException("handle: " + handle + " or c: " + c); |
342 | |
} |
343 | |
|
344 | |
|
345 | |
public void setContexts(Object handle, Collection c) { |
346 | 0 | if (handle instanceof Signal) { |
347 | 0 | Collection actualContexts = Model.getFacade().getContexts(handle); |
348 | 0 | if (!actualContexts.isEmpty()) { |
349 | 0 | Collection contexts = new ArrayList(actualContexts); |
350 | 0 | for (Object context : contexts) { |
351 | 0 | removeContext(handle, context); |
352 | |
} |
353 | |
} |
354 | 0 | for (Object context : c) { |
355 | 0 | addContext(handle, context); |
356 | |
} |
357 | 0 | return; |
358 | |
} |
359 | 0 | throw new IllegalArgumentException("handle: " + handle); |
360 | |
} |
361 | |
|
362 | |
|
363 | |
public void setDispatchAction(Object handle, Object value) { |
364 | 0 | if (handle instanceof Stimulus |
365 | |
&& (value == null || value instanceof Action)) { |
366 | 0 | ((Stimulus) handle).setDispatchAction((Action) value); |
367 | 0 | return; |
368 | |
} |
369 | 0 | throw new IllegalArgumentException("handle: " + handle + " or value: " |
370 | |
+ value); |
371 | |
} |
372 | |
|
373 | |
|
374 | |
public void setInstance(Object handle, Object inst) { |
375 | 0 | if (inst == null || inst instanceof Instance) { |
376 | 0 | if (handle instanceof LinkEnd) { |
377 | 0 | ((LinkEnd) handle).setInstance((Instance) inst); |
378 | 0 | return; |
379 | |
} |
380 | 0 | if (handle instanceof AttributeLink) { |
381 | 0 | ((AttributeLink) handle).setInstance((Instance) inst); |
382 | 0 | return; |
383 | |
} |
384 | |
} |
385 | 0 | throw new IllegalArgumentException("handle: " + handle + " or inst: " |
386 | |
+ inst); |
387 | |
} |
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
public void setNodeInstance(Object handle, Object nodeInstance) { |
394 | 0 | if (handle instanceof ComponentInstance |
395 | |
&& nodeInstance instanceof NodeInstance) { |
396 | 0 | ((ComponentInstance) handle). |
397 | |
setNodeInstance((NodeInstance) nodeInstance); |
398 | 0 | return; |
399 | 0 | } else if (handle instanceof ComponentInstance |
400 | |
&& nodeInstance == null) { |
401 | |
|
402 | 0 | ((ComponentInstance) handle).setNodeInstance(null); |
403 | 0 | return; |
404 | |
} |
405 | |
|
406 | 0 | throw new IllegalArgumentException("handle: " + handle |
407 | |
+ " or nodeInstance: " + nodeInstance); |
408 | |
} |
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
public void setReceiver(Object handle, Object receiver) { |
415 | 0 | if (handle instanceof Message |
416 | |
&& (receiver instanceof ClassifierRole || receiver == null)) { |
417 | 0 | ((Message) handle).setReceiver((ClassifierRole) receiver); |
418 | 0 | return; |
419 | |
} |
420 | 0 | if (handle instanceof Stimulus && receiver instanceof Instance) { |
421 | 0 | ((Stimulus) handle).setReceiver((Instance) receiver); |
422 | 0 | return; |
423 | |
} |
424 | 0 | throw new IllegalArgumentException("handle: " + handle |
425 | |
+ " or receiver: " + receiver); |
426 | |
} |
427 | |
|
428 | |
|
429 | |
public void setReception(Object handle, Collection c) { |
430 | 0 | if (handle instanceof Signal) { |
431 | 0 | Collection actualReceptions = |
432 | |
Model.getFacade().getReceptions(handle); |
433 | 0 | if (!actualReceptions.isEmpty()) { |
434 | 0 | Collection receptions = new ArrayList(actualReceptions); |
435 | 0 | for (Object reception : receptions) { |
436 | 0 | removeReception(handle, reception); |
437 | |
} |
438 | |
} |
439 | 0 | for (Object reception : c) { |
440 | 0 | addReception(handle, reception); |
441 | |
} |
442 | 0 | return; |
443 | |
} |
444 | 0 | throw new IllegalArgumentException("handle: " + handle); |
445 | |
} |
446 | |
|
447 | |
|
448 | |
public void setRecurrence(Object handle, Object expr) { |
449 | 0 | Action action = (Action) handle; |
450 | 0 | IterationExpression oldExpr = action.getRecurrence(); |
451 | 0 | IterationExpression newExpr = (IterationExpression) expr; |
452 | 0 | if (!equal(oldExpr, newExpr)) { |
453 | 0 | action.setRecurrence(newExpr); |
454 | 0 | if (oldExpr != null) { |
455 | 0 | Model.getUmlFactory().delete(oldExpr); |
456 | |
} |
457 | |
} |
458 | 0 | } |
459 | |
|
460 | |
private boolean equal(Expression expr1, Expression expr2) { |
461 | 0 | if (expr1 == null) { |
462 | 0 | if (expr2 == null) { |
463 | 0 | return true; |
464 | |
} else { |
465 | 0 | return false; |
466 | |
} |
467 | |
} else { |
468 | 0 | return expr1.equals(expr2); |
469 | |
} |
470 | |
} |
471 | |
|
472 | |
public void setScript(Object handle, Object expr) { |
473 | 0 | if (handle instanceof Action |
474 | |
&& (expr == null || expr instanceof ActionExpression)) { |
475 | 0 | Action a = (Action) handle; |
476 | 0 | ActionExpression oldae =a.getScript(); |
477 | 0 | ActionExpression newae = (ActionExpression) expr; |
478 | 0 | if (equal(oldae,newae)) { |
479 | 0 | return; |
480 | |
} |
481 | 0 | a.setScript(newae); |
482 | 0 | if (oldae != null) { |
483 | |
|
484 | 0 | modelImpl.getUmlFactory().delete(oldae); |
485 | |
} |
486 | 0 | return; |
487 | |
} |
488 | 0 | throw new IllegalArgumentException("handle: " + handle + " or expr: " |
489 | |
+ expr); |
490 | |
} |
491 | |
|
492 | |
|
493 | |
public void setSender(Object handle, Object sender) { |
494 | 0 | if (handle instanceof Message |
495 | |
&& (sender instanceof ClassifierRole || sender == null)) { |
496 | 0 | ((Message) handle).setSender((ClassifierRole) sender); |
497 | 0 | return; |
498 | |
} |
499 | 0 | if (handle instanceof Stimulus && sender instanceof Instance) { |
500 | 0 | ((Stimulus) handle).setSender((Instance) sender); |
501 | 0 | return; |
502 | |
} |
503 | 0 | throw new IllegalArgumentException("handle: " + handle + " or sender: " |
504 | |
+ sender); |
505 | |
} |
506 | |
|
507 | |
|
508 | |
public void setSignal(Object handle, Object signal) { |
509 | 0 | if (signal == null || signal instanceof Signal) { |
510 | 0 | if (handle instanceof SendAction) { |
511 | 0 | ((SendAction) handle).setSignal((Signal) signal); |
512 | 0 | return; |
513 | |
} |
514 | 0 | if (handle instanceof Reception) { |
515 | 0 | ((Reception) handle).setSignal((Signal) signal); |
516 | 0 | return; |
517 | |
} |
518 | 0 | if (handle instanceof SignalEvent) { |
519 | 0 | ((SignalEvent) handle).setSignal((Signal) signal); |
520 | 0 | return; |
521 | |
} |
522 | |
} |
523 | 0 | throw new IllegalArgumentException("handle: " + handle + " or signal: " |
524 | |
+ signal); |
525 | |
} |
526 | |
|
527 | |
|
528 | |
public void setSpecification(Object handle, String specification) { |
529 | 0 | if (handle instanceof Reception) { |
530 | 0 | ((Reception) handle).setSpecification(specification); |
531 | 0 | return; |
532 | |
} |
533 | 0 | throw new IllegalArgumentException("handle: " + handle); |
534 | |
} |
535 | |
|
536 | |
|
537 | |
public void setTarget(Object handle, Object element) { |
538 | 0 | if (handle instanceof Action |
539 | |
&& element instanceof ObjectSetExpression) { |
540 | 0 | Action action = (Action) handle; |
541 | 0 | ObjectSetExpression oldExpr = action.getTarget(); |
542 | 0 | ObjectSetExpression newExpr = (ObjectSetExpression) element; |
543 | 0 | if (!equal(oldExpr, newExpr)) { |
544 | 0 | action.setTarget(newExpr); |
545 | 0 | if (oldExpr != null) { |
546 | 0 | Model.getUmlFactory().delete(oldExpr); |
547 | |
} |
548 | |
} |
549 | 0 | return; |
550 | |
} |
551 | 0 | if (handle instanceof Transition && |
552 | |
(element == null || element instanceof StateVertex)) { |
553 | 0 | ((Transition) handle).setTarget((StateVertex) element); |
554 | 0 | return; |
555 | |
} |
556 | 0 | throw new IllegalArgumentException("handle: " + handle |
557 | |
+ " or element: " + element); |
558 | |
} |
559 | |
|
560 | |
|
561 | |
public void setTransition(Object handle, Object trans) { |
562 | 0 | if (trans instanceof Transition) { |
563 | 0 | if (handle instanceof Guard) { |
564 | 0 | ((Guard) handle).setTransition((Transition) trans); |
565 | 0 | return; |
566 | |
} |
567 | 0 | if (handle instanceof Action) { |
568 | 0 | ((Transition) trans).setEffect((Action) handle); |
569 | 0 | return; |
570 | |
} |
571 | |
} |
572 | 0 | throw new IllegalArgumentException("handle: " + handle + " or trans: " |
573 | |
+ trans); |
574 | |
} |
575 | |
|
576 | |
|
577 | |
public void setValue(Object handle, Object value) { |
578 | 0 | if (handle instanceof Argument) { |
579 | 0 | ((Argument) handle).setValue((Expression) value); |
580 | 0 | Argument argument = (Argument) handle; |
581 | 0 | Expression oldExpr = argument.getValue(); |
582 | 0 | Expression newExpr = (Expression) value; |
583 | 0 | if (!equal(oldExpr, newExpr)) { |
584 | 0 | argument.setValue(newExpr); |
585 | 0 | if (oldExpr != null) { |
586 | 0 | Model.getUmlFactory().delete(oldExpr); |
587 | |
} |
588 | |
} |
589 | 0 | return; |
590 | |
} |
591 | 0 | if (handle instanceof AttributeLink) { |
592 | 0 | ((AttributeLink) handle).setValue((Instance) value); |
593 | 0 | return; |
594 | |
} |
595 | 0 | if (handle instanceof TaggedValue && value instanceof String) { |
596 | 0 | modelImpl.getExtensionMechanismsHelper().setDataValues(handle, |
597 | |
new String[] {(String) value}); |
598 | 0 | return; |
599 | |
} |
600 | 0 | throw new IllegalArgumentException("handle: " + handle + ", value:" |
601 | |
+ value); |
602 | |
} |
603 | |
|
604 | |
|
605 | |
public Classifier getInstantiation(Object createaction) { |
606 | |
try { |
607 | 0 | if (createaction instanceof CreateAction) { |
608 | 0 | return ((CreateAction) createaction).getInstantiation(); |
609 | |
} |
610 | 0 | } catch (InvalidObjectException e) { |
611 | 0 | throw new InvalidElementException(e); |
612 | 0 | } |
613 | 0 | throw new IllegalArgumentException("handle: " + createaction); |
614 | |
} |
615 | |
|
616 | |
|
617 | |
public void setInstantiation(Object createaction, Object instantiation) { |
618 | 0 | if (createaction instanceof CreateAction) { |
619 | 0 | if (instantiation instanceof Classifier) { |
620 | 0 | ((CreateAction) createaction).setInstantiation( |
621 | |
(Classifier) instantiation); |
622 | 0 | return; |
623 | |
} |
624 | 0 | if (instantiation == null) |
625 | 0 | ((CreateAction) createaction).setInstantiation(null); |
626 | 0 | return; |
627 | |
} |
628 | 0 | throw new IllegalArgumentException("handle: " + createaction |
629 | |
+ ", value:" + instantiation); |
630 | |
|
631 | |
} |
632 | |
|
633 | |
|
634 | |
public Object getActionOwner(Object action) { |
635 | 0 | if (!(action instanceof Action)) { |
636 | 0 | throw new IllegalArgumentException(); |
637 | |
} |
638 | |
|
639 | |
try { |
640 | 0 | if (Model.getFacade().getStimuli(action) != null) { |
641 | 0 | Iterator iter = Model.getFacade().getStimuli(action).iterator(); |
642 | 0 | if (iter.hasNext()) { |
643 | 0 | return iter.next(); |
644 | |
} |
645 | |
} |
646 | 0 | if (Model.getFacade().getMessages(action) != null) { |
647 | 0 | Iterator iter = |
648 | |
Model.getFacade().getMessages(action).iterator(); |
649 | 0 | if (iter.hasNext()) { |
650 | 0 | return iter.next(); |
651 | |
} |
652 | |
} |
653 | 0 | if (Model.getFacade().getTransition(action) != null) { |
654 | 0 | return Model.getFacade().getTransition(action); |
655 | |
} |
656 | 0 | } catch (InvalidObjectException e) { |
657 | 0 | throw new InvalidElementException(e); |
658 | 0 | } |
659 | 0 | return null; |
660 | |
} |
661 | |
|
662 | |
public void addAction(Object handle, Object action) { |
663 | 0 | if (!(handle instanceof ActionSequence) |
664 | |
|| !(action instanceof Action)) { |
665 | 0 | throw new IllegalArgumentException(); |
666 | |
} |
667 | |
try { |
668 | 0 | ((ActionSequence) handle).getAction().add((Action) action); |
669 | 0 | } catch (InvalidObjectException e) { |
670 | 0 | throw new InvalidElementException(e); |
671 | 0 | } |
672 | 0 | } |
673 | |
|
674 | |
public void addAction(Object handle, int position, Object action) { |
675 | 0 | if (!(handle instanceof ActionSequence) |
676 | |
|| !(action instanceof Action)) { |
677 | 0 | throw new IllegalArgumentException(); |
678 | |
} |
679 | |
try { |
680 | 0 | ((ActionSequence) handle).getAction() |
681 | |
.add(position, (Action) action); |
682 | 0 | } catch (InvalidObjectException e) { |
683 | 0 | throw new InvalidElementException(e); |
684 | 0 | } |
685 | 0 | } |
686 | |
|
687 | |
public void removeAction(Object handle, Object action) { |
688 | 0 | if (!(handle instanceof ActionSequence) |
689 | |
|| !(action instanceof Action)) { |
690 | 0 | throw new IllegalArgumentException(); |
691 | |
} |
692 | |
try { |
693 | 0 | ((ActionSequence) handle).getAction().remove(action); |
694 | 0 | } catch (InvalidObjectException e) { |
695 | 0 | throw new InvalidElementException(e); |
696 | 0 | } |
697 | 0 | } |
698 | |
|
699 | |
} |