Search in sources :

Example 1 with Trigger

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

the class STextJavaValidatorTest method checkUnboundEntryPoints.

@Test
public void checkUnboundEntryPoints() {
    statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "UnboundDefaultEntryPoints.sct");
    Iterator<EObject> iter = statechart.eAllContents();
    // create and add triggers to all transitions to prevent to trigger
    // additional warnings
    // (see Check in SGrapJavaValidator transitionsWithNoGuard)
    Trigger trigger = StextFactoryImpl.init().createDefaultTrigger();
    while (iter.hasNext()) {
        EObject element = iter.next();
        if (element instanceof Transition) {
            ((Transition) element).setTrigger(trigger);
            validator.validate(element, diagnostics, new HashMap<>());
        }
        if (element instanceof State) {
            validator.validate(element, diagnostics, new HashMap<>());
        }
    }
    assertIssueCount(diagnostics, 4);
    assertError(diagnostics, TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT);
    assertError(diagnostics, REGION_UNBOUND_DEFAULT_ENTRY_POINT);
    resetDiagnostics();
    statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "UnboundEntryPoints02.sct");
    iter = statechart.eAllContents();
    while (iter.hasNext()) {
        EObject element = iter.next();
        if (element instanceof Transition) {
            ((Transition) element).setTrigger(trigger);
            validator.validate(element, diagnostics, new HashMap<>());
        }
        if (element instanceof State) {
            validator.validate(element, diagnostics, new HashMap<>());
        }
    }
    assertIssueCount(diagnostics, 4);
}
Also used : Trigger(org.yakindu.sct.model.sgraph.Trigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) State(org.yakindu.sct.model.sgraph.State) EObject(org.eclipse.emf.ecore.EObject) Transition(org.yakindu.sct.model.sgraph.Transition) Test(org.junit.Test)

Example 2 with Trigger

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

the class StatechartObjectViewerFilter method select.

@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    if (element instanceof DomainNavigatorItem) {
        DomainNavigatorItem navigatorItem = (DomainNavigatorItem) element;
        EObject modelElement = navigatorItem.getEObject();
        if (modelElement instanceof Diagram) {
            return false;
        }
        if (modelElement instanceof Trigger) {
            return false;
        }
        if (modelElement instanceof InternalScope || modelElement instanceof InterfaceScope) {
            return true;
        }
        if (modelElement instanceof Scope) {
            return false;
        }
        if (modelElement instanceof LocalReaction) {
            return false;
        }
        if (modelElement instanceof ReactionEffect) {
            return false;
        }
        if (modelElement instanceof Expression) {
            return false;
        }
    }
    return true;
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) Trigger(org.yakindu.sct.model.sgraph.Trigger) Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Expression(org.yakindu.base.expressions.expressions.Expression) EObject(org.eclipse.emf.ecore.EObject) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 3 with Trigger

use of org.yakindu.sct.model.sgraph.Trigger 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)

Example 4 with Trigger

use of org.yakindu.sct.model.sgraph.Trigger 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;
}
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) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Reaction(org.yakindu.sct.model.sgraph.Reaction) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent)

Example 5 with Trigger

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

the class ReactionImpl method basicSetTrigger.

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

Aggregations

Trigger (org.yakindu.sct.model.sgraph.Trigger)6 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)3 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)3 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Reaction (org.yakindu.sct.model.sgraph.Reaction)2 EventSpec (org.yakindu.sct.model.stext.stext.EventSpec)2 Diagram (org.eclipse.gmf.runtime.notation.Diagram)1 Test (org.junit.Test)1 Expression (org.yakindu.base.expressions.expressions.Expression)1 Scope (org.yakindu.sct.model.sgraph.Scope)1 State (org.yakindu.sct.model.sgraph.State)1 Transition (org.yakindu.sct.model.sgraph.Transition)1 EntryEvent (org.yakindu.sct.model.stext.stext.EntryEvent)1 ExitEvent (org.yakindu.sct.model.stext.stext.ExitEvent)1 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)1 InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)1 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)1