use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class RefactoringHelper method getAllActions.
/**
* Collects all actions of the specified transitions and returns them.
*
* @param transitions
* @return list of list of actions for the specified transitions
*/
public List<List<Expression>> getAllActions(List<Transition> transitions) {
List<List<Expression>> allActions = new ArrayList<List<Expression>>();
for (Transition transition : transitions) {
Effect effect = transition.getEffect();
if (effect instanceof ReactionEffect) {
ReactionEffect reactionEffect = (ReactionEffect) effect;
allActions.add(reactionEffect.getActions());
} else {
allActions.add(Collections.<Expression>emptyList());
}
}
return allActions;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class RefactoringHelper method oneOutgoingTransitionLeavesCompositeWithExitActions.
/**
* Checks if at least one of the outgoing transitions of the specified state
* leaves a parent composite of this state which has exit actions.
*
* @param state
* @return true if condition is satisfied, false otherwise
*/
public boolean oneOutgoingTransitionLeavesCompositeWithExitActions(State state) {
Set<State> sourceParentStates = new HashSet<State>(getParentStates(state));
for (Transition transition : state.getOutgoingTransitions()) {
// all parent states of target need to be contained in the set of
// the source's parent states
Set<State> targetParentStates = getParentStates(transition.getTarget());
Set<State> crossedStates = new HashSet<State>(sourceParentStates);
crossedStates.removeAll(targetParentStates);
for (State crossedCompositeState : crossedStates) {
if (hasExitAction(crossedCompositeState))
return true;
}
}
return false;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class RefactoringHelper method oneIncomingTransitionEntersCompositeWithEntryActions.
/**
* Checks if at least one of the incoming transitions of the specified state
* enters a parent composite of this state which has entry actions.
*
* @param state
* @return true if condition is satisfied, false otherwise
*/
public boolean oneIncomingTransitionEntersCompositeWithEntryActions(State state) {
Set<State> targetParentStates = new HashSet<State>(getParentStates(state));
for (Transition transition : state.getIncomingTransitions()) {
// all parent states of source need to be contained in the set of
// the target's parent states
Set<State> sourceParentStates = getParentStates(transition.getSource());
Set<State> crossedStates = new HashSet<State>(targetParentStates);
crossedStates.removeAll(sourceParentStates);
for (State crossedCompositeState : crossedStates) {
if (hasEntryAction(crossedCompositeState))
return true;
}
}
return false;
}
use of org.yakindu.sct.model.sgraph.Transition 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);
}
use of org.yakindu.sct.model.sgraph.Transition 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;
}
Aggregations