01: package org.andromda.metafacades.emf.uml2;
02:
03: import java.util.Collection;
04: import java.util.Iterator;
05:
06: import org.andromda.metafacades.uml.ActionStateFacade;
07: import org.andromda.metafacades.uml.FinalStateFacade;
08: import org.andromda.metafacades.uml.PseudostateFacade;
09: import org.andromda.metafacades.uml.StateVertexFacade;
10: import org.eclipse.uml2.Action;
11: import org.eclipse.uml2.Activity;
12:
13: /**
14: * MetafacadeLogic implementation for
15: * org.andromda.metafacades.uml.TransitionFacade.
16: *
17: * @see org.andromda.metafacades.uml.TransitionFacade
18: */
19: public class TransitionFacadeLogicImpl extends TransitionFacadeLogic {
20: public TransitionFacadeLogicImpl(
21: final org.eclipse.uml2.Transition metaObject,
22: final String context) {
23: super (metaObject, context);
24: }
25:
26: protected Object handleGetEffect() {
27: // Effect is mapped to action, not activity
28: // We return the first action encountered in the activity
29: Action effectAction = null;
30: Activity effect = this .metaObject.getEffect();
31: if (effect != null) {
32: Collection nodes = effect.getNodes();
33: for (Iterator nodesIt = nodes.iterator(); nodesIt.hasNext()
34: && effectAction == null;) {
35: Object nextNode = nodesIt.next();
36: if (nextNode instanceof Action) {
37: effectAction = (Action) nextNode;
38: }
39: }
40: }
41: return effectAction;
42: }
43:
44: protected Object handleGetSource() {
45: return this .metaObject.getSource();
46: }
47:
48: protected Object handleGetTarget() {
49: return this .metaObject.getTarget();
50: }
51:
52: protected Object handleGetTrigger() {
53: // We use the effect instead of trigger. It's the same "trick" as
54: // using entry instead of deferrable events
55: return this .metaObject.getEffect();
56: }
57:
58: protected Object handleGetGuard() {
59: return this .metaObject.getGuard();
60: }
61:
62: protected boolean handleIsTriggerPresent() {
63: return this .metaObject.getEffect() != null;
64: }
65:
66: protected boolean handleIsExitingDecisionPoint() {
67: final StateVertexFacade sourceVertex = this .getSource();
68: return sourceVertex instanceof PseudostateFacade
69: && ((PseudostateFacade) sourceVertex).isDecisionPoint();
70: }
71:
72: protected boolean handleIsEnteringDecisionPoint() {
73: final StateVertexFacade target = this .getTarget();
74: return target instanceof PseudostateFacade
75: && ((PseudostateFacade) target).isDecisionPoint();
76: }
77:
78: protected boolean handleIsExitingActionState() {
79: return this .getSource() instanceof ActionStateFacade;
80: }
81:
82: protected boolean handleIsEnteringActionState() {
83: return this .getTarget() instanceof ActionStateFacade;
84: }
85:
86: protected boolean handleIsExitingInitialState() {
87: StateVertexFacade sourceVertex = this .getSource();
88: return sourceVertex instanceof PseudostateFacade
89: && ((PseudostateFacade) sourceVertex).isInitialState();
90: }
91:
92: protected boolean handleIsEnteringFinalState() {
93: return this .getTarget() instanceof FinalStateFacade;
94: }
95:
96: public Object getValidationOwner() {
97: return this.getTarget().getStateMachine();
98: }
99: }
|