only:refactoring: get rid of redundant `UpdateOperationCallbacks.append` and `UpdateOperationCallbacks.appendLine` methods because they duplicate `UpdateOperationCallbacks.log` and `UpdateOperationCallbacks.logLine` methods #7199

This commit is contained in:
kifir23917 2025-01-23 16:25:58 +03:00 committed by rusefillc
parent 3f9193bb6a
commit a461d40a7e
5 changed files with 28 additions and 41 deletions

View File

@ -7,14 +7,6 @@ public interface UpdateOperationCallbacks {
log(message, true, true);
}
default void append(final String message, final boolean breakLineOnTextArea, final boolean sendToLogger) {
log(message, breakLineOnTextArea, sendToLogger);
}
default void appendLine(final String message) {
append(message, true, true);
}
void done();
void error();

View File

@ -52,8 +52,8 @@ public class DfuFlasher {
return;
if (isSignatureValidated.get()) {
if (!FileLog.isWindows()) {
callbacks.appendLine("Switched to DFU mode!");
callbacks.appendLine("rusEFI console can only program on Windows");
callbacks.logLine("Switched to DFU mode!");
callbacks.logLine("rusEFI console can only program on Windows");
return;
}
@ -93,14 +93,14 @@ public class DfuFlasher {
return null;
});
if (signature.get() == null) {
callbacks.appendLine("");
callbacks.appendLine("");
callbacks.appendLine("");
callbacks.appendLine("Make sure TUNERSTUDIO IS DISCONNECTED FROM ECU");
callbacks.appendLine("");
callbacks.appendLine("");
callbacks.appendLine("");
callbacks.appendLine("*** ERROR *** rusEFI has not responded on selected " + port + "\n" +
callbacks.logLine("");
callbacks.logLine("");
callbacks.logLine("");
callbacks.logLine("Make sure TUNERSTUDIO IS DISCONNECTED FROM ECU");
callbacks.logLine("");
callbacks.logLine("");
callbacks.logLine("");
callbacks.logLine("*** ERROR *** rusEFI has not responded on selected " + port + "\n" +
"Maybe try automatic serial port detection?");
callbacks.error();
return null;
@ -119,11 +119,11 @@ public class DfuFlasher {
return null;
}).getSerialPort();
if (port == null) {
callbacks.appendLine("*** ERROR *** rusEFI serial port not detected");
callbacks.logLine("*** ERROR *** rusEFI serial port not detected");
callbacks.error();
return null;
} else {
callbacks.appendLine("Detected rusEFI on " + port + "\n");
callbacks.logLine("Detected rusEFI on " + port + "\n");
}
}
return isSignatureValidated;
@ -170,7 +170,7 @@ public class DfuFlasher {
private static void executeDFU(UpdateOperationCallbacks callbacks, String firmwareBinFile) {
boolean driverIsHappy = detectSTM32BootloaderDriverState(callbacks);
if (!driverIsHappy) {
callbacks.appendLine("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?");
callbacks.logLine("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?");
callbacks.error();
return;
}
@ -193,10 +193,10 @@ public class DfuFlasher {
callbacks.logLine("Please power cycle device to exit DFU mode");
callbacks.done();
} else if (stdout.toString().contains("Target device not found")) {
callbacks.appendLine("ERROR: Device not connected or STM32 Bootloader driver not installed?");
callbacks.logLine("ERROR: Device not connected or STM32 Bootloader driver not installed?");
appendWindowsVersion(callbacks);
callbacks.appendLine("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen");
callbacks.appendLine("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder");
callbacks.logLine("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen");
callbacks.logLine("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder");
appendDeviceReport(callbacks);
callbacks.error();
} else {

View File

@ -52,7 +52,7 @@ public class DriverInstall {
log.info("IsWindows=" + FileLog.isWindows());
if (!new File(FOLDER).exists()) {
String message = FOLDER + " not found";
wnd.appendLine(message);
wnd.logLine(message);
log.info(message);
return;
}
@ -65,7 +65,7 @@ public class DriverInstall {
String batch = isWindows7orBelow() ? WINDOWS7_BATCH : WINDOWS8_BATCH;
ExecHelper.executeCommand(UNPACKED_FOLDER, ExecHelper.getBatchCommand(batch), batch, wnd);
} catch (FileNotFoundException e) {
wnd.appendLine(e.toString());
wnd.logLine(e.toString());
wnd.error();
}
}

View File

@ -50,7 +50,7 @@ public class StLinkFlasher {
private static void doFlashFirmware(UpdateOperationCallbacks wnd, String fileName) {
if (!new File(fileName).exists()) {
wnd.appendLine(fileName + " not found, cannot proceed !!!");
wnd.logLine(fileName + " not found, cannot proceed !!!");
wnd.error();
return;
}
@ -60,16 +60,16 @@ public class StLinkFlasher {
fileName +
" verify reset exit 0x08000000\"", wnd);
} catch (FileNotFoundException e) {
wnd.appendLine(e.toString());
wnd.logLine(e.toString());
wnd.error();
return;
}
if (error.contains(SUCCESS_MESSAGE_TAG) && !error.toLowerCase().contains(FAILED_MESSAGE_TAG)) {
wnd.appendLine("Flashing looks good!");
wnd.logLine("Flashing looks good!");
wnd.done();
} else {
wnd.error();
wnd.appendLine("!!! FIRMWARE FLASH: DOES NOT LOOK RIGHT !!!");
wnd.logLine("!!! FIRMWARE FLASH: DOES NOT LOOK RIGHT !!!");
}
}

View File

@ -43,11 +43,6 @@ public class StatusPanel extends JPanel implements UpdateOperationCallbacks, Sta
copyContentToClipboard();
}
@Override
public void log(final String message, final boolean breakLineOnTextArea, final boolean sendToLogger) {
append(message, breakLineOnTextArea, sendToLogger);
}
@Override
public void done() {
setSuccessState();
@ -68,20 +63,20 @@ public class StatusPanel extends JPanel implements UpdateOperationCallbacks, Sta
SwingUtilities.invokeLater(() -> Toolkit.getDefaultToolkit().getSystemClipboard()
.setContents(new StringSelection(logTextArea.getText()), null));
appendLine("hint: error state is already in your clipboard, please use PASTE or Ctrl-V while reporting issues");
logLine("hint: error state is already in your clipboard, please use PASTE or Ctrl-V while reporting issues");
}
@Override
public void clear() {
logTextArea.setText("");
logTextArea.setBackground(Color.WHITE);
appendLine("Console version " + rusEFIVersion.CONSOLE_VERSION);
appendLine(FileLog.getOsName() + " " + System.getProperty("os.version"));
appendLine("Bundle " + BundleUtil.readBundleFullNameNotNull());
logLine("Console version " + rusEFIVersion.CONSOLE_VERSION);
logLine(FileLog.getOsName() + " " + System.getProperty("os.version"));
logLine("Bundle " + BundleUtil.readBundleFullNameNotNull());
}
@Override
public void append(final String string, final boolean breakLineOnTextArea, final boolean sendToLogger) {
public void log(final String string, final boolean breakLineOnTextArea, final boolean sendToLogger) {
// todo: check if AWT thread and do not invokeLater if already on AWT thread
SwingUtilities.invokeLater(() -> {
String s = string.replaceAll(Character.toString((char) 219), "");
@ -103,6 +98,6 @@ public class StatusPanel extends JPanel implements UpdateOperationCallbacks, Sta
@Override
public void appendStatus(final String string) {
append(string, true, true);
log(string, true, true);
}
}