JAL-3785 set full title on automatically opened Overview windows
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 11 Dec 2020 21:04:42 +0000 (21:04 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 11 Dec 2020 21:04:42 +0000 (21:04 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/io/FileLoader.java

index 6916a55..eed9846 100644 (file)
@@ -2853,6 +2853,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       viewport.setGatherViewsHere(true);
     }
     tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
+
+    /*
+     * finally if new view has acquired an Overview window (because
+     * Preferences option to open Overview is selected), set its title
+     */
+    OverviewPanel ov = newap.overviewPanel;
+    if (ov != null)
+    {
+      String ttl = getOverviewTitle();
+      ((JInternalFrame) SwingUtilities
+              .getAncestorOfClass(JInternalFrame.class, ov))
+                      .setTitle(ttl);
+    }
+
     return newap;
   }
 
@@ -3389,14 +3403,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     JInternalFrame frame = new JInternalFrame();
     final OverviewPanel overview = new OverviewPanel(alignPanel, showHidden);
     frame.setContentPane(overview);
-    String overviewTitle = MessageManager
-            .formatMessage("label.overview_params", new Object[]
-            { this.getTitle() });
-    String viewName = alignPanel.getViewName();
-    if (viewName != null)
-    {
-      overviewTitle += (" " + viewName);
-    }
+    String overviewTitle = getOverviewTitle();
     Desktop.addInternalFrame(frame, overviewTitle, true, frame.getWidth(), frame.getHeight(),
             true, true);
     frame.pack();
@@ -3423,6 +3430,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     return overview;
   }
 
+  /**
+   * Constructs a title for the Overview window including the alignment window's
+   * title, and view name (if applicable)
+   * 
+   * @return
+   */
+  public String getOverviewTitle()
+  {
+    String overviewTitle = MessageManager
+            .formatMessage("label.overview_params", new Object[]
+            { this.getTitle() });
+    String viewName = alignPanel.getViewName();
+    if (viewName != null)
+    {
+      overviewTitle += (" " + viewName);
+    }
+    return overviewTitle;
+  }
+
   @Override
   public void textColour_actionPerformed()
   {
index 3aa433e..78ef1ad 100755 (executable)
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import javax.swing.JInternalFrame;
 import javax.swing.SwingUtilities;
 
 import jalview.api.ComplexAlignFile;
@@ -41,6 +42,7 @@ import jalview.gui.AlignFrame;
 import jalview.gui.AlignViewport;
 import jalview.gui.Desktop;
 import jalview.gui.JvOptionPane;
+import jalview.gui.OverviewPanel;
 import jalview.json.binding.biojson.v1.ColourSchemeMapper;
 import jalview.project.Jalview2XML;
 import jalview.schemes.ColourSchemeI;
@@ -482,6 +484,20 @@ public class FileLoader implements Runnable
               // that perform queries to find the 'current working alignment'
               Desktop.addInternalFrame(alignFrame, title,
                       AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+              
+              OverviewPanel ov = alignFrame.alignPanel.getOverviewPanel();
+              if (ov != null)
+              {
+                /*
+                 * Overview automatically opened with alignment
+                 * - set its title now alignFrame title has been set
+                 */
+                String ttl = alignFrame.getOverviewTitle();
+                ((JInternalFrame) SwingUtilities
+                        .getAncestorOfClass(JInternalFrame.class, ov))
+                                .setTitle(ttl);
+              }
+
             }
 
             try