Search in sources :

Example 6 with ReactionProperty

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

the class ExtractSubdiagramRefactoring method addExitPointSpec.

private void addExitPointSpec(Transition transition, Exit exitPoint) {
    EList<ReactionProperty> properties = transition.getProperties();
    ExitPointSpec exitPointSpec = StextFactory.eINSTANCE.createExitPointSpec();
    // A transition can only have one exit point so alter the existing
    for (ReactionProperty reactionProperty : properties) {
        if (reactionProperty instanceof ExitPointSpec) {
            exitPointSpec = (ExitPointSpec) reactionProperty;
        }
    }
    exitPointSpec.setExitpoint(exitPoint.getName());
    properties.add(exitPointSpec);
}
Also used : ExitPointSpec(org.yakindu.sct.model.stext.stext.ExitPointSpec) ReactionProperty(org.yakindu.sct.model.sgraph.ReactionProperty)

Example 7 with ReactionProperty

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

the class STextValidationModelUtils method getEntrySpecSortedTransitions.

/**
 * Sorts the given elements in transition without and with
 * {@link EntryPointSpec}s
 *
 * @param elements
 *            list of transitions to sort
 * @return an array with the sorted elements. The first index contains a
 *         list of the transitions without {@link EntryPointSpec}s. The
 *         second index contains a list of the transitions with
 *         {@link EntryPointSpec}s.
 */
public static List<Transition>[] getEntrySpecSortedTransitions(List<Transition> elements) {
    @SuppressWarnings("unchecked") final List<Transition>[] transitions = new ArrayList[2];
    // first list contains Transitions without entry spec
    transitions[0] = new ArrayList<Transition>();
    // second list contains Transitions with entry spec
    transitions[1] = new ArrayList<Transition>();
    for (Transition transition : elements) {
        boolean hasEntrySpec = false;
        for (ReactionProperty property : transition.getProperties()) {
            if (property instanceof EntryPointSpec) {
                transitions[1].add(transition);
                hasEntrySpec = true;
                break;
            }
        }
        if (!hasEntrySpec) {
            transitions[0].add(transition);
        }
    }
    return transitions;
}
Also used : ArrayList(java.util.ArrayList) Transition(org.yakindu.sct.model.sgraph.Transition) ArrayList(java.util.ArrayList) List(java.util.List) EntryPointSpec(org.yakindu.sct.model.stext.stext.EntryPointSpec) ReactionProperty(org.yakindu.sct.model.sgraph.ReactionProperty)

Example 8 with ReactionProperty

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

the class STextValidationModelUtils method isNamedExitTransition.

/**
 * Validates if the a {@link Transition} has an {@link ExitPointSpec} with
 * the given name.
 *
 * @param transition
 *            - the transition to check
 * @param name
 *            - the name to check
 * @return {@code true} if the transition contains an ExitPointSpec with the
 *         name. Otherwise {@code false}.
 */
public static boolean isNamedExitTransition(Transition transition, String name) {
    boolean isNamedExitTransition = false;
    Iterator<ReactionProperty> propertyIt = transition.getProperties().iterator();
    while (propertyIt.hasNext() && !isNamedExitTransition) {
        ReactionProperty property = propertyIt.next();
        if (property instanceof ExitPointSpec) {
            isNamedExitTransition = name.equals(((ExitPointSpec) property).getExitpoint());
        }
    }
    return isNamedExitTransition;
}
Also used : ExitPointSpec(org.yakindu.sct.model.stext.stext.ExitPointSpec) ReactionProperty(org.yakindu.sct.model.sgraph.ReactionProperty)

Aggregations

ReactionProperty (org.yakindu.sct.model.sgraph.ReactionProperty)8 Transition (org.yakindu.sct.model.sgraph.Transition)4 EntryPointSpec (org.yakindu.sct.model.stext.stext.EntryPointSpec)4 List (java.util.List)3 ExitPointSpec (org.yakindu.sct.model.stext.stext.ExitPointSpec)3 ArrayList (java.util.ArrayList)2 Check (org.eclipse.xtext.validation.Check)2 LinkedList (java.util.LinkedList)1 EList (org.eclipse.emf.common.util.EList)1 Entry (org.yakindu.sct.model.sgraph.Entry)1 Region (org.yakindu.sct.model.sgraph.Region)1