Merge branch 'develop' into bug/JAL-2399textColour
[jalview.git] / src / jalview / gui / Preferences.java
index c5bff31..cf80a6d 100755 (executable)
@@ -29,7 +29,9 @@ import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.GPreferences;
 import jalview.jbgui.GSequenceLink;
-import jalview.schemes.ColourSchemeProperty;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemes;
+import jalview.schemes.ResidueColourScheme;
 import jalview.urls.UrlLinkTableModel;
 import jalview.urls.api.UrlProviderFactoryI;
 import jalview.urls.api.UrlProviderI;
@@ -284,12 +286,16 @@ public class Preferences extends GPreferences
     /*
      * Set Colours tab defaults
      */
-    for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
+    protColour.addItem(ResidueColourScheme.NONE);
+    nucColour.addItem(ResidueColourScheme.NONE);
+    for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
     {
-      protColour.addItem(ColourSchemeProperty.getColourName(i));
-      nucColour.addItem(ColourSchemeProperty.getColourName(i));
+      String name = cs.getSchemeName();
+      protColour.addItem(name);
+      nucColour.addItem(name);
     }
-    String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
+    String oldProp = Cache.getDefault(DEFAULT_COLOUR,
+            ResidueColourScheme.NONE);
     String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
     protColour.setSelectedItem(newProp != null ? newProp : oldProp);
     newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
@@ -459,8 +465,6 @@ public class Preferences extends GPreferences
 
     useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
     useProxy_actionPerformed(); // make sure useProxy is correctly initialised
-    proxyServerTB.setEnabled(useProxy.isSelected());
-    proxyPortTB.setEnabled(useProxy.isSelected());
     proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
     proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
 
@@ -809,7 +813,7 @@ public class Preferences extends GPreferences
       if (format != null)
       {
         Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
-                format.toString());
+                format.getName());
       }
       startupFileTextfield.setText(chooser.getSelectedFile()
               .getAbsolutePath());
@@ -902,8 +906,13 @@ public class Preferences extends GPreferences
       return;
     }
 
-    link.setName(linkUrlTable.getValueAt(index, 0).toString());
-    link.setURL(linkUrlTable.getValueAt(index, 1).toString());
+    int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
+            .getNameColumn();
+    int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
+            .getUrlColumn();
+    String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
+    link.setName(oldName);
+    link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
 
     boolean valid = false;
     while (!valid)
@@ -914,11 +923,12 @@ public class Preferences extends GPreferences
       {
         if (link.checkValid())
         {
-          if (((UrlLinkTableModel) linkUrlTable.getModel())
-                  .isUniqueName(link.getName()))
+          if ((oldName.equals(link.getName()))
+                  || (((UrlLinkTableModel) linkUrlTable.getModel())
+                          .isUniqueName(link.getName())))
           {
-            linkUrlTable.setValueAt(link.getName(), index, 0);
-            linkUrlTable.setValueAt(link.getURL(), index, 1);
+            linkUrlTable.setValueAt(link.getName(), index, nameCol);
+            linkUrlTable.setValueAt(link.getURL(), index, urlCol);
             valid = true;
           }
           else