Just a rearrangement
[jalview.git] / src / jalview / gui / Preferences.java
index dbb5aec..61a4573 100755 (executable)
@@ -84,67 +84,6 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
 @SuppressWarnings("serial")
 public class Preferences extends GPreferences
 {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
   public static final String ADD_SS_ANN = "ADD_SS_ANN";
 
   public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
@@ -161,6 +100,8 @@ public class Preferences extends GPreferences
 
   public static final String AUTOASSOCIATE_PDBANDSEQS = "AUTOASSOCIATE_PDBANDSEQS";
 
+  public static final String BLOSUM62_PCA_FOR_NUCLEOTIDE = "BLOSUM62_PCA_FOR_NUCLEOTIDE";
+
   public static final String CENTRE_COLUMN_LABELS = "CENTRE_COLUMN_LABELS";
 
   public static final String CHIMERA_PATH = "CHIMERA_PATH";
@@ -233,10 +174,14 @@ public class Preferences extends GPreferences
 
   public static final String SHOW_DBREFS_TOOLTIP = "SHOW_DBREFS_TOOLTIP";
 
+  public static final String SHOW_FULLSCREEN = "SHOW_FULLSCREEN";
+
   public static final String SHOW_GROUP_CONSENSUS = "SHOW_GROUP_CONSENSUS";
 
   public static final String SHOW_GROUP_CONSERVATION = "SHOW_GROUP_CONSERVATION";
 
+  public static final String SHOW_IDENTITY = "SHOW_IDENTITY";
+
   public static final String SHOW_JVSUFFIX = "SHOW_JVSUFFIX";
 
   public static final String SHOW_NPFEATS_TOOLTIP = "SHOW_NPFEATS_TOOLTIP";
@@ -261,6 +206,8 @@ public class Preferences extends GPreferences
 
   public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
 
+  public static final String STRUCTURE_DIMENSIONS = "STRUCTURE_DIMENSIONS";
+
   public static final String UNIPROT_DOMAIN = "UNIPROT_DOMAIN";
 
   public static final String USE_FULL_SO = "USE_FULL_SO";
@@ -296,12 +243,8 @@ public class Preferences extends GPreferences
 
   public static final List<String> groupURLLinks; // not implemented
 
-  public static final String BLOSUM62_PCA_FOR_NUCLEOTIDE = "BLOSUM62_PCA_FOR_NUCLEOTIDE";
-
-  public static final String SHOW_IDENTITY = "SHOW_IDENTITY";
-
-  public static final String SHOW_FULLSCREEN = "SHOW_FULLSCREEN";
-
+  public static final Dimension DEFAULT_STRUCTURE_DIMENSIONS = new Dimension(
+          600, 600);
 
   static
   {
@@ -363,11 +306,16 @@ public class Preferences extends GPreferences
       wsPrefs = new WsPreferences();
       wsTab.add(wsPrefs, BorderLayout.CENTER);
     }
-    int width = 500, height = 450;
+    int width = 700, height = 510; // BH 2019.07.12 added 60 to height and 40 to
+                                   // width (for Visual check boxes and Links
+                                   // "Double Click" header)
+    // BH 2019.09.24 added 20 to width
+    // (structure panel was too small anyway, and I added a default dimension
+    // for Jmol
     if (Platform.isAMacAndNotJS())
     {
       width = 570;
-      height = 480;
+      height = 540; // BH 2019.07.12 added 30
     }
 
     Desktop.addInternalFrame(frame,
@@ -510,8 +458,15 @@ public class Preferences extends GPreferences
     addSecondaryStructure.setEnabled(structSelected);
     addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
     addTempFactor.setEnabled(structSelected);
+    if (!Platform.isJS())
+    {
     structViewer.setSelectedItem(
             Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
+    }
+    Dimension d = Cache.getDefaultDim(STRUCTURE_DIMENSIONS,
+            DEFAULT_STRUCTURE_DIMENSIONS);
+    String s = d.width + "," + d.height;
+    structureDimensions.setText(s);
     chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
     chimeraPath.addActionListener(new ActionListener()
     {
@@ -710,7 +665,11 @@ public class Preferences extends GPreferences
     /*
      * Set Backups tab defaults
      */
-    loadLastSavedBackupsOptions();
+    if (!Platform.isJS())
+    {
+      loadLastSavedBackupsOptions();
+    }
+
   }
 
   /**
@@ -816,8 +775,7 @@ public class Preferences extends GPreferences
     Cache.setPropertyNoSave(WRAP_ALIGNMENT,
             Boolean.toString(wrap.isSelected()));
 
-    Cache.setPropertyNoSave("STARTUP_FILE",
-            startupFileTextfield.getText());
+    Cache.setPropertyNoSave("STARTUP_FILE", startupFileTextfield.getText());
     Cache.setPropertyNoSave("SHOW_STARTUP_FILE",
             Boolean.toString(startupCheckbox.isSelected()));
 
@@ -829,8 +787,7 @@ public class Preferences extends GPreferences
             .forDescription(sortAnnBy.getSelectedItem().toString());
     if (annSortOrder != null)
     {
-      Cache.setPropertyNoSave(SORT_ANNOTATIONS,
-              annSortOrder.name());
+      Cache.setPropertyNoSave(SORT_ANNOTATIONS, annSortOrder.name());
     }
 
     final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
@@ -844,16 +801,17 @@ public class Preferences extends GPreferences
             protColour.getSelectedItem().toString());
     Cache.setPropertyNoSave(DEFAULT_COLOUR_NUC,
             nucColour.getSelectedItem().toString());
-    Cache.setColourProperty(ANNOTATIONCOLOUR_MIN,
+    Cache.setColourPropertyNoSave(ANNOTATIONCOLOUR_MIN,
             minColour.getBackground());
-    Cache.setColourProperty(ANNOTATIONCOLOUR_MAX,
+    Cache.setColourPropertyNoSave(ANNOTATIONCOLOUR_MAX,
             maxColour.getBackground());
 
     /*
      * Save Overview settings
      */
-    Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
-    Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
+    Cache.setColourPropertyNoSave(GAP_COLOUR, gapColour.getBackground());
+    Cache.setColourPropertyNoSave(HIDDEN_COLOUR,
+            hiddenColour.getBackground());
     Cache.setPropertyNoSave(USE_LEGACY_GAP,
             Boolean.toString(useLegacyGap.isSelected()));
     Cache.setPropertyNoSave(SHOW_OV_HIDDEN_AT_START,
@@ -872,6 +830,8 @@ public class Preferences extends GPreferences
             Boolean.toString(structFromPdb.isSelected()));
     Cache.setPropertyNoSave(STRUCTURE_DISPLAY,
             structViewer.getSelectedItem().toString());
+    Cache.setPropertyNoSave(STRUCTURE_DIMENSIONS,
+            structureDimensions.getText()); // BH 2019.07.12
     Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
     Cache.setPropertyNoSave(MAP_WITH_SIFTS,
             Boolean.toString(siftsMapping.isSelected()));
@@ -906,8 +866,7 @@ public class Preferences extends GPreferences
     }
     else
     {
-      Cache.setPropertyNoSave("SEQUENCE_LINKS",
-              menuLinks.toString());
+      Cache.setPropertyNoSave("SEQUENCE_LINKS", menuLinks.toString());
     }
 
     String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
@@ -917,8 +876,7 @@ public class Preferences extends GPreferences
     }
     else
     {
-      Cache.setPropertyNoSave("STORED_LINKS",
-              nonMenuLinks.toString());
+      Cache.setPropertyNoSave("STORED_LINKS", nonMenuLinks.toString());
     }
 
     Cache.setPropertyNoSave("DEFAULT_URL",
@@ -984,8 +942,7 @@ public class Preferences extends GPreferences
     Cache.setPropertyNoSave(FIGURE_AUTOIDWIDTH,
             Boolean.toString(autoIdWidth.isSelected()));
     userIdWidth_actionPerformed();
-    Cache.setPropertyNoSave("FIGURE_FIXEDIDWIDTH",
-            userIdWidth.getText());
+    Cache.setPropertyNoSave("FIGURE_FIXEDIDWIDTH", userIdWidth.getText());
 
     /*
      * Save Editing settings
@@ -1000,27 +957,26 @@ public class Preferences extends GPreferences
     if (!Platform.isJS())
     {
       wsPrefs.updateAndRefreshWsMenuConfig(false);
-    }
+      /*
+       * Save Backups settings
+       */
+      Cache.setPropertyNoSave(BackupFiles.CONFIRM_DELETE_OLD,
+              Boolean.toString(backupfilesConfirmDelete.isSelected()));
+      Cache.setPropertyNoSave(BackupFiles.ENABLED,
+              Boolean.toString(enableBackupFiles.isSelected()));
+      Cache.setPropertyNoSave(BackupFiles.NO_MAX,
+              Boolean.toString(backupfilesKeepAll.isSelected()));
+      Cache.setPropertyNoSave(BackupFiles.REVERSE_ORDER,
+              Boolean.toString(suffixReverse.isSelected()));
+      Cache.setPropertyNoSave(BackupFiles.SUFFIX, suffixTemplate.getText());
+      Cache.setPropertyNoSave(BackupFiles.ROLL_MAX, Integer
+              .toString(getSpinnerInt(backupfilesRollMaxSpinner, 4)));
+      Cache.setPropertyNoSave(BackupFiles.SUFFIX_DIGITS,
+              Integer.toString(getSpinnerInt(suffixDigitsSpinner, 3)));
+      Cache.setPropertyNoSave(BackupFiles.NS + "_PRESET", Integer
+              .toString(getComboIntStringKey(backupfilesPresetsCombo)));
 
-    /*
-     * Save Backups settings
-     */
-    Cache.setPropertyNoSave(BackupFiles.CONFIRM_DELETE_OLD,
-            Boolean.toString(backupfilesConfirmDelete.isSelected()));
-    Cache.setPropertyNoSave(BackupFiles.ENABLED,
-            Boolean.toString(enableBackupFiles.isSelected()));
-    Cache.setPropertyNoSave(BackupFiles.NO_MAX,
-            Boolean.toString(backupfilesKeepAll.isSelected()));
-    Cache.setPropertyNoSave(BackupFiles.REVERSE_ORDER,
-            Boolean.toString(suffixReverse.isSelected()));
-    Cache.setPropertyNoSave(BackupFiles.SUFFIX,
-            suffixTemplate.getText());
-    Cache.setPropertyNoSave(BackupFiles.ROLL_MAX,
-            Integer.toString(getSpinnerInt(backupfilesRollMaxSpinner, 4)));
-    Cache.setPropertyNoSave(BackupFiles.SUFFIX_DIGITS,
-            Integer.toString(getSpinnerInt(suffixDigitsSpinner, 3)));
-    Cache.setPropertyNoSave(BackupFiles.NS + "_PRESET",
-            Integer.toString(getComboIntStringKey(backupfilesPresetsCombo)));
+    }
 
     Cache.saveProperties();
     Desktop.getInstance().doConfigureStructurePrefs();
@@ -1093,7 +1049,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * DOCUMENT ME!
+   * Opens a file browser, and if a file is chosen, sets its path as the text of
+   * the 'startup file' text field
    */
   @Override
   public void startupFileTextfield_mouseClicked()
@@ -1113,8 +1070,10 @@ public class Preferences extends GPreferences
       FileFormatI format = chooser.getSelectedFormat();
       if (format != null)
       {
-        Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT",
-                format.getName());
+        /*
+         * saving properties to file is deferred to the 'OK' action
+         */
+        Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT", format.getName());
       }
       startupFileTextfield
               .setText(chooser.getSelectedFile().getAbsolutePath());