too much usability? Show Device Manager icon

This commit is contained in:
rusefi 2019-07-14 09:24:12 -04:00
parent 464f5f698d
commit b24b1b4619
5 changed files with 32 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -46,7 +46,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20190713;
public static final int CONSOLE_VERSION = 20190714;
public static final boolean SHOW_STIMULATOR = false;
public static final String INPUT_FILES_PATH = "..";
private static final String TAB_INDEX = "main_tab";

View File

@ -5,6 +5,7 @@ import com.rusefi.io.serial.PortHolder;
import com.rusefi.io.tcp.TcpConnector;
import com.rusefi.maintenance.DriverInstall;
import com.rusefi.maintenance.EraseChip;
import com.rusefi.maintenance.ExecHelper;
import com.rusefi.maintenance.FirmwareFlasher;
import com.rusefi.ui.util.HorizontalLine;
import com.rusefi.ui.util.URLLabel;
@ -21,6 +22,7 @@ import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -32,8 +34,8 @@ import static com.rusefi.ui.util.UiUtils.setToolTip;
* This frame is used on startup to select the port we would be using
*
* @author Andrey Belomutskiy
* <p/>
* 2/14/14
* <p/>
* 2/14/14
* @see SimulatorHelper
* @see FirmwareFlasher
*/
@ -106,6 +108,7 @@ public class StartupFrame {
connectPanel.add(comboSpeeds);
final JButton connect = new JButton("Connect");
connect.setBackground(new Color(0xff7d03)); // custom orange
setToolTip(connect, "Connect to real hardware");
connectPanel.add(connect);
connect.addActionListener(new ActionListener() {
@ -120,8 +123,12 @@ public class StartupFrame {
leftPanel.add(realHardwarePanel);
leftPanel.add(miscPanel);
if (FileLog.isWindows())
realHardwarePanel.add(DriverInstall.createButton());
if (FileLog.isWindows()) {
JPanel topButtons = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
topButtons.add(createShowDeviceManagerButton());
topButtons.add(DriverInstall.createButton());
realHardwarePanel.add(topButtons);
}
realHardwarePanel.add(connectPanel);
realHardwarePanel.add(noPortsMessage);
installMessage(noPortsMessage, "Check you cables. Check your drivers. Do you want to start simulator maybe?");
@ -177,6 +184,20 @@ public class StartupFrame {
UiUtils.centerWindow(frame);
}
private Component createShowDeviceManagerButton() {
JButton showDeviceManager = new JButton(UiUtils.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);
}

View File

@ -58,7 +58,7 @@ public class DriverInstall {
wnd);
String batch = isWindows7orBelow() ? WINDOWS7_BATCH : WINDOWS8_BATCH;
ExecHelper.executeCommand(UNPACKED_FOLDER, "cmd /c start " + batch, batch, wnd);
ExecHelper.executeCommand(UNPACKED_FOLDER, ExecHelper.getBatchCommand(batch), batch, wnd);
}
private static boolean isWindows7orBelow() {

View File

@ -73,4 +73,9 @@ public class ExecHelper {
thread.setDaemon(true);
thread.start();
}
@NotNull
public static String getBatchCommand(String batch) {
return "cmd /c start " + batch;
}
}