Merge branch 'feature/JAL-3127_seqidChainshading' into merge/JAL-3127
[jalview.git] / src / jalview / gui / Preferences.java
index 7ceb04e..ad3bfb5 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;
@@ -121,13 +122,6 @@ public class Preferences extends GPreferences
 
   private static final int MAX_FONT_SIZE = 30;
 
-  public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray;
-
-  public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white;
-
-  public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
-          .darker();
-
   /**
    * Holds name and link separated with | character. Sequence ID must be
    * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
@@ -175,8 +169,6 @@ public class Preferences extends GPreferences
 
   JInternalFrame frame;
 
-  DasSourceBrowser dasSource;
-
   private WsPreferences wsPrefs;
 
   private OptionsParam promptEachTimeOpt = new OptionsParam(
@@ -197,8 +189,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;
@@ -327,10 +317,11 @@ public class Preferences extends GPreferences
      * Set overview panel defaults
      */
     gapColour.setBackground(
-            Cache.getDefaultColour(GAP_COLOUR, OVERVIEW_DEFAULT_GAP));
+            Cache.getDefaultColour(GAP_COLOUR,
+                    jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
     hiddenColour.setBackground(
             Cache.getDefaultColour(HIDDEN_COLOUR,
-                    OVERVIEW_DEFAULT_HIDDEN));
+                    jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
     useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
     gapLabel.setEnabled(!useLegacyGap.isSelected());
     gapColour.setEnabled(!useLegacyGap.isSelected());
@@ -531,8 +522,10 @@ public class Preferences extends GPreferences
     autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
     userIdWidth.setEnabled(!autoIdWidth.isSelected());
     userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
-    Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
+    Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
     userIdWidth.setText(wi == null ? "" : wi.toString());
+    // TODO: refactor to use common enum via FormatAdapter and allow extension
+    // for new flat file formats
     blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
     clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
     fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
@@ -554,6 +547,12 @@ public class Preferences extends GPreferences
 
     annotations_actionPerformed(null); // update the display of the annotation
                                        // settings
+    
+    
+    /*
+     * Set Backups tab defaults
+     */
+    loadLastSavedBackupsOptions();
   }
 
   /**
@@ -788,7 +787,7 @@ public class Preferences extends GPreferences
     Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
             Boolean.toString(autoIdWidth.isSelected()));
     userIdWidth_actionPerformed();
-    Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
+    Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
             userIdWidth.getText());
 
     /*
@@ -801,8 +800,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
@@ -1108,11 +1127,13 @@ public class Preferences extends GPreferences
     boolean enabled = useLegacyGap.isSelected();
     if (enabled)
     {
-      gapColour.setBackground(OVERVIEW_DEFAULT_LEGACY_GAP);
+      gapColour.setBackground(
+              jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
     }
     else
     {
-      gapColour.setBackground(OVERVIEW_DEFAULT_GAP);
+      gapColour.setBackground(
+              jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
     }
     gapColour.setEnabled(!enabled);
     gapLabel.setEnabled(!enabled);
@@ -1124,7 +1145,8 @@ public class Preferences extends GPreferences
     useLegacyGap.setSelected(false);
     useLegacyGaps_actionPerformed(null);
     showHiddenAtStart.setSelected(true);
-    hiddenColour.setBackground(OVERVIEW_DEFAULT_HIDDEN);
+    hiddenColour.setBackground(
+            jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
   }
 
   @Override