use of org.yakindu.sct.model.sgraph.Vertex 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.Vertex 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.Vertex in project statecharts by Yakindu.
the class VertexEditHelper method getDestroyDependentsCommand.
@Override
protected ICommand getDestroyDependentsCommand(DestroyDependentsRequest req) {
Vertex elementToDestroy = (Vertex) req.getElementToDestroy();
EList<Transition> incomingTransitions = elementToDestroy.getIncomingTransitions();
if (incomingTransitions.size() != 0) {
CompositeCommand compoundCommand = new CompositeCommand("Delete vertex");
for (Transition transition : incomingTransitions) {
DestroyElementCommand destroyCommand = new DestroyElementCommand(new DestroyElementRequest(transition, false));
compoundCommand.add(destroyCommand);
}
return compoundCommand;
}
return super.getDestroyDependentsCommand(req);
}
use of org.yakindu.sct.model.sgraph.Vertex in project statecharts by Yakindu.
the class SGraphNameProvider method qualifiedName.
public QualifiedName qualifiedName(Choice ele) {
// first get order number of choice node
List<Vertex> choiceList = new ArrayList<Vertex>();
choiceList.addAll(Collections2.filter(((Region) ele.eContainer()).getVertices(), new Predicate<Vertex>() {
public boolean apply(Vertex input) {
return input instanceof Choice;
}
}));
int index = choiceList.indexOf(ele);
QualifiedName qualifiedNameFromConverter = QualifiedName.create(_CHOICE_NAME + index);
return getParentQualifiedName(ele, qualifiedNameFromConverter);
}
use of org.yakindu.sct.model.sgraph.Vertex in project statecharts by Yakindu.
the class SGraphJavaValidator method regionCantBeEnteredUsingShallowHistory.
/**
* Checks if all composite states that are siblings of a shallow history can
* enter their regions.
*
* @param e
*/
@Check(CheckType.FAST)
public void regionCantBeEnteredUsingShallowHistory(Entry e) {
if (e.getKind() == EntryKind.SHALLOW_HISTORY) {
// get all regions off all sibling states
List<Region> regions = new ArrayList<>();
for (Vertex v : e.getParentRegion().getVertices()) {
if (v instanceof org.yakindu.sct.model.sgraph.State) {
org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) v;
regions.addAll(state.getRegions());
}
}
// check each region
for (Region r : regions) {
// first determine if the region contains a default entry
Entry defaultEntry = null;
for (Vertex v : r.getVertices()) {
if (v instanceof Entry) {
String name = v.getName().trim().toLowerCase();
if (name != null || "".equals(name) || "default".equals(name)) {
defaultEntry = (Entry) v;
break;
}
}
}
// now check error conditions
if (defaultEntry == null) {
error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY, r, null, -1);
} else if (defaultEntry.getOutgoingTransitions().size() != 1) {
error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY, r, null, -1);
}
}
}
}
Aggregations