refactoring composition better than inheritance
only:uaefi
This commit is contained in:
parent
120d03a61d
commit
7d14e45a59
|
@ -47,7 +47,7 @@ public class BasicStartupFrame {
|
||||||
|
|
||||||
public BasicStartupFrame() {
|
public BasicStartupFrame() {
|
||||||
final JPanel panel = new JPanel();
|
final JPanel panel = new JPanel();
|
||||||
panel.add(basicUpdaterPanel);
|
panel.add(basicUpdaterPanel.getContent());
|
||||||
if (doNotUseStatusWindow) {
|
if (doNotUseStatusWindow) {
|
||||||
panel.add(statusPanel);
|
panel.add(statusPanel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,10 @@ import static com.rusefi.FileLog.isWindows;
|
||||||
import static com.rusefi.StartupFrame.newReleaseAnnounce;
|
import static com.rusefi.StartupFrame.newReleaseAnnounce;
|
||||||
import static com.rusefi.core.net.ConnectionAndMeta.getProperties;
|
import static com.rusefi.core.net.ConnectionAndMeta.getProperties;
|
||||||
|
|
||||||
// todo: composition better than inheritance!
|
public class BasicUpdaterPanel {
|
||||||
public class BasicUpdaterPanel extends JPanel {
|
|
||||||
private static final Logging log = getLogging(BasicUpdaterPanel.class);
|
private static final Logging log = getLogging(BasicUpdaterPanel.class);
|
||||||
|
|
||||||
final UpdateOperationCallbacks updateOperationCallbacks;
|
private final JPanel content = new JPanel(new VerticalFlowLayout());
|
||||||
|
|
||||||
private final boolean isObfuscated = FindFileHelper.isObfuscated();
|
private final boolean isObfuscated = FindFileHelper.isObfuscated();
|
||||||
|
|
||||||
|
@ -51,9 +50,6 @@ public class BasicUpdaterPanel extends JPanel {
|
||||||
final UpdateOperationCallbacks updateOperationCallbacks,
|
final UpdateOperationCallbacks updateOperationCallbacks,
|
||||||
final boolean doNotUseStatusWindow
|
final boolean doNotUseStatusWindow
|
||||||
) {
|
) {
|
||||||
super(new VerticalFlowLayout());
|
|
||||||
|
|
||||||
this.updateOperationCallbacks = updateOperationCallbacks;
|
|
||||||
singleAsyncJobExecutor = new SingleAsyncJobExecutor(
|
singleAsyncJobExecutor = new SingleAsyncJobExecutor(
|
||||||
updateOperationCallbacks,
|
updateOperationCallbacks,
|
||||||
doNotUseStatusWindow,
|
doNotUseStatusWindow,
|
||||||
|
@ -68,37 +64,37 @@ public class BasicUpdaterPanel extends JPanel {
|
||||||
() -> 0
|
() -> 0
|
||||||
);
|
);
|
||||||
if (newReleaseNotification.isPresent()) {
|
if (newReleaseNotification.isPresent()) {
|
||||||
super.add(newReleaseNotification.get());
|
content.add(newReleaseNotification.get());
|
||||||
}
|
}
|
||||||
super.add(ToolButtons.createShowDeviceManagerButton());
|
content.add(ToolButtons.createShowDeviceManagerButton());
|
||||||
super.add(StartupFrame.binaryModificationControl());
|
content.add(StartupFrame.binaryModificationControl());
|
||||||
|
|
||||||
updateFirmwareButton.addActionListener(this::onUpdateFirmwareButtonClicked);
|
updateFirmwareButton.addActionListener(this::onUpdateFirmwareButtonClicked);
|
||||||
updateFirmwareButton.setEnabled(false);
|
updateFirmwareButton.setEnabled(false);
|
||||||
|
|
||||||
statusMessage.setForeground(Color.red);
|
statusMessage.setForeground(Color.red);
|
||||||
super.add(statusMessage);
|
content.add(statusMessage);
|
||||||
super.add(updateFirmwareButton);
|
content.add(updateFirmwareButton);
|
||||||
} else {
|
} else {
|
||||||
super.add(new JLabel("Sorry only works on Windows"));
|
content.add(new JLabel("Sorry only works on Windows"));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.add(new HorizontalLine());
|
content.add(new HorizontalLine());
|
||||||
JLabel logoLabel = LogoHelper.createLogoLabel();
|
JLabel logoLabel = LogoHelper.createLogoLabel();
|
||||||
if (logoLabel != null) {
|
if (logoLabel != null) {
|
||||||
String panamaUrl = getProperties().getProperty("panama_url");
|
String panamaUrl = getProperties().getProperty("panama_url");
|
||||||
if (panamaUrl != null) {
|
if (panamaUrl != null) {
|
||||||
logoLabel.setComponentPopupMenu(new LogoLabelPopupMenu(panamaUrl));
|
logoLabel.setComponentPopupMenu(new LogoLabelPopupMenu(panamaUrl));
|
||||||
}
|
}
|
||||||
super.add(logoLabel);
|
content.add(logoLabel);
|
||||||
}
|
}
|
||||||
if (showUrlLabel)
|
if (showUrlLabel)
|
||||||
super.add(LogoHelper.createUrlLabel());
|
content.add(LogoHelper.createUrlLabel());
|
||||||
|
|
||||||
updateCalibrationsButton.addActionListener(this::onUpdateCalibrationsButtonClicked);
|
updateCalibrationsButton.addActionListener(this::onUpdateCalibrationsButtonClicked);
|
||||||
updateCalibrationsButton.setEnabled(false);
|
updateCalibrationsButton.setEnabled(false);
|
||||||
if (ConnectionAndMeta.showUpdateCalibrations()) {
|
if (ConnectionAndMeta.showUpdateCalibrations()) {
|
||||||
super.add(updateCalibrationsButton);
|
content.add(updateCalibrationsButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,4 +276,8 @@ public class BasicUpdaterPanel extends JPanel {
|
||||||
updateFirmwareButton.setEnabled(false);
|
updateFirmwareButton.setEnabled(false);
|
||||||
updateCalibrationsButton.setEnabled(false);
|
updateCalibrationsButton.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Component getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue