use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class StateEditHelper method createCompositeStateCommand.
private ICommand createCompositeStateCommand(ConfigureRequest req) {
Region region = SGraphFactory.eINSTANCE.createRegion();
region.setName("r1");
return new SetValueCommand(new SetRequest(req.getElementToConfigure(), SGraphPackage.Literals.COMPOSITE_ELEMENT__REGIONS, region));
}
use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createEntryPoint.
protected void createEntryPoint(Edge edge, Diagram subdiagram) {
Transition transition = (Transition) edge.getElement();
Region entryPointContainer = getEntryPointContainer(transition);
Entry entryPoint = createSemanticEntryPoint(transition);
// re-wire old transition to targeting the selected state
transition.setTarget((State) subdiagram.getElement());
View oldTarget = edge.getTarget();
edge.setTarget(getContextObject());
// create node for entry point
View entryPointContainerView = helper.getViewForSemanticElement(entryPointContainer, subdiagram);
View entryPointRegionCompartment = ViewUtil.getChildBySemanticHint(entryPointContainerView, SemanticHints.REGION_COMPARTMENT);
Node entryNode = ViewService.createNode(entryPointRegionCompartment, entryPoint, SemanticHints.ENTRY, preferencesHint);
ViewService.createEdge(entryNode, oldTarget, entryPoint.getOutgoingTransitions().get(0), SemanticHints.TRANSITION, preferencesHint);
addEntryPointSpec(transition, entryPoint);
}
use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createSemanticEntryPoint.
protected Entry createSemanticEntryPoint(Transition transition) {
Region entryPointTarget = getEntryPointContainer(transition);
String name = getEntryPointName(transition);
Entry entryPoint = null;
Iterator<Vertex> iterator = entryPointTarget.getVertices().iterator();
while (iterator.hasNext()) {
Vertex next = iterator.next();
if (next instanceof Entry) {
Entry current = (Entry) next;
if (name.equals(current.getName())) {
// Do nothing, there already exists an entry point
return current;
}
}
}
entryPoint = SGraphFactory.eINSTANCE.createEntry();
entryPoint.setName(name);
entryPointTarget.getVertices().add(entryPoint);
Transition entryPointTransition = SGraphFactory.eINSTANCE.createTransition();
entryPointTransition.setSource(entryPoint);
entryPointTransition.setTarget(transition.getTarget());
return entryPoint;
}
use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createSemanticExitPoint.
private Exit createSemanticExitPoint(Transition transition) {
Region exitPointContainer = getExitPointContainer(transition);
String name = getExitPointName(transition);
Exit exitPoint = null;
Iterator<Vertex> iterator = exitPointContainer.getVertices().iterator();
while (iterator.hasNext()) {
Vertex next = iterator.next();
if (next instanceof Exit) {
Exit current = (Exit) next;
if (name.equals(current.getName())) {
// Do nothing, there already exists an entry point
return current;
}
}
}
exitPoint = SGraphFactory.eINSTANCE.createExit();
exitPoint.setName(name);
exitPointContainer.getVertices().add(exitPoint);
return exitPoint;
}
use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class STextJavaValidator method checkUnboundEntryPoints.
@Check(CheckType.NORMAL)
public void checkUnboundEntryPoints(final org.yakindu.sct.model.sgraph.State state) {
if (state.isComposite()) {
final List<Transition>[] transitions = STextValidationModelUtils.getEntrySpecSortedTransitions(state.getIncomingTransitions());
Map<Region, List<Entry>> regions = null;
// first list contains Transitions without entry spec
if (!transitions[0].isEmpty()) {
regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
if (!regions.isEmpty()) {
for (Transition transition : transitions[0]) {
error(TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT, transition, null, -1);
}
for (Region region : regions.keySet()) {
error(REGION_UNBOUND_DEFAULT_ENTRY_POINT, region, null, -1);
}
}
}
// second list contains Transitions with entry spec
if (!transitions[1].isEmpty()) {
if (regions == null) {
regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
}
for (Transition transition : transitions[1]) {
boolean hasTargetEntry = true;
for (ReactionProperty property : transition.getProperties()) {
if (property instanceof EntryPointSpec) {
EntryPointSpec spec = (EntryPointSpec) property;
String specName = "'" + spec.getEntrypoint() + "'";
for (Region region : regions.keySet()) {
boolean hasEntry = false;
for (Entry entry : regions.get(region)) {
if (entry.getName().equals(spec.getEntrypoint())) {
hasEntry = true;
break;
}
}
if (!hasEntry) {
error(REGION_UNBOUND_NAMED_ENTRY_POINT + specName, region, null, -1);
hasTargetEntry = false;
}
}
if (!hasTargetEntry) {
error(TRANSITION_UNBOUND_NAMED_ENTRY_POINT + specName, transition, null, -1);
}
}
}
}
}
}
}
Aggregations