Search in sources :

Example 1 with State

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

Example 2 with State

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

Example 3 with State

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

Example 4 with State

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

Example 5 with State

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

Aggregations

State (org.yakindu.sct.model.sgraph.State)106 Test (org.junit.Test)77 Region (org.yakindu.sct.model.sgraph.Region)63 Statechart (org.yakindu.sct.model.sgraph.Statechart)59 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)51 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)51 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)50 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)46 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)46 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)46 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)46 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)39 Sequence (org.yakindu.sct.model.sexec.Sequence)36 FinalState (org.yakindu.sct.model.sgraph.FinalState)35 Entry (org.yakindu.sct.model.sgraph.Entry)30 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)28 Transition (org.yakindu.sct.model.sgraph.Transition)23 EnterState (org.yakindu.sct.model.sexec.EnterState)21