use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class SGraphJavaValidationTest method vertexNotReachable_AcceptThroughSubstate.
/**
* A transition to a sub entry is considered implies reachability.
*/
@Test
public void vertexNotReachable_AcceptThroughSubstate() {
prepareStateTest();
State stateA = factory.createState();
Region subRegion = factory.createRegion();
state.getRegions().add(subRegion);
State stateC = factory.createState();
subRegion.getVertices().add(stateC);
Transition t1 = factory.createTransition();
t1.setSource(stateA);
t1.setTarget(stateC);
validate(state);
assertNoIssues(diagnostics);
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class SGraphTestFactory method _createTransition.
public static Transition _createTransition(Vertex source, Vertex target) {
Transition t = SGraphFactory.eINSTANCE.createTransition();
t.setSource(source);
t.setTarget(target);
return t;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class CreateTransitionCommand method doExecuteWithResult.
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
Vertex source = (Vertex) getRequest().getSource();
Vertex target = (Vertex) getRequest().getTarget();
if (source != null && target != null) {
Transition transition = SGraphFactory.eINSTANCE.createTransition();
source.getOutgoingTransitions().add(transition);
transition.setSource(source);
transition.setTarget(target);
source.getOutgoingTransitions().add(transition);
target.getIncomingTransitions().add(transition);
((CreateElementRequest) getRequest()).setNewElement(transition);
}
return CommandResult.newOKCommandResult();
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createExitPoint.
protected void createExitPoint(Edge edge, Diagram subdiagram) {
Transition transition = (Transition) edge.getElement();
// create semantic exit point
Region exitPointContainer = getExitPointContainer(transition);
Exit exitPoint = createSemanticExitPoint(transition);
// create node for exit point
View exitPointContainerView = helper.getViewForSemanticElement(exitPointContainer, subdiagram);
View exitPointRegionCompartment = ViewUtil.getChildBySemanticHint(exitPointContainerView, SemanticHints.REGION_COMPARTMENT);
Node exitNode = ViewService.createNode(exitPointRegionCompartment, exitPoint, SemanticHints.EXIT, preferencesHint);
// re-wire existing transition to new exit point
Vertex oldTransitionTarget = transition.getTarget();
transition.setTarget(exitPoint);
View oldEdgeTarget = edge.getTarget();
edge.setTarget(exitNode);
// create transition from selected state to former transition target
Transition exitPointTransition = SGraphFactory.eINSTANCE.createTransition();
exitPointTransition.setSource((State) subdiagram.getElement());
exitPointTransition.setTarget(oldTransitionTarget);
ViewService.createEdge(getContextObject(), oldEdgeTarget, exitPointTransition, SemanticHints.TRANSITION, preferencesHint);
addExitPointSpec(exitPointTransition, exitPoint);
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method removeLastActions.
private void removeLastActions(EList<Transition> transitions, int number) {
for (Transition transition : transitions) {
List<Expression> actionsToRemove = getLastActions(transition, number);
Effect effect = transition.getEffect();
if (effect instanceof ReactionEffect && actionsToRemove.size() == ((ReactionEffect) effect).getActions().size()) {
// we need to remove all actions, so just remove the effect
// recursively which avoids serializer exceptions
EcoreUtil.delete(effect, true);
} else {
for (Expression action : actionsToRemove) {
EcoreUtil.delete(action);
}
}
}
}
Aggregations