use of org.yakindu.sct.model.sgraph.Vertex in project statecharts by Yakindu.
the class SGraphJavaValidator method orthogonalSynchronizedTransition.
@Check
public void orthogonalSynchronizedTransition(Synchronization sync) {
List<Transition> incoming = sync.getIncomingTransitions();
List<List<EObject>> inAncestorsList = new ArrayList<>();
for (Transition trans : incoming) {
inAncestorsList.add(collectAncestors(trans.getSource(), new ArrayList<EObject>()));
}
List<Transition> outgoing = sync.getOutgoingTransitions();
List<List<EObject>> outAncestorsList = new ArrayList<>();
for (Transition trans : outgoing) {
outAncestorsList.add(collectAncestors(trans.getTarget(), new ArrayList<EObject>()));
}
Set<Transition> inOrthogonal = new HashSet<>();
Set<Transition> outOrthogonal = new HashSet<>();
if (incoming.size() == 0 || outgoing.size() == 0) {
return;
}
for (int i = 0; i < incoming.size(); i++) {
for (int j = 0; j < outgoing.size(); j++) {
List<Vertex> states = new ArrayList<>(Arrays.asList(incoming.get(i).getSource(), outgoing.get(j).getTarget()));
if (areOrthogonal(states)) {
inOrthogonal.add(incoming.get(i));
outOrthogonal.add(outgoing.get(j));
}
}
}
for (Transition trans : inOrthogonal) {
error(ISSUE_SYNCHRONIZATION_SOURCE_TARGET_STATES_PARENT_REGION, trans, null, -1);
}
for (Transition trans : outOrthogonal) {
error(ISSUE_SYNCHRONIZATION_SOURCE_TARGET_STATES_PARENT_REGION, trans, null, -1);
}
}
use of org.yakindu.sct.model.sgraph.Vertex in project statecharts by Yakindu.
the class SGraphJavaValidator method orthogonalTransition.
@Check
public void orthogonalTransition(Transition transition) {
Vertex source = transition.getSource();
Vertex target = transition.getTarget();
if ((source instanceof Synchronization) || (target instanceof Synchronization))
// ... the check does not apply.
return;
EObject commonAncestor = commonAncestor(source, target);
if (commonAncestor instanceof CompositeElement) {
error(ISSUE_TRANSITION_ORTHOGONAL, transition, null, -1);
}
}
use of org.yakindu.sct.model.sgraph.Vertex in project statecharts by Yakindu.
the class RegionCompartmentCanonicalEditPolicy method getSemanticConnectionsList.
@Override
protected List getSemanticConnectionsList() {
List<Transition> transitions = Lists.newArrayList();
EList<Vertex> vertices = getSemanticHost().getVertices();
for (Vertex vertex : vertices) {
transitions.addAll(vertex.getOutgoingTransitions());
}
return transitions;
}
use of org.yakindu.sct.model.sgraph.Vertex 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.Vertex in project statecharts by Yakindu.
the class CreateTransitionCommand method canExecute.
@Override
public boolean canExecute() {
EObject source = getRequest().getSource();
EObject target = getRequest().getTarget();
if (source == null && target == null) {
return false;
}
if (source != null && !(source instanceof Vertex))
return false;
if (target != null && !(target instanceof Vertex))
return false;
return true;
}
Aggregations