JAL-3117 bring alignment to foreground on click on Overview
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 14 Dec 2020 02:43:46 +0000 (02:43 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 14 Dec 2020 02:43:46 +0000 (02:43 +0000)
src/jalview/gui/AlignFrame.java

index 5370437..4a18067 100644 (file)
@@ -46,6 +46,7 @@ import java.awt.event.MouseEvent;
 import java.awt.print.PageFormat;
 import java.awt.print.PrinterJob;
 import java.beans.PropertyChangeEvent;
+import java.beans.PropertyVetoException;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -3459,6 +3460,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       frame.addKeyListener(getKeyListeners()[0]);
     }
+    
+    /*
+     * bring alignment panel to front when Overview gets focus
+     * (even after New View / eXpand / Gather!)
+     */
+    final AlignmentPanel ap = alignPanel;
+    frame.addFocusListener(new FocusAdapter()
+    {
+      @Override
+      public void focusGained(FocusEvent e)
+      {
+        try
+        {
+          ap.alignFrame.setSelected(true);
+          ap.alignFrame.setIcon(false);
+          ap.alignFrame.setDisplayedView(ap);
+        } catch (PropertyVetoException e1)
+        {
+        }
+      }
+    });
 
     alignPanel.setOverviewPanel(overview);
   }