Search in sources :

Example 1 with Region

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

the class StateEditHelper method createCompositeStateCommand.

private ICommand createCompositeStateCommand(ConfigureRequest req) {
    Region region = SGraphFactory.eINSTANCE.createRegion();
    region.setName("r1");
    return new SetValueCommand(new SetRequest(req.getElementToConfigure(), SGraphPackage.Literals.COMPOSITE_ELEMENT__REGIONS, region));
}
Also used : SetRequest(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest) SetValueCommand(org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand) Region(org.yakindu.sct.model.sgraph.Region)

Example 2 with Region

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

the class ExtractSubdiagramRefactoring method createEntryPoint.

protected void createEntryPoint(Edge edge, Diagram subdiagram) {
    Transition transition = (Transition) edge.getElement();
    Region entryPointContainer = getEntryPointContainer(transition);
    Entry entryPoint = createSemanticEntryPoint(transition);
    // re-wire old transition to targeting the selected state
    transition.setTarget((State) subdiagram.getElement());
    View oldTarget = edge.getTarget();
    edge.setTarget(getContextObject());
    // create node for entry point
    View entryPointContainerView = helper.getViewForSemanticElement(entryPointContainer, subdiagram);
    View entryPointRegionCompartment = ViewUtil.getChildBySemanticHint(entryPointContainerView, SemanticHints.REGION_COMPARTMENT);
    Node entryNode = ViewService.createNode(entryPointRegionCompartment, entryPoint, SemanticHints.ENTRY, preferencesHint);
    ViewService.createEdge(entryNode, oldTarget, entryPoint.getOutgoingTransitions().get(0), SemanticHints.TRANSITION, preferencesHint);
    addEntryPointSpec(transition, entryPoint);
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) 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)

Example 3 with Region

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

the class ExtractSubdiagramRefactoring method createSemanticEntryPoint.

protected Entry createSemanticEntryPoint(Transition transition) {
    Region entryPointTarget = getEntryPointContainer(transition);
    String name = getEntryPointName(transition);
    Entry entryPoint = null;
    Iterator<Vertex> iterator = entryPointTarget.getVertices().iterator();
    while (iterator.hasNext()) {
        Vertex next = iterator.next();
        if (next instanceof Entry) {
            Entry current = (Entry) next;
            if (name.equals(current.getName())) {
                // Do nothing, there already exists an entry point
                return current;
            }
        }
    }
    entryPoint = SGraphFactory.eINSTANCE.createEntry();
    entryPoint.setName(name);
    entryPointTarget.getVertices().add(entryPoint);
    Transition entryPointTransition = SGraphFactory.eINSTANCE.createTransition();
    entryPointTransition.setSource(entryPoint);
    entryPointTransition.setTarget(transition.getTarget());
    return entryPoint;
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Entry(org.yakindu.sct.model.sgraph.Entry) Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region)

Example 4 with Region

use of org.yakindu.sct.model.sgraph.Region 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 5 with Region

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

the class STextJavaValidator method checkUnboundEntryPoints.

@Check(CheckType.NORMAL)
public void checkUnboundEntryPoints(final org.yakindu.sct.model.sgraph.State state) {
    if (state.isComposite()) {
        final List<Transition>[] transitions = STextValidationModelUtils.getEntrySpecSortedTransitions(state.getIncomingTransitions());
        Map<Region, List<Entry>> regions = null;
        // first list contains Transitions without entry spec
        if (!transitions[0].isEmpty()) {
            regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
            if (!regions.isEmpty()) {
                for (Transition transition : transitions[0]) {
                    error(TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT, transition, null, -1);
                }
                for (Region region : regions.keySet()) {
                    error(REGION_UNBOUND_DEFAULT_ENTRY_POINT, region, null, -1);
                }
            }
        }
        // second list contains Transitions with entry spec
        if (!transitions[1].isEmpty()) {
            if (regions == null) {
                regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
            }
            for (Transition transition : transitions[1]) {
                boolean hasTargetEntry = true;
                for (ReactionProperty property : transition.getProperties()) {
                    if (property instanceof EntryPointSpec) {
                        EntryPointSpec spec = (EntryPointSpec) property;
                        String specName = "'" + spec.getEntrypoint() + "'";
                        for (Region region : regions.keySet()) {
                            boolean hasEntry = false;
                            for (Entry entry : regions.get(region)) {
                                if (entry.getName().equals(spec.getEntrypoint())) {
                                    hasEntry = true;
                                    break;
                                }
                            }
                            if (!hasEntry) {
                                error(REGION_UNBOUND_NAMED_ENTRY_POINT + specName, region, null, -1);
                                hasTargetEntry = false;
                            }
                        }
                        if (!hasTargetEntry) {
                            error(TRANSITION_UNBOUND_NAMED_ENTRY_POINT + specName, transition, null, -1);
                        }
                    }
                }
            }
        }
    }
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) List(java.util.List) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) EntryPointSpec(org.yakindu.sct.model.stext.stext.EntryPointSpec) ReactionProperty(org.yakindu.sct.model.sgraph.ReactionProperty) Check(org.eclipse.xtext.validation.Check)

Aggregations

Region (org.yakindu.sct.model.sgraph.Region)93 Test (org.junit.Test)71 State (org.yakindu.sct.model.sgraph.State)63 Statechart (org.yakindu.sct.model.sgraph.Statechart)59 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)57 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)57 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)53 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)48 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)48 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)47 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)47 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)41 Entry (org.yakindu.sct.model.sgraph.Entry)38 Sequence (org.yakindu.sct.model.sexec.Sequence)36 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)29 Transition (org.yakindu.sct.model.sgraph.Transition)26 FinalState (org.yakindu.sct.model.sgraph.FinalState)25 Reaction (org.yakindu.sct.model.sexec.Reaction)22