Search in sources :

Example 1 with Exit

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

the class ExtractSubdiagramRefactoring method createSemanticExitPoint.

private Exit createSemanticExitPoint(Transition transition) {
    Region exitPointContainer = getExitPointContainer(transition);
    String name = getExitPointName(transition);
    Exit exitPoint = null;
    Iterator<Vertex> iterator = exitPointContainer.getVertices().iterator();
    while (iterator.hasNext()) {
        Vertex next = iterator.next();
        if (next instanceof Exit) {
            Exit current = (Exit) next;
            if (name.equals(current.getName())) {
                // Do nothing, there already exists an entry point
                return current;
            }
        }
    }
    exitPoint = SGraphFactory.eINSTANCE.createExit();
    exitPoint.setName(name);
    exitPointContainer.getVertices().add(exitPoint);
    return exitPoint;
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Region(org.yakindu.sct.model.sgraph.Region) Exit(org.yakindu.sct.model.sgraph.Exit)

Example 2 with Exit

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

the class STextValidationModelUtils method getRegionsWithoutDefaultExit.

/**
 * If a {@link Region} contains no 'default' named {@link exit} it is added
 * as key to a map with a list of all exits of the region.
 *
 * @param elements
 *            - a list with {@link Region} elements.
 * @return a map with a region (key) which contains no default {@link exit}
 *         and a list of all {@link exit} elements of the {@link Region}
 *         (value).
 */
public static Map<Region, List<Exit>> getRegionsWithoutDefaultExit(List<Region> elements) {
    Map<Region, List<Exit>> regions = new HashMap<Region, List<Exit>>();
    for (Region region : elements) {
        boolean hasDefaultExit = false;
        final List<Exit> exits = getExits(region.eContents());
        if (!exits.isEmpty()) {
            for (Exit exit : exits) {
                if (isDefault(exit)) {
                    hasDefaultExit = true;
                    break;
                }
            }
        } else {
            hasDefaultExit = true;
        }
        if (!hasDefaultExit) {
            regions.put(region, exits);
        }
    }
    return regions;
}
Also used : HashMap(java.util.HashMap) Region(org.yakindu.sct.model.sgraph.Region) ArrayList(java.util.ArrayList) List(java.util.List) Exit(org.yakindu.sct.model.sgraph.Exit)

Example 3 with Exit

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

the class SGraphJavaValidationTest method cleanExit.

/**
 * Tests a scenario where no issues for an exit nodes exists.
 */
@Test
public void cleanExit() {
    prepareStateTest();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    Exit exit = factory.createExit();
    subRegion.getVertices().add(exit);
    State s = factory.createState();
    subRegion.getVertices().add(s);
    Transition t = factory.createTransition();
    t.setTarget(exit);
    t.setSource(s);
    assertTrue(validate(exit));
    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) Exit(org.yakindu.sct.model.sgraph.Exit) Test(org.junit.Test)

Example 4 with Exit

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

the class SGraphJavaValidationTest method exitOnStatechart.

/**
 * An exit node must not be used in top level regions.
 */
@Test
public void exitOnStatechart() {
    prepareStateTest();
    Exit exit = factory.createExit();
    region.getVertices().add(exit);
    assertFalse(validate(exit));
    assertError(diagnostics, ISSUE_EXIT_ON_STATECHART);
}
Also used : Exit(org.yakindu.sct.model.sgraph.Exit) Test(org.junit.Test)

Example 5 with Exit

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

the class SGraphJavaValidationTest method exitWithOutgoingTransition.

/**
 * An exit node must have no outgoing transitions.
 */
@Test
public void exitWithOutgoingTransition() {
    prepareStateTest();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    Exit exit = factory.createExit();
    subRegion.getVertices().add(exit);
    State s = factory.createState();
    subRegion.getVertices().add(s);
    Transition t = factory.createTransition();
    t.setSource(exit);
    t.setTarget(s);
    assertFalse(validate(exit));
    assertError(diagnostics, ISSUE_EXIT_WITH_OUT_TRANS);
}
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) Exit(org.yakindu.sct.model.sgraph.Exit) Test(org.junit.Test)

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