groovy support without compile-time dependency.
authorjprocter <Jim Procter>
Thu, 26 Apr 2007 10:35:19 +0000 (10:35 +0000)
committerjprocter <Jim Procter>
Thu, 26 Apr 2007 10:35:19 +0000 (10:35 +0000)
doc/AddingGroovySupport.html
src/jalview/bin/Cache.java
src/jalview/gui/Desktop.java
src/jalview/jbgui/GDesktop.java

index 6726612..966c9b4 100644 (file)
@@ -8,109 +8,30 @@ Adding Groovy Support to Jalview
 <p>
 There is currently no scripting language 
 extension within Jalview, in part because a 
-scripting API has not been developed.
+scripting API has not yet been developed.
 </p>
 <p>It is, however, really easy to embed scripting
-engines within Jalview. We haven't done it
-with the Bean Scripting Framework, but the
-code snippets below show you how to get going
-with groovy.
+engines like groovy. If groovy is detected on the 
+classpath, a new menu entry on the Desktop's Tools 
+menu will open the GroovyShell.
 </p>
-<h2>Modifications</h2>
-<p>
-For each class below, add the following objects and methods to their definitions.
-</p>
-<ul><li>
-jalview.jbgui.GDesktop
+<p>Here are some scripts to get you started:</p>
+<ul><li>Getting the title, alignment and first sequence from the current alignFrame<br>
 <pre>
-..
-protected JMenuItem groovyShell = new JMenuItem();
-..
-jbInit() {
-..
-groovyShell.setText("Groovy Shell...");
-groovyShell.addActionListener(new ActionListener() 
-{
-    public void actionPerformed(ActionEvent e) {
-        groovyShell_actionPerformed(e);
-    }  
-});
-..
-}
-..
-protected void groovyShell_actionPerformed(ActionEvent e) 
-{
-}
-..
-</pre></li>
-<li>jalview.gui.Desktop
-<pre>
-..
-/** 
- * Accessor method to quickly get all the AlignmentFrames
- * loaded.  
- */    
-protected AlignFrame[] getAlignframes() {
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
-
-    if (frames == null)
-    {
-        return null;
-    }
-    Vector avp=new Vector();
-    try
-    {
-        //REVERSE ORDER
-        for (int i = frames.length - 1; i > -1; i--)
-        {
-            if (frames[i] instanceof AlignFrame)
-            {
-                AlignFrame af = (AlignFrame) frames[i];
-                avp.addElement(af);
-            }
-        }
-    }
-    catch (Exception ex)
-    {
-        ex.printStackTrace();
-    }
-    if (avp.size()==0)
-    {
-        return null;
-    }
-    AlignFrame afs[] = new AlignFrame[avp.size()];
-    for (int i=0,j=avp.size(); i&lt;j; i++) {
-        afs[i] = (AlignFrame) avp.elementAt(i);
-    }
-    avp.clear();
-    return afs;
-}
-
-/**
-  * Add Groovy Support to Jalview
-  */
-public void groovyShell_actionPerformed(ActionEvent e) {
-    Console gc = new Console();
-    gc.setVariable("Jalview", this);
-    gc.run();
-}
-..
+def alf = Jalview.getAlignframes();
+print alf[0].getTitle();
+def alignment = alf[0].viewport.alignment;
+def seq = alignment.getSequenceAt(0);
 </pre>
 </li>
 </ul>
+<h1>Getting Groovy...</h1>
 <p>
-Finally, compile and run with the groovy-all-*.jar (get the jar 
-from the <em>embedded</em> directory within the <a 
+You need the core groovy jars which include the GroovyShell. The easiest way of doing
+this is to add the groovy-all-*.jar to the lib directory whose path is given in the java.ext.dirs property.</p>
+<p>The is obtained from the <em>embedded</em> directory within the <a 
 href="http://dist.codehaus.org/groovy/distributions"/>groovy distribution</a>).
-Then, you should be able to open the Groovy shell 
-window from the Desktop's Tools menu. To check things are working,
-try a simple test script :<br>
-<pre>
-  
-  print Jalview.getAlignframes()[0].getTitle();
-</pre>
-Executing this will print the title of the first alignment loaded into Jalview.</p>
-</hr>
+</p>
 <h2>TODO</h2>
 <p>
 Using Java class methods from Groovy is straightforward, but currently, there isn't a set of easy to use methods for the jalview objects. A Jalview Scripting API needs to be developed to make this easier.</p>
index 72fec6c..195ad29 100755 (executable)
@@ -334,5 +334,42 @@ public class Cache
     }
     return (vamsasJarsArePresent > 0);
   }
+  /**
+   * internal vamsas class discovery state
+   */
+  private static int groovyJarsArePresent = -1;
+  /**
+   * Searches for vamsas client classes on class path.
+   * @return true if vamsas client is present on classpath
+   */
+  public static boolean groovyJarsPresent()
+  {
+    if (groovyJarsArePresent == -1)
+    {
+      try
+      {
+        if (Cache.class.getClassLoader().loadClass(
+            "groovy.lang.GroovyObject") != null)
+        {
+          jalview.bin.Cache.log.debug(
+              "Found Groovy (groovy.lang.GroovyObject can be loaded)");
+          groovyJarsArePresent = 1;
+          Logger lgclient = Logger.getLogger("groovy");
+          lgclient.setLevel(Level.toLevel(Cache.getDefault("logs.Groovy.Level",
+              Level.INFO.toString())));
+
+          lgclient.addAppender(log.getAppender("JalviewLogger"));
+          // Tell the user that debug is enabled
+          lgclient.debug("Jalview Groovy Client Debugging Output Follows.");
+        }
+      }
+      catch (Exception e)
+      {
+        groovyJarsArePresent = 0;
+        jalview.bin.Cache.log.debug("Groovy Classes are not present");
+      }
+    }
+    return (groovyJarsArePresent > 0);
+  }
 
 }
index 0304ea1..0310f2a 100755 (executable)
@@ -23,6 +23,7 @@ import java.awt.*;
 import java.awt.datatransfer.*;
 import java.awt.dnd.*;
 import java.awt.event.*;
+import java.lang.reflect.Constructor;
 import java.util.*;
 
 import javax.swing.*;
@@ -63,6 +64,7 @@ public class Desktop
   {
     instance = this;
     doVamsasClientCheck();
+    doGroovyCheck();
     Image image = null;
 
 
@@ -1104,5 +1106,87 @@ public class Desktop
       }
     }
   }*/
+  protected JMenuItem groovyShell;
+  public void doGroovyCheck() {
+    if (jalview.bin.Cache.groovyJarsPresent())
+    {
+      groovyShell = new JMenuItem();
+      groovyShell.setText("Groovy Shell...");
+      groovyShell.addActionListener(new ActionListener() 
+      {
+          public void actionPerformed(ActionEvent e) {
+              groovyShell_actionPerformed(e);
+          }  
+      });
+      toolsMenu.add(groovyShell);
+      groovyShell.setVisible(true);
+    }
+  }
+  /** 
+   * Accessor method to quickly get all the AlignmentFrames
+   * loaded.  
+   */    
+  protected AlignFrame[] getAlignframes() {
+    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    
+    if (frames == null)
+    {
+      return null;
+      }
+      Vector avp=new Vector();
+      try
+      {
+          //REVERSE ORDER
+          for (int i = frames.length - 1; i > -1; i--)
+          {
+              if (frames[i] instanceof AlignFrame)
+              {
+                  AlignFrame af = (AlignFrame) frames[i];
+                  avp.addElement(af);
+              }
+          }
+      }
+      catch (Exception ex)
+      {
+          ex.printStackTrace();
+      }
+      if (avp.size()==0)
+      {
+          return null;
+      }
+      AlignFrame afs[] = new AlignFrame[avp.size()];
+      for (int i=0,j=avp.size(); i<j; i++) {
+          afs[i] = (AlignFrame) avp.elementAt(i);
+      }
+      avp.clear();
+      return afs;
+  }
 
+  /**
+    * Add Groovy Support to Jalview
+    */
+  public void groovyShell_actionPerformed(ActionEvent e) {
+    // use reflection to avoid creating compilation dependency.
+    if (!jalview.bin.Cache.groovyJarsPresent())
+    {
+      throw new Error("Implementation Error. Cannot create groovyShell without Groovy on the classpath!");
+    }
+    try {
+    Class gcClass = Desktop.class.getClassLoader().loadClass("groovy.ui.Console");
+    Constructor gccons = gcClass.getConstructor(null);
+    java.lang.reflect.Method setvar = gcClass.getMethod("setVariable", new Class[] { String.class, Object.class} );
+    java.lang.reflect.Method run = gcClass.getMethod("run", null);
+    Object gc = gccons.newInstance(null);
+    setvar.invoke(gc, new Object[] { "Jalview", this});
+    run.invoke(gc, null);
+    }
+    catch (Exception ex)
+    {
+      jalview.bin.Cache.log.error("Groovy Shell Creation failed.",ex);
+      JOptionPane.showInternalMessageDialog(Desktop.desktop,
+
+              "Couldn't create the groovy Shell. Check the error log for the details of what went wrong.", "Jalview Groovy Support Failed",
+              JOptionPane.ERROR_MESSAGE);
+    }
   }
+}
index 722a408..59e4457 100755 (executable)
-/*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
- */\r
-package jalview.jbgui;\r
-\r
-import java.awt.*;\r
-import java.awt.event.*;\r
-import javax.swing.*;\r
-\r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-public class GDesktop\r
-    extends JFrame\r
-{\r
-  protected static JMenu windowMenu = new JMenu();\r
-  JMenuBar desktopMenubar = new JMenuBar();\r
-  JMenu FileMenu = new JMenu();\r
-  JMenu HelpMenu = new JMenu();\r
-  protected JMenu VamsasMenu = new JMenu();\r
-  JMenuItem inputLocalFileMenuItem = new JMenuItem();\r
-  JMenuItem inputURLMenuItem = new JMenuItem();\r
-  JMenuItem inputTextboxMenuItem = new JMenuItem();\r
-  JMenuItem quit = new JMenuItem();\r
-  JMenuItem aboutMenuItem = new JMenuItem();\r
-  JMenuItem documentationMenuItem = new JMenuItem();\r
-  FlowLayout flowLayout1 = new FlowLayout();\r
-  JMenu toolsMenu = new JMenu();\r
-  JMenuItem preferences = new JMenuItem();\r
-  JMenuItem saveState = new JMenuItem();\r
-  JMenuItem loadState = new JMenuItem();\r
-  JMenu inputMenu = new JMenu();\r
-  protected JMenuItem vamsasLoad = new JMenuItem();\r
-  JMenuItem inputSequence = new JMenuItem();\r
-  protected JMenuItem vamsasStop = new JMenuItem();\r
-  JMenuItem closeAll = new JMenuItem();\r
-  JMenuItem raiseRelated = new JMenuItem();\r
-  JMenuItem minimizeAssociated = new JMenuItem();\r
-\r
-  /**\r
-   * Creates a new GDesktop object.\r
-   */\r
-  public GDesktop()\r
-  {\r
-    try\r
-    {\r
-      jbInit();\r
-      this.setJMenuBar(desktopMenubar);\r
-    }\r
-    catch (Exception e)\r
-    {\r
-      e.printStackTrace();\r
-    }\r
-\r
-    if (!System.getProperty("os.name").startsWith("Mac"))\r
-    {\r
-      FileMenu.setMnemonic('F');\r
-      inputLocalFileMenuItem.setMnemonic('L');\r
-      VamsasMenu.setMnemonic('V');\r
-      inputURLMenuItem.setMnemonic('U');\r
-      inputTextboxMenuItem.setMnemonic('C');\r
-      quit.setMnemonic('Q');\r
-      saveState.setMnemonic('S');\r
-      loadState.setMnemonic('L');\r
-      inputMenu.setMnemonic('I');\r
-    }\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @throws Exception DOCUMENT ME!\r
-   */\r
-  private void jbInit()\r
-      throws Exception\r
-  {\r
-    FileMenu.setText("File");\r
-    HelpMenu.setText("Help");\r
-    VamsasMenu.setText("Vamsas");\r
-    VamsasMenu.setToolTipText("Share data with other vamsas applications.");\r
-    inputLocalFileMenuItem.setText("from File");\r
-    inputLocalFileMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(\r
-        java.awt.event.KeyEvent.VK_O,\r
-        Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));\r
-    inputLocalFileMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        inputLocalFileMenuItem_actionPerformed(null);\r
-      }\r
-    });\r
-    inputURLMenuItem.setText("from URL");\r
-    inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        inputURLMenuItem_actionPerformed(null);\r
-      }\r
-    });\r
-    inputTextboxMenuItem.setText("from Textbox");\r
-    inputTextboxMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        inputTextboxMenuItem_actionPerformed(null);\r
-      }\r
-    });\r
-    quit.setText("Quit");\r
-    quit.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        quit();\r
-      }\r
-    });\r
-    aboutMenuItem.setText("About");\r
-    aboutMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        aboutMenuItem_actionPerformed(e);\r
-      }\r
-    });\r
-    documentationMenuItem.setText("Documentation");\r
-    documentationMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(\r
-        java.awt.event.KeyEvent.VK_F1, 0, false));\r
-    documentationMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        documentationMenuItem_actionPerformed(e);\r
-      }\r
-    });\r
-    this.getContentPane().setLayout(flowLayout1);\r
-    windowMenu.setText("Window");\r
-    preferences.setText("Preferences...");\r
-    preferences.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        preferences_actionPerformed(e);\r
-      }\r
-    });\r
-    toolsMenu.setText("Tools");\r
-    saveState.setText("Save Project");\r
-    saveState.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        saveState_actionPerformed(e);\r
-      }\r
-    });\r
-    loadState.setText("Load Project");\r
-    loadState.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        loadState_actionPerformed(e);\r
-      }\r
-    });\r
-    inputMenu.setText("Input Alignment");\r
-    vamsasLoad.setText("Start Vamsas Session...");\r
-    vamsasLoad.setVisible(false);\r
-    vamsasLoad.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        vamsasLoad_actionPerformed(e);\r
-      }\r
-    });\r
-    inputSequence.setText("Fetch Sequence(s)...");\r
-    inputSequence.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        inputSequence_actionPerformed(e);\r
-      }\r
-    });\r
-    vamsasStop.setText("Stop Vamsas Session");\r
-    vamsasStop.setVisible(false);\r
-    vamsasStop.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        vamsasStop_actionPerformed(e);\r
-      }\r
-    });\r
-    closeAll.setText("Close All");\r
-    closeAll.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        closeAll_actionPerformed(e);\r
-      }\r
-    });\r
-    raiseRelated.setText("Raise Associated Windows");\r
-    raiseRelated.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        raiseRelated_actionPerformed(e);\r
-      }\r
-    });\r
-    minimizeAssociated.setText("Minimize Associated Windows");\r
-    minimizeAssociated.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        minimizeAssociated_actionPerformed(e);\r
-      }\r
-    });\r
-    desktopMenubar.add(FileMenu);\r
-    desktopMenubar.add(toolsMenu);\r
-    VamsasMenu.setVisible(false);\r
-    desktopMenubar.add(VamsasMenu);\r
-    desktopMenubar.add(HelpMenu);\r
-    desktopMenubar.add(windowMenu);\r
-    FileMenu.add(inputMenu);\r
-    FileMenu.add(inputSequence);\r
-    FileMenu.addSeparator();\r
-    FileMenu.add(saveState);\r
-    FileMenu.add(loadState);\r
-    FileMenu.addSeparator();\r
-    FileMenu.add(quit);\r
-    HelpMenu.add(aboutMenuItem);\r
-    HelpMenu.add(documentationMenuItem);\r
-    VamsasMenu.add(vamsasLoad);\r
-    VamsasMenu.add(vamsasStop);\r
-    toolsMenu.add(preferences);\r
-    inputMenu.add(inputLocalFileMenuItem);\r
-    inputMenu.add(inputURLMenuItem);\r
-    inputMenu.add(inputTextboxMenuItem);\r
-    windowMenu.add(closeAll);\r
-    windowMenu.add(raiseRelated);\r
-    windowMenu.add(minimizeAssociated);\r
-    windowMenu.addSeparator();\r
-    //    inputMenu.add(vamsasLoad);\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  protected void inputLocalFileMenuItem_actionPerformed(jalview.gui.\r
-      AlignViewport av)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  protected void inputURLMenuItem_actionPerformed(jalview.gui.AlignViewport av)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  protected void inputTextboxMenuItem_actionPerformed(jalview.gui.AlignViewport\r
-      av)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   */\r
-  protected void quit()\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  protected void aboutMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  protected void documentationMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  public void SaveState_actionPerformed(ActionEvent e)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  protected void preferences_actionPerformed(ActionEvent e)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  public void saveState_actionPerformed(ActionEvent e)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  public void loadState_actionPerformed(ActionEvent e)\r
-  {\r
-  }\r
-\r
-  /**\r
-   * DOCUMENT ME!\r
-   *\r
-   * @param e DOCUMENT ME!\r
-   */\r
-  public void loadJalviewAlign_actionPerformed(ActionEvent e)\r
-  {\r
-  }\r
-\r
-  public void vamsasLoad_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
-\r
-  public void inputSequence_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
-\r
-  public void vamsasStop_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
-\r
-  public void closeAll_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
-\r
-  public void raiseRelated_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
-\r
-  public void minimizeAssociated_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
-}\r
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+package jalview.jbgui;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class GDesktop
+    extends JFrame
+{
+  protected static JMenu windowMenu = new JMenu();
+  JMenuBar desktopMenubar = new JMenuBar();
+  JMenu FileMenu = new JMenu();
+  JMenu HelpMenu = new JMenu();
+  protected JMenu VamsasMenu = new JMenu();
+  JMenuItem inputLocalFileMenuItem = new JMenuItem();
+  JMenuItem inputURLMenuItem = new JMenuItem();
+  JMenuItem inputTextboxMenuItem = new JMenuItem();
+  JMenuItem quit = new JMenuItem();
+  JMenuItem aboutMenuItem = new JMenuItem();
+  JMenuItem documentationMenuItem = new JMenuItem();
+  FlowLayout flowLayout1 = new FlowLayout();
+  protected JMenu toolsMenu = new JMenu();
+  JMenuItem preferences = new JMenuItem();
+  JMenuItem saveState = new JMenuItem();
+  JMenuItem loadState = new JMenuItem();
+  JMenu inputMenu = new JMenu();
+  protected JMenuItem vamsasLoad = new JMenuItem();
+  JMenuItem inputSequence = new JMenuItem();
+  protected JMenuItem vamsasStop = new JMenuItem();
+  JMenuItem closeAll = new JMenuItem();
+  JMenuItem raiseRelated = new JMenuItem();
+  JMenuItem minimizeAssociated = new JMenuItem();
+
+  /**
+   * Creates a new GDesktop object.
+   */
+  public GDesktop()
+  {
+    try
+    {
+      jbInit();
+      this.setJMenuBar(desktopMenubar);
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+
+    if (!System.getProperty("os.name").startsWith("Mac"))
+    {
+      FileMenu.setMnemonic('F');
+      inputLocalFileMenuItem.setMnemonic('L');
+      VamsasMenu.setMnemonic('V');
+      inputURLMenuItem.setMnemonic('U');
+      inputTextboxMenuItem.setMnemonic('C');
+      quit.setMnemonic('Q');
+      saveState.setMnemonic('S');
+      loadState.setMnemonic('L');
+      inputMenu.setMnemonic('I');
+    }
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @throws Exception DOCUMENT ME!
+   */
+  private void jbInit()
+      throws Exception
+  {
+    FileMenu.setText("File");
+    HelpMenu.setText("Help");
+    VamsasMenu.setText("Vamsas");
+    VamsasMenu.setToolTipText("Share data with other vamsas applications.");
+    inputLocalFileMenuItem.setText("from File");
+    inputLocalFileMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+        java.awt.event.KeyEvent.VK_O,
+        Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
+    inputLocalFileMenuItem.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        inputLocalFileMenuItem_actionPerformed(null);
+      }
+    });
+    inputURLMenuItem.setText("from URL");
+    inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        inputURLMenuItem_actionPerformed(null);
+      }
+    });
+    inputTextboxMenuItem.setText("from Textbox");
+    inputTextboxMenuItem.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        inputTextboxMenuItem_actionPerformed(null);
+      }
+    });
+    quit.setText("Quit");
+    quit.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        quit();
+      }
+    });
+    aboutMenuItem.setText("About");
+    aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        aboutMenuItem_actionPerformed(e);
+      }
+    });
+    documentationMenuItem.setText("Documentation");
+    documentationMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+        java.awt.event.KeyEvent.VK_F1, 0, false));
+    documentationMenuItem.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        documentationMenuItem_actionPerformed(e);
+      }
+    });
+    this.getContentPane().setLayout(flowLayout1);
+    windowMenu.setText("Window");
+    preferences.setText("Preferences...");
+    preferences.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        preferences_actionPerformed(e);
+      }
+    });
+    toolsMenu.setText("Tools");
+    saveState.setText("Save Project");
+    saveState.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        saveState_actionPerformed(e);
+      }
+    });
+    loadState.setText("Load Project");
+    loadState.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        loadState_actionPerformed(e);
+      }
+    });
+    inputMenu.setText("Input Alignment");
+    vamsasLoad.setText("Start Vamsas Session...");
+    vamsasLoad.setVisible(false);
+    vamsasLoad.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        vamsasLoad_actionPerformed(e);
+      }
+    });
+    inputSequence.setText("Fetch Sequence(s)...");
+    inputSequence.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        inputSequence_actionPerformed(e);
+      }
+    });
+    vamsasStop.setText("Stop Vamsas Session");
+    vamsasStop.setVisible(false);
+    vamsasStop.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        vamsasStop_actionPerformed(e);
+      }
+    });
+    closeAll.setText("Close All");
+    closeAll.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        closeAll_actionPerformed(e);
+      }
+    });
+    raiseRelated.setText("Raise Associated Windows");
+    raiseRelated.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        raiseRelated_actionPerformed(e);
+      }
+    });
+    minimizeAssociated.setText("Minimize Associated Windows");
+    minimizeAssociated.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        minimizeAssociated_actionPerformed(e);
+      }
+    });
+    desktopMenubar.add(FileMenu);
+    desktopMenubar.add(toolsMenu);
+    VamsasMenu.setVisible(false);
+    desktopMenubar.add(VamsasMenu);
+    desktopMenubar.add(HelpMenu);
+    desktopMenubar.add(windowMenu);
+    FileMenu.add(inputMenu);
+    FileMenu.add(inputSequence);
+    FileMenu.addSeparator();
+    FileMenu.add(saveState);
+    FileMenu.add(loadState);
+    FileMenu.addSeparator();
+    FileMenu.add(quit);
+    HelpMenu.add(aboutMenuItem);
+    HelpMenu.add(documentationMenuItem);
+    VamsasMenu.add(vamsasLoad);
+    VamsasMenu.add(vamsasStop);
+    toolsMenu.add(preferences);
+    inputMenu.add(inputLocalFileMenuItem);
+    inputMenu.add(inputURLMenuItem);
+    inputMenu.add(inputTextboxMenuItem);
+    windowMenu.add(closeAll);
+    windowMenu.add(raiseRelated);
+    windowMenu.add(minimizeAssociated);
+    windowMenu.addSeparator();
+    //    inputMenu.add(vamsasLoad);
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  protected void inputLocalFileMenuItem_actionPerformed(jalview.gui.
+      AlignViewport av)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  protected void inputURLMenuItem_actionPerformed(jalview.gui.AlignViewport av)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  protected void inputTextboxMenuItem_actionPerformed(jalview.gui.AlignViewport
+      av)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   */
+  protected void quit()
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  protected void aboutMenuItem_actionPerformed(ActionEvent e)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  protected void documentationMenuItem_actionPerformed(ActionEvent e)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  public void SaveState_actionPerformed(ActionEvent e)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  protected void preferences_actionPerformed(ActionEvent e)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  public void saveState_actionPerformed(ActionEvent e)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  public void loadState_actionPerformed(ActionEvent e)
+  {
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  public void loadJalviewAlign_actionPerformed(ActionEvent e)
+  {
+  }
+
+  public void vamsasLoad_actionPerformed(ActionEvent e)
+  {
+
+  }
+
+  public void inputSequence_actionPerformed(ActionEvent e)
+  {
+
+  }
+
+  public void vamsasStop_actionPerformed(ActionEvent e)
+  {
+
+  }
+
+  public void closeAll_actionPerformed(ActionEvent e)
+  {
+
+  }
+
+  public void raiseRelated_actionPerformed(ActionEvent e)
+  {
+
+  }
+
+  public void minimizeAssociated_actionPerformed(ActionEvent e)
+  {
+
+  }
+}