JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / jbgui / GDesktop.java
index aa86809..8fd5921 100755 (executable)
 /*
- * 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
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview 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 3
  * 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.
- *
+ *  
+ * Jalview 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
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.jbgui;
 
-import java.awt.*;
-import java.awt.event.*;
+import jalview.api.AlignmentViewPanel;
+import jalview.util.MessageManager;
 
-import javax.swing.*;
+import java.awt.FlowLayout;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
 
 /**
  * DOCUMENT ME!
- *
+ * 
  * @author $author$
  * @version $Revision$
  */
-public class GDesktop
-    extends JFrame
+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();
+
   protected JMenu VamsasStMenu = 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 vamsasStart = new JMenuItem();
+
   protected JMenuItem vamsasImport = new JMenuItem();
+
   protected JMenuItem vamsasSave = new JMenuItem();
+
   JMenuItem inputSequence = new JMenuItem();
+
   protected JMenuItem vamsasStop = new JMenuItem();
+
   JMenuItem closeAll = new JMenuItem();
+
   JMenuItem raiseRelated = new JMenuItem();
+
   JMenuItem minimizeAssociated = new JMenuItem();
+
   protected JCheckBoxMenuItem showMemusage = new JCheckBoxMenuItem();
+
   JMenuItem garbageCollect = new JMenuItem();
 
+  protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
+
+  protected JMenuItem snapShotWindow = new JMenuItem();
+
   /**
    * Creates a new GDesktop object.
    */
@@ -70,8 +113,7 @@ public class GDesktop
     {
       jbInit();
       this.setJMenuBar(desktopMenubar);
-    }
-    catch (Exception e)
+    } catch (Exception e)
     {
       e.printStackTrace();
     }
@@ -92,30 +134,35 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @throws Exception DOCUMENT ME!
+   * 
+   * @throws Exception
+   *           DOCUMENT ME!
    */
-  private void jbInit()
-      throws Exception
+  private void jbInit() throws Exception
   {
-    FileMenu.setText("File");
-    HelpMenu.setText("Help");
+
+    FileMenu.setText(MessageManager.getString("action.file"));
+    HelpMenu.setText(MessageManager.getString("action.help"));
     VamsasMenu.setText("Vamsas");
-    VamsasMenu.setToolTipText("Share data with other vamsas applications.");
-    VamsasStMenu.setText("Connect to");
-    VamsasStMenu.setToolTipText("Join an existing vamsas session");
-    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");
+    VamsasMenu.setToolTipText(MessageManager
+            .getString("label.share_data_vamsas_applications"));
+    VamsasStMenu.setText(MessageManager.getString("label.connect_to"));
+    VamsasStMenu.setToolTipText(MessageManager
+            .getString("label.join_existing_vamsas_session"));
+    inputLocalFileMenuItem.setText(MessageManager
+            .getString("label.load_tree_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(MessageManager.getString("label.from_url"));
     inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -123,15 +170,17 @@ public class GDesktop
         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");
+    inputTextboxMenuItem.setText(MessageManager
+            .getString("label.from_textbox"));
+    inputTextboxMenuItem
+            .addActionListener(new java.awt.event.ActionListener()
+            {
+              public void actionPerformed(ActionEvent e)
+              {
+                inputTextboxMenuItem_actionPerformed(null);
+              }
+            });
+    quit.setText(MessageManager.getString("action.quit"));
     quit.addActionListener(new java.awt.event.ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -139,7 +188,7 @@ public class GDesktop
         quit();
       }
     });
-    aboutMenuItem.setText("About");
+    aboutMenuItem.setText(MessageManager.getString("label.about"));
     aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -147,19 +196,21 @@ public class GDesktop
         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);
-      }
-    });
+    documentationMenuItem.setText(MessageManager
+            .getString("label.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...");
+    windowMenu.setText(MessageManager.getString("label.window"));
+    preferences.setText(MessageManager.getString("label.preferences"));
     preferences.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -167,8 +218,8 @@ public class GDesktop
         preferences_actionPerformed(e);
       }
     });
-    toolsMenu.setText("Tools");
-    saveState.setText("Save Project");
+    toolsMenu.setText(MessageManager.getString("label.tools"));
+    saveState.setText(MessageManager.getString("action.save_project"));
     saveState.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -176,7 +227,7 @@ public class GDesktop
         saveState_actionPerformed(e);
       }
     });
-    loadState.setText("Load Project");
+    loadState.setText(MessageManager.getString("action.load_project"));
     loadState.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -184,8 +235,9 @@ public class GDesktop
         loadState_actionPerformed(e);
       }
     });
-    inputMenu.setText("Input Alignment");
-    vamsasStart.setText("New Vamsas Session...");
+    inputMenu.setText(MessageManager.getString("label.input_alignment"));
+    vamsasStart.setText(MessageManager
+            .getString("label.new_vamsas_session"));
     vamsasStart.setVisible(false);
     vamsasStart.addActionListener(new ActionListener()
     {
@@ -194,7 +246,8 @@ public class GDesktop
         vamsasStart_actionPerformed(e);
       }
     });
-    vamsasImport.setText("Load Vamsas Session...");
+    vamsasImport.setText(MessageManager
+            .getString("action.load_vamsas_session"));
     vamsasImport.setVisible(false);
     vamsasImport.addActionListener(new ActionListener()
     {
@@ -203,7 +256,8 @@ public class GDesktop
         vamsasImport_actionPerformed(e);
       }
     });
-    vamsasSave.setText("Save Vamsas Session...");
+    vamsasSave.setText(MessageManager
+            .getString("action.save_vamsas_session"));
     vamsasSave.setVisible(false);
     vamsasSave.addActionListener(new ActionListener()
     {
@@ -212,7 +266,8 @@ public class GDesktop
         vamsasSave_actionPerformed(e);
       }
     });
-    inputSequence.setText("Fetch Sequence(s)...");
+    inputSequence.setText(MessageManager
+            .getString("action.fetch_sequences"));
     inputSequence.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -220,7 +275,8 @@ public class GDesktop
         inputSequence_actionPerformed(e);
       }
     });
-    vamsasStop.setText("Stop Vamsas Session");
+    vamsasStop.setText(MessageManager
+            .getString("label.stop_vamsas_session"));
     vamsasStop.setVisible(false);
     vamsasStop.addActionListener(new ActionListener()
     {
@@ -229,7 +285,7 @@ public class GDesktop
         vamsasStop_actionPerformed(e);
       }
     });
-    closeAll.setText("Close All");
+    closeAll.setText(MessageManager.getString("action.close_all"));
     closeAll.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -237,7 +293,8 @@ public class GDesktop
         closeAll_actionPerformed(e);
       }
     });
-    raiseRelated.setText("Raise Associated Windows");
+    raiseRelated.setText(MessageManager
+            .getString("action.raise_associated_windows"));
     raiseRelated.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -245,7 +302,8 @@ public class GDesktop
         raiseRelated_actionPerformed(e);
       }
     });
-    minimizeAssociated.setText("Minimize Associated Windows");
+    minimizeAssociated.setText(MessageManager
+            .getString("action.minimize_associated_windows"));
     minimizeAssociated.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -253,7 +311,8 @@ public class GDesktop
         minimizeAssociated_actionPerformed(e);
       }
     });
-    garbageCollect.setText("Collect Garbage");
+    garbageCollect.setText(MessageManager
+            .getString("label.collect_garbage"));
     garbageCollect.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -261,7 +320,8 @@ public class GDesktop
         garbageCollect_actionPerformed(e);
       }
     });
-    showMemusage.setText("Show Memory Usage");
+    showMemusage.setText(MessageManager
+            .getString("label.show_memory_usage"));
     showMemusage.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -269,6 +329,32 @@ public class GDesktop
         showMemusage_actionPerformed(e);
       }
     });
+    showConsole
+            .setText(MessageManager.getString("label.show_java_console"));
+    showConsole.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        showConsole_actionPerformed(e);
+      }
+    });
+    showNews.setText(MessageManager.getString("label.show_jalview_news"));
+    showNews.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        showNews_actionPerformed(e);
+      }
+    });
+    snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
+    snapShotWindow.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        snapShotWindow_actionPerformed(e);
+      }
+    });
+
     desktopMenubar.add(FileMenu);
     desktopMenubar.add(toolsMenu);
     VamsasMenu.setVisible(false);
@@ -292,7 +378,10 @@ public class GDesktop
     VamsasMenu.add(vamsasStop);
     toolsMenu.add(preferences);
     toolsMenu.add(showMemusage);
+    toolsMenu.add(showConsole);
+    toolsMenu.add(showNews);
     toolsMenu.add(garbageCollect);
+    // toolsMenu.add(snapShotWindow);
     inputMenu.add(inputLocalFileMenuItem);
     inputMenu.add(inputURLMenuItem);
     inputMenu.add(inputTextboxMenuItem);
@@ -300,19 +389,37 @@ public class GDesktop
     windowMenu.add(raiseRelated);
     windowMenu.add(minimizeAssociated);
     windowMenu.addSeparator();
-    //    inputMenu.add(vamsasLoad);
+    // inputMenu.add(vamsasLoad);
+  }
+
+  protected void snapShotWindow_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showConsole_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showNews_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
   }
 
   protected void showMemusage_actionPerformed(ActionEvent e)
   {
     // TODO Auto-generated method stub
-    
+
   }
 
   protected void garbageCollect_actionPerformed(ActionEvent e)
   {
     // TODO Auto-generated method stub
-    
+
   }
 
   protected void vamsasStMenu_actionPerformed()
@@ -325,30 +432,33 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
-  protected void inputLocalFileMenuItem_actionPerformed(jalview.gui.
-      AlignViewport av)
+  protected void inputLocalFileMenuItem_actionPerformed(
+          jalview.gui.AlignViewport av)
   {
   }
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
-  protected void inputURLMenuItem_actionPerformed(jalview.gui.AlignViewport av)
+  protected void inputURLMenuItem_actionPerformed(
+          jalview.gui.AlignViewport av)
   {
   }
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
-  protected void inputTextboxMenuItem_actionPerformed(jalview.gui.AlignViewport
-      av)
+  protected void inputTextboxMenuItem_actionPerformed(AlignmentViewPanel avp)
   {
   }
 
@@ -361,8 +471,9 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   protected void aboutMenuItem_actionPerformed(ActionEvent e)
   {
@@ -370,8 +481,9 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   protected void documentationMenuItem_actionPerformed(ActionEvent e)
   {
@@ -379,8 +491,9 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   public void SaveState_actionPerformed(ActionEvent e)
   {
@@ -388,8 +501,9 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   protected void preferences_actionPerformed(ActionEvent e)
   {
@@ -397,8 +511,9 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   public void saveState_actionPerformed(ActionEvent e)
   {
@@ -406,8 +521,9 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   public void loadState_actionPerformed(ActionEvent e)
   {
@@ -415,8 +531,9 @@ public class GDesktop
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   public void loadJalviewAlign_actionPerformed(ActionEvent e)
   {