JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / io / FileLoader.java
index 8e68067..95f85e6 100755 (executable)
@@ -33,12 +33,13 @@ import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.gui.AlignViewport;
 import jalview.gui.Desktop;
-import jalview.gui.Jalview2XML;
 import jalview.gui.JvOptionPane;
 import jalview.json.binding.biojson.v1.ColourSchemeMapper;
+import jalview.project.Jalview2XML;
 import jalview.schemes.ColourSchemeI;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
+import jalview.util.Platform;
 import jalview.ws.utils.UrlDownloadClient;
 
 import java.io.BufferedReader;
@@ -47,7 +48,6 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -338,7 +338,8 @@ public class FileLoader implements Runnable
                   "IMPLEMENTATION ERROR: Cannot read consecutive Jalview XML projects from a stream.");
           // We read the data anyway - it might make sense.
         }
-        alignFrame = new Jalview2XML(raiseGUI).loadJalviewAlign(file);
+        // BH 2018 switch to File object here instead of filename
+        alignFrame = new Jalview2XML(raiseGUI).loadJalviewAlign(selectedFile == null ? file : selectedFile);
       }
       else
       {
@@ -366,8 +367,13 @@ public class FileLoader implements Runnable
                       file.lastIndexOf("."));
               String tempStructureFileStr = createNamedJvTempFile(
                       urlLeafName, structExt);
-              UrlDownloadClient.download(file, tempStructureFileStr);
-              al = fa.readFile(tempStructureFileStr, DataSourceType.FILE,
+              
+              // BH - switching to File object here so as to hold
+              // ._bytes array directly
+              File tempFile = new File(tempStructureFileStr);
+              UrlDownloadClient.download(file, tempFile);
+              
+              al = fa.readFile(tempFile, DataSourceType.FILE,
                       format);
               source = fa.getAlignFile();
             }
@@ -468,7 +474,7 @@ public class FileLoader implements Runnable
               alignFrame.getViewport()
                       .applyFeaturesStyle(proxyColourScheme);
             }
-            alignFrame.statusBar.setText(MessageManager.formatMessage(
+            alignFrame.setStatus(MessageManager.formatMessage(
                     "label.successfully_loaded_file", new String[]
                     { title }));
 
@@ -640,14 +646,16 @@ public class FileLoader implements Runnable
    * @return
    * @throws FileNotFoundException 
    */
-  @SuppressWarnings("unused")
-  public static BufferedReader getBuffereReader(Object file) throws FileNotFoundException {
+  public static BufferedReader getBufferedReader(Object file) throws FileNotFoundException {
     if (file instanceof String)
+    {
       return new BufferedReader(new FileReader((String) file));
-    
-    byte[] bytes = /** @j2sNative file._bytes || */ null;
+    }
+    byte[] bytes = Platform.getFileBytes((File) file);
     if (bytes != null)
+    {
       return new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes)));
+    }
     return  new BufferedReader(new FileReader((File) file));
   }