Commit 3816df66 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

prevent opening a dialog if there is only one variable

parent ac1f906b
......@@ -21,6 +21,7 @@ import static java.util.stream.Collectors.toList;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.af3.component.ui.AF3ComponentUIActivator.getDefault;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.isAtomicComponent;
import static org.fortiss.af3.specification.constraint.BoundsConstraint.getBoundsViolationTrace;
import static org.fortiss.tooling.kernel.ui.util.EditorUtils.getOpenedEditor;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
......@@ -128,23 +129,30 @@ public class BoundsConstraintUI extends ConstraintUIBases.ConstraintUIBaseAutoch
}
} else {
try {
TraceSelectionDialog dlg =
new TraceSelectionDialog(Display.getDefault().getActiveShell(),
BoundsConstraint
.getBoundsViolationTrace(ci)
.stream()
.collect(
// only take one failed constraint per Var
groupSingle(oob -> oob.getFirst().getVariable()
.getVar().getIdentifier(),
p -> p.getSecond())));
if(dlg.open() != Window.OK)
Map<String, CounterExample> traces =
getBoundsViolationTrace(ci).stream().collect(
// only take one failed constraint per Var
groupSingle(oob -> oob.getFirst().getVariable().getVar()
.getIdentifier(), p -> p.getSecond()));
CounterExample selectedTtrace;
if(traces.size() == 1) {
selectedTtrace = traces.get(0);
} else if(traces.size() > 1) {
TraceSelectionDialog dlg =
new TraceSelectionDialog(Display.getDefault().getActiveShell(),
traces);
if(dlg.open() != Window.OK) {
return false;
}
selectedTtrace = dlg.getSelectedTrace();
} else {
return false;
}
getWorkbench().showPerspective(SimulationPerspective.ID,
getWorkbench().getActiveWorkbenchWindow());
SimulationManager.INSTANCE.setCurrentSimulation(new CounterExampleSimulator(dlg
.getSelectedTrace()));
SimulationManager.INSTANCE.setCurrentSimulation(new CounterExampleSimulator(
selectedTtrace));
} catch(ChainTransformationFailedException e) {
e.printStackTrace();
} catch(WorkbenchException e) {
......@@ -231,7 +239,7 @@ public class BoundsConstraintUI extends ConstraintUIBases.ConstraintUIBaseAutoch
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("Observe state reachability");
shell.setText("Observe bound mismatch");
}
/** {@inheritDoc} */
......@@ -239,7 +247,7 @@ public class BoundsConstraintUI extends ConstraintUIBases.ConstraintUIBaseAutoch
protected Control createDialogArea(Composite parent) {
parent.setLayout(new GridLayout(1, true));
Label label = new Label(parent, SWT.NONE);
label.setText("Pick a state:");
label.setText("Pick a port:");
l = new org.eclipse.swt.widgets.List(parent, SWT.BORDER | SWT.CENTER);
l.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
for(String s : traces.keySet()) {
......
Supports Markdown
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