From: gmungoc Date: Fri, 11 Dec 2020 21:04:42 +0000 (+0000) Subject: JAL-3785 set full title on automatically opened Overview windows X-Git-Tag: Release_2_11_3_0~18^2~20^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=aaaf192e6f685c0917c217d011a077ca1883b2fd;p=jalview.git JAL-3785 set full title on automatically opened Overview windows --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 6916a55..eed9846 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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() { diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 3aa433e..78ef1ad 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -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