JAL-845 further code/tests/refactoring
[jalview.git] / src / jalview / gui / AlignViewport.java
index 5a9fa6b..676d180 100644 (file)
@@ -59,6 +59,7 @@ import jalview.structure.SelectionSource;
 import jalview.structure.StructureSelectionManager;
 import jalview.structure.VamsasSource;
 import jalview.util.MessageManager;
+import jalview.util.StringUtils;
 import jalview.viewmodel.AlignmentViewport;
 import jalview.ws.params.AutoCalcSetting;
 
@@ -1146,7 +1147,6 @@ public class AlignViewport extends AlignmentViewport implements
   {
     AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
             .getSequenceSetId());
-    AlignmentPanel ap = null;
     for (int p = 0; aps != null && p < aps.length; p++)
     {
       if (aps[p].av == this)
@@ -1498,6 +1498,7 @@ public class AlignViewport extends AlignmentViewport implements
      */
     AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
             AlignFrame.DEFAULT_HEIGHT);
+    newAlignFrame.setTitle(title);
 
     /*
      * Identify protein and dna alignments. Make a copy of this one if opening
@@ -1570,27 +1571,35 @@ public class AlignViewport extends AlignmentViewport implements
        */
       AlignFrame copyMe = new AlignFrame(thisAlignment,
               AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
-      copyMe.setTitle(""); // TODO would like this AlignFrame.title here
+      copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
       final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
               : newAlignFrame;
       final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame
               : copyMe;
-      newAlignFrame.setTitle(title);
 
       cdnaFrame.setVisible(true);
       proteinFrame.setVisible(true);
+      String proteinShortName = StringUtils.getLastToken(
+              proteinFrame.getTitle(), "/");
+      String dnaShortName = StringUtils.getLastToken(cdnaFrame.getTitle(),
+              "/");
+      String linkedTitle = MessageManager.formatMessage(
+              "label.linked_view_title", dnaShortName, proteinShortName);
       JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
-      Desktop.addInternalFrame(splitFrame, title, AlignFrame.DEFAULT_WIDTH,
+      Desktop.addInternalFrame(splitFrame, linkedTitle,
+              AlignFrame.DEFAULT_WIDTH,
               AlignFrame.DEFAULT_HEIGHT);
 
       /*
-       * Set the frames to list for each other's edit and sort commands.
+       * Set the frames to listen for each other's edit and sort commands.
        */
       ssm.addCommandListener(cdnaFrame.getViewport());
       ssm.addCommandListener(proteinFrame.getViewport());
 
       /*
-       * cDNA view will mirror edits, selection, sorting, show/hide on protein
+       * 'Coding complement' (dna/protein) views will mirror each others' edits,
+       * selections, sorting etc as decided from time to time by the relevant
+       * authorities.
        */
       proteinFrame.getViewport().setCodingComplement(cdnaFrame.getViewport());
     }