Search in sources :

Example 1 with CompositeElement

use of org.yakindu.sct.model.sgraph.CompositeElement 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;
}
Also used : State(org.yakindu.sct.model.sgraph.State) CompositeElement(org.yakindu.sct.model.sgraph.CompositeElement) HashSet(java.util.HashSet)

Example 2 with CompositeElement

use of org.yakindu.sct.model.sgraph.CompositeElement 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 3 with CompositeElement

use of org.yakindu.sct.model.sgraph.CompositeElement in project statecharts by Yakindu.

the class SGraphNameProvider method qualifiedName.

public QualifiedName qualifiedName(Region ele) {
    QualifiedName qualifiedNameFromConverter = null;
    if (ele.getName() == null || ele.getName().isEmpty()) {
        if (ele.eContainer() instanceof CompositeElement) {
            CompositeElement parent = (CompositeElement) ele.eContainer();
            int index = parent.getRegions().indexOf(ele);
            if (index != -1) {
                qualifiedNameFromConverter = QualifiedName.create("_region" + index);
            }
        }
        if (qualifiedNameFromConverter == null) {
            return null;
        }
    } else {
        qualifiedNameFromConverter = QualifiedName.create(identifierConverter.toIdentifier(ele.getName()));
    }
    return getParentQualifiedName(ele, qualifiedNameFromConverter);
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) CompositeElement(org.yakindu.sct.model.sgraph.CompositeElement)

Aggregations

CompositeElement (org.yakindu.sct.model.sgraph.CompositeElement)3 HashSet (java.util.HashSet)1 EObject (org.eclipse.emf.ecore.EObject)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 Check (org.eclipse.xtext.validation.Check)1 State (org.yakindu.sct.model.sgraph.State)1 Synchronization (org.yakindu.sct.model.sgraph.Synchronization)1 Vertex (org.yakindu.sct.model.sgraph.Vertex)1