JAL-1713 don’t close an automatically created overview window for projects from Jalvi...
authorJames Procter <j.procter@dundee.ac.uk>
Thu, 16 Feb 2023 12:25:41 +0000 (12:25 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Thu, 16 Feb 2023 12:25:41 +0000 (12:25 +0000)
src/jalview/project/Jalview2XML.java
test/jalview/project/Jalview2xmlTests.java

index 4d35021..8d2efe0 100644 (file)
@@ -1510,7 +1510,7 @@ public class Jalview2XML
                 ov.getCanvas().getResidueColour().getRGB());
         overview.setHiddenColour(ov.getCanvas().getHiddenColour().getRGB());
         view.setOverview(overview);
-      }
+      } 
       if (av.getGlobalColourScheme() instanceof jalview.schemes.UserColourScheme)
       {
         view.setBgColour(setUserColourScheme(av.getGlobalColourScheme(),
@@ -4122,7 +4122,7 @@ public class Jalview2XML
       loadPCAViewers(jalviewModel, ap);
       loadPDBStructures(jprovider, jseqs, af, ap);
       loadRnaViewers(jprovider, jseqs, ap);
-      loadOverview(view, af);
+      loadOverview(view, jalviewModel.getVersion(), af);
     }
     // and finally return.
     return af;
@@ -4135,8 +4135,13 @@ public class Jalview2XML
    * @param view
    * @param af
    */
-  protected void loadOverview(Viewport view, AlignFrame af)
+  protected void loadOverview(Viewport view, String version, AlignFrame af)
   {
+    if (!isVersionStringLaterThan("2.11.3",
+            version) && view.getOverview()==null)
+    {
+      return;
+    }
     /*
      * first close any Overview that was opened automatically
      * (if so configured in Preferences) so that the view is
@@ -4676,7 +4681,7 @@ public class Jalview2XML
    *          - minimum version we are comparing against
    * @param version
    *          - version of data being processsed
-   * @return
+   * @return true if version is equal to or later than supported
    */
   public static boolean isVersionStringLaterThan(String supported,
           String version)
index cd8a4b0..c070edb 100644 (file)
@@ -593,6 +593,14 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3"));
     assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.2b1"));
     assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.0b2", "2.8.0b1"));
+    /*
+     * test for patch release versions
+     */
+    assertFalse(Jalview2XML.isVersionStringLaterThan("2.11.3.0", "2.11.2"));
+    assertTrue(Jalview2XML.isVersionStringLaterThan("2.11.3.0","2.11.4"));
+    assertFalse(Jalview2XML.isVersionStringLaterThan("2.12.2.0b1","2.12.2.0"));
+    assertFalse(Jalview2XML.isVersionStringLaterThan("2.12.2.3","2.12.2.2"));
+
   }
 
   /**
@@ -1479,6 +1487,23 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   }
 
   /**
+   * Test that a view from an older version of Jalview is restored with Overview automatically shown when the preference is set
+   * 
+   * @throws Exception
+   */
+  @Test(groups = { "Functional" }, enabled = true)
+  public void testAutoShowOverviewForLegacyProjects() throws Exception
+  {
+    Desktop.instance.closeAll_actionPerformed(null);
+    Cache.setProperty("SHOW_OVERVIEW", "true");
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+            "examples/exampleFile.jvp", DataSourceType.FILE);
+
+    Cache.setProperty("SHOW_OVERVIEW", "false");
+    assertNotNull(af.alignPanel.getOverviewPanel());
+  }
+
+  /**
    * Test that loading example.jvp, doing some stuff, then hitting reload
    * doesn't leave the modified window still open
    *