admin: added auto-connection support in admin tools (#5388)

This commit is contained in:
Oleg Agafonov 2024-04-01 23:18:26 +04:00
parent 86ca3673ff
commit 27aa791ab9
2 changed files with 44 additions and 3 deletions

View file

@ -32,6 +32,7 @@ public class ConnectDialog extends JDialog {
public ConnectDialog() {
initComponents();
cbProxyType.setModel(new DefaultComboBoxModel(Connection.ProxyType.values()));
setVisible(false);
}
public void showDialog(ConsoleFrame console) {
@ -39,8 +40,8 @@ public class ConnectDialog extends JDialog {
this.txtServer.setText(ConsoleFrame.getPreferences().get("serverAddress", "localhost"));
this.txtPort.setText(ConsoleFrame.getPreferences().get("serverPort", Integer.toString(17171)));
this.chkAutoConnect.setSelected(Boolean.parseBoolean(ConsoleFrame.getPreferences().get("autoConnect", "false")));
this.txtProxyServer.setText(ConsoleFrame.getPreferences().get("proxyAddress", "localhost"));
this.txtProxyPort.setText(ConsoleFrame.getPreferences().get("proxyPort", Integer.toString(17171)));
this.txtProxyServer.setText(ConsoleFrame.getPreferences().get("proxyAddress", ""));
this.txtProxyPort.setText(ConsoleFrame.getPreferences().get("proxyPort", Integer.toString(0)));
this.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(ConsoleFrame.getPreferences().get("proxyType", "NONE").toUpperCase(Locale.ENGLISH)));
this.txtProxyUserName.setText(ConsoleFrame.getPreferences().get("proxyUsername", ""));
this.txtPasswordField.setText(ConsoleFrame.getPreferences().get("proxyPassword", ""));
@ -71,7 +72,16 @@ public class ConnectDialog extends JDialog {
private void saveSettings() {
ConsoleFrame.getPreferences().put("serverAddress", txtServer.getText());
ConsoleFrame.getPreferences().put("serverPort", txtPort.getText());
ConsoleFrame.getPreferences().put("autoConnect", Boolean.toString(chkAutoConnect.isSelected()));
if (chkAutoConnect.isSelected()) {
ConsoleFrame.getPreferences().putBoolean("autoConnect", true);
char[] input = txtPassword.getPassword();
ConsoleFrame.getPreferences().put("password", new String(input));
Arrays.fill(input, '0');
} else {
ConsoleFrame.getPreferences().putBoolean("autoConnect", false);
ConsoleFrame.getPreferences().put("password", "");
}
ConsoleFrame.getPreferences().put("proxyAddress", txtProxyServer.getText());
ConsoleFrame.getPreferences().put("proxyPort", txtProxyPort.getText());
ConsoleFrame.getPreferences().put("proxyType", cbProxyType.getSelectedItem().toString());