Merge branch 'develop' into trialMerge
[jalview.git] / src / jalview / gui / Preferences.java
index 6271ba9..284d3af 100755 (executable)
@@ -22,9 +22,9 @@ package jalview.gui;
 
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
-import jalview.bin.Jalview;
 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;
@@ -189,13 +189,13 @@ public class Preferences extends GPreferences
     super();
     frame = new JInternalFrame();
     frame.setContentPane(this);
-    if (!Jalview.isJS())
+    if (!Platform.isJS())
     {
       wsPrefs = new WsPreferences();
       wsTab.add(wsPrefs, BorderLayout.CENTER);
     }
     int width = 500, height = 450;
-    if (Platform.isAMac())
+    if (Platform.isAMacAndNotJS())
     {
       width = 570;
       height = 480;
@@ -536,6 +536,12 @@ public class Preferences extends GPreferences
 
     annotations_actionPerformed(null); // update the display of the annotation
                                        // settings
+    
+    
+    /*
+     * Set Backups tab defaults
+     */
+    loadLastSavedBackupsOptions();
   }
 
   /**
@@ -551,8 +557,12 @@ public class Preferences extends GPreferences
     comboBox.addItem(promptEachTimeOpt);
     comboBox.addItem(lineArtOpt);
     comboBox.addItem(textOpt);
-    String defaultOption = Cache.getDefault(propertyKey,
-            "Prompt each time");
+    
+    /*
+     * JalviewJS doesn't support Lineart so force it to Text
+     */
+    String defaultOption = Platform.isJS() ? "Text"
+            : Cache.getDefault(propertyKey, "Prompt each time");
     if (defaultOption.equalsIgnoreCase("Text"))
     {
       comboBox.setSelectedItem(textOpt);
@@ -816,10 +826,31 @@ public class Preferences extends GPreferences
     Cache.applicationProperties.setProperty("PAD_GAPS",
             Boolean.toString(padGaps.isSelected()));
 
-    if (!Jalview.isJS())
+    if (!Platform.isJS())
     {
       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
@@ -893,7 +924,7 @@ public class Preferences extends GPreferences
   {
     try
     {
-      if (!Jalview.isJS())
+      if (!Platform.isJS())
       {
         wsPrefs.updateWsMenuConfig(true);
         wsPrefs.refreshWs_actionPerformed(e);