From: jprocter Date: Tue, 14 Sep 2010 15:49:31 +0000 (+0000) Subject: streamlined app and applet jmol console + event handling via component listener X-Git-Tag: Release_2_6~44 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=4c5b46336a4a57c09b4a1d2ab13c81b0958a6c9e streamlined app and applet jmol console + event handling via component listener --- diff --git a/.classpath b/.classpath index ccbed55..6815d73 100644 --- a/.classpath +++ b/.classpath @@ -19,6 +19,7 @@ - + + diff --git a/appletlib/JmolApplet-12.1.11_dev_patched.jar b/appletlib/JmolApplet-12.1.11_dev.jar 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 Binary files a/appletlib/JmolApplet-12.1.11_dev_patched.jar and b/appletlib/JmolApplet-12.1.11_dev.jar differ diff --git a/build.xml b/build.xml index 08cd98e..9141683 100755 --- a/build.xml +++ b/build.xml @@ -100,7 +100,7 @@ - + diff --git a/lib/Jmol-12.1.11_dev_patched.jar b/lib/Jmol-12.1.11_dev.jar 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 Binary files a/lib/Jmol-12.1.11_dev_patched.jar and b/lib/Jmol-12.1.11_dev.jar differ diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index e45bd28..bf38d32 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -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(); } diff --git a/src/jalview/appletgui/AppletJmolBinding.java b/src/jalview/appletgui/AppletJmolBinding.java index d6be32d..12a09d5 100644 --- a/src/jalview/appletgui/AppletJmolBinding.java +++ b/src/jalview/appletgui/AppletJmolBinding.java @@ -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 diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 31f91ee..09303c7 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -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) { diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 0cc04f7..1b0a5cb 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -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(); diff --git a/src/jalview/gui/AppJmolBinding.java b/src/jalview/gui/AppJmolBinding.java index babffed..5280900 100644 --- a/src/jalview/gui/AppJmolBinding.java +++ b/src/jalview/gui/AppJmolBinding.java @@ -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 diff --git a/src/jalview/gui/ScriptWindow.java b/src/jalview/gui/ScriptWindow.java index 652830d..da3133f 100644 --- a/src/jalview/gui/ScriptWindow.java +++ b/src/jalview/gui/ScriptWindow.java @@ -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) {