use of org.yakindu.sct.model.sgraph.State 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.State 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.State in project statecharts by Yakindu.
the class RefactoringHelper method getParentStates.
/**
* Returns all parent states of the specified child state.
*
* @param state
* child state
* @return all parent states of the specified child state
*/
// TODO are hierarchies of regions possible?
private Set<State> getParentStates(Vertex state) {
Set<State> parentStates = new HashSet<State>();
CompositeElement composite = state.getParentRegion().getComposite();
if (composite instanceof State) {
State parentState = (State) composite;
parentStates.add(parentState);
parentStates.addAll(getParentStates(parentState));
}
return parentStates;
}
use of org.yakindu.sct.model.sgraph.State in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method isExecutable.
@Override
public boolean isExecutable() {
EObject element = getContextObject().getElement();
if (!(element instanceof State)) {
return false;
}
State state = (State) element;
BooleanValueStyle inlineStyle = getInlineStyle(getContextObject());
return super.isExecutable() && state.isComposite() && (inlineStyle == null || inlineStyle.isBooleanValue());
}
use of org.yakindu.sct.model.sgraph.State in project statecharts by Yakindu.
the class AddOutgoingStateModification method execute.
@Override
protected void execute(EObject semanticElement, View view) {
State state = (State) semanticElement;
State newState = SGraphFactory.eINSTANCE.createState();
Transition transition = SGraphFactory.eINSTANCE.createTransition();
state.getParentRegion().getVertices().add(newState);
transition.setSource(state);
transition.setTarget(newState);
if (transitionSpecification != null)
transition.setSpecification(transitionSpecification);
if (stateName != null)
newState.setName(stateName);
}
Aggregations