reducing logging confusion
This commit is contained in:
parent
44a38441cd
commit
41021c4911
|
@ -138,20 +138,30 @@ public class AutoupdateUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void assertNotAwtThread() {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
showError("Non AWT thread expected");
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertAwtThread() {
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
Exception e = new IllegalStateException("Not on AWT thread but " + Thread.currentThread().getName());
|
||||
|
||||
StringBuilder trace = new StringBuilder(e + "\n");
|
||||
for(StackTraceElement element : e.getStackTrace())
|
||||
trace.append(element.toString()).append("\n");
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
Window w = getSelectedWindow(Window.getWindows());
|
||||
JOptionPane.showMessageDialog(w, trace, "Error", JOptionPane.ERROR_MESSAGE);
|
||||
});
|
||||
showError("Not on AWT thread but " + Thread.currentThread().getName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void showError(String error) {
|
||||
Exception e = new IllegalStateException(error);
|
||||
|
||||
StringBuilder trace = new StringBuilder(e + "\n");
|
||||
for(StackTraceElement element : e.getStackTrace())
|
||||
trace.append(element.toString()).append("\n");
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
Window w = getSelectedWindow(Window.getWindows());
|
||||
JOptionPane.showMessageDialog(w, trace, "Error", JOptionPane.ERROR_MESSAGE);
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean hasExistingFile(String zipFileName, long completeFileSize, long lastModified) {
|
||||
File file = new File(zipFileName);
|
||||
System.out.println("We have " + file.length() + " " + new Date(file.lastModified()) + " " + file.getAbsolutePath());
|
||||
|
|
|
@ -187,19 +187,22 @@ public class ProgramSelector {
|
|||
// Check that the ECU disappeared from the "after" list
|
||||
final boolean ecuPortStillAlive = !PortDetector.AUTO.equals(ecuPort) && Arrays.stream(currentPorts).anyMatch(ecuPort::equals);
|
||||
if (!ecuPortStillAlive) {
|
||||
callbacks.logLine("[Disappeared]");
|
||||
return new Pair<>(true, currentPorts);
|
||||
} else {
|
||||
callbacks.log(".", false, false);
|
||||
}
|
||||
}
|
||||
callbacks.log("", true, false);
|
||||
callbacks.logLine("[Not found]");
|
||||
return new Pair<>(false, currentPorts);
|
||||
}
|
||||
|
||||
private static void flashOpenbltSerialAutomatic(JComponent parent, String ecuPort, UpdateOperationCallbacks callbacks) {
|
||||
AutoupdateUtil.assertNotAwtThread();
|
||||
final String[] portsBefore = LinkManager.getCommPorts();
|
||||
rebootToOpenblt(parent, ecuPort, callbacks);
|
||||
|
||||
// invoking blocking method
|
||||
final Pair<Boolean, String[]> rebootResult = waitForEcuPortDisappeared(ecuPort, parent, callbacks);
|
||||
final boolean ecuPrtDisappeared = rebootResult.first;
|
||||
final String[] portsAfter = rebootResult.second;
|
||||
|
|
Loading…
Reference in New Issue