Skip to content

Commit

Permalink
Quite horrendous code.
Browse files Browse the repository at this point in the history
The doVisualize(s) method took a string that had
a type and a parameter, like "XML: /foo/bar..". There
was a public method setLatestInstance(s) that sets
the parameter part. However, that meant that we could
not remember the latest if it wasn't XML. The doVisualize(s)
was the central dispatcher for visualization and called
from many places.

The doVisualize(s) now takes an _optionally_ typed
argument. If it is not typed, we assume XML. So now
can we set a typed string via setLatestInstance(s).

When we create an output file as is now supported by
the solver architecture, we safe it as "CNF: /...".
So when we hit show latest instance, we get the file.

Ugly as hell ...

Fixes #273
  • Loading branch information
pkriens committed May 14, 2024
1 parent d1b71cf commit 52a0527
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.regex.Pattern;

import javax.swing.Action;
import javax.swing.Box;
Expand Down Expand Up @@ -203,6 +204,8 @@
*/
public final class SimpleGUI implements ComponentListener, Listener {

final static Pattern TYPED_P = Pattern.compile("([A-Z]{3,6}):");

MacUtil macUtil;

/**
Expand Down Expand Up @@ -1164,6 +1167,7 @@ private Runner doRun(Integer commandIndex) {
* This method stops the current run or check (how==0 means DONE, how==1 means
* FAIL, how==2 means STOP).
*/

Runner doStop(Integer how) {
if (wrap)
return wrapMe(how);
Expand All @@ -1188,8 +1192,9 @@ Runner doStop(Integer how) {
viz.loadXML(f, true, 0);
else if (subrunningTask == 3)
viz.loadXML(f, true);
else if (AutoVisualize.get() || subrunningTask == 1)
doVisualize("XML: " + f);
else if (AutoVisualize.get() || subrunningTask == 1) {
doVisualize(f);
}
}
return null;
}
Expand Down Expand Up @@ -1256,8 +1261,9 @@ private Runner doShowLatest() {
return wrapMe();
if (latestInstance.length() == 0)
log.logRed("No previous instances are available for viewing.\n\n");
else
doVisualize("XML: " + latestInstance);
else {
doVisualize(latestInstance);
}
return null;
}

Expand Down Expand Up @@ -1293,7 +1299,7 @@ private Runner doRefreshWindow(Boolean isViz) {
for (String f : viz.getInstances()) {
JMenuItem it = new JMenuItem("Instance: " + viz.getInstanceTitle(f), null);
it.setIcon((isViz && f.equals(viz.getXMLfilename())) ? iconYes : iconNo);
it.addActionListener(doVisualize("XML: " + f));
it.addActionListener(doVisualize(f));
w.add(it);
}
} finally {
Expand Down Expand Up @@ -1639,6 +1645,11 @@ void doSetLatest(String arg) {
Runner doVisualize(String arg) {
if (wrap)
return wrapMe(arg);

if (!TYPED_P.matcher(arg).lookingAt()) {
arg = "XML: " + arg;
}

text.clearShade();
if (arg.startsWith("MSG: ")) { // MSG: message
OurDialog.showtext("Detailed Message", arg.substring(5));
Expand Down Expand Up @@ -2363,8 +2374,4 @@ public void stateChanged(ChangeEvent e) {
}
};
}

private FindReplace getOrderedTab() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ else if (ex instanceof ErrorType)
results.add(null);
span.setLength(len3);
span.log(" File written to ");
span.logLink(array[1].toString(), "file://" + array[1]);
String linkDestination = "CNF: " + array[1];
span.logLink(array[1].toString(), linkDestination);
span.log("\n\n");
gui.doSetLatest(linkDestination);
}
if (array[0].equals("debug") && verbosity > 2) {
span.log(" " + array[1] + "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ public String type() {
return "transformer";
}

@Override
public String name() {
return "Electrod elo output";
}

}

0 comments on commit 52a0527

Please sign in to comment.