Search in sources :

Example 26 with ReactionTrigger

use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.

the class FoldOutgoingActionsRefactoring method createExitBlock.

private EList<Expression> createExitBlock(List<Expression> actionsToAdd) {
    EList<Expression> actionsOriginal;
    LocalReaction newLocalReaction = StextFactory.eINSTANCE.createLocalReaction();
    ReactionTrigger newReactionTrigger = StextFactory.eINSTANCE.createReactionTrigger();
    ExitEvent exitEvent = StextFactory.eINSTANCE.createExitEvent();
    ReactionEffect newReactionEffect = StextFactory.eINSTANCE.createReactionEffect();
    newLocalReaction.setTrigger(newReactionTrigger);
    newReactionTrigger.getTriggers().add(exitEvent);
    newReactionEffect.getActions().addAll(actionsToAdd);
    newLocalReaction.setEffect(newReactionEffect);
    Scope scope = getContextObject().getScopes().get(0);
    scope.getReactions().add(newLocalReaction);
    actionsOriginal = newReactionEffect.getActions();
    return actionsOriginal;
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) Scope(org.yakindu.sct.model.sgraph.Scope) Expression(org.yakindu.base.expressions.expressions.Expression) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent)

Aggregations

ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)26 Test (org.junit.Test)20 StextTestFactory._createReactionTrigger (org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger)16 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)14 Statechart (org.yakindu.sct.model.sgraph.Statechart)13 Region (org.yakindu.sct.model.sgraph.Region)12 Transition (org.yakindu.sct.model.sgraph.Transition)12 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)11 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)11 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)11 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)10 If (org.yakindu.sct.model.sexec.If)10 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)10 StextTestFactory._createLocalReaction (org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction)10 State (org.yakindu.sct.model.sgraph.State)9 SGraphTestFactory._createTransition (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition)9 EventDefinition (org.yakindu.sct.model.stext.stext.EventDefinition)9 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)8 PrimitiveValueExpression (org.yakindu.base.expressions.expressions.PrimitiveValueExpression)8 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)8