Search in sources :

Example 6 with Exit

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

the class SGraphJavaValidationTest method exitWithoutIncomingTransition.

/**
 * An exit node should have at leat one incoming transition.
 */
@Test
public void exitWithoutIncomingTransition() {
    prepareStateTest();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    Exit exit = factory.createExit();
    subRegion.getVertices().add(exit);
    assertFalse(validate(exit));
    assertWarning(diagnostics, ISSUE_EXIT_WITHOUT_IN_TRANS);
}
Also used : Region(org.yakindu.sct.model.sgraph.Region) Exit(org.yakindu.sct.model.sgraph.Exit) Test(org.junit.Test)

Example 7 with Exit

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

Aggregations

Exit (org.yakindu.sct.model.sgraph.Exit)7 Region (org.yakindu.sct.model.sgraph.Region)6 Test (org.junit.Test)4 Transition (org.yakindu.sct.model.sgraph.Transition)3 FinalState (org.yakindu.sct.model.sgraph.FinalState)2 State (org.yakindu.sct.model.sgraph.State)2 Vertex (org.yakindu.sct.model.sgraph.Vertex)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Node (org.eclipse.gmf.runtime.notation.Node)1 View (org.eclipse.gmf.runtime.notation.View)1