refactored list of file extensions and file format descriptions
authorjprocter <Jim Procter>
Thu, 4 Oct 2007 16:34:27 +0000 (16:34 +0000)
committerjprocter <Jim Procter>
Thu, 4 Oct 2007 16:34:27 +0000 (16:34 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/gui/Desktop.java
src/jalview/io/AppletFormatAdapter.java

index 05beb00..53b721d 100755 (executable)
@@ -696,10 +696,8 @@ public class AlignFrame
   {
     JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
         getProperty( "LAST_DIRECTORY"),
-        new String[]
-        { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","amsa","jar" },
-        new String[]
-        { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Jalview" },
+        jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
+        jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
         currentFileFormat,
         false);
 
index f61e7a8..36fbcf9 100755 (executable)
@@ -432,15 +432,9 @@ public class Desktop
     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"));
+            jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS,
+            jalview.io.AppletFormatAdapter.READABLE_FNAMES, 
+            jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
 
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle("Open local file");
index df432cc..fbfaab1 100755 (executable)
@@ -39,11 +39,41 @@ public class AppletFormatAdapter
       "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM" , "AMSA"
   };
 
+  public static final String[] WRITABLE_EXTENSIONS = new String[]
+        { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","amsa","jar" };
+
+  public static final String[] WRITABLE_FNAMES = new String[]
+        { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Jalview" };
+
+  public static final String[] READABLE_EXTENSIONS =         new String[]
+        {
+        "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
+        "amsa","jar"
+    };
+  public static final String[] READABLE_FNAMES =         new String[]
+        {
+        "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA","Jalview"
+    };
+        
   public static String INVALID_CHARACTERS = "Contains invalid characters";
   // TODO: make these messages dynamic
   public static String SUPPORTED_FORMATS = "Formats currently supported are\n" +
-      "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM";
-
+    prettyPrint(READABLE_FORMATS);
+  /**
+   * 
+   * @param els
+   * @return grammatically correct(ish) list consisting of els elements.
+   */
+  public static String prettyPrint(String[] els) {
+    StringBuffer list = new StringBuffer();
+    for (int i=0,iSize=els.length-1; i<iSize;i++)
+    {
+      list.append(els[i]);
+      list.append(",");
+    }
+    list.append(" and "+els[els.length-1]+".");
+    return list.toString();
+  }
   public static String FILE = "File";
   public static String URL = "URL";
   public static String PASTE = "Paste";
@@ -51,7 +81,11 @@ public class AppletFormatAdapter
 
   AlignFile afile = null;
   String inFile;
-
+  /**
+   * check that this format is valid for reading
+   * @param format a format string to be compared with READABLE_FORMATS
+   * @return true if format is readable
+   */
   public static final boolean isValidFormat(String format)
   {
     boolean valid = false;