Search in sources :

Example 56 with Transition

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

the class SGraphJavaValidationTest method vertexNotReachable_AcceptThroughSubstate.

/**
 * A transition to a sub entry is considered implies reachability.
 */
@Test
public void vertexNotReachable_AcceptThroughSubstate() {
    prepareStateTest();
    State stateA = factory.createState();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    State stateC = factory.createState();
    subRegion.getVertices().add(stateC);
    Transition t1 = factory.createTransition();
    t1.setSource(stateA);
    t1.setTarget(stateC);
    validate(state);
    assertNoIssues(diagnostics);
}
Also used : FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) Test(org.junit.Test)

Example 57 with Transition

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

the class SGraphTestFactory method _createTransition.

public static Transition _createTransition(Vertex source, Vertex target) {
    Transition t = SGraphFactory.eINSTANCE.createTransition();
    t.setSource(source);
    t.setTarget(target);
    return t;
}
Also used : Transition(org.yakindu.sct.model.sgraph.Transition)

Example 58 with Transition

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

the class CreateTransitionCommand method doExecuteWithResult.

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    Vertex source = (Vertex) getRequest().getSource();
    Vertex target = (Vertex) getRequest().getTarget();
    if (source != null && target != null) {
        Transition transition = SGraphFactory.eINSTANCE.createTransition();
        source.getOutgoingTransitions().add(transition);
        transition.setSource(source);
        transition.setTarget(target);
        source.getOutgoingTransitions().add(transition);
        target.getIncomingTransitions().add(transition);
        ((CreateElementRequest) getRequest()).setNewElement(transition);
    }
    return CommandResult.newOKCommandResult();
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Transition(org.yakindu.sct.model.sgraph.Transition) CreateElementRequest(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)

Example 59 with Transition

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

the class ExtractSubdiagramRefactoring method createExitPoint.

protected void createExitPoint(Edge edge, Diagram subdiagram) {
    Transition transition = (Transition) edge.getElement();
    // create semantic exit point
    Region exitPointContainer = getExitPointContainer(transition);
    Exit exitPoint = createSemanticExitPoint(transition);
    // create node for exit point
    View exitPointContainerView = helper.getViewForSemanticElement(exitPointContainer, subdiagram);
    View exitPointRegionCompartment = ViewUtil.getChildBySemanticHint(exitPointContainerView, SemanticHints.REGION_COMPARTMENT);
    Node exitNode = ViewService.createNode(exitPointRegionCompartment, exitPoint, SemanticHints.EXIT, preferencesHint);
    // re-wire existing transition to new exit point
    Vertex oldTransitionTarget = transition.getTarget();
    transition.setTarget(exitPoint);
    View oldEdgeTarget = edge.getTarget();
    edge.setTarget(exitNode);
    // create transition from selected state to former transition target
    Transition exitPointTransition = SGraphFactory.eINSTANCE.createTransition();
    exitPointTransition.setSource((State) subdiagram.getElement());
    exitPointTransition.setTarget(oldTransitionTarget);
    ViewService.createEdge(getContextObject(), oldEdgeTarget, exitPointTransition, SemanticHints.TRANSITION, preferencesHint);
    addExitPointSpec(exitPointTransition, exitPoint);
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Node(org.eclipse.gmf.runtime.notation.Node) Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) View(org.eclipse.gmf.runtime.notation.View) Exit(org.yakindu.sct.model.sgraph.Exit)

Example 60 with Transition

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

Aggregations

Transition (org.yakindu.sct.model.sgraph.Transition)63 Test (org.junit.Test)34 Region (org.yakindu.sct.model.sgraph.Region)26 State (org.yakindu.sct.model.sgraph.State)23 Statechart (org.yakindu.sct.model.sgraph.Statechart)19 FinalState (org.yakindu.sct.model.sgraph.FinalState)13 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)13 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)13 SGraphTestFactory._createTransition (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition)13 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)13 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)10 Entry (org.yakindu.sct.model.sgraph.Entry)10 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)10 StextTestFactory._createReactionTrigger (org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger)9 EventDefinition (org.yakindu.sct.model.stext.stext.EventDefinition)8 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)8 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)8 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)7 If (org.yakindu.sct.model.sexec.If)7 Vertex (org.yakindu.sct.model.sgraph.Vertex)7