Dont setSelected on new frames
[jalview.git] / src / jalview / gui / Preferences.java
index f90f09c..be1455b 100755 (executable)
@@ -45,8 +45,26 @@ import jalview.bin.Cache;
 public class Preferences extends GPreferences\r
 {\r
     /** Holds name and link separated with | character. Sequence ID must be $SEQUENCE_ID$ */\r
-    public static Vector sequenceURLLinks = new Vector();\r
-    static { sequenceURLLinks.addElement("SRS|http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:$SEQUENCE_ID$]+-vn+2");}\r
+    public static Vector sequenceURLLinks;\r
+    static\r
+    {\r
+      String string = Cache.getDefault("SEQUENCE_LINKS",\r
+                                       "SRS|http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:$SEQUENCE_ID$]+-vn+2");\r
+      sequenceURLLinks = new Vector();\r
+\r
+      try\r
+      {\r
+        StringTokenizer st = new StringTokenizer(string, "|");\r
+        while (st.hasMoreElements())\r
+        {\r
+          sequenceURLLinks.addElement(st.nextToken() + "|" + st.nextToken());\r
+        }\r
+      }\r
+      catch (Exception ex)\r
+      {\r
+        System.out.println(ex + "\nError parsing sequence links");\r
+      }\r
+    }\r
     Vector nameLinks, urlLinks;\r
 \r
     JInternalFrame frame;\r
@@ -75,21 +93,14 @@ public class Preferences extends GPreferences
         quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));\r
         identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));\r
 \r
-        for (int i = 0; i < 12; i++)\r
+        for (int i = 0; i < 13; i++)\r
         {\r
             colour.addItem(ColourSchemeProperty.getColourName(i));\r
         }\r
 \r
-        String string = Cache.getProperty("DEFAULT_COLOUR");\r
+        String string = Cache.getDefault("DEFAULT_COLOUR", "None");\r
 \r
-        if (string != null)\r
-        {\r
-            colour.setSelectedItem(string);\r
-        }\r
-        else\r
-        {\r
-            colour.setSelectedIndex(11);\r
-        }\r
+        colour.setSelectedItem(string);\r
 \r
         String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()\r
                                                      .getAvailableFontFamilyNames();\r
@@ -124,20 +135,6 @@ public class Preferences extends GPreferences
   /****************************************************\r
    * Set up Connections\r
    */\r
-\r
-      string = Cache.getDefault("SEQUENCE_LINKS",\r
-                            "SRS|http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:$SEQUENCE_ID$]+-vn+2");\r
-      sequenceURLLinks = new Vector();\r
-\r
-        try{\r
-          StringTokenizer st = new StringTokenizer(string, "|");\r
-          while (st.hasMoreElements())\r
-          {\r
-            sequenceURLLinks.addElement(st.nextToken() + "|" + st.nextToken());\r
-          }\r
-        }catch(Exception ex)\r
-        {System.out.println(ex+"\nError parsing sequence links");}\r
-\r
         nameLinks = new Vector();\r
         urlLinks = new Vector();\r
         for(int i=0; i<sequenceURLLinks.size(); i++)\r
@@ -194,7 +191,13 @@ public class Preferences extends GPreferences
       Cache.applicationProperties.setProperty("STARTUP_FILE", startupFileTextfield.getText());\r
       Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",  Boolean.toString(startupCheckbox.isSelected()));\r
 \r
-      Cache.applicationProperties.setProperty("DEFAULT_BROWSER", defaultBrowser.getText());\r
+      if(defaultBrowser.getText().trim().length()<1)\r
+        Cache.applicationProperties.remove("DEFAULT_BROWSER");\r
+      else\r
+        Cache.applicationProperties.setProperty("DEFAULT_BROWSER",\r
+                                                defaultBrowser.getText());\r
+\r
+        jalview.util.BrowserLauncher.resetBrowser();\r
 \r
         if(nameLinks.size()>0)\r
         {\r
@@ -210,16 +213,33 @@ public class Preferences extends GPreferences
           links.setLength( links.length()-1 );\r
           Cache.applicationProperties.setProperty("SEQUENCE_LINKS", links.toString());\r
         }\r
+        else\r
+          Cache.applicationProperties.remove("SEQUENCE_LINKS");\r
+\r
 \r
         Cache.applicationProperties.setProperty("USE_PROXY", Boolean.toString(useProxy.isSelected()));\r
-        Cache.applicationProperties.setProperty("PROXY_SERVER",proxyServerTB.getText());\r
-        Cache.applicationProperties.setProperty("PROXY_PORT", proxyPortTB.getText());\r
+\r
+        if (proxyServerTB.getText().trim().length() < 1)\r
+          Cache.applicationProperties.remove("PROXY_SERVER");\r
+        else\r
+          Cache.applicationProperties.setProperty("PROXY_SERVER",\r
+                                                  proxyServerTB.getText());\r
+\r
+        if (proxyPortTB.getText().trim().length() < 1)\r
+          Cache.applicationProperties.remove("PROXY_PORT");\r
+        else\r
+          Cache.applicationProperties.setProperty("PROXY_PORT", proxyPortTB.getText());\r
 \r
         if(useProxy.isSelected())\r
         {\r
           System.setProperty("http.proxyHost", proxyServerTB.getText());\r
           System.setProperty("http.proxyPort", proxyPortTB.getText());\r
         }\r
+        else\r
+        {\r
+          System.setProperty("http.proxyHost","");\r
+          System.setProperty("http.proxyPort","");\r
+        }\r
 \r
 \r
 \r