Merge branch 'develop' into spike/matrix_annot
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index 4c9324c..1c97900 100755 (executable)
@@ -65,7 +65,7 @@ public class AppletFormatAdapter
    */
   boolean serviceSecondaryStruct = false;
 
-  private AlignmentFileI alignFile = null;
+  private AlignmentFileReaderI alignFile = null;
 
   String inFile;
 
@@ -78,9 +78,16 @@ public class AppletFormatAdapter
 
   public static String INVALID_CHARACTERS = "Contains invalid characters";
 
-  public static String SUPPORTED_FORMATS = "Formats currently supported are\n"
-          + prettyPrint(FileFormat.getReadableFormats());
-
+  /**
+   * Returns an error message with a list of supported readable file formats
+   * 
+   * @return
+   */
+  public static String getSupportedFormats()
+  {
+    return "Formats currently supported are\n"
+          + prettyPrint(FileFormats.getInstance().getReadableFormats());
+  }
   public AppletFormatAdapter()
   {
   }
@@ -158,7 +165,7 @@ public class AppletFormatAdapter
         }
         else
         {
-          // todo is MCview parsing obsolete yet?
+          // todo is MCview parsing obsolete yet? JAL-2120
           StructureImportSettings.setShowSeqFeatures(true);
           alignFile = new MCview.PDBfile(annotFromStructure,
                   localSecondaryStruct, serviceSecondaryStruct, inFile,
@@ -169,7 +176,9 @@ public class AppletFormatAdapter
       }
       else
       {
-        alignFile = fileFormat.getAlignmentFile(inFile, sourceType);
+        // alignFile = fileFormat.getAlignmentFile(inFile, sourceType);
+        alignFile = fileFormat.getReader(new FileParse(inFile,
+                sourceType));
       }
       return buildAlignmentFromFile();
     } catch (Exception e)
@@ -209,7 +218,7 @@ public class AppletFormatAdapter
         throw new IOException(e.getMessage());
       }
     }
-    throw new FileFormatException(SUPPORTED_FORMATS);
+    throw new FileFormatException(getSupportedFormats());
   }
 
   /**
@@ -249,7 +258,7 @@ public class AppletFormatAdapter
       }
       else
       {
-        alignFile = format.getAlignmentFile(source);
+        alignFile = format.getReader(source);
       }
 
       return buildAlignmentFromFile();
@@ -288,7 +297,7 @@ public class AppletFormatAdapter
       }
 
       // If we get to this stage, the format was not supported
-      throw new FileFormatException(SUPPORTED_FORMATS);
+      throw new FileFormatException(getSupportedFormats());
     }
   }
 
@@ -364,7 +373,7 @@ public class AppletFormatAdapter
   {
     try
     {
-      AlignmentFileI afile = format.getAlignmentFile(alignment);
+      AlignmentFileWriterI afile = format.getWriter(alignment);
 
       afile.setNewlineString(newline);
       afile.setExportSettings(exportSettings);
@@ -392,7 +401,8 @@ public class AppletFormatAdapter
       return afileresp;
     } catch (Exception e)
     {
-      System.err.println("Failed to write alignment as a '" + format
+      System.err.println("Failed to write alignment as a '"
+              + format.getName()
               + "' file\n");
       e.printStackTrace();
     }
@@ -641,7 +651,7 @@ public class AppletFormatAdapter
     return null;
   }
 
-  public AlignmentFileI getAlignFile()
+  public AlignmentFileReaderI getAlignFile()
   {
     return alignFile;
   }