use of org.yakindu.sct.model.stext.stext.ExitEvent in project statecharts by Yakindu.
the class SCTResourceTest method testStateSerializing.
@Test
public void testStateSerializing() throws Exception {
res.setSerializerEnabled(true);
State state = createState("entry / 3 * 3");
res.getContents().add(state);
LocalReaction reaction = (LocalReaction) state.getLocalReactions().get(0);
ReactionTrigger trigger = (ReactionTrigger) reaction.getTrigger();
ExitEvent exitEvent = stextFac.createExitEvent();
trigger.getTriggers().add(exitEvent);
assertEquals("entry , exit / 3 * 3", state.getSpecification());
assertEquals("" + res.getErrors(), 0, res.getErrors().size());
}
use of org.yakindu.sct.model.stext.stext.ExitEvent in project statecharts by Yakindu.
the class RefactoringHelper method getFirstExitActions.
/**
* Returns the exit actions of a state. Returns null if no exit block is
* defined. If multiple exit blocks are defined, only the actions of the first
* one are returned.
*
* @param state
* @return list of actions of the first exit block defined in the specified
* state
*/
public EList<Expression> getFirstExitActions(State state) {
EList<Reaction> localReactions = state.getLocalReactions();
for (Reaction reaction : localReactions) {
Trigger trigger = reaction.getTrigger();
if (trigger instanceof ReactionTrigger) {
ReactionTrigger reactionTrigger = (ReactionTrigger) trigger;
EList<EventSpec> triggers = reactionTrigger.getTriggers();
for (EventSpec eventSpec : triggers) {
if (eventSpec instanceof ExitEvent && reaction.getEffect() instanceof ReactionEffect) {
return ((ReactionEffect) reaction.getEffect()).getActions();
}
}
}
}
return null;
}
use of org.yakindu.sct.model.stext.stext.ExitEvent 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;
}
Aggregations