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);
}
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;
}
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;
}
Aggregations