JAL-3032 part2 local file reading by JFileChooser
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index 3f51ea8..bc2465a 100755 (executable)
@@ -75,6 +75,8 @@ public class AppletFormatAdapter
 
   private AlignExportSettingI exportSettings;
 
+  private File selectedFile;
+
   public static String INVALID_CHARACTERS = "Contains invalid characters";
 
   /**
@@ -147,6 +149,16 @@ public class AppletFormatAdapter
   public AlignmentI readFile(String file, DataSourceType sourceType,
           FileFormatI fileFormat) throws IOException
   {
+    return readFile(null, file, sourceType, fileFormat);
+  }
+  
+  public AlignmentI readFile(File selectedFile, String file, DataSourceType sourceType,
+          FileFormatI fileFormat) throws IOException
+  {
+
+    this.selectedFile = selectedFile;
+    if (selectedFile != null)
+      this.inFile = selectedFile.getPath();
     this.inFile = file;
     try
     {
@@ -161,6 +173,7 @@ public class AppletFormatAdapter
                 localSecondaryStruct, serviceSecondaryStruct);
         if (isParseWithJMOL)
         {
+          // needs a File option
           alignFile = new JmolParser(inFile, sourceType);
         }
         else
@@ -174,7 +187,9 @@ public class AppletFormatAdapter
         ((StructureFile) alignFile).setDbRefType(
                 FileFormat.PDB.equals(fileFormat) ? Type.PDB : Type.MMCIF);
       }
-      else
+      else if (selectedFile != null) {
+        alignFile = fileFormat.getReader(new FileParse(selectedFile, sourceType));
+      } else 
       {
         // alignFile = fileFormat.getAlignmentFile(inFile, sourceType);
         alignFile = fileFormat.getReader(new FileParse(inFile, sourceType));