Merge remote-tracking branch 'origin/features/JAL-2620alternativeCodeTables' into...
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index d5c8c01..0ee03bc 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;
@@ -137,7 +139,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();
 
@@ -1221,16 +1223,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()
     {
@@ -2440,7 +2459,7 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void showTranslation_actionPerformed(ActionEvent e)
+  public void showTranslation_actionPerformed(GeneticCodeI codeTable)
   {
 
   }