JAL-2527 Added overview prefs - don't get picked up by overview yet
[jalview.git] / src / jalview / gui / Preferences.java
index 6fdaa0d..e8dc07c 100755 (executable)
@@ -54,7 +54,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.help.HelpSetException;
-import javax.swing.JButton;
 import javax.swing.JColorChooser;
 import javax.swing.JFileChooser;
 import javax.swing.JInternalFrame;
@@ -110,6 +109,10 @@ public class Preferences extends GPreferences
 
   public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
 
+  public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
+
+  public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
+
   private static final int MIN_FONT_SIZE = 1;
 
   private static final int MAX_FONT_SIZE = 30;
@@ -308,10 +311,19 @@ public class Preferences extends GPreferences
             Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
     maxColour.setBackground(
             Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
+
+    /*
+     * Set overview panel defaults
+     */
     gapColour.setBackground(
             Cache.getDefaultColour("GAP_COLOUR", Color.lightGray));
     hiddenColour.setBackground(
             Cache.getDefaultColour("HIDDEN_COLOUR", Color.darkGray));
+    useLegacyGap.setSelected(Cache.getDefault("USE_LEGACY_GAP", false));
+    gapLabel.setEnabled(!useLegacyGap.isSelected());
+    gapColour.setEnabled(!useLegacyGap.isSelected());
+    showHiddenAtStart
+            .setSelected(Cache.getDefault("SHOW_OV_HIDDEN_AT_START", true));
 
     /*
      * Set Structure tab defaults.
@@ -636,6 +648,16 @@ public class Preferences extends GPreferences
             maxColour.getBackground());
 
     /*
+     * Save Overview settings
+     */
+    Cache.setColourProperty("GAP_COLOUR", gapColour.getBackground());
+    Cache.setColourProperty("HIDDEN_COLOUR", hiddenColour.getBackground());
+    Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
+            Boolean.toString(useLegacyGap.isSelected()));
+    Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
+            Boolean.toString(showHiddenAtStart.isSelected()));
+
+    /*
      * Save Structure settings
      */
     Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
@@ -1040,29 +1062,32 @@ public class Preferences extends GPreferences
   }
 
   @Override
-  public void gapColour_actionPerformed(JButton btn)
+  public void gapColour_actionPerformed(JPanel gap)
   {
-    Color col = JColorChooser.showDialog(this,
-            MessageManager.getString("label.select_gap_colour"),
-            gapColour.getForeground());
-    if (col != null)
+    if (!useLegacyGap.isSelected())
     {
-      btn.setForeground(col);
+      Color col = JColorChooser.showDialog(this,
+              MessageManager.getString("label.select_gap_colour"),
+              gapColour.getBackground());
+      if (col != null)
+      {
+        gap.setBackground(col);
+      }
+      gap.repaint();
     }
-    btn.repaint();
   }
 
   @Override
-  public void hiddenColour_actionPerformed(JButton btn)
+  public void hiddenColour_actionPerformed(JPanel hidden)
   {
     Color col = JColorChooser.showDialog(this,
             MessageManager.getString("label.select_hidden_colour"),
-            hiddenColour.getForeground());
+            hiddenColour.getBackground());
     if (col != null)
     {
-      btn.setForeground(col);
+      hidden.setBackground(col);
     }
-    btn.repaint();
+    hidden.repaint();
   }
 
   @Override