only:refactoring: now `switchToPort` method deducts update button text itself from port type #6864

This commit is contained in:
kifir 2024-09-16 17:52:56 +03:00 committed by Andrey
parent 62acc8459a
commit 894eb2befc
1 changed files with 17 additions and 4 deletions

View File

@ -127,9 +127,9 @@ public class BasicStartupFrame {
}
case 1: {
if (!ecuPorts.isEmpty()) {
switchToPort(ecuPorts.get(0), "Auto Update Firmware");
switchToPort(ecuPorts.get(0));
} else if (!bootloaderPorts.isEmpty()) {
switchToPort(bootloaderPorts.get(0), "Blt Update Firmware");
switchToPort(bootloaderPorts.get(0));
} else {
log.error("Do nothing.");
}
@ -148,11 +148,24 @@ public class BasicStartupFrame {
}
}
private void switchToPort(final SerialPortScanner.PortResult port, final String updateButtonText) {
private void switchToPort(final SerialPortScanner.PortResult port) {
portToUpdateFirmware = Optional.of(port);
hideStatusMessage();
updateFirmwareButton.setEnabled(true);
updateFirmwareButton.setText(updateButtonText);
switch (port.type) {
case EcuWithOpenblt: {
updateFirmwareButton.setText("Auto Update Firmware");
break;
}
case OpenBlt: {
updateFirmwareButton.setText("Blt Update Firmware");
break;
}
default: {
log.error(String.format("Unexpected port type: %s", port));
break;
}
}
}
private void resetPort(final String reason) {