From 9092d9f4c2231645b58968e964c858e010be14e2 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 30 Jul 2020 12:06:29 +0100 Subject: [PATCH] JAL-3633 Apply (proxy) button enabled when needed --- src/jalview/bin/Cache.java | 2 +- src/jalview/gui/Preferences.java | 1 + src/jalview/jbgui/GPreferences.java | 50 ++++++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index a6f05db..594046f 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -1432,7 +1432,7 @@ public class Cache .getString("label.proxy_password_required"); Preferences.openPreferences(Preferences.CONNECTIONS_TAB, message); - Preferences.getInstance().proxyAuthPasswordHighlight(true); + Preferences.getInstance().proxyAuthPasswordCheckHighlight(true); } else { diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index b447214..0e04117 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -611,6 +611,7 @@ public class Preferences extends GPreferences proxyAuthPasswordPB.setText(Cache.proxyAuthPassword == null ? "" : new String(Cache.proxyAuthPassword)); setCustomProxyEnabled(); + applyProxyButtonEnabled(false); defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", "")); diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index ddef7a4..40dc4df 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -990,6 +990,33 @@ public class GPreferences extends JPanel proxyPortHttpsTB.setColumns(4); proxyAuthUsernameTB.setFont(LABEL_FONT); proxyAuthUsernameTB.setColumns(30); + + // check for any change to enable applyProxyButton + DocumentListener d = new DocumentListener() + { + @Override + public void changedUpdate(DocumentEvent e) + { + applyProxyButtonEnabled(true); + } + + @Override + public void insertUpdate(DocumentEvent e) + { + applyProxyButtonEnabled(true); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + applyProxyButtonEnabled(true); + } + }; + proxyServerHttpTB.getDocument().addDocumentListener(d); + proxyPortHttpTB.getDocument().addDocumentListener(d); + proxyServerHttpsTB.getDocument().addDocumentListener(d); + proxyPortHttpsTB.getDocument().addDocumentListener(d); + proxyAuthUsernameTB.getDocument().addDocumentListener(d); proxyAuthPasswordPB.setFont(LABEL_FONT); proxyAuthPasswordPB.setColumns(30); proxyAuthPasswordPB.getDocument() @@ -998,19 +1025,22 @@ public class GPreferences extends JPanel @Override public void changedUpdate(DocumentEvent e) { - proxyAuthPasswordHighlight(true); + proxyAuthPasswordCheckHighlight(true); + applyProxyButtonEnabled(true); } @Override public void insertUpdate(DocumentEvent e) { - proxyAuthPasswordHighlight(true); + proxyAuthPasswordCheckHighlight(true); + applyProxyButtonEnabled(true); } @Override public void removeUpdate(DocumentEvent e) { - proxyAuthPasswordHighlight(true); + proxyAuthPasswordCheckHighlight(true); + applyProxyButtonEnabled(true); } }); @@ -1222,6 +1252,7 @@ public class GPreferences extends JPanel public void actionPerformed(ActionEvent e) { saveProxySettings(); + applyProxyButton.setEnabled(false); } }); gbc.gridy++; @@ -1232,7 +1263,7 @@ public class GPreferences extends JPanel return proxyPanel; } - public void proxyAuthPasswordHighlight(boolean enabled) + public void proxyAuthPasswordCheckHighlight(boolean enabled) { if (enabled && proxyType.isSelected(customProxy.getModel()) && proxyAuth.isSelected() @@ -1249,6 +1280,11 @@ public class GPreferences extends JPanel } } + public void applyProxyButtonEnabled(boolean enabled) + { + applyProxyButton.setEnabled(enabled); + } + public void saveProxySettings() { // overridden in Preferences @@ -3195,13 +3231,15 @@ public class GPreferences extends JPanel public void proxyType_actionPerformed() { setCustomProxyEnabled(); - proxyAuthPasswordHighlight(true); + proxyAuthPasswordCheckHighlight(true); + applyProxyButtonEnabled(true); } public void proxyAuth_actionPerformed() { setProxyAuthEnabled(); - proxyAuthPasswordHighlight(true); + proxyAuthPasswordCheckHighlight(true); + applyProxyButtonEnabled(true); } /** -- 1.7.10.2