refactoring
This commit is contained in:
parent
29b2b2680e
commit
4e4caa5d65
|
@ -5,19 +5,17 @@ import com.rusefi.autodetect.PortDetector;
|
|||
import com.rusefi.autodetect.SerialAutoChecker;
|
||||
import com.rusefi.core.io.BundleUtil;
|
||||
import com.rusefi.core.preferences.storage.PersistentConfiguration;
|
||||
import com.rusefi.core.ui.AutoupdateUtil;
|
||||
import com.rusefi.core.ui.FrameHelper;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.serial.BaudRateHolder;
|
||||
import com.rusefi.maintenance.DriverInstall;
|
||||
import com.rusefi.maintenance.ExecHelper;
|
||||
import com.rusefi.maintenance.FirmwareFlasher;
|
||||
import com.rusefi.maintenance.ProgramSelector;
|
||||
import com.rusefi.ui.LogoHelper;
|
||||
import com.rusefi.ui.PcanConnectorUI;
|
||||
import com.rusefi.ui.util.HorizontalLine;
|
||||
import com.rusefi.ui.util.URLLabel;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.ui.widgets.ToolButtons;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -28,7 +26,6 @@ import javax.swing.border.TitledBorder;
|
|||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
@ -143,14 +140,14 @@ public class StartupFrame {
|
|||
|
||||
if (FileLog.isWindows()) {
|
||||
JPanel topButtons = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
|
||||
topButtons.add(createShowDeviceManagerButton());
|
||||
topButtons.add(ToolButtons.createShowDeviceManagerButton());
|
||||
topButtons.add(DriverInstall.createButton());
|
||||
topButtons.add(createPcanConnectorButton());
|
||||
topButtons.add(ToolButtons.createPcanConnectorButton());
|
||||
realHardwarePanel.add(topButtons, "right, wrap");
|
||||
}
|
||||
realHardwarePanel.add(connectPanel, "right, wrap");
|
||||
realHardwarePanel.add(noPortsMessage, "right, wrap");
|
||||
installMessage(noPortsMessage, "Check you cables. Check your drivers. Do you want to start simulator maybe?");
|
||||
noPortsMessage.setToolTipText("Check you cables. Check your drivers. Do you want to start simulator maybe?");
|
||||
|
||||
ProgramSelector selector = new ProgramSelector(comboPorts);
|
||||
|
||||
|
@ -294,31 +291,6 @@ public class StartupFrame {
|
|||
};
|
||||
}
|
||||
|
||||
private Component createPcanConnectorButton() {
|
||||
JButton button = new JButton("PCAN");
|
||||
button.setToolTipText("PCAN connector for TS");
|
||||
button.addActionListener(e -> PcanConnectorUI.show());
|
||||
return button;
|
||||
}
|
||||
|
||||
private Component createShowDeviceManagerButton() {
|
||||
JButton showDeviceManager = new JButton(AutoupdateUtil.loadIcon("DeviceManager.png"));
|
||||
showDeviceManager.setMargin(new Insets(0, 0, 0, 0));
|
||||
showDeviceManager.setToolTipText("Show Device Manager");
|
||||
showDeviceManager.addActionListener(event -> {
|
||||
try {
|
||||
Runtime.getRuntime().exec(ExecHelper.getBatchCommand("devmgmt.msc"));
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
});
|
||||
return showDeviceManager;
|
||||
}
|
||||
|
||||
private void installMessage(JComponent component, String s) {
|
||||
component.setToolTipText(s);
|
||||
}
|
||||
|
||||
public void disposeFrameAndProceed() {
|
||||
isProceeding = true;
|
||||
frame.dispose();
|
||||
|
|
|
@ -52,8 +52,7 @@ public class ProgramSelector {
|
|||
if (Arrays.asList(AUTO_DFU, MANUAL_DFU, ST_LINK, OPENBLT_CAN , DFU_ERASE, DFU_SWITCH).contains(persistedMode))
|
||||
mode.setSelectedItem(persistedMode);
|
||||
|
||||
JButton updateFirmware = new JButton("Update Firmware",
|
||||
AutoupdateUtil.loadIcon("upload48.png"));
|
||||
JButton updateFirmware = createUpdateFirmwareButton();
|
||||
controls.add(updateFirmware);
|
||||
|
||||
updateFirmware.addActionListener(new ActionListener() {
|
||||
|
@ -95,6 +94,11 @@ public class ProgramSelector {
|
|||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JButton createUpdateFirmwareButton() {
|
||||
return new JButton("Update Firmware", AutoupdateUtil.loadIcon("upload48.png"));
|
||||
}
|
||||
|
||||
private void flashOpenBltCan() {
|
||||
StatusWindow wnd = new StatusWindow();
|
||||
wnd.showFrame(appendBundleName("OpenBLT via CAN " + Launcher.CONSOLE_VERSION));
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.rusefi.ui.widgets;
|
||||
|
||||
import com.rusefi.core.ui.AutoupdateUtil;
|
||||
import com.rusefi.maintenance.ExecHelper;
|
||||
import com.rusefi.ui.PcanConnectorUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ToolButtons {
|
||||
public static Component createShowDeviceManagerButton() {
|
||||
JButton showDeviceManager = new JButton(AutoupdateUtil.loadIcon("DeviceManager.png"));
|
||||
showDeviceManager.setMargin(new Insets(0, 0, 0, 0));
|
||||
showDeviceManager.setToolTipText("Show Device Manager");
|
||||
showDeviceManager.addActionListener(event -> {
|
||||
try {
|
||||
Runtime.getRuntime().exec(ExecHelper.getBatchCommand("devmgmt.msc"));
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
});
|
||||
return showDeviceManager;
|
||||
}
|
||||
|
||||
public static Component createPcanConnectorButton() {
|
||||
JButton button = new JButton("PCAN");
|
||||
button.setToolTipText("PCAN connector for TS");
|
||||
button.addActionListener(e -> PcanConnectorUI.show());
|
||||
return button;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue