only:refactoring: now `onUpdateFirmwareButtonClicked` method handles click on update firmware button click for the both cases - with obfuscation and without obfuscation #6864
This commit is contained in:
parent
58e69cdcc3
commit
62acc8459a
|
@ -42,6 +42,7 @@ public class BasicStartupFrame {
|
|||
private final FrameHelper frame = FrameHelper.createFrame(
|
||||
whiteLabel + " basic console " + Launcher.CONSOLE_VERSION
|
||||
);
|
||||
private final boolean isObfusacted = FindFileHelper.isObfuscated();
|
||||
|
||||
private final JLabel statusMessage = new JLabel();
|
||||
private final StatusAnimation status = new StatusAnimation(this::updateStatus, StartupFrame.SCANNING_PORTS);
|
||||
|
@ -64,9 +65,8 @@ public class BasicStartupFrame {
|
|||
panel.add(ToolButtons.createShowDeviceManagerButton());
|
||||
panel.add(StartupFrame.binaryModificationControl());
|
||||
|
||||
boolean requireBlt = FindFileHelper.isObfuscated();
|
||||
if (requireBlt) {
|
||||
updateFirmwareButton.addActionListener(e-> onUpdateFirmwareButtonClicked());
|
||||
updateFirmwareButton.addActionListener(e-> onUpdateFirmwareButtonClicked());
|
||||
if (isObfusacted) {
|
||||
updateFirmwareButton.setEnabled(false);
|
||||
|
||||
statusMessage.setForeground(Color.red);
|
||||
|
@ -75,8 +75,6 @@ public class BasicStartupFrame {
|
|||
SerialPortScanner.INSTANCE.addListener(currentHardware -> SwingUtilities.invokeLater(() -> {
|
||||
onHardwareUpdated(currentHardware);
|
||||
}));
|
||||
} else {
|
||||
updateFirmwareButton.addActionListener(e -> DfuFlasher.doAutoDfu(updateFirmwareButton, PortDetector.AUTO, new UpdateStatusWindow("Update")));
|
||||
}
|
||||
panel.add(updateFirmwareButton);
|
||||
} else {
|
||||
|
@ -164,25 +162,29 @@ public class BasicStartupFrame {
|
|||
}
|
||||
|
||||
private void onUpdateFirmwareButtonClicked() {
|
||||
portToUpdateFirmware.ifPresentOrElse(port -> {
|
||||
switch (port.type) {
|
||||
case EcuWithOpenblt: {
|
||||
ProgramSelector.executeJob(updateFirmwareButton, ProgramSelector.OPENBLT_AUTO, port);
|
||||
break;
|
||||
}
|
||||
case OpenBlt: {
|
||||
ProgramSelector.executeJob(updateFirmwareButton, ProgramSelector.OPENBLT_MANUAL, port);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
log.error(String.format("Unexpected port type: %s (%s)", port.type, port));
|
||||
break;
|
||||
if (isObfusacted) {
|
||||
portToUpdateFirmware.ifPresentOrElse(port -> {
|
||||
switch (port.type) {
|
||||
case EcuWithOpenblt: {
|
||||
ProgramSelector.executeJob(updateFirmwareButton, ProgramSelector.OPENBLT_AUTO, port);
|
||||
break;
|
||||
}
|
||||
case OpenBlt: {
|
||||
ProgramSelector.executeJob(updateFirmwareButton, ProgramSelector.OPENBLT_MANUAL, port);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
log.error(String.format("Unexpected port type: %s (%s)", port.type, port));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, () -> {
|
||||
log.error("Port to update firmware is not defined.");
|
||||
}
|
||||
}, ()-> {
|
||||
log.error("Port to update firmware is not defined.");
|
||||
}
|
||||
);
|
||||
);
|
||||
} else {
|
||||
DfuFlasher.doAutoDfu(updateFirmwareButton, PortDetector.AUTO, new UpdateStatusWindow("Update"));
|
||||
}
|
||||
}
|
||||
|
||||
private void runTool() {
|
||||
|
|
Loading…
Reference in New Issue