X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileLoader.java;h=9d5fd934d3ce5df299c5b75af4b8c36c9c468ceb;hb=136c0793b90b72b928c4d77dc109dd5c644e00d3;hp=4f83ab1235e14be8b9879f6797f55d70cd7dceff;hpb=8677e6e34e291edc58c1da2fc9c958473754143f;p=jalview.git diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 4f83ab1..9d5fd93 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -27,7 +27,7 @@ import jalview.api.FeaturesSourceI; import jalview.bin.Cache; import jalview.bin.Jalview; import jalview.datamodel.AlignmentI; -import jalview.datamodel.ColumnSelection; +import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -39,7 +39,10 @@ import jalview.json.binding.biojson.v1.ColourSchemeMapper; import jalview.schemes.ColourSchemeI; import jalview.structure.StructureSelectionManager; import jalview.util.MessageManager; +import jalview.ws.utils.UrlDownloadClient; +import java.io.File; +import java.io.IOException; import java.util.StringTokenizer; import java.util.Vector; @@ -205,6 +208,12 @@ public class FileLoader implements Runnable // refer to it as. return; } + if (file != null + && file.indexOf(System.getProperty("java.io.tmpdir")) > -1) + { + // ignore files loaded from the system's temporary directory + return; + } String type = protocol == DataSourceType.FILE ? "RECENT_FILE" : "RECENT_URL"; @@ -325,9 +334,27 @@ public class FileLoader implements Runnable // open a new source and read from it FormatAdapter fa = new FormatAdapter(); - al = fa.readFile(file, protocol, format); - source = fa.getAlignFile(); // keep reference for later if - // necessary. + boolean downloadStructureFile = format.isStructureFile() + && protocol.equals(DataSourceType.URL); + if (downloadStructureFile) + { + String structExt = format.getExtensions().split(",")[0]; + String urlLeafName = file.substring(file.lastIndexOf(System + .getProperty("file.separator")), file + .lastIndexOf(".")); + String tempStructureFileStr = createNamedJvTempFile( + urlLeafName, structExt); + UrlDownloadClient.download(file, tempStructureFileStr); + al = fa.readFile(tempStructureFileStr, DataSourceType.FILE, + format); + source = fa.getAlignFile(); + } + else + { + al = fa.readFile(file, protocol, format); + source = fa.getAlignFile(); // keep reference for later if + // necessary. + } } } catch (java.io.IOException ex) { @@ -372,8 +399,8 @@ public class FileLoader implements Runnable if (source instanceof ComplexAlignFile) { - ColumnSelection colSel = ((ComplexAlignFile) source) - .getColumnSelection(); + HiddenColumns colSel = ((ComplexAlignFile) source) + .getHiddenColumns(); SequenceI[] hiddenSeqs = ((ComplexAlignFile) source) .getHiddenSequences(); String colourSchemeName = ((ComplexAlignFile) source) @@ -556,6 +583,29 @@ public class FileLoader implements Runnable } + /** + * This method creates the file - + * {tmpdir}/jalview/{current_timestamp}/fileName.exetnsion using the supplied + * file name and extension + * + * @param fileName + * the name of the temp file to be created + * @param extension + * the extension of the temp file to be created + * @return + */ + private static String createNamedJvTempFile(String fileName, + String extension) throws IOException + { + String seprator = System.getProperty("file.separator"); + String jvTempDir = System.getProperty("java.io.tmpdir") + "jalview" + + seprator + System.currentTimeMillis(); + File tempStructFile = new File(jvTempDir + seprator + fileName + "." + + extension); + tempStructFile.mkdirs(); + return tempStructFile.toString(); + } + /* * (non-Javadoc) *