Merge branch 'releases/Release_2_11_4_Branch'
[jalview.git] / src / jalview / gui / Preferences.java
index 493deee..883d270 100755 (executable)
@@ -156,6 +156,9 @@ public class Preferences extends GPreferences
   public static List<String> groupURLLinks;
   static
   {
+    // don't populate with session properties
+    Cache.disableSessionProperties();
+
     // get links selected to be in the menu (SEQUENCE_LINKS)
     // and links entered by the user but not selected (STORED_LINKS)
     String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
@@ -180,6 +183,9 @@ public class Preferences extends GPreferences
      */
 
     groupURLLinks = new ArrayList<>();
+
+    // reenable
+    Cache.enableSessionProperties();
   }
 
   JInternalFrame frame;
@@ -188,7 +194,7 @@ public class Preferences extends GPreferences
 
   private OptionsParam promptEachTimeOpt = new OptionsParam(
           MessageManager.getString("label.prompt_each_time"),
-          "Prompt each time");
+          LineartOptions.PROMPT_EACH_TIME);
 
   private OptionsParam lineArtOpt = new OptionsParam(
           MessageManager.getString("label.lineart"), "Lineart");
@@ -248,6 +254,9 @@ public class Preferences extends GPreferences
   private Preferences()
   {
     super();
+    // don't populate with session properties
+    Cache.disableSessionProperties();
+
     frame = new JInternalFrame();
     frame.setFrameIcon(null);
     frame.setContentPane(this);
@@ -283,6 +292,7 @@ public class Preferences extends GPreferences
     conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
     quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
     identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
+    ssConsensus.setSelected(Cache.getDefault("SHOW_SS_CONSENSUS", false));
     openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
     showUnconserved
             .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
@@ -689,6 +699,8 @@ public class Preferences extends GPreferences
      * Set Startup tab defaults
      */
 
+    // re-enable
+    Cache.enableSessionProperties();
   }
 
   /**
@@ -701,6 +713,8 @@ public class Preferences extends GPreferences
   protected void setupOutputCombo(JComboBox<Object> comboBox,
           String propertyKey)
   {
+    Cache.disableSessionProperties();
+
     comboBox.addItem(promptEachTimeOpt);
     comboBox.addItem(lineArtOpt);
     comboBox.addItem(textOpt);
@@ -722,6 +736,8 @@ public class Preferences extends GPreferences
     {
       comboBox.setSelectedItem(promptEachTimeOpt);
     }
+
+    Cache.enableSessionProperties();
   }
 
   /**
@@ -733,6 +749,8 @@ public class Preferences extends GPreferences
   @Override
   public void ok_actionPerformed(ActionEvent e)
   {
+    Cache.disableSessionProperties();
+
     if (!validateSettings())
     {
       return;
@@ -746,6 +764,7 @@ public class Preferences extends GPreferences
     /*
      * Save Visual settings
      */
+
     Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
             Boolean.toString(seqLimit.isSelected()));
     Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
@@ -763,6 +782,9 @@ public class Preferences extends GPreferences
     Cache.applicationProperties.setProperty("SHOW_IDENTITY",
             Boolean.toString(identity.isSelected()));
 
+    Cache.applicationProperties.setProperty("SHOW_SS_CONSENSUS",
+            Boolean.toString(ssConsensus.isSelected()));
+
     Cache.applicationProperties.setProperty("GAP_SYMBOL",
             gapSymbolCB.getSelectedItem().toString());
 
@@ -1020,10 +1042,14 @@ public class Preferences extends GPreferences
     } catch (Exception ex)
     {
     }
+
+    Cache.enableSessionProperties();
   }
 
   public void saveProxySettings()
   {
+    Cache.disableSessionProperties();
+
     String newProxyType = customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
             : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
                     : Cache.PROXYTYPE_SYSTEM;
@@ -1044,6 +1070,8 @@ public class Preferences extends GPreferences
       wsPrefs.update++;
     }
     previousProxyType = newProxyType;
+
+    Cache.enableSessionProperties();
   }
 
   /**
@@ -1075,10 +1103,12 @@ public class Preferences extends GPreferences
   @Override
   public void startupFileTextfield_mouseClicked()
   {
+    Cache.disableSessionProperties();
+
     // TODO: JAL-3048 not needed for Jalview-JS
-    String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
+    // default file format now determined by JalviewFileChooser
     JalviewFileChooser chooser = JalviewFileChooser
-            .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
+            .forRead(Cache.getProperty("LAST_DIRECTORY"), null);
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(
             MessageManager.getString("label.select_startup_file"));
@@ -1096,6 +1126,8 @@ public class Preferences extends GPreferences
       startupFileTextfield
               .setText(chooser.getSelectedFile().getAbsolutePath());
     }
+
+    Cache.enableSessionProperties();
   }
 
   /**
@@ -1132,6 +1164,7 @@ public class Preferences extends GPreferences
     conservation.setEnabled(annotations.isSelected());
     quality.setEnabled(annotations.isSelected());
     identity.setEnabled(annotations.isSelected());
+    ssConsensus.setEnabled(annotations.isSelected());
     showOccupancy.setEnabled(annotations.isSelected());
     showGroupConsensus.setEnabled(annotations.isSelected());
     showGroupConservation.setEnabled(annotations.isSelected());
@@ -1405,6 +1438,7 @@ public class Preferences extends GPreferences
      */
     String viewerPath = "";
     List<String> paths = null;
+    Cache.disableSessionProperties();
     try
     {
       ViewerType viewerType = ViewerType.valueOf(selectedItem);
@@ -1430,6 +1464,7 @@ public class Preferences extends GPreferences
     {
       // only valid entries should be in the drop-down
     }
+    Cache.enableSessionProperties();
     structureViewerPath.setText(viewerPath);
 
     paths.add(0, structureViewerPath.getText());