Commit 0c5c2eb8 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Resolving bug on drawing with choices with stopstate as next

parent b54dd2d2
This diff is collapsed.
......@@ -843,6 +843,30 @@ public class TMLActivity extends TMLElement {
}
public void addStopAfterElementsWithNoNext() {
List<TMLActivityElement> newStop = new LinkedList<>();
for (TMLActivityElement elt : elements) {
if (! ((elt instanceof TMLStopState) || (elt instanceof TMLChoice))) {
if (elt.getNbNext() == 0) {
TMLStopState ss = new TMLStopState("stopMissing", elt.getReferenceObject());
elt.addNext(ss);
newStop.add(ss);
}
if (elt instanceof TMLForLoop) {
if (elt.getNbNext() < 2) {
TMLStopState ss = new TMLStopState("stopMissing", elt.getReferenceObject());
elt.addNext(ss);
newStop.add(ss);
}
}
}
}
elements.addAll(newStop);
}
......@@ -882,4 +906,6 @@ public class TMLActivity extends TMLElement {
}
}
}
......@@ -50,6 +50,7 @@ import proverifspec.ProVerifQueryAuthResult;
import proverifspec.ProVerifQueryResult;
import proverifspec.ProVerifResultTrace;
import ui.TGComponent;
import ui.tmlad.TMLADStopState;
import java.util.*;
......@@ -2080,17 +2081,21 @@ public class TMLModeling<E> {
ArrayList<TMLActivityElement> toBeRemoved = new ArrayList<>();
ArrayList<TMLActivityElement> toBeRemovedLocal = new ArrayList<>();
for (int i = 0; i < activity.nElements(); i++) {
elt0 = activity.get(i);
if (elt0 instanceof TMLSequence) {
toBeRemovedLocal.clear();
int cpt = 0;
for(TMLActivityElement next: elt0.getNexts()) {
if (next instanceof TMLStopState) {
toBeRemoved.add(next);
toBeRemovedLocal.add(next);
if (elt0.getNbNext() > 1) {
for (TMLActivityElement next : elt0.getNexts()) {
if (next instanceof TMLStopState) {
toBeRemoved.add(next);
toBeRemovedLocal.add(next);
}
cpt++;
}
cpt ++;
}
for(TMLActivityElement elt: toBeRemovedLocal) {
......@@ -2117,6 +2122,30 @@ public class TMLModeling<E> {
for(TMLActivityElement elt: toBeRemoved) {
activity.removeElement(elt);
}
toBeRemoved.clear();
ArrayList<TMLActivityElement> toBeAdded = new ArrayList<>();
// We now remove sequences with no next and replace them by a Stop
for (int i = 0; i < activity.nElements(); i++) {
elt0 = activity.get(i);
if (elt0 instanceof TMLSequence) {
if (elt0.getNbNext() == 0) {
TMLStopState newStop = new TMLStopState("OldSequence", elt0.getReferenceObject());
toBeAdded.add(newStop);
toBeRemoved.add(elt0);
activity.replaceAllNext(elt0, newStop);
}
}
}
for(TMLActivityElement elt: toBeAdded) {
activity.addElement(elt);
}
for(TMLActivityElement elt: toBeRemoved) {
activity.removeElement(elt);
}
}
......
......@@ -454,6 +454,7 @@ public class DrawerTMLModeling {
"The activity diagram shall contain exactly one start state for component " + comp.getValue());
drawRecursiveBehaviour(t, activity, activity.getFirst(), comp, first, activityPanel);
activity.addStopAfterElementsWithNoNext();
}
private void drawRecursiveBehaviour(TMLTask t, TMLActivity activity, TMLActivityElement firstTML, TMLCPrimitiveComponent comp,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment