use of org.yakindu.sct.model.sgraph.State in project statecharts by Yakindu.
the class StateTemplatesModification method execute.
@SuppressWarnings("unchecked")
@Override
protected void execute(EObject semanticObject, View view) {
State state = (State) semanticObject;
Resource resource = loadTemplateResource(getTemplatePath());
Diagram diagram = (Diagram) getObjectByType(resource.getContents(), NotationPackage.Literals.DIAGRAM);
EList<View> children = diagram.getChildren();
List<Node> regions = new ArrayList<Node>();
for (View child : children) {
if (child.getType().equals(SemanticHints.REGION)) {
regions.add((Node) child);
}
}
View figureCompartment = ViewUtil.getChildBySemanticHint(view, SemanticHints.STATE_FIGURE_COMPARTMENT);
while (regions.size() > 0) {
Node child = regions.get(0);
regions.remove(child);
setPreferredSize(child);
figureCompartment.insertChild(child);
state.getRegions().add((Region) child.getElement());
}
EList<Edge> edges = diagram.getEdges();
while (edges.size() > 0) {
view.getDiagram().insertEdge(edges.get(0));
}
setPreferredSize(view);
}
use of org.yakindu.sct.model.sgraph.State in project statecharts by Yakindu.
the class StatePropertySection method createSpecificationControl.
protected void createSpecificationControl(final Composite parent) {
Label lblDocumentation = getToolkit().createLabel(parent, "State Behavior: ");
Injector injector = getInjector(State.class.getName());
if (injector != null) {
txtSpecification = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
((StyledText) txtSpecification).setAlwaysShowScrollBars(false);
enableXtext(txtSpecification, injector);
createHelpWidget(parent, txtSpecification, HelpContextIds.SC_PROPERTIES_STATE_EXPRESSION);
} else {
txtSpecification = getToolkit().createText(parent, "", SWT.MULTI);
}
GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(txtSpecification);
}
use of org.yakindu.sct.model.sgraph.State in project statecharts by Yakindu.
the class GroupStatesIntoCompositeRefactoringTest method getStatesByName.
protected List<State> getStatesByName(Statechart statechart, List<String> names) {
List<State> allStates = EcoreUtil2.getAllContentsOfType(statechart, State.class);
List<State> result = Lists.newArrayList();
for (State state : allStates) {
if (names.contains(state.getName())) {
result.add(state);
}
}
return result;
}
use of org.yakindu.sct.model.sgraph.State in project statecharts by Yakindu.
the class GroupStatesIntoCompositeRefactoringTest method testSemanticalRefactoring.
@Test
public void testSemanticalRefactoring() {
Statechart initial = models.loadStatechartFromResource(GROUPING_STATES + INITIAL_STATECHART);
List<State> states = getStatesByName(initial, Lists.newArrayList("B", "C", "D"));
GroupStatesIntoCompositeRefactoring refactoring = new GroupStatesIntoCompositeRefactoring();
refactoring.contextStates = Lists.newArrayList(states);
AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
initialRes.setSerializerEnabled(true);
refactoring.doSemanticalRefactoring();
initialRes.setSerializerEnabled(false);
initialRes.linkSpecificationElements();
Statechart expected = models.loadStatechartFromResource(GROUPING_STATES + EXPECTED_STATECHART);
compareStatecharts(initial, expected);
}
use of org.yakindu.sct.model.sgraph.State in project statecharts by Yakindu.
the class SGraphJavaValidationTest method vertexNotReachable_FailOnExternalPseudoPathToSubstate.
/**
* If an incoming transitions is part of an external transition path to an
* internal state that only consists of pseudo states and only has state
* predecessors within the state then the state is not reachable and the
* validation must fail with an error.
*/
@Test
public void vertexNotReachable_FailOnExternalPseudoPathToSubstate() {
prepareStateTest();
Region subRegion = factory.createRegion();
state.getRegions().add(subRegion);
State stateA = factory.createState();
subRegion.getVertices().add(stateA);
Choice choice = factory.createChoice();
region.getVertices().add(choice);
createTransition(stateA, choice);
createTransition(choice, stateA);
validate(state);
assertIssue(diagnostics, ISSUE_NODE_NOT_REACHABLE);
}
Aggregations