JAL-3485 constants for CDNA_CONSENSUS, STRUCTURE_CONSENSUS added
[jalview.git] / src / jalview / gui / Preferences.java
index 5aab26d..663390d 100755 (executable)
@@ -24,6 +24,7 @@ import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
 import jalview.gui.Help.HelpId;
 import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.BackupFiles;
 import jalview.io.FileFormatI;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
@@ -39,6 +40,7 @@ import jalview.urls.desktop.DesktopUrlProviderFactory;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.util.UrlConstants;
+import jalview.viewmodel.AlignmentViewport.AutoAnnotation;
 import jalview.ws.sifts.SiftsSettings;
 
 import java.awt.BorderLayout;
@@ -107,8 +109,6 @@ public class Preferences extends GPreferences
 
   public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
 
-  public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
-
   public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
 
   public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
@@ -168,8 +168,6 @@ public class Preferences extends GPreferences
 
   JInternalFrame frame;
 
-  DasSourceBrowser dasSource;
-
   private WsPreferences wsPrefs;
 
   private OptionsParam promptEachTimeOpt = new OptionsParam(
@@ -190,8 +188,6 @@ public class Preferences extends GPreferences
     super();
     frame = new JInternalFrame();
     frame.setContentPane(this);
-    dasSource = new DasSourceBrowser();
-    dasTab.add(dasSource, BorderLayout.CENTER);
     wsPrefs = new WsPreferences();
     wsTab.add(wsPrefs, BorderLayout.CENTER);
     int width = 500, height = 450;
@@ -214,13 +210,17 @@ public class Preferences extends GPreferences
     fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
     annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
 
-    conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
-    quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
-    identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
+    conservation.setSelected(Cache
+            .getDefault(AutoAnnotation.CONSERVATION.preferenceKey, true));
+    quality.setSelected(
+            Cache.getDefault(AutoAnnotation.QUALITY.preferenceKey, true));
+    identity.setSelected(
+            Cache.getDefault(AutoAnnotation.CONSENSUS.preferenceKey, true));
     openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
     showUnconserved
             .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
-    showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
+    showOccupancy.setSelected(Cache
+            .getDefault(AutoAnnotation.OCCUPANCY.preferenceKey, false));
     showGroupConsensus
             .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
     showGroupConservation.setSelected(
@@ -329,7 +329,7 @@ public class Preferences extends GPreferences
     gapLabel.setEnabled(!useLegacyGap.isSelected());
     gapColour.setEnabled(!useLegacyGap.isSelected());
     showHiddenAtStart
-            .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, true));
+            .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
 
     /*
      * Set Structure tab defaults.
@@ -550,6 +550,12 @@ public class Preferences extends GPreferences
 
     annotations_actionPerformed(null); // update the display of the annotation
                                        // settings
+    
+    
+    /*
+     * Set Backups tab defaults
+     */
+    loadLastSavedBackupsOptions();
   }
 
   /**
@@ -579,12 +585,18 @@ public class Preferences extends GPreferences
             Boolean.toString(openoverv.isSelected()));
     Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
             Boolean.toString(annotations.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
+    Cache.applicationProperties.setProperty(
+            AutoAnnotation.CONSERVATION.preferenceKey,
             Boolean.toString(conservation.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_QUALITY",
+    Cache.applicationProperties.setProperty(
+            AutoAnnotation.QUALITY.preferenceKey,
             Boolean.toString(quality.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+    Cache.applicationProperties.setProperty(
+            AutoAnnotation.CONSENSUS.preferenceKey,
             Boolean.toString(identity.isSelected()));
+    Cache.applicationProperties.setProperty(
+            AutoAnnotation.OCCUPANCY.preferenceKey,
+            Boolean.toString(showOccupancy.isSelected()));
 
     Cache.applicationProperties.setProperty("GAP_SYMBOL",
             gapSymbolCB.getSelectedItem().toString());
@@ -600,8 +612,6 @@ public class Preferences extends GPreferences
             Boolean.toString(idItalics.isSelected()));
     Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
             Boolean.toString(showUnconserved.isSelected()));
-    Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
-            Boolean.toString(showOccupancy.isSelected()));
     Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
             Boolean.toString(showGroupConsensus.isSelected()));
     Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
@@ -797,8 +807,28 @@ public class Preferences extends GPreferences
     Cache.applicationProperties.setProperty("PAD_GAPS",
             Boolean.toString(padGaps.isSelected()));
 
-    dasSource.saveProperties(Cache.applicationProperties);
     wsPrefs.updateAndRefreshWsMenuConfig(false);
+
+    /*
+     * Save Backups settings
+     */
+    Cache.applicationProperties.setProperty(BackupFiles.CONFIRM_DELETE_OLD,
+            Boolean.toString(backupfilesConfirmDelete.isSelected()));
+    Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
+            Boolean.toString(enableBackupFiles.isSelected()));
+    Cache.applicationProperties.setProperty(BackupFiles.NO_MAX,
+            Boolean.toString(backupfilesKeepAll.isSelected()));
+    Cache.applicationProperties.setProperty(BackupFiles.REVERSE_ORDER,
+            Boolean.toString(suffixReverse.isSelected()));
+    Cache.applicationProperties.setProperty(BackupFiles.SUFFIX,
+            suffixTemplate.getText());
+    Cache.applicationProperties.setProperty(BackupFiles.ROLL_MAX,
+            Integer.toString(getSpinnerInt(backupfilesRollMaxSpinner, 4)));
+    Cache.applicationProperties.setProperty(BackupFiles.SUFFIX_DIGITS,
+            Integer.toString(getSpinnerInt(suffixDigitsSpinner, 3)));
+    Cache.applicationProperties.setProperty(BackupFiles.NS+"_PRESET",
+            Integer.toString(getComboIntStringKey(backupfilesPresetsCombo)));
+
     Cache.saveProperties();
     Desktop.instance.doConfigureStructurePrefs();
     try
@@ -1121,7 +1151,7 @@ public class Preferences extends GPreferences
   {
     useLegacyGap.setSelected(false);
     useLegacyGaps_actionPerformed(null);
-    showHiddenAtStart.setSelected(true);
+    showHiddenAtStart.setSelected(false);
     hiddenColour.setBackground(
             jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
   }