patched Jmol and code for embedding JmolAppConsole in a JPanel (JAL-638)
[jalview.git] / src / jalview / gui / AppJmol.java
index 74a9c22..0cc04f7 100644 (file)
@@ -40,6 +40,7 @@ import org.jmol.api.*;
 import org.jmol.adapter.smarter.SmarterJmolAdapter;
 import org.jmol.popup.*;
 import org.jmol.viewer.JmolConstants;
+import org.openscience.jmol.app.jmolpanel.AppConsole;
 
 public class AppJmol extends GStructureViewer implements Runnable,
         SequenceStructureBinding
@@ -47,8 +48,8 @@ public class AppJmol extends GStructureViewer implements Runnable,
 {
   AppJmolBinding jmb;
 
-  ScriptWindow scriptWindow;
-
+  JPanel scriptWindow;
+  
   JSplitPane splitPane;
 
   RenderPanel renderPanel;
@@ -332,7 +333,15 @@ public class AppJmol extends GStructureViewer implements Runnable,
     this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
     jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
             getBounds().width, getBounds().height);
-    jmb.allocateViewer(renderPanel, true, "", null, null, "");
+    if (scriptWindow == null)
+    {
+      BorderLayout bl = new BorderLayout();
+      bl.setHgap(0);
+      bl.setVgap(0);
+      scriptWindow = new JPanel(bl);
+    };
+    
+    jmb.allocateViewer(renderPanel, true, "", null, null, "", scriptWindow, null);
     jmb.newJmolPopup(true, "Jmol", true);
     jmb.evalStateCommand(command);
     jmb.setFinishedInit(true);
@@ -777,11 +786,8 @@ public class AppJmol extends GStructureViewer implements Runnable,
     {
     }
   }
-
   public void showConsole(boolean showConsole)
   {
-    if (scriptWindow == null)
-      scriptWindow = new ScriptWindow(this);
 
     if (showConsole)
     {
@@ -791,15 +797,19 @@ public class AppJmol extends GStructureViewer implements Runnable,
         splitPane.setTopComponent(renderPanel);
         splitPane.setBottomComponent(scriptWindow);
         this.getContentPane().add(splitPane, BorderLayout.CENTER);
+        splitPane.setDividerLocation(getHeight() - 200);
+        scriptWindow.setVisible(true);
+        scriptWindow.validate();
+        splitPane.validate();
       }
 
-      splitPane.setDividerLocation(getHeight() - 200);
-      splitPane.validate();
     }
     else
     {
       if (splitPane != null)
-        splitPane.setVisible(false);
+        {
+          splitPane.setVisible(false);
+        }
 
       splitPane = null;