JAL-3026 GD#107,128,130,139 build-site.xml
authorhansonr <hansonr@STO24954W.ad.stolaf.edu>
Fri, 24 Aug 2018 07:26:06 +0000 (02:26 -0500)
committerhansonr <hansonr@STO24954W.ad.stolaf.edu>
Fri, 24 Aug 2018 07:26:06 +0000 (02:26 -0500)
JInternalFrame z-order issues resolved
EBIFeching via server proxy as no access-control-origin:*
Temp file creation by File.createTempFile

Jmol app fixes for virtual key issues and starting to display now. Still
not dynamic, though. (No mouse action)

URL downloads now allow checking of status code (actually a hack, just
200 or 404, but we can get access to the real code.

libjs/jmol-app.zip
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/io/FileLoader.java
src/jalview/ws/dbsources/Pdb.java
src/jalview/ws/ebi/EBIFetchClient.java
src/jalview/ws/utils/UrlDownloadClient.java
swingjs/SwingJS-site.zip
swingjs/timestamp
swingjs/ver/3.2.2/SwingJS-site.zip
swingjs/ver/3.2.2/timestamp

index c9c31a6..dd6b193 100644 (file)
Binary files a/libjs/jmol-app.zip and b/libjs/jmol-app.zip differ
index 5afbc8e..ca82744 100644 (file)
@@ -473,7 +473,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     jmolHistory(false);
     if (lastCommand == null || !lastCommand.equals(command))
     {
-      viewer.evalStringQuiet(command + "\n");
+      jmolScript(command + "\n");
     }
     jmolHistory(true);
     lastCommand = command;
@@ -739,7 +739,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     {
       if (resetLastRes.length() > 0)
       {
-        viewer.evalStringQuiet(resetLastRes.toString());
+        jmolScript(resetLastRes.toString());
         resetLastRes.setLength(0);
       }
       for (AtomSpec atom : atoms)
@@ -797,7 +797,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
     cmd.append("spacefill 200;select none");
 
-    viewer.evalStringQuiet(cmd.toString());
+    jmolScript(cmd.toString());
     jmolHistory(true);
 
   }
@@ -806,7 +806,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
   private void jmolHistory(boolean enable)
   {
-    viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
+    jmolScript("History " + ((debug || enable) ? "on" : "off"));
   }
 
   public void loadInline(String string)
@@ -966,7 +966,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
     if (!atomsPicked.contains(picked))
     {
-      viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
+      jmolScript("select " + picked + ";label %n %r:%c");
       atomsPicked.addElement(picked);
     }
     else
@@ -1230,7 +1230,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     // }
     if (!isLoadingFromArchive())
     {
-      viewer.evalStringQuiet(
+      jmolScript(
               "model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
     }
     // register ourselves as a listener and notify the gui that it needs to
@@ -1400,7 +1400,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
     viewer.setJmolStatusListener(this); // extends JmolCallbackListener
 
-    console = createJmolConsole(consolePanel, buttonsToShow);
+    console = null;//createJmolConsole(consolePanel, buttonsToShow);
     if (consolePanel != null)
     {
       consolePanel.addComponentListener(this);
@@ -1418,11 +1418,16 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public void setBackgroundColour(java.awt.Color col)
   {
     jmolHistory(false);
-    viewer.evalStringQuiet("background [" + col.getRed() + ","
+    jmolScript("background [" + col.getRed() + ","
             + col.getGreen() + "," + col.getBlue() + "];");
     jmolHistory(true);
   }
 
+  private String jmolScript(String script)
+  {
+    return viewer.scriptWait(script);
+  }
+
   @Override
   public int[] resizeInnerPanel(String data)
   {
index 8e68067..4b2f797 100755 (executable)
@@ -366,8 +366,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();
             }
index e4326d1..a658089 100644 (file)
@@ -165,7 +165,7 @@ public class Pdb extends EbiFileRetrievedProxy
       // todo get rid of Type and use FileFormatI instead?
       FileFormatI fileFormat = (pdbFileFormat == Type.PDB) ? FileFormat.PDB
               : FileFormat.MMCif;
-      pdbAlignment = new FormatAdapter().readFile(file, DataSourceType.FILE,
+      pdbAlignment = new FormatAdapter().readFile(tmpFile, DataSourceType.FILE,
               fileFormat);
       if (pdbAlignment != null)
       {
index 07a9df4..5dc3c94 100644 (file)
@@ -216,6 +216,12 @@ public class EBIFetchClient
       InputStream is = new BufferedInputStream(conn.getInputStream());
       if (outFile != null)
       {
+        /**@j2sNative 
+         * if (outFile._isTemp) {
+         * outFile._bytes = is.$in.$in.buf;
+         * return null;
+         * }
+         */
         FileOutputStream fio = new FileOutputStream(outFile);
         byte[] bb = new byte[32 * 1024];
         int l;
index 448edd9..cfe080c 100644 (file)
@@ -21,6 +21,8 @@
 
 package jalview.ws.utils;
 
+import java.io.ByteArrayInputStream;
+import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -50,61 +52,75 @@ public class UrlDownloadClient
   public static void download(String urlstring, String outfile)
           throws IOException
   {
-    FileOutputStream fos = null;
-    ReadableByteChannel rbc = null;
-    Path temp = null;
-    try
-    {
-      temp = Files.createTempFile(".jalview_", ".tmp");
 
-      URL url = new URL(urlstring);
-      rbc = Channels.newChannel(url.openStream());
-      fos = new FileOutputStream(temp.toString());
-      fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
-
-      // copy tempfile to outfile once our download completes
-      // incase something goes wrong
-      Files.copy(temp, Paths.get(outfile),
-              StandardCopyOption.REPLACE_EXISTING);
-    } catch (IOException e)
-    {
-      throw e;
-    } finally
-    {
+      FileOutputStream fos = null;
+      ReadableByteChannel rbc = null;
+      Path temp = null;
       try
       {
-        if (fos != null)
-        {
-          fos.close();
-        }
+        temp = Files.createTempFile(".jalview_", ".tmp");
+
+        URL url = new URL(urlstring);
+        rbc = Channels.newChannel(url.openStream());
+        fos = new FileOutputStream(temp.toString());
+        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+
+        // copy tempfile to outfile once our download completes
+        // incase something goes wrong
+        Files.copy(temp, Paths.get(outfile),
+                StandardCopyOption.REPLACE_EXISTING);
       } catch (IOException e)
       {
-        System.out.println(
-                "Exception while closing download file output stream: "
-                        + e.getMessage());
-      }
-      try
+        throw e;
+      } finally
       {
-        if (rbc != null)
+        try
+        {
+          if (fos != null)
+          {
+            fos.close();
+          }
+        } catch (IOException e)
         {
-          rbc.close();
+          System.out.println(
+                  "Exception while closing download file output stream: "
+                          + e.getMessage());
         }
-      } catch (IOException e)
-      {
-        System.out.println("Exception while closing download channel: "
-                + e.getMessage());
-      }
-      try
-      {
-        if (temp != null)
+        try
+        {
+          if (rbc != null)
+          {
+            rbc.close();
+          }
+        } catch (IOException e)
         {
-          Files.deleteIfExists(temp);
+          System.out.println("Exception while closing download channel: "
+                  + e.getMessage());
+        }
+        try
+        {
+          if (temp != null)
+          {
+            Files.deleteIfExists(temp);
+          }
+        } catch (IOException e)
+        {
+          System.out.println("Exception while deleting download temp file: "
+                  + e.getMessage());
         }
-      } catch (IOException e)
-      {
-        System.out.println("Exception while deleting download temp file: "
-                + e.getMessage());
       }
+
+  }
+
+  public static void download(String urlstring, File tempFile) throws IOException
+  {
+    if (/** @j2sNative 1?false: */true) {
+      download(urlstring, tempFile.toString());
     }
+    // JavaScript only
+
+    /** @j2sNative 
+     * tempFile._bytes = swingjs.JSUtil.getFileAsBytes(urlstring); 
+     */
   }
 }
index 498bfc3..0a54e13 100644 (file)
Binary files a/swingjs/SwingJS-site.zip and b/swingjs/SwingJS-site.zip differ
index a5b4b63..3c00905 100644 (file)
@@ -1 +1 @@
-20180822094549 
+20180824015733 
index 498bfc3..0a54e13 100644 (file)
Binary files a/swingjs/ver/3.2.2/SwingJS-site.zip and b/swingjs/ver/3.2.2/SwingJS-site.zip differ
index a5b4b63..3c00905 100644 (file)
@@ -1 +1 @@
-20180822094549 
+20180824015733