JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / gui / Preferences.java
index cc2961f..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;
@@ -546,7 +547,10 @@ public class Preferences extends GPreferences
     /*
      * Set Backups tab defaults
      */
-    loadLastSavedBackupsOptions();
+    if (!Platform.isJS())
+    {
+      loadLastSavedBackupsOptions();
+    }
   }
 
   /**
@@ -839,25 +843,32 @@ 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.getInstance().doConfigureStructurePrefs();
+    Desktop.instance.doConfigureStructurePrefs();
     try
     {
       frame.setClosed(true);
@@ -968,7 +979,7 @@ public class Preferences extends GPreferences
     boolean valid = false;
     while (!valid)
     {
-      if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
+      if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
               MessageManager.getString("label.new_sequence_url_link"),
               JvOptionPane.OK_CANCEL_OPTION, -1,
               null) == JvOptionPane.OK_OPTION)
@@ -1020,7 +1031,7 @@ public class Preferences extends GPreferences
     boolean valid = false;
     while (!valid)
     {
-      if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
+      if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
               MessageManager.getString("label.edit_sequence_url_link"),
               JvOptionPane.OK_CANCEL_OPTION, -1,
               null) == JvOptionPane.OK_OPTION)
@@ -1193,7 +1204,7 @@ public class Preferences extends GPreferences
     } catch (NumberFormatException x)
     {
       userIdWidth.setText("");
-      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
+      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
               MessageManager
                       .getString("warn.user_defined_width_requirements"),
               MessageManager.getString("label.invalid_id_column_width"),
@@ -1219,7 +1230,7 @@ public class Preferences extends GPreferences
       File f = new File(chimeraPath.getText());
       if (!f.canExecute())
       {
-        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
+        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                 MessageManager.getString("label.invalid_chimera_path"),
                 MessageManager.getString("label.invalid_name"),
                 JvOptionPane.ERROR_MESSAGE);
@@ -1258,7 +1269,7 @@ public class Preferences extends GPreferences
     if (!found)
     {
       String[] options = { "OK", "Help" };
-      int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.getDesktopPane(),
+      int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
               JvSwingUtils.wrapTooltip(true,
                       MessageManager.getString("label.chimera_missing")),
               "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,