JAL-2650 configure new viewport settings before selecting view tab
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 8 Aug 2017 09:08:46 +0000 (11:08 +0200)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 8 Aug 2017 09:08:46 +0000 (11:08 +0200)
src/jalview/gui/Jalview2XML.java
src/jalview/gui/SliderPanel.java
test/jalview/gui/AlignFrameTest.java

index 45988fb..d472ef8 100644 (file)
@@ -4423,13 +4423,6 @@ public class Jalview2XML
 
     }
     // recover view properties and display parameters
-    if (view.getViewName() != null)
-    {
-      af.viewport.viewName = view.getViewName();
-      af.setInitialTabVisible();
-    }
-    af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),
-            view.getHeight());
 
     af.viewport.setShowAnnotation(view.getShowAnnotation());
     af.viewport.setAbovePIDThreshold(view.getPidSelected());
@@ -4463,6 +4456,14 @@ public class Jalview2XML
     af.viewport.setShowUnconserved(view.hasShowUnconserved() ? view
             .isShowUnconserved() : false);
     af.viewport.getRanges().setStartRes(view.getStartRes());
+
+    if (view.getViewName() != null)
+    {
+      af.viewport.viewName = view.getViewName();
+      af.setInitialTabVisible();
+    }
+    af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),
+            view.getHeight());
     // startSeq set in af.alignPanel.updateLayout below
     af.alignPanel.updateLayout();
     ColourSchemeI cs = null;
index ec53e93..2176719 100755 (executable)
@@ -365,7 +365,7 @@ public class SliderPanel extends GSliderPanel
     }
     if (forConservation)
     {
-      if (!scheme.conservationApplied())
+      if (!scheme.conservationApplied() && sg != null)
       {
         /*
          * first time the colour scheme has had Conservation shading applied
index 67098ae..1d8b240 100644 (file)
@@ -26,6 +26,7 @@ import static org.testng.Assert.assertNotSame;
 import static org.testng.Assert.assertSame;
 import static org.testng.Assert.assertTrue;
 
+import jalview.api.AlignCalcManagerI;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.datamodel.Alignment;
@@ -538,16 +539,28 @@ public class AlignFrameTest
             new String[] { "Background" }));
 
     /*
-     * make a new View, verify alignment and group colour schemes
+     * make a new View, wait for Conservation thread to complete,
+     * verify alignment and group colour schemes
      */
     af.newView_actionPerformed(null);
     assertEquals(af.alignPanel.getViewName(), "View 1");
     AlignViewport av2 = af.getViewport();
     assertNotSame(av, av2);
+    assertSame(av2, af.alignPanel.av);
+    AlignCalcManagerI calcManager = av2.getCalcManager();
+    do
+    {
+      try
+      {
+        Thread.sleep(50);
+      } catch (InterruptedException x)
+      {
+      }
+    } while (calcManager.isWorking());
     rs = av2.getResidueShading();
     assertNotSame(av.getResidueShading(), rs);
     assertEquals(rs.getThreshold(), 10);
-    assertTrue(rs.conservationApplied());
+    assertTrue(rs.conservationApplied(), rs.toString());
     assertEquals(rs.getConservationInc(), 20);
     assertEquals(av2.getAlignment().getGroups().size(), 1);
     sg = av2.getAlignment().getGroups().get(0);