Merge branch 'develop' into trialMerge
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index aac8428..18731ad 100755 (executable)
@@ -21,6 +21,8 @@
 package jalview.jbgui;
 
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
+import jalview.analysis.GeneticCodeI;
+import jalview.analysis.GeneticCodes;
 import jalview.api.SplitContainerI;
 import jalview.bin.Cache;
 import jalview.gui.JvSwingUtils;
@@ -76,7 +78,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenu sortByAnnotScore = new JMenu();
 
-  public JLabel statusBar = new JLabel();
+  protected JLabel statusBar = new JLabel();
 
   protected JMenu outputTextboxMenu = new JMenu();
 
@@ -138,7 +140,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem showDbRefsMenuitem = new JCheckBoxMenuItem();
 
-  protected JMenuItem showTranslation = new JMenuItem();
+  protected JMenu showTranslation = new JMenu();
 
   protected JMenuItem showReverse = new JMenuItem();
 
@@ -170,7 +172,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem();
 
-  protected JTabbedPane tabbedPane = new JTabbedPane();
+  protected JTabbedPane tabbedPane = jalview.jbgui.GDesktop.createTabbedPane();
 
   protected JMenuItem reload = new JMenuItem();
 
@@ -197,6 +199,8 @@ public class GAlignFrame extends JInternalFrame
   protected JCheckBoxMenuItem normaliseSequenceLogo = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem();
+  
+  protected JMenuItem openFeatureSettings;
 
   private SequenceAnnotationOrder annotationSortOrder;
 
@@ -223,7 +227,7 @@ public class GAlignFrame extends JInternalFrame
           @Override
           public void actionPerformed(ActionEvent e)
           {
-            outputText_actionPerformed(e);
+            outputText_actionPerformed(e.getActionCommand());
           }
         });
 
@@ -234,7 +238,7 @@ public class GAlignFrame extends JInternalFrame
       System.err.println(e.toString());
     }
 
-    if (!Platform.isAMac())
+    if (Platform.allowMnemonics()) // was "not mac and not JS"
     {
       closeMenuItem.setMnemonic('C');
       outputTextboxMenu.setMnemonic('T');
@@ -258,7 +262,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        saveAs_actionPerformed(e);
+        saveAs_actionPerformed();
       }
     };
 
@@ -968,7 +972,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        copy_actionPerformed(e);
+        copy_actionPerformed();
       }
     };
     addMenuActionAndAccelerator(keyStroke, copy, al);
@@ -981,7 +985,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        cut_actionPerformed(e);
+        cut_actionPerformed();
       }
     };
     addMenuActionAndAccelerator(keyStroke, cut, al);
@@ -993,7 +997,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        delete_actionPerformed(e);
+        delete_actionPerformed();
       }
     });
 
@@ -1222,16 +1226,33 @@ public class GAlignFrame extends JInternalFrame
         vamsasStore_actionPerformed(e);
       }
     });
-    showTranslation
-            .setText(MessageManager.getString("label.translate_cDNA"));
-    showTranslation.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
+
+    /*
+     * Translate as cDNA with sub-menu of translation tables
+     */
+    showTranslation.setText(MessageManager
+            .getString("label.translate_cDNA"));
+    boolean first = true;
+    for (final GeneticCodeI table : GeneticCodes.getInstance()
+            .getCodeTables())
+    {
+      JMenuItem item = new JMenuItem(table.getId() + " " + table.getName());
+      showTranslation.add(item);
+      item.addActionListener(new ActionListener()
+      {
+        @Override
+        public void actionPerformed(ActionEvent e)
+        {
+          showTranslation_actionPerformed(table);
+        }
+      });
+      if (first)
       {
-        showTranslation_actionPerformed(e);
+        showTranslation.addSeparator();
       }
-    });
+      first = false;
+    }
+
     showReverse.setText(MessageManager.getString("label.reverse"));
     showReverse.addActionListener(new ActionListener()
     {
@@ -1280,7 +1301,7 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    JMenuItem openFeatureSettings = new JMenuItem(
+    openFeatureSettings = new JMenuItem(
             MessageManager.getString("action.feature_settings"));
     openFeatureSettings.addActionListener(new ActionListener()
     {
@@ -1290,6 +1311,10 @@ public class GAlignFrame extends JInternalFrame
         featureSettings_actionPerformed(e);
       }
     });
+
+    /*
+     * add sub-menu of database we can fetch from
+     */
     JMenuItem fetchSequence = new JMenuItem(
             MessageManager.getString("label.fetch_sequences"));
     fetchSequence.addActionListener(new ActionListener()
@@ -1297,7 +1322,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        fetchSequence_actionPerformed(e);
+        fetchSequence_actionPerformed();
       }
     });
 
@@ -1705,7 +1730,10 @@ public class GAlignFrame extends JInternalFrame
     alignFrameMenuBar.add(formatMenu);
     alignFrameMenuBar.add(colourMenu);
     alignFrameMenuBar.add(calculateMenu);
-    alignFrameMenuBar.add(webService);
+    if (!Platform.isJS())
+    {
+      alignFrameMenuBar.add(webService);
+    }
 
     fileMenu.add(fetchSequence);
     fileMenu.add(addSequenceMenu);
@@ -1723,7 +1751,10 @@ public class GAlignFrame extends JInternalFrame
     fileMenu.add(exportAnnotations);
     fileMenu.add(loadTreeMenuItem);
     fileMenu.add(associatedData);
-    fileMenu.add(loadVcf);
+    if (!Platform.isJS())
+    {
+      fileMenu.add(loadVcf);
+    }
     fileMenu.addSeparator();
     fileMenu.add(closeMenuItem);
 
@@ -1818,17 +1849,26 @@ public class GAlignFrame extends JInternalFrame
     calculateMenu.addSeparator();
     calculateMenu.add(expandAlignment);
     calculateMenu.add(extractScores);
-    calculateMenu.addSeparator();
-    calculateMenu.add(runGroovy);
+    if (!Platform.isJS())
+    {
+      calculateMenu.addSeparator();
+      calculateMenu.add(runGroovy);
+    }
 
     webServiceNoServices = new JMenuItem(
             MessageManager.getString("label.no_services"));
     webService.add(webServiceNoServices);
-    exportImageMenu.add(htmlMenuItem);
+    if (!Platform.isJS())
+    {
+      exportImageMenu.add(htmlMenuItem);
+    }
     exportImageMenu.add(epsFile);
     exportImageMenu.add(createPNG);
-    exportImageMenu.add(createBioJS);
-    exportImageMenu.add(createSVG);
+    if (!Platform.isJS())
+    {
+      exportImageMenu.add(createBioJS);
+      exportImageMenu.add(createSVG);
+    }
     addSequenceMenu.add(addFromFile);
     addSequenceMenu.add(addFromText);
     addSequenceMenu.add(addFromURL);
@@ -2166,7 +2206,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void outputText_actionPerformed(ActionEvent e)
+  protected void outputText_actionPerformed(String formatName)
   {
   }
 
@@ -2332,15 +2372,15 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void copy_actionPerformed(ActionEvent e)
+  protected void copy_actionPerformed()
   {
   }
 
-  protected void cut_actionPerformed(ActionEvent e)
+  protected void cut_actionPerformed()
   {
   }
 
-  protected void delete_actionPerformed(ActionEvent e)
+  protected void delete_actionPerformed()
   {
   }
 
@@ -2424,7 +2464,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void saveAs_actionPerformed(ActionEvent e)
+  protected void saveAs_actionPerformed()
   {
   }
 
@@ -2442,7 +2482,7 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void showTranslation_actionPerformed(ActionEvent e)
+  public void showTranslation_actionPerformed(GeneticCodeI codeTable)
   {
 
   }
@@ -2452,7 +2492,7 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void fetchSequence_actionPerformed(ActionEvent e)
+  public void fetchSequence_actionPerformed()
   {
 
   }