Startup screen: should be a way to hit "enter" on connect button fix #1440

This commit is contained in:
rusefi 2020-05-16 15:09:42 -04:00
parent ce17e945b1
commit 81503a1fa7
1 changed files with 21 additions and 12 deletions

View File

@ -3,7 +3,6 @@ package com.rusefi;
import com.rusefi.autodetect.PortDetector;
import com.rusefi.io.LinkManager;
import com.rusefi.io.serial.BaudRateHolder;
import com.rusefi.io.serial.PortHolder;
import com.rusefi.maintenance.*;
import com.rusefi.ui.util.HorizontalLine;
import com.rusefi.ui.util.URLLabel;
@ -110,22 +109,19 @@ public class StartupFrame {
//connectButton.setBackground(new Color(RUSEFI_ORANGE)); // custom orange
setToolTip(connectButton, "Connect to real hardware");
connectPanel.add(connectButton);
connectButton.addActionListener(new ActionListener() {
frame.getRootPane().setDefaultButton(connectButton);
connectButton.addKeyListener(new KeyAdapter() {
@Override
public void actionPerformed(ActionEvent e) {
BaudRateHolder.INSTANCE.baudRate = Integer.parseInt((String) comboSpeeds.getSelectedItem());
String selectedPort = comboPorts.getSelectedItem().toString();
if (SerialPortScanner.AUTO_SERIAL.equals(selectedPort)) {
String autoDetectedPort = PortDetector.autoDetectPort(StartupFrame.this.frame);
if (autoDetectedPort == null)
return;
selectedPort = autoDetectedPort;
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
connectButtonAction(comboSpeeds);
}
disposeFrameAndProceed();
new Launcher(selectedPort);
}
});
connectButton.addActionListener(e -> connectButtonAction(comboSpeeds));
leftPanel.add(realHardwarePanel);
leftPanel.add(miscPanel);
@ -225,6 +221,19 @@ public class StartupFrame {
}
}
private void connectButtonAction(JComboBox<String> comboSpeeds) {
BaudRateHolder.INSTANCE.baudRate = Integer.parseInt((String) comboSpeeds.getSelectedItem());
String selectedPort = comboPorts.getSelectedItem().toString();
if (SerialPortScanner.AUTO_SERIAL.equals(selectedPort)) {
String autoDetectedPort = PortDetector.autoDetectPort(StartupFrame.this.frame);
if (autoDetectedPort == null)
return;
selectedPort = autoDetectedPort;
}
disposeFrameAndProceed();
new Launcher(selectedPort);
}
/**
* Here we listen to keystrokes while console start-up frame is being displayed and if magic "test" word is typed
* we launch a functional test on real hardware, same as Jenkins runs within continues integration