Search in sources :

Example 6 with Vertex

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);
    }
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Transition(org.yakindu.sct.model.sgraph.Transition) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) Check(org.eclipse.xtext.validation.Check)

Example 7 with Vertex

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);
    }
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) EObject(org.eclipse.emf.ecore.EObject) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) CompositeElement(org.yakindu.sct.model.sgraph.CompositeElement) Check(org.eclipse.xtext.validation.Check)

Example 8 with Vertex

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;
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Transition(org.yakindu.sct.model.sgraph.Transition)

Example 9 with Vertex

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();
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Transition(org.yakindu.sct.model.sgraph.Transition) CreateElementRequest(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)

Example 10 with Vertex

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;
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

Vertex (org.yakindu.sct.model.sgraph.Vertex)14 Transition (org.yakindu.sct.model.sgraph.Transition)7 Region (org.yakindu.sct.model.sgraph.Region)6 ArrayList (java.util.ArrayList)4 Check (org.eclipse.xtext.validation.Check)4 EObject (org.eclipse.emf.ecore.EObject)3 Entry (org.yakindu.sct.model.sgraph.Entry)3 HashSet (java.util.HashSet)2 Exit (org.yakindu.sct.model.sgraph.Exit)2 FinalState (org.yakindu.sct.model.sgraph.FinalState)2 Predicate (com.google.common.base.Predicate)1 List (java.util.List)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 CompositeCommand (org.eclipse.gmf.runtime.common.core.command.CompositeCommand)1 PreferencesHint (org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint)1 DestroyElementCommand (org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand)1 CreateElementRequest (org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)1 DestroyElementRequest (org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest)1 Node (org.eclipse.gmf.runtime.notation.Node)1 View (org.eclipse.gmf.runtime.notation.View)1