java console: option not to remember latest used port
This commit is contained in:
parent
720ba01d04
commit
29df5a635d
|
@ -44,6 +44,14 @@ public class PersistentConfiguration {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getBoolProperty(String name) {
|
||||||
|
return getConfig().getRoot().getBoolProperty(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBoolProperty(String name, boolean value) {
|
||||||
|
getConfig().getRoot().setBoolProperty(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load() {
|
public void load() {
|
||||||
if (!config.isEmpty()) {
|
if (!config.isEmpty()) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20230805;
|
public static final int CONSOLE_VERSION = 20230829;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
public static long classBuildTimeMillis() {
|
public static long classBuildTimeMillis() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.devexperts.logging.Logging;
|
||||||
import com.rusefi.autodetect.PortDetector;
|
import com.rusefi.autodetect.PortDetector;
|
||||||
import com.rusefi.autodetect.SerialAutoChecker;
|
import com.rusefi.autodetect.SerialAutoChecker;
|
||||||
import com.rusefi.core.io.BundleUtil;
|
import com.rusefi.core.io.BundleUtil;
|
||||||
|
import com.rusefi.core.preferences.storage.PersistentConfiguration;
|
||||||
import com.rusefi.core.ui.AutoupdateUtil;
|
import com.rusefi.core.ui.AutoupdateUtil;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.io.serial.BaudRateHolder;
|
import com.rusefi.io.serial.BaudRateHolder;
|
||||||
|
@ -45,6 +46,7 @@ import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||||
*/
|
*/
|
||||||
public class StartupFrame {
|
public class StartupFrame {
|
||||||
private static final Logging log = getLogging(Launcher.class);
|
private static final Logging log = getLogging(Launcher.class);
|
||||||
|
public static final String ALWAYS_AUTO_PORT = "always_auto_port";
|
||||||
|
|
||||||
// private static final int RUSEFI_ORANGE = 0xff7d03;
|
// private static final int RUSEFI_ORANGE = 0xff7d03;
|
||||||
|
|
||||||
|
@ -112,6 +114,22 @@ public class StartupFrame {
|
||||||
final JButton connectButton = new JButton("Connect", new ImageIcon(getClass().getResource("/com/rusefi/connect48.png")));
|
final JButton connectButton = new JButton("Connect", new ImageIcon(getClass().getResource("/com/rusefi/connect48.png")));
|
||||||
//connectButton.setBackground(new Color(RUSEFI_ORANGE)); // custom orange
|
//connectButton.setBackground(new Color(RUSEFI_ORANGE)); // custom orange
|
||||||
setToolTip(connectButton, "Connect to real hardware");
|
setToolTip(connectButton, "Connect to real hardware");
|
||||||
|
|
||||||
|
JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem("Always auto-connect port");
|
||||||
|
menuItem.setState(PersistentConfiguration.getBoolProperty(ALWAYS_AUTO_PORT));
|
||||||
|
menuItem.addActionListener(e -> PersistentConfiguration.setBoolProperty(ALWAYS_AUTO_PORT, menuItem.getState()));
|
||||||
|
|
||||||
|
connectButton.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
if (!SwingUtilities.isRightMouseButton(e))
|
||||||
|
return;
|
||||||
|
JPopupMenu menu = new JPopupMenu();
|
||||||
|
menu.add(menuItem);
|
||||||
|
menu.show(connectButton, e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
connectPanel.add(connectButton);
|
connectPanel.add(connectButton);
|
||||||
connectPanel.setVisible(false);
|
connectPanel.setVisible(false);
|
||||||
|
|
||||||
|
@ -319,7 +337,10 @@ public class StartupFrame {
|
||||||
for (final String port : ports)
|
for (final String port : ports)
|
||||||
comboPorts.addItem(port);
|
comboPorts.addItem(port);
|
||||||
String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY);
|
String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY);
|
||||||
comboPorts.setSelectedItem(defaultPort);
|
if (!PersistentConfiguration.getBoolProperty(ALWAYS_AUTO_PORT)) {
|
||||||
|
comboPorts.setSelectedItem(defaultPort);
|
||||||
|
}
|
||||||
|
|
||||||
trueLayout(comboPorts);
|
trueLayout(comboPorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue