Merge branch 'develop' into trialMerge
[jalview.git] / src / jalview / gui / Preferences.java
index b57b951..c45feb9 100755 (executable)
  */
 package jalview.gui;
 
+import static jalview.util.UrlConstants.DB_ACCESSION;
 import static jalview.util.UrlConstants.EMBLEBI_STRING;
-import static jalview.util.UrlConstants.OLD_EMBLEBI_STRING;
 import static jalview.util.UrlConstants.SEQUENCE_ID;
-import static jalview.util.UrlConstants.SEQUENCE_NAME;
 import static jalview.util.UrlConstants.SRS_STRING;
 
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
 import jalview.gui.Help.HelpId;
 import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.FileFormatI;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.GPreferences;
@@ -127,10 +127,10 @@ public class Preferences extends GPreferences
         String name = st.nextToken();
         String url = st.nextToken();
         // check for '|' within a regex
-        int rxstart = url.indexOf("$" + SEQUENCE_ID + "$");
+        int rxstart = url.indexOf("$" + DB_ACCESSION + "$");
         if (rxstart == -1)
         {
-          rxstart = url.indexOf("$" + SEQUENCE_NAME + "$");
+          rxstart = url.indexOf("$" + SEQUENCE_ID + "$");
         }
         while (rxstart == -1 && url.indexOf("/=$") == -1)
         {
@@ -149,12 +149,6 @@ public class Preferences extends GPreferences
       {
         sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos);
       }
-      // upgrade old EMBL-EBI link
-      int emblPos = sequenceURLLinks.indexOf(OLD_EMBLEBI_STRING);
-      if (emblPos > -1)
-      {
-        sequenceURLLinks.setElementAt(EMBLEBI_STRING, emblPos);
-      }
     }
 
     /**
@@ -574,6 +568,7 @@ public class Preferences extends GPreferences
     else
     {
       Cache.applicationProperties.remove("SEQUENCE_LINKS");
+      sequenceURLLinks.clear();
     }
 
     Cache.applicationProperties.setProperty("USE_PROXY",
@@ -692,12 +687,14 @@ public class Preferences extends GPreferences
   @Override
   public void startupFileTextfield_mouseClicked()
   {
-    JalviewFileChooser chooser = new JalviewFileChooser(
-            jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
-                "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
-                "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
-                "PIR", "BLC", "Jalview" },
-            jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
+    String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
+    JalviewFileChooser chooser = JalviewFileChooser.forRead(
+            Cache.getProperty("LAST_DIRECTORY"), fileFormat, true);
+    // new String[] {
+    // "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
+    // "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
+    // "PIR", "BLC", "Jalview" },
+    // fileFormat);
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager
             .getString("label.select_startup_file"));
@@ -706,8 +703,12 @@ public class Preferences extends GPreferences
 
     if (value == JalviewFileChooser.APPROVE_OPTION)
     {
-      jalview.bin.Cache.applicationProperties.setProperty(
-              "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
+      FileFormatI format = chooser.getSelectedFormat();
+      if (format != null)
+      {
+        Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
+                format.toString());
+      }
       startupFileTextfield.setText(chooser.getSelectedFile()
               .getAbsolutePath());
     }