JAL-3633 Apply (proxy) button enabled when needed
authorBen Soares <b.soares@dundee.ac.uk>
Thu, 30 Jul 2020 11:06:29 +0000 (12:06 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 13 Nov 2020 17:15:31 +0000 (17:15 +0000)
src/jalview/bin/Cache.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GPreferences.java

index a6f05db..594046f 100755 (executable)
@@ -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
               {
index b447214..0e04117 100755 (executable)
@@ -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", ""));
 
index ddef7a4..40dc4df 100755 (executable)
@@ -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);
   }
 
   /**