X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAppJmol.java;h=1c0dfe6c2e534bddc3d733588bfdc9542c17e5a0;hb=62cdf4a06bef088c02f81c66ab2fe0bc3264e321;hp=2299c2602b767098e161817d5615d4481337545e;hpb=7d34fe9736520832bd6269cf2bbde3a8739e5e82;p=jalview.git diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 2299c26..1c0dfe6 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -79,6 +79,9 @@ import javax.swing.event.MenuListener; public class AppJmol extends StructureViewerBase { + // ms to wait for Jmol to load files + private static final int JMOL_LOAD_TIMEOUT = 20000; + private static final String SPACE = " "; private static final String BACKSLASH = "\""; @@ -309,12 +312,10 @@ public class AppJmol extends StructureViewerBase jmb.setColourBySequence(true); setSize(400, 400); // probably should be a configurable/dynamic default here initMenus(); - worker = null; - { - addingStructures = false; - worker = new Thread(this); - worker.start(); - } + addingStructures = false; + worker = new Thread(this); + worker.start(); + this.addInternalFrameListener(new InternalFrameAdapter() { @Override @@ -381,10 +382,7 @@ public class AppJmol extends StructureViewerBase scriptWindow.setVisible(false); } - /* - * -i for no info logging (less verbose) - */ - jmb.allocateViewer(renderPanel, true, "", null, null, "-i", + jmb.allocateViewer(renderPanel, true, "", null, null, "", scriptWindow, null); // jmb.newJmolPopup("Jmol"); if (command == null) @@ -511,8 +509,8 @@ public class AppJmol extends StructureViewerBase StringBuilder fileList = new StringBuilder(); for (String s : files) { - fileList.append(SPACE).append(BACKSLASH).append(Platform.escapeString(s)) - .append(BACKSLASH); + fileList.append(SPACE).append(BACKSLASH) + .append(Platform.escapeString(s)).append(BACKSLASH); } String filesString = fileList.toString(); @@ -544,8 +542,7 @@ public class AppJmol extends StructureViewerBase jmb.evalStateCommand(command); } catch (OutOfMemoryError oomerror) { - new OOMWarning( - "When trying to add structures to the Jmol viewer!", + new OOMWarning("When trying to add structures to the Jmol viewer!", oomerror); Cache.log.debug("File locations are " + filesString); } catch (Exception ex) @@ -555,7 +552,7 @@ public class AppJmol extends StructureViewerBase } // need to wait around until script has finished - int waitMax = 5000; // give up after 5 seconds + int waitMax = JMOL_LOAD_TIMEOUT; int waitFor = 35; int waitTotal = 0; while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled() @@ -572,7 +569,13 @@ public class AppJmol extends StructureViewerBase } if (waitTotal > waitMax) { - System.err.println("Timed out waiting for Jmol to load files"); + System.err + .println("Timed out waiting for Jmol to load files after " + + waitTotal + "ms"); +// System.err.println("finished: " + jmb.isFinishedInit() +// + "; loaded: " + Arrays.toString(jmb.getPdbFile()) +// + "; files: " + files.toString()); + jmb.getPdbFile(); break; } }