JAL-3364 more careful save/restore of preferences
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 30 Jul 2019 13:08:01 +0000 (14:08 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 30 Jul 2019 13:08:01 +0000 (14:08 +0100)
src/jalview/gui/AlignmentPanel.java

index b77f9db..cd31bed 100644 (file)
@@ -1211,8 +1211,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     * split frame with 'protein scaled to codons' and 'auto id width'
     */
 
-    final boolean autoIdWidth = Cache.getDefault("FIGURE_AUTOIDWIDTH",
-            false);
+    final String autoIdWidth = Cache.getProperty("FIGURE_AUTOIDWIDTH");
     final Integer fixedIdWidth = Cache
             .getIntegerProperty("FIGURE_FIXEDIDWIDTH");
 
@@ -1234,7 +1233,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
         complement = ((AlignViewport) av.getCodingComplement())
                 .getAlignPanel();
         dim2 = complement.getAlignmentDimension();
-        if (autoIdWidth && av.isScaleProteinAsCdna())
+        if (Boolean.valueOf(autoIdWidth) && av.isScaleProteinAsCdna())
         {
           int w1 = this.getVisibleIdWidth(false);
           int w2 = complement.getVisibleIdWidth(false);
@@ -1306,10 +1305,23 @@ public class AlignmentPanel extends GAlignmentPanel implements
       /*
        * restore preference settings in case they were fudged
        */
-      Cache.setProperty("FIGURE_AUTOIDWIDTH",
-              String.valueOf(autoIdWidth));
-      Cache.setProperty("FIGURE_FIXEDIDWIDTH",
-              String.valueOf(fixedIdWidth));
+      if (autoIdWidth == null)
+      {
+        Cache.removeProperty("FIGURE_AUTOIDWIDTH");
+      }
+      else
+      {
+        Cache.setProperty("FIGURE_AUTOIDWIDTH", autoIdWidth);
+      }
+      if (fixedIdWidth == null)
+      {
+        Cache.removeProperty("FIGURE_FIXEDIDWIDTH");
+      }
+      else
+      {
+        Cache.setProperty("FIGURE_FIXEDIDWIDTH",
+                String.valueOf(fixedIdWidth));
+      }
     }
   }