From: hansonr Date: Fri, 24 Aug 2018 07:26:06 +0000 (-0500) Subject: JAL-3026 GD#107,128,130,139 build-site.xml X-Git-Tag: Release_2_11_4_0~45^2~18^2~462 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=75b38b407cf19737bcc9013a483e1beee32f5523;p=jalview.git JAL-3026 GD#107,128,130,139 build-site.xml 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. --- diff --git a/libjs/jmol-app.zip b/libjs/jmol-app.zip index c9c31a6..dd6b193 100644 Binary files a/libjs/jmol-app.zip and b/libjs/jmol-app.zip differ diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 5afbc8e..ca82744 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -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) { diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 8e68067..4b2f797 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -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(); } diff --git a/src/jalview/ws/dbsources/Pdb.java b/src/jalview/ws/dbsources/Pdb.java index e4326d1..a658089 100644 --- a/src/jalview/ws/dbsources/Pdb.java +++ b/src/jalview/ws/dbsources/Pdb.java @@ -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) { diff --git a/src/jalview/ws/ebi/EBIFetchClient.java b/src/jalview/ws/ebi/EBIFetchClient.java index 07a9df4..5dc3c94 100644 --- a/src/jalview/ws/ebi/EBIFetchClient.java +++ b/src/jalview/ws/ebi/EBIFetchClient.java @@ -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; diff --git a/src/jalview/ws/utils/UrlDownloadClient.java b/src/jalview/ws/utils/UrlDownloadClient.java index 448edd9..cfe080c 100644 --- a/src/jalview/ws/utils/UrlDownloadClient.java +++ b/src/jalview/ws/utils/UrlDownloadClient.java @@ -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); + */ } } diff --git a/swingjs/SwingJS-site.zip b/swingjs/SwingJS-site.zip index 498bfc3..0a54e13 100644 Binary files a/swingjs/SwingJS-site.zip and b/swingjs/SwingJS-site.zip differ diff --git a/swingjs/timestamp b/swingjs/timestamp index a5b4b63..3c00905 100644 --- a/swingjs/timestamp +++ b/swingjs/timestamp @@ -1 +1 @@ -20180822094549 +20180824015733 diff --git a/swingjs/ver/3.2.2/SwingJS-site.zip b/swingjs/ver/3.2.2/SwingJS-site.zip index 498bfc3..0a54e13 100644 Binary files a/swingjs/ver/3.2.2/SwingJS-site.zip and b/swingjs/ver/3.2.2/SwingJS-site.zip differ diff --git a/swingjs/ver/3.2.2/timestamp b/swingjs/ver/3.2.2/timestamp index a5b4b63..3c00905 100644 --- a/swingjs/ver/3.2.2/timestamp +++ b/swingjs/ver/3.2.2/timestamp @@ -1 +1 @@ -20180822094549 +20180824015733