streamlined app and applet jmol console + event handling via component listener
authorjprocter <Jim Procter>
Tue, 14 Sep 2010 15:49:31 +0000 (15:49 +0000)
committerjprocter <Jim Procter>
Tue, 14 Sep 2010 15:49:31 +0000 (15:49 +0000)
.classpath
appletlib/JmolApplet-12.1.11_dev.jar [moved from appletlib/JmolApplet-12.1.11_dev_patched.jar with 92% similarity]
build.xml
lib/Jmol-12.1.11_dev.jar [moved from lib/Jmol-12.1.11_dev_patched.jar with 92% similarity]
src/jalview/appletgui/AppletJmol.java
src/jalview/appletgui/AppletJmolBinding.java
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/gui/AppJmol.java
src/jalview/gui/AppJmolBinding.java
src/jalview/gui/ScriptWindow.java

index ccbed55..6815d73 100644 (file)
@@ -19,6 +19,7 @@
        <classpathentry kind="lib" path="lib/JGoogleAnalytics-0.2.1-SNAPSHOT.jar" sourcepath="/JGoogleAnalytics/src/main/java"/>
        <classpathentry kind="lib" path="lib/vamsas-client.jar"/>
        <classpathentry kind="lib" path="lib/min-jaba-client.jar" sourcepath="/clustengine/webservices"/>
-       <classpathentry kind="lib" path="lib/Jmol-12.1.11_dev_patched.jar"/>
+       <classpathentry kind="lib" path="lib/Jmol-12.1.11_dev.jar"/>
+       <classpathentry kind="lib" path="appletlib/JmolApplet-12.1.11_dev.jar"/>
        <classpathentry kind="output" path="classes"/>
 </classpath>
similarity index 92%
rename from appletlib/JmolApplet-12.1.11_dev_patched.jar
rename to appletlib/JmolApplet-12.1.11_dev.jar
index 5a7c6f2..096c350 100644 (file)
Binary files a/appletlib/JmolApplet-12.1.11_dev_patched.jar and b/appletlib/JmolApplet-12.1.11_dev.jar differ
index 08cd98e..9141683 100755 (executable)
--- a/build.xml
+++ b/build.xml
                <property name="packageDir" value="dist" />
                <property name="outputJar" value="jalview.jar" />
                <!-- Jalview Applet JMol Jar Dependency -->
-               <property name="jmolJar" value="JmolApplet-12.1.11_dev_patched.jar" />
+               <property name="jmolJar" value="JmolApplet-12.1.11_dev.jar" />
                <property name="jalviewLiteJar" value="jalviewApplet.jar"/>
                <!-- switch to indicate if we should obfuscate jalviewLite -->
                <!--<property name="donotobfuscate" value="true"/> -->
similarity index 92%
rename from lib/Jmol-12.1.11_dev_patched.jar
rename to lib/Jmol-12.1.11_dev.jar
index d4f255a..945a997 100644 (file)
Binary files a/lib/Jmol-12.1.11_dev_patched.jar and b/lib/Jmol-12.1.11_dev.jar differ
index e45bd28..bf38d32 100644 (file)
@@ -184,17 +184,22 @@ public class AppletJmol extends EmbmenuFrame implements
     coloursMenu.add(user);
 
     helpMenu.add(jmolHelp);
+    this.setLayout(new BorderLayout());
 
     setMenuBar(menuBar);
 
     renderPanel = new RenderPanel();
     embedMenuIfNeeded(renderPanel);
     this.add(renderPanel, BorderLayout.CENTER);
+    scriptWindow = new Panel();
+    scriptWindow.setVisible(false);
+    // this.add(scriptWindow, BorderLayout.SOUTH);
+    
     try
     {
       jmb.allocateViewer(renderPanel, true, ap.av.applet.getName()+"_jmol_",
               ap.av.applet.getDocumentBase(), ap.av.applet.getCodeBase(),
-              "-applet");
+              "-applet", scriptWindow, null);
     } catch (Exception e)
     {
       System.err
@@ -520,23 +525,27 @@ public class AppletJmol extends EmbmenuFrame implements
     {
     }
   }
-
+  Panel splitPane=null;
   public void showConsole(boolean showConsole)
   {
-    if (scriptWindow == null)
+    if (showConsole)
     {
-      scriptWindow = new Panel(new BorderLayout());
-      inputLine = new TextField();
-      history = new TextArea(5, 40);
-      scriptWindow.add(history, BorderLayout.CENTER);
-      scriptWindow.add(inputLine, BorderLayout.SOUTH);
-      add(scriptWindow, BorderLayout.SOUTH);
+      remove(renderPanel);
+      splitPane = new Panel();
+      
+      splitPane.setLayout(new java.awt.GridLayout(2,1));
+      splitPane.add(renderPanel);
+      splitPane.add(scriptWindow);
+      scriptWindow.setVisible(true);
+      this.add(splitPane, BorderLayout.CENTER);
+      splitPane.setVisible(true);
+      splitPane.validate();
+    } else {
       scriptWindow.setVisible(false);
-      history.setEditable(false);
-      inputLine.addKeyListener(this);
+      remove(splitPane);
+      add(renderPanel, BorderLayout.CENTER);
+      splitPane=null;
     }
-
-    scriptWindow.setVisible(!scriptWindow.isVisible());
     validate();
   }
 
index d6be32d..12a09d5 100644 (file)
@@ -11,6 +11,7 @@ import jalview.datamodel.SequenceI;
 
 import org.jmol.api.JmolAppConsoleInterface;
 import org.jmol.api.JmolViewer;
+import org.jmol.applet.AppletConsole;
 import org.jmol.popup.JmolPopup;
 
 class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
@@ -126,8 +127,7 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
   protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
           Container consolePanel, String buttonsToShow)
   {
-    // TODO Auto-generated method stub
-    return null;
+    return new AppletConsole(viewer2, consolePanel);
   }
 
 }
\ No newline at end of file
index 31f91ee..09303c7 100644 (file)
@@ -43,7 +43,7 @@ import org.jmol.viewer.Viewer;
 import jalview.schemes.*;
 
 public abstract class JalviewJmolBinding implements StructureListener,
-        JmolStatusListener, SequenceStructureBinding, JmolSelectionListener
+        JmolStatusListener, SequenceStructureBinding, JmolSelectionListener, ComponentListener
 
 {
   /**
@@ -1348,75 +1348,44 @@ public abstract class JalviewJmolBinding implements StructureListener,
             commandOptions, this);
 
     console = createJmolConsole(viewer, consolePanel, buttonsToShow);
-    if (console != null)
+    if (consolePanel != null)
     {
-      viewer.setConsole(new JmolAppConsoleInterface()
-      {
-
-        @Override
-        public JmolScriptEditorInterface getScriptEditor()
-        {
-          return console.getScriptEditor();
-        }
-
-        @Override
-        public JmolAppConsoleInterface getAppConsole(Viewer viewer,
-                Component display)
-        {
-          return console;
-        }
-
-        public String getText()
-        {
-          return console.getText();
-        }
-
-        @Override
-        public Object getMyMenuBar()
-        {
-          return console.getMyMenuBar();
-        }
-
-        @Override
-        public void setVisible(boolean b)
-        {
-          showConsole(b);
-        }
+      consolePanel.addComponentListener(this);
+      
+    }
 
-        @Override
-        public void sendConsoleEcho(String strEcho)
-        {
-          console.sendConsoleEcho(strEcho);
 
-        }
+  }
 
-        @Override
-        public void sendConsoleMessage(String strInfo)
-        {
-          console.sendConsoleMessage(strInfo);
-        }
+  protected abstract JmolAppConsoleInterface createJmolConsole(
+          JmolViewer viewer2, Container consolePanel, String buttonsToShow);
 
-        @Override
-        public void zap()
-        {
-          console.zap();
-        }
+  protected org.jmol.api.JmolAppConsoleInterface console = null;
 
-        @Override
-        public void dispose()
-        {
-          console.dispose();
-        }
+@Override
+public void componentResized(ComponentEvent e)
+{
+  
+}
 
-      });
-    }
+@Override
+public void componentMoved(ComponentEvent e)
+{
+  
+}
 
-  }
+@Override
+public void componentShown(ComponentEvent e)
+{
+  showConsole(true);
+}
 
-  protected abstract JmolAppConsoleInterface createJmolConsole(
-          JmolViewer viewer2, Container consolePanel, String buttonsToShow);
+@Override
+public void componentHidden(ComponentEvent e)
+{
+  showConsole(false);
+}
 
-  protected org.jmol.api.JmolAppConsoleInterface console = null;
 
   public void setLoadingFromArchive(boolean loadingFromArchive)
   {
index 0cc04f7..1b0a5cb 100644 (file)
@@ -339,8 +339,8 @@ public class AppJmol extends GStructureViewer implements Runnable,
       bl.setHgap(0);
       bl.setVgap(0);
       scriptWindow = new JPanel(bl);
+      scriptWindow.setVisible(false);
     };
-    
     jmb.allocateViewer(renderPanel, true, "", null, null, "", scriptWindow, null);
     jmb.newJmolPopup(true, "Jmol", true);
     jmb.evalStateCommand(command);
@@ -786,7 +786,7 @@ public class AppJmol extends GStructureViewer implements Runnable,
     {
     }
   }
-  public void showConsole(boolean showConsole)
+public void showConsole(boolean showConsole)
   {
 
     if (showConsole)
@@ -818,7 +818,6 @@ public class AppJmol extends GStructureViewer implements Runnable,
 
     validate();
   }
-
   class RenderPanel extends JPanel
   {
     final Dimension currentSize = new Dimension();
index babffed..5280900 100644 (file)
@@ -4,6 +4,10 @@
 package jalview.gui;
 
 import java.awt.Container;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
 import java.util.BitSet;
 
 import javax.swing.JPanel;
@@ -17,7 +21,7 @@ import org.jmol.api.JmolViewer;
 import org.jmol.popup.JmolPopup;
 import org.openscience.jmol.app.jmolpanel.AppConsole;
 
-public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
+public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding 
 {
 
   /**
@@ -168,6 +172,6 @@ public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
   protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
           Container consolePanel, String buttonsToShow)
   {
-    return new AppConsole(viewer, null, consolePanel, buttonsToShow);
+    return new AppConsole(viewer, consolePanel, buttonsToShow);
   }
 }
\ No newline at end of file
index 652830d..da3133f 100644 (file)
@@ -259,7 +259,7 @@ public final class ScriptWindow extends JPanel implements ActionListener,
     Object source = e.getSource();
     if (source == closeButton)
     {
-      appJmol.showConsole(false);
+      // appJmol.showConsole(false);
     }
     else if (source == runButton)
     {