Merge branch 'develop' into Jalview-BH/JAL-3026-JAL-3063-JAXB
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 6 Dec 2018 13:26:46 +0000 (13:26 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 6 Dec 2018 13:26:46 +0000 (13:26 +0000)
1  2 
src/jalview/appletgui/AppletJmolBinding.java
src/jalview/appletgui/ExtJmol.java
src/jalview/ext/jmol/JalviewJmolBinding.java
test/jalview/io/cache/JvCacheableInputBoxTest.java

@@@ -24,7 -24,6 +24,6 @@@ import jalview.api.AlignmentViewPanel
  import jalview.datamodel.PDBEntry;
  import jalview.datamodel.SequenceI;
  import jalview.ext.jmol.JalviewJmolBinding;
- import jalview.gui.IProgressIndicator;
  import jalview.io.DataSourceType;
  import jalview.structure.StructureSelectionManager;
  
@@@ -33,7 -32,7 +32,7 @@@ import java.util.Map
  
  import org.jmol.api.JmolAppConsoleInterface;
  import org.jmol.console.AppletConsole;
 -import org.jmol.java.BS;
 +import javajs.util.BS;
  
  class AppletJmolBinding extends JalviewJmolBinding
  {
    @Override
    public int[] resizeInnerPanel(String data)
    {
-     // TODO Auto-generated method stub
      return null;
    }
  
    @Override
    public Map<String, Object> getJSpecViewProperty(String arg0)
    {
-     // TODO Auto-generated method stub
-     return null;
-   }
-   @Override
-   protected IProgressIndicator getIProgressIndicator()
-   {
-     // no progress indicators on the applet
      return null;
    }
  }
@@@ -26,7 -26,6 +26,6 @@@ import jalview.api.SequenceRenderer
  import jalview.datamodel.PDBEntry;
  import jalview.datamodel.SequenceI;
  import jalview.ext.jmol.JalviewJmolBinding;
- import jalview.gui.IProgressIndicator;
  import jalview.io.DataSourceType;
  
  import java.awt.Container;
@@@ -36,7 -35,7 +35,7 @@@ import java.util.Map
  import java.util.Vector;
  
  import org.jmol.api.JmolAppConsoleInterface;
 -import org.jmol.java.BS;
 +import javajs.util.BS;
  import org.jmol.viewer.Viewer;
  
  /**
@@@ -66,18 -65,8 +65,8 @@@ public class ExtJmol extends JalviewJmo
    }
  
    @Override
-   protected IProgressIndicator getIProgressIndicator()
-   {
-     // no progress indicators on applet (could access javascript for this)
-     return null;
-   }
-   @Override
    public void updateColours(Object source)
    {
-     // TODO Auto-generated method stub
    }
  
    @Override
    protected JmolAppConsoleInterface createJmolConsole(
            Container consolePanel, String buttonsToShow)
    {
-     // TODO Auto-generated method stub
      return null;
    }
  
    @Override
    public void releaseReferences(Object svl)
    {
-     // TODO Auto-generated method stub
    }
  
    @Override
    public Map<String, Object> getJSpecViewProperty(String arg0)
    {
-     // TODO Auto-generated method stub
      return null;
    }
  
@@@ -166,8 -166,7 +166,8 @@@ public abstract class JalviewJmolBindin
    {
      // remove listeners for all structures in viewer
      getSsm().removeStructureViewerListener(this, this.getStructureFiles());
 -    viewer.dispose();
 +    if (viewer != null)
 +      viewer.dispose();
      lastCommand = null;
      viewer = null;
      releaseUIResources();
      jmolHistory(false);
      if (lastCommand == null || !lastCommand.equals(command))
      {
 -      viewer.evalStringQuiet(command + "\n");
 +      jmolScript(command + "\n");
      }
      jmolHistory(true);
      lastCommand = command;
      {
        if (resetLastRes.length() > 0)
        {
 -        viewer.evalStringQuiet(resetLastRes.toString());
 +        jmolScript(resetLastRes.toString());
          resetLastRes.setLength(0);
        }
        for (AtomSpec atom : atoms)
  
      cmd.append("spacefill 200;select none");
  
 -    viewer.evalStringQuiet(cmd.toString());
 +    jmolScript(cmd.toString());
      jmolHistory(true);
  
    }
  
    private void jmolHistory(boolean enable)
    {
 -    viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
 +    jmolScript("History " + ((debug || enable) ? "on" : "off"));
    }
  
    public void loadInline(String string)
    {
      /**
       * this implements the toggle label behaviour copied from the original
 -     * structure viewer, MCView
 +     * structure viewer, mc_view
       */
      if (strData != null)
      {
  
      if (!atomsPicked.contains(picked))
      {
 -      viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
 +      jmolScript("select " + picked + ";label %n %r:%c");
        atomsPicked.addElement(picked);
      }
      else
      // }
      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
      return chainNames;
    }
  
-   protected abstract IProgressIndicator getIProgressIndicator();
+   protected IProgressIndicator getIProgressIndicator()
+   {
+     return null;
+   }
  
    public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
    {
     */
    public abstract void showConsole(boolean show);
  
 +  
 +  public static Viewer getJmolData(JmolParser jmolParser)
 +  {
 +    return (Viewer) JmolViewer.allocateViewer(null, null, null, null, null,
 +            "-x -o -n", jmolParser);
 +  }
 +
    /**
 +   * 
 +   * 
 +   * 
     * @param renderPanel
     * @param jmolfileio
     *          - when true will initialise jmol's file IO system (should be false
     * @param consolePanel
     *          - panel to contain Jmol console
     * @param buttonsToShow
 -   *          - buttons to show on the console, in ordr
 +   *          - buttons to show on the console, in order
     */
    public void allocateViewer(Container renderPanel, boolean jmolfileio,
            String htmlName, URL documentBase, URL codeBase,
            String commandOptions, final Container consolePanel,
            String buttonsToShow)
    {
 +    
 +    System.err.println("Allocating Jmol Viewer: " + commandOptions);
 +    
      if (commandOptions == null)
      {
        commandOptions = "";
  
      viewer.setJmolStatusListener(this); // extends JmolCallbackListener
  
 -    console = createJmolConsole(consolePanel, buttonsToShow);
 +    try {
 +      console = createJmolConsole(consolePanel, buttonsToShow);
 +    } catch (Throwable e) {
 +      System.err.println("Could not create Jmol application console. " + e.getMessage());
 +      e.printStackTrace();
 +    }
      if (consolePanel != null)
      {
        consolePanel.addComponentListener(this);
    protected abstract JmolAppConsoleInterface createJmolConsole(
            Container consolePanel, String buttonsToShow);
  
 +  // BH 2018 -- Jmol console is not working due to problems with styled documents.
 +  
 +
    protected org.jmol.api.JmolAppConsoleInterface console = null;
  
    @Override
    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)
 +  {
 +    
 +    System.err.println(">>Jmol>> " + script);
 +    
 +    String s = viewer.scriptWait(script);
 +    
 +    System.err.println("<<Jmol<< " + s);
 +    
 +    return s;
 +  }
 +
    @Override
    public int[] resizeInnerPanel(String data)
    {
    {
      showConsole(false);
    }
 +
  }
@@@ -34,7 -34,7 +34,7 @@@ public class JvCacheableInputBoxTes
  
      try
      {
 -      // This 1ms delay is essential to prevent the
 +      // This delay is essential to prevent the
        // assertion below from executing before
        // swing thread finishes updating the combo-box
        Thread.sleep(100);
      cacheBox.updateCache();
      try
      {
-       // This 1ms delay is essential to prevent the
-       // assertion below from executing before
-       // cacheBox.updateCache() finishes updating the cache
-       Thread.sleep(100);
+       // This delay is to let
+       // cacheBox.updateCache() finish updating the cache
+       Thread.sleep(200);
      } catch (InterruptedException e)
      {
        e.printStackTrace();