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;
// 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";
// 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)
{
}
+ /**
+ * 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)
*