use of org.yakindu.sct.model.stext.stext.EntryEvent in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method createEntryBlock.
private EList<Expression> createEntryBlock(List<Expression> actionsToAdd) {
EList<Expression> actionsOriginal;
LocalReaction newLocalReaction = StextFactory.eINSTANCE.createLocalReaction();
ReactionTrigger newReactionTrigger = StextFactory.eINSTANCE.createReactionTrigger();
EntryEvent entryEvent = StextFactory.eINSTANCE.createEntryEvent();
ReactionEffect newReactionEffect = StextFactory.eINSTANCE.createReactionEffect();
newLocalReaction.setTrigger(newReactionTrigger);
newReactionTrigger.getTriggers().add(entryEvent);
newReactionEffect.getActions().addAll(actionsToAdd);
newLocalReaction.setEffect(newReactionEffect);
Scope scope = getContextObject().getScopes().get(0);
scope.getReactions().add(newLocalReaction);
actionsOriginal = newReactionEffect.getActions();
return actionsOriginal;
}
use of org.yakindu.sct.model.stext.stext.EntryEvent in project statecharts by Yakindu.
the class RefactoringHelper method getFirstEntryActions.
/**
* Returns the entry actions of a state. Returns null if no entry block is
* defined. If multiple entry blocks are defined, only the actions of the first
* one are returned.
*
* @param state
* @return list of actions of the first entry block defined in the specified
* state
*/
public EList<Expression> getFirstEntryActions(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 EntryEvent && reaction.getEffect() instanceof ReactionEffect) {
return ((ReactionEffect) reaction.getEffect()).getActions();
}
}
}
}
return null;
}
Aggregations