Merge branch 'develop' into features/JAL-518_justify_seqs_in_region
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index 71b6b9e..9b9a44a 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;
-
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.GridLayout;
@@ -61,6 +49,18 @@ import javax.swing.event.ChangeEvent;
 import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
 
+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;
+
 @SuppressWarnings("serial")
 public class GAlignFrame extends JInternalFrame
 {
@@ -104,6 +104,8 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem copy = new JMenuItem();
 
+  JMenuItem copyHighlighted = new JMenuItem();
+
   JMenuItem cut = new JMenuItem();
 
   JMenu pasteMenu = new JMenu();
@@ -218,6 +220,7 @@ public class GAlignFrame extends JInternalFrame
   {
     try
     {
+      setFrameIcon(null);
 
       // for Web-page embedding using id=align-frame-div
       setName("jalview-alignment");
@@ -243,7 +246,7 @@ public class GAlignFrame extends JInternalFrame
       }
     } catch (Exception e)
     {
-      System.err.println(e.toString());
+      jalview.bin.Console.errPrintln(e.toString());
     }
 
     if (Platform.allowMnemonics()) // was "not mac and not JS"
@@ -261,6 +264,7 @@ public class GAlignFrame extends JInternalFrame
 
   private void jbInit() throws Exception
   {
+    setFrameIcon(null);
     initColourMenu();
 
     JMenuItem saveAs = new JMenuItem(
@@ -437,7 +441,9 @@ public class GAlignFrame extends JInternalFrame
     addMenuActionAndAccelerator(keyStroke, removeAllGapsMenuItem, al);
 
     JMenuItem justifyLeftMenuItem = new JMenuItem(
-            MessageManager.getString("action.left_justify_alignment"));
+            MessageManager.getString("action.left_justify"));
+    justifyLeftMenuItem.setToolTipText(
+            MessageManager.getString("tooltip.left_justify"));
     justifyLeftMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -447,7 +453,10 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     JMenuItem justifyRightMenuItem = new JMenuItem(
-            MessageManager.getString("action.right_justify_alignment"));
+            MessageManager.getString("action.right_justify"));
+    justifyRightMenuItem.setToolTipText(
+            MessageManager.getString("action.left_justify"));
+
     justifyRightMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -1078,7 +1087,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        createPNG(null);
+        createPNG_actionPerformed(e);
       }
     });
     createPNG.setActionCommand(
@@ -1110,7 +1119,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        createEPS(null);
+        createEPS_actionPerformed(e);
       }
     });
 
@@ -1120,7 +1129,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        createSVG(null);
+        createSVG_actionPerformed(e);
       }
     });
 
@@ -1756,6 +1765,26 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     selectHighlighted.addActionListener(al);
+
+    copyHighlighted = new JMenuItem(
+            MessageManager.getString("action.copy_highlighted_regions"));
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_C,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+                    + jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
+            false);
+    copyHighlighted.setToolTipText(
+            MessageManager.getString("tooltip.copy_highlighted_regions"));
+    al = new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        copyHighlightedColumns_actionPerformed(actionEvent);
+      }
+    };
+    addMenuActionAndAccelerator(keyStroke, copyHighlighted, al);
+    copyHighlighted.addActionListener(al);
+
     JMenu tooltipSettingsMenu = new JMenu(
             MessageManager.getString("label.sequence_id_tooltip"));
     JMenu autoAnnMenu = new JMenu(
@@ -1806,6 +1835,7 @@ public class GAlignFrame extends JInternalFrame
     editMenu.add(redoMenuItem);
     editMenu.add(cut);
     editMenu.add(copy);
+    editMenu.add(copyHighlighted);
     editMenu.add(pasteMenu);
     editMenu.add(delete);
     editMenu.addSeparator();
@@ -1815,11 +1845,11 @@ public class GAlignFrame extends JInternalFrame
     editMenu.add(removeAllGapsMenuItem);
     editMenu.add(removeRedundancyMenuItem);
     editMenu.addSeparator();
-    // dont add these yet in the CVS build - they cannot be undone!
-    // Excluded from Jalview 2.5 release - undo needs to be implemented.
-    // editMenu.add(justifyLeftMenuItem);
-    // editMenu.add(justifyRightMenuItem);
-    // editMenu.addSeparator();
+
+    editMenu.add(justifyLeftMenuItem);
+    editMenu.add(justifyRightMenuItem);
+
+    editMenu.addSeparator();
     editMenu.add(padGapsMenuitem);
 
     showMenu.add(showAllColumns);
@@ -1951,6 +1981,30 @@ public class GAlignFrame extends JInternalFrame
     // selectMenu.add(listenToViewSelections);
   }
 
+  protected void createPNG_actionPerformed(ActionEvent object)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void createEPS_actionPerformed(ActionEvent object)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void createSVG_actionPerformed(ActionEvent object)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void copyHighlightedColumns_actionPerformed(
+          ActionEvent actionEvent)
+  {
+
+  }
+
   protected void loadVcf_actionPerformed()
   {
   }
@@ -2128,7 +2182,7 @@ public class GAlignFrame extends JInternalFrame
    * @param forAlignment
    *          update non-sequence-related annotations
    */
-  protected void setAnnotationsVisibility(boolean visible,
+  public void setAnnotationsVisibility(boolean visible,
           boolean forSequences, boolean forAlignment)
   {
 
@@ -2438,10 +2492,6 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  public void createPNG(java.io.File f)
-  {
-  }
-
   protected void font_actionPerformed(ActionEvent e)
   {
   }
@@ -2455,15 +2505,6 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void createEPS(java.io.File f)
-  {
-  }
-
-  public void createSVG(java.io.File f)
-  {
-
-  }
-
   protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
   {