Search in sources :

Example 1 with EntryEvent

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;
}
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) EntryEvent(org.yakindu.sct.model.stext.stext.EntryEvent) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect)

Example 2 with EntryEvent

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;
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) Trigger(org.yakindu.sct.model.sgraph.Trigger) EventSpec(org.yakindu.sct.model.stext.stext.EventSpec) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) EntryEvent(org.yakindu.sct.model.stext.stext.EntryEvent) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Reaction(org.yakindu.sct.model.sgraph.Reaction)

Aggregations

EntryEvent (org.yakindu.sct.model.stext.stext.EntryEvent)2 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)2 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)2 Expression (org.yakindu.base.expressions.expressions.Expression)1 Reaction (org.yakindu.sct.model.sgraph.Reaction)1 Scope (org.yakindu.sct.model.sgraph.Scope)1 Trigger (org.yakindu.sct.model.sgraph.Trigger)1 EventSpec (org.yakindu.sct.model.stext.stext.EventSpec)1 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)1