JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / gui / Preferences.java
index 6a558d5..94f67f6 100755 (executable)
@@ -22,9 +22,10 @@ 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.BackupFilesPresetEntry;
 import jalview.io.FileFormatI;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
@@ -189,7 +190,12 @@ public class Preferences extends GPreferences
     super();
     frame = new JInternalFrame();
     frame.setContentPane(this);
-    if (!Jalview.isJS())
+    if (!Platform.isJS())
+    /**
+     * Java only
+     * 
+     * @j2sIgnore
+     */
     {
       wsPrefs = new WsPreferences();
       wsTab.add(wsPrefs, BorderLayout.CENTER);
@@ -328,7 +334,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.
@@ -536,6 +542,15 @@ public class Preferences extends GPreferences
 
     annotations_actionPerformed(null); // update the display of the annotation
                                        // settings
+    
+    
+    /*
+     * Set Backups tab defaults
+     */
+    if (!Platform.isJS())
+    {
+      loadLastSavedBackupsOptions();
+    }
   }
 
   /**
@@ -555,7 +570,7 @@ public class Preferences extends GPreferences
     /*
      * JalviewJS doesn't support Lineart so force it to Text
      */
-    String defaultOption = Jalview.isJS() ? "Text"
+    String defaultOption = Platform.isJS() ? "Text"
             : Cache.getDefault(propertyKey, "Prompt each time");
     if (defaultOption.equalsIgnoreCase("Text"))
     {
@@ -820,10 +835,38 @@ 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.ENABLED,
+            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();
     try
@@ -897,7 +940,7 @@ public class Preferences extends GPreferences
   {
     try
     {
-      if (!Jalview.isJS())
+      if (!Platform.isJS())
       {
         wsPrefs.updateWsMenuConfig(true);
         wsPrefs.refreshWs_actionPerformed(e);
@@ -1041,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(".");
@@ -1135,7 +1181,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);
   }