+ public boolean vamsasImport(URL url)
+ {
+ // TODO: create progress bar
+ if (v_client != null)
+ {
+
+ jalview.bin.Cache.log
+ .error("Implementation error - load session from a running session is not supported.");
+ return false;
+ }
+
+ try
+ {
+ // copy the URL content to a temporary local file
+ // TODO: be a bit cleverer here with nio (?!)
+ File file = File.createTempFile("vdocfromurl", ".vdj");
+ FileOutputStream fos = new FileOutputStream(file);
+ BufferedInputStream bis = new BufferedInputStream(url.openStream());
+ byte[] buffer = new byte[2048];
+ int ln;
+ while ((ln = bis.read(buffer))>-1)
+ {
+ fos.write(buffer,0,ln);
+ }
+ bis.close();
+ fos.close();
+ v_client = new jalview.gui.VamsasApplication(this, file, url.toExternalForm());
+ } catch (Exception ex)
+ {
+ jalview.bin.Cache.log.error(
+ "Failed to create new vamsas session from contents of URL "+url,ex);
+ return false;
+ }
+ setupVamsasConnectedGui();
+ v_client.initial_update(); // TODO: thread ?
+ return v_client.inSession();
+ }
+
+ /**
+ * import file into a new vamsas session (uses jalview.gui.VamsasApplication)
+ * @param file
+ * @return true if import was a success and a session was started.
+ */