Search in sources :

Example 6 with Effect

use of org.yakindu.sct.model.sgraph.Effect in project statecharts by Yakindu.

the class ReactionImpl method basicSetEffect.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetEffect(Effect newEffect, NotificationChain msgs) {
    Effect oldEffect = effect;
    effect = newEffect;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SGraphPackage.REACTION__EFFECT, oldEffect, newEffect);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Effect(org.yakindu.sct.model.sgraph.Effect)

Example 7 with Effect

use of org.yakindu.sct.model.sgraph.Effect in project statecharts by Yakindu.

the class FoldIncomingActionsRefactoring method getLastActions.

private List<Expression> getLastActions(Transition transition, int number) {
    List<Expression> lastActions = new ArrayList<Expression>();
    Effect effect = transition.getEffect();
    if (effect instanceof ReactionEffect) {
        ReactionEffect reactionEffect = (ReactionEffect) effect;
        List<Expression> actions = reactionEffect.getActions();
        for (int i = 1; i <= number; i++) {
            lastActions.add(actions.get(actions.size() - i));
        }
    }
    return lastActions;
}
Also used : Expression(org.yakindu.base.expressions.expressions.Expression) ArrayList(java.util.ArrayList) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Effect(org.yakindu.sct.model.sgraph.Effect) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect)

Example 8 with Effect

use of org.yakindu.sct.model.sgraph.Effect in project statecharts by Yakindu.

the class FoldIncomingActionsRefactoring method removeLastActions.

private void removeLastActions(EList<Transition> transitions, int number) {
    for (Transition transition : transitions) {
        List<Expression> actionsToRemove = getLastActions(transition, number);
        Effect effect = transition.getEffect();
        if (effect instanceof ReactionEffect && actionsToRemove.size() == ((ReactionEffect) effect).getActions().size()) {
            // we need to remove all actions, so just remove the effect
            // recursively which avoids serializer exceptions
            EcoreUtil.delete(effect, true);
        } else {
            for (Expression action : actionsToRemove) {
                EcoreUtil.delete(action);
            }
        }
    }
}
Also used : Expression(org.yakindu.base.expressions.expressions.Expression) Transition(org.yakindu.sct.model.sgraph.Transition) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Effect(org.yakindu.sct.model.sgraph.Effect) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect)

Example 9 with Effect

use of org.yakindu.sct.model.sgraph.Effect in project statecharts by Yakindu.

the class UnfoldExitActionsRefactoring method addActionsToTransition.

private void addActionsToTransition(final Transition transition, final Collection<Expression> actionsToAdd) {
    Effect effect = transition.getEffect();
    if (effect instanceof ReactionEffect) {
        ReactionEffect reactionEffect = (ReactionEffect) effect;
        reactionEffect.getActions().addAll(0, actionsToAdd);
    } else {
        ReactionEffect reactionEffect = StextFactory.eINSTANCE.createReactionEffect();
        reactionEffect.getActions().addAll(actionsToAdd);
        transition.setEffect(reactionEffect);
    }
}
Also used : ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Effect(org.yakindu.sct.model.sgraph.Effect) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect)

Example 10 with Effect

use of org.yakindu.sct.model.sgraph.Effect in project statecharts by Yakindu.

the class TransitionImpl method basicSetEffect.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetEffect(Effect newEffect, NotificationChain msgs) {
    Effect oldEffect = effect;
    effect = newEffect;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SGraphPackage.TRANSITION__EFFECT, oldEffect, newEffect);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Effect(org.yakindu.sct.model.sgraph.Effect)

Aggregations

Effect (org.yakindu.sct.model.sgraph.Effect)10 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)8 Expression (org.yakindu.base.expressions.expressions.Expression)6 ArrayList (java.util.ArrayList)3 Transition (org.yakindu.sct.model.sgraph.Transition)3 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1