JAL-2446 merged to spike branch
[jalview.git] / src / jalview / io / JalviewFileChooser.java
index 7ccdaa9..98cd162 100755 (executable)
@@ -21,6 +21,7 @@
 //////////////////////////////////////////////////////////////////
 package jalview.io;
 
+import jalview.bin.Cache;
 import jalview.gui.JvOptionPane;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
@@ -68,12 +69,12 @@ public class JalviewFileChooser extends JFileChooser
   {
     List<String> extensions = new ArrayList<String>();
     List<String> descs = new ArrayList<String>();
-    for (FileFormatI format : FileFormat.values())
+    for (FileFormatI format : FileFormats.getInstance().getFormats())
     {
       if (format.isReadable())
       {
         extensions.add(format.getExtensions());
-        descs.add(format.toString());
+        descs.add(format.getName());
       }
     }
     return new JalviewFileChooser(directory,
@@ -96,12 +97,12 @@ public class JalviewFileChooser extends JFileChooser
     // with a lambda expression parameter for isReadable/isWritable
     List<String> extensions = new ArrayList<String>();
     List<String> descs = new ArrayList<String>();
-    for (FileFormatI format : FileFormat.values())
+    for (FileFormatI format : FileFormats.getInstance().getFormats())
     {
       if (format.isWritable())
       {
         extensions.add(format.getExtensions());
-        descs.add(format.toString());
+        descs.add(format.getName());
       }
     }
     return new JalviewFileChooser(directory,
@@ -124,16 +125,13 @@ public class JalviewFileChooser extends JFileChooser
   /**
    * Constructor for a single choice of file extension and description
    * 
-   * @param dir
    * @param extension
    * @param desc
    */
-  public JalviewFileChooser(String dir, String extension, String desc)
+  public JalviewFileChooser(String extension, String desc)
   {
-    // TODO inline dir as Cache.getProperty("LAST_DIRECTORY") ? if applet
-    // builds ok
-    this(dir, new String[] { extension }, new String[] { desc }, desc,
-            true);
+    this(Cache.getProperty("LAST_DIRECTORY"), new String[] { extension },
+            new String[] { desc }, desc, true);
   }
 
   JalviewFileChooser(String dir, String[] extensions, String[] descs,
@@ -269,7 +267,7 @@ public class JalviewFileChooser extends JFileChooser
       format = format.substring(0, parenPos).trim();
       try
       {
-        return FileFormat.valueOf(format);
+        return FileFormats.getInstance().forName(format);
       } catch (IllegalArgumentException e)
       {
         System.err.println("Unexpected format: " + format);