Merge branch 'develop' into trialMerge
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index 2e6aab8..18731ad 100755 (executable)
 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;
 import jalview.gui.Preferences;
 import jalview.io.FileFormats;
+import jalview.schemes.ResidueColourScheme;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 
@@ -75,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();
 
@@ -123,7 +126,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem modifyPID;
 
-  protected JMenuItem annotationColour;
+  protected JRadioButtonMenuItem annotationColour;
 
   protected JMenu sortByTreeMenu = new JMenu();
 
@@ -137,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();
 
@@ -203,7 +206,7 @@ public class GAlignFrame extends JInternalFrame
 
   private boolean showAutoCalculatedAbove = false;
 
-  private Map<KeyStroke, JMenuItem> accelerators = new HashMap<KeyStroke, JMenuItem>();
+  private Map<KeyStroke, JMenuItem> accelerators = new HashMap<>();
 
   private SplitContainerI splitFrame;
 
@@ -969,7 +972,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        copy_actionPerformed(e);
+        copy_actionPerformed();
       }
     };
     addMenuActionAndAccelerator(keyStroke, copy, al);
@@ -982,7 +985,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        cut_actionPerformed(e);
+        cut_actionPerformed();
       }
     };
     addMenuActionAndAccelerator(keyStroke, cut, al);
@@ -994,7 +997,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        delete_actionPerformed(e);
+        delete_actionPerformed();
       }
     });
 
@@ -1223,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()
     {
@@ -1844,9 +1864,9 @@ public class GAlignFrame extends JInternalFrame
     }
     exportImageMenu.add(epsFile);
     exportImageMenu.add(createPNG);
-    exportImageMenu.add(createBioJS);
     if (!Platform.isJS())
     {
+      exportImageMenu.add(createBioJS);
       exportImageMenu.add(createSVG);
     }
     addSequenceMenu.add(addFromFile);
@@ -1964,8 +1984,9 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    annotationColour = new JMenuItem(
+    annotationColour = new JRadioButtonMenuItem(
             MessageManager.getString("action.by_annotation"));
+    annotationColour.setName(ResidueColourScheme.ANNOTATION_COLOUR);
     annotationColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2351,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()
   {
   }
 
@@ -2461,7 +2482,7 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void showTranslation_actionPerformed(ActionEvent e)
+  public void showTranslation_actionPerformed(GeneticCodeI codeTable)
   {
 
   }