Skip to content

Commit 1571bee

Browse files
committed
Merge branch 'simulator' into v2.1
2 parents 98b1480 + 7888884 commit 1571bee

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGUI.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,10 @@ private void updateDisplay() {
860860
default :
861861
vizButton.setEnabled(false);
862862
}
863-
final boolean isMeta = myStates.get(statepanes - 1).getOriginalInstance().isMetamodel; // [HASLab]
864-
final boolean isTrace = myStates.get(statepanes - 1).getOriginalInstance().originalA4.getMaxTrace() >= 0; // [HASLab]
863+
final AlloyInstance oInst = myStates.get(statepanes - 1).getOriginalInstance();
864+
final boolean isMeta = oInst.isMetamodel; // [HASLab]
865+
final boolean isTrace = oInst.originalA4.getMaxTrace() >= 0; // [HASLab]
866+
final boolean hasConfigs = oInst.originalA4.hasConfigs(); // [HASLab]
865867
vizButton.setVisible(frame != null);
866868
treeButton.setVisible(frame != null);
867869
txtButton.setVisible(frame != null);
@@ -888,9 +890,10 @@ private void updateDisplay() {
888890
pathMenu.setVisible(isTrace); // [HASLab]
889891
pathButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && isTrace); // [HASLab]
890892
pathButton.setEnabled(!seg_iteration); // [HASLab]
891-
cnfgMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null); // [HASLab]
893+
cnfgMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null && hasConfigs); // [HASLab]
892894
cnfgMenu.setVisible(isTrace); // [HASLab]
893895
cnfgButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && isTrace); // [HASLab]
896+
cnfgButton.setEnabled(hasConfigs); // [HASLab]
894897
forkMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null); // [HASLab]
895898
forkMenu.setVisible(isTrace); // [HASLab]
896899
forkButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && isTrace); // [HASLab]
@@ -949,7 +952,7 @@ public final void focusLost(FocusEvent e) {}
949952
mySplitTemporal.setVisible(true);
950953
} else {
951954
mySplitTemporal = null;
952-
myGraphPanel = new VizGraphPanel(myStates.subList(statepanes - 1, statepanes), false); // [HASLab]
955+
myGraphPanel = new VizGraphPanel(myStates.subList(statepanes - 1, statepanes), false); // [HASLab]
953956
}
954957
} else {
955958
if (isTrace && !isMeta) { // [HASLab]
@@ -995,7 +998,7 @@ public final void focusLost(FocusEvent e) {}
995998
left = myCustomPanel;
996999
} else if (settingsOpen > 1) {
9971000
if (myEvaluatorPanel == null)
998-
myEvaluatorPanel = new OurConsole(evaluator, true, "The ", true, "Alloy Evaluator ", false, "allows you to type\nin Alloy expressions and see their values\nat the currently focused state (left-hand side).\nFor example, ", true, "univ", false, " shows the list of all\natoms on the left-hand state.\n(You can press UP and DOWN to recall old inputs).\n"); // [HASLab]
1001+
myEvaluatorPanel = new OurConsole(evaluator, true, "The ", true, "Alloy Evaluator ", false, "allows you to type\nin Alloy expressions and see their values\nat the currently focused state (left-hand side).\nFor example, ", true, "univ", false, " shows the list of all\natoms on the left-hand state.\n(You can press UP and DOWN to recall old inputs).\n"); // [HASLab]
9991002
try {
10001003
evaluator.compute(new File(xmlFileName));
10011004
myEvaluatorPanel.setCurrent(current); // [HASLab] set evaluator state

org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4Solution.java

+16
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,22 @@ public SafeList<Sig> getAllReachableSigs() {
937937
return sigs.dup();
938938
}
939939

940+
/**
941+
* Checks whether the this solution's model contains any configuration (static)
942+
* elements.
943+
*/
944+
// [HASLab]
945+
public boolean hasConfigs() {
946+
for (Sig s : sigs) {
947+
if (s.isVariable == null && !s.builtin)
948+
return true;
949+
for (edu.mit.csail.sdg.ast.Decl f : s.getFieldDecls())
950+
if (f.isVar == null)
951+
return true;
952+
}
953+
return false;
954+
}
955+
940956
/**
941957
* Returns an unmodifiable copy of the list of all skolems if the problem is
942958
* solved and is satisfiable; else returns an empty list.

0 commit comments

Comments
 (0)