X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FFileLoader.java;h=1d5be1b832a5452184c66e0d8f838aba1f609f11;hb=915c9e36bbe05968b0b128667803387f322d9f29;hp=8e68067fa7579a788c9a8ad424961368a3911748;hpb=4ecd680a70a52359793d2cdc082d48a07573de79;p=jalview.git diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 8e68067..1d5be1b 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -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; @@ -214,6 +214,7 @@ public class FileLoader implements Runnable protected AlignFrame _LoadFileWaitTillLoaded() { this.run(); + return alignFrame; } @@ -338,7 +339,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 +368,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 +475,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 +647,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)); }