From ee8473877416ef61b7555f09c18fc8969e451593 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 27 Nov 2022 09:49:36 -0500 Subject: [PATCH] better API --- .../main/java/com/rusefi/maintenance/DfuFlasher.java | 12 ++++++------ .../java/com/rusefi/maintenance/FirmwareFlasher.java | 2 +- .../ui/src/main/java/com/rusefi/ui/StatusWindow.java | 11 ++++------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java b/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java index 47191ef01e..36403e6419 100644 --- a/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java +++ b/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java @@ -83,7 +83,7 @@ public class DfuFlasher { if (signature.get() == null) { wnd.append("*** ERROR *** rusEFI has not responded on selected " + port + "\n" + "Maybe try automatic serial port detection?"); - wnd.setErrorState(true); + wnd.setErrorState(); return null; } boolean isSignatureValidatedLocal = DfuHelper.sendDfuRebootCommand(parent, signature.get(), stream, wnd); @@ -100,7 +100,7 @@ public class DfuFlasher { }).getSerialPort(); if (port == null) { wnd.append("*** ERROR *** rusEFI serial port not detected"); - wnd.setErrorState(true); + wnd.setErrorState(); return null; } else { wnd.append("Detected rusEFI on " + port + "\n"); @@ -136,7 +136,7 @@ public class DfuFlasher { boolean driverIsHappy = detectSTM32BootloaderDriverState(wnd); if (!driverIsHappy) { wnd.append("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?"); - wnd.setErrorState(true); + wnd.setErrorState(); return; } @@ -148,7 +148,7 @@ public class DfuFlasher { DFU_BINARY, wnd, stdout); } catch (FileNotFoundException e) { wnd.append("ERROR: " + e); - wnd.setErrorState(true); + wnd.setErrorState(); return; } if (stdout.toString().contains("Download verified successfully")) { @@ -161,12 +161,12 @@ public class DfuFlasher { wnd.append("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen"); wnd.append("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder"); appendDeviceReport(wnd); - wnd.setErrorState(true); + wnd.setErrorState(); } else { wnd.append(stdout.length() + " / " + errorResponse.length()); appendWindowsVersion(wnd); appendDeviceReport(wnd); - wnd.setErrorState(true); + wnd.setErrorState(); } } diff --git a/java_console/ui/src/main/java/com/rusefi/maintenance/FirmwareFlasher.java b/java_console/ui/src/main/java/com/rusefi/maintenance/FirmwareFlasher.java index bf1dd2522f..f207a866a7 100644 --- a/java_console/ui/src/main/java/com/rusefi/maintenance/FirmwareFlasher.java +++ b/java_console/ui/src/main/java/com/rusefi/maintenance/FirmwareFlasher.java @@ -80,7 +80,7 @@ public class FirmwareFlasher { sa.stop(); wnd.setStatus(DONE); } else { - wnd.setErrorState(true); + wnd.setErrorState(); wnd.append("!!! FIRMWARE FLASH: DOES NOT LOOK RIGHT !!!"); } } diff --git a/java_console/ui/src/main/java/com/rusefi/ui/StatusWindow.java b/java_console/ui/src/main/java/com/rusefi/ui/StatusWindow.java index 1c2c7cf8a4..e3dbcf0aba 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/StatusWindow.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/StatusWindow.java @@ -54,13 +54,10 @@ public class StatusWindow implements StatusConsumer { return content; } - public void setErrorState(boolean isErrorState) { - if (isErrorState) { - logTextArea.setBackground(LIGHT_RED); - copyContentToClipboard(); - } else { - logTextArea.setBackground(LIGHT_GREEN); - } + + public void setErrorState() { + logTextArea.setBackground(LIGHT_RED); + copyContentToClipboard(); } public JFrame getFrame() {