JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / gui / Preferences.java
index cd3b9e5..94f67f6 100755 (executable)
@@ -25,6 +25,7 @@ import jalview.bin.Cache;
 import jalview.gui.Help.HelpId;
 import jalview.gui.StructureViewer.ViewerType;
 import jalview.io.BackupFiles;
+import jalview.io.BackupFilesPresetEntry;
 import jalview.io.FileFormatI;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
@@ -190,6 +191,11 @@ public class Preferences extends GPreferences
     frame = new JInternalFrame();
     frame.setContentPane(this);
     if (!Platform.isJS())
+    /**
+     * Java only
+     * 
+     * @j2sIgnore
+     */
     {
       wsPrefs = new WsPreferences();
       wsTab.add(wsPrefs, BorderLayout.CENTER);
@@ -541,7 +547,10 @@ public class Preferences extends GPreferences
     /*
      * Set Backups tab defaults
      */
-    loadLastSavedBackupsOptions();
+    if (!Platform.isJS())
+    {
+      loadLastSavedBackupsOptions();
+    }
   }
 
   /**
@@ -834,22 +843,29 @@ public class Preferences extends GPreferences
     /*
      * 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)));
+            Platform.isJS() ? Boolean.FALSE.toString()
+                    : Boolean.toString(enableBackupFiles.isSelected()));
+    if (!Platform.isJS())
+    {
+      int preset = getComboIntStringKey(backupfilesPresetsCombo);
+      Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET",
+              Integer.toString(preset));
+
+      if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
+      {
+        BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
+        BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
+                BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
+        Cache.applicationProperties.setProperty(
+                BackupFilesPresetEntry.CUSTOMCONFIG, customBFPE.toString());
+      }
+
+      BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
+              .get(preset);
+      Cache.applicationProperties.setProperty(
+              BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
+    }
 
     Cache.saveProperties();
     Desktop.instance.doConfigureStructurePrefs();
@@ -1068,8 +1084,11 @@ public class Preferences extends GPreferences
   public void defaultBrowser_mouseClicked(MouseEvent e)
   {
     // TODO: JAL-3048 not needed for j2s
-    /*
-     * @j2sNative
+    if (!Platform.isJS()) // BH 2019
+    /**
+     * Java only
+     * 
+     * @j2sIgnore
      */
     {
       JFileChooser chooser = new JFileChooser(".");