Jalview 2.6 source licence
[jalview.git] / src / jalview / gui / Preferences.java
index 88f438e..c9c5f6d 100755 (executable)
@@ -1,20 +1,19 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
  * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  */
 package jalview.gui;
 
@@ -45,10 +44,12 @@ public class Preferences extends GPreferences
    * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
    */
   public static Vector sequenceURLLinks;
+
   /**
-   * Holds name and link separated with | character. Sequence IDS and Sequences must be
-   * $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$
-   * and separation character for first and second token specified after a pipe character at end |,|.
+   * Holds name and link separated with | character. Sequence IDS and Sequences
+   * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
+   * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
+   * for first and second token specified after a pipe character at end |,|.
    * (TODO: proper escape for using | to separate ids or sequences
    */
 
@@ -60,7 +61,7 @@ public class Preferences extends GPreferences
                     "SEQUENCE_LINKS",
                     "SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
     sequenceURLLinks = new Vector();
-    
+
     try
     {
       StringTokenizer st = new StringTokenizer(string, "|");
@@ -81,13 +82,14 @@ public class Preferences extends GPreferences
       System.out.println(ex + "\nError parsing sequence links");
     }
     /**
-     * TODO: reformulate groupURL encoding so two or more can be stored in the .properties file as '|' separated strings 
+     * TODO: reformulate groupURL encoding so two or more can be stored in the
+     * .properties file as '|' separated strings
      */
-    
+
     groupURLLinks = new Vector();
-    //groupURLLinks.addElement("UNIPROT|EnVision2|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?tool=Jalview&workflow=Default&datasetName=JalviewIDs$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,");
-    //groupURLLinks.addElement("Seqs|EnVision2|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?tool=Jalview&workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/([A-Za-z]+)+/=$&inputType=1|,");
-    
+    // groupURLLinks.addElement("UNIPROT|EnVision2|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?tool=Jalview&workflow=Default&datasetName=JalviewIDs$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,");
+    // groupURLLinks.addElement("Seqs|EnVision2|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?tool=Jalview&workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/([A-Za-z]+)+/=$&inputType=1|,");
+
   }
 
   Vector nameLinks, urlLinks;
@@ -96,6 +98,8 @@ public class Preferences extends GPreferences
 
   DasSourceBrowser dasSource;
 
+  private WsPreferences wsPrefs;
+
   /**
    * Creates a new Preferences object.
    */
@@ -106,7 +110,8 @@ public class Preferences extends GPreferences
     frame.setContentPane(this);
     dasSource = new DasSourceBrowser();
     dasPanel.add(dasSource, BorderLayout.CENTER);
-
+    wsPrefs = new WsPreferences();
+    wsPanel.add(wsPrefs, BorderLayout.CENTER);
     int width = 500, height = 420;
     if (new jalview.util.Platform().isAMac())
     {
@@ -126,9 +131,14 @@ public class Preferences extends GPreferences
     quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
     identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
     openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
-    showUnconserved.setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
+    showUnconserved
+            .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
+    showNpTooltip.setSelected(Cache
+            .getDefault("SHOW_NPFEATS_TOOLTIP", true));
+    showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
+            true));
 
-    for (int i = 0; i < 13; i++)
+    for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
     {
       colour.addItem(ColourSchemeProperty.getColourName(i));
     }
@@ -198,11 +208,15 @@ public class Preferences extends GPreferences
 
     autoCalculateConsCheck.setSelected(Cache.getDefault(
             "AUTO_CALC_CONSENSUS", true));
-    showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",false));
-    showGroupConservation.setSelected(Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
-    showConsensHistogram.setSelected(Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",true));
-    showConsensProfile.setSelected(Cache.getDefault("SHOW_CONSENSUS_PROFILE",false));
-    
+    showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
+            false));
+    showGroupConservation.setSelected(Cache.getDefault(
+            "SHOW_GROUP_CONSERVATION", false));
+    showConsensHistogram.setSelected(Cache.getDefault(
+            "SHOW_CONSENSUS_HISTOGRAM", true));
+    showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
+            false));
+
     padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
 
     /***************************************************************************
@@ -226,11 +240,17 @@ public class Preferences extends GPreferences
     proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
 
     defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
-    
+
     usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
-    questionnaire.setSelected(Cache.getProperty("NOQUESTIONNAIRES")==null); // note antisense here
-    versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true)); // default is true
-    annotations_actionPerformed(null); // update the display of the annotation settings
+    questionnaire
+            .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null); // note
+                                                                         // antisense
+                                                                         // here
+    versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true)); // default
+                                                                       // is
+                                                                       // true
+    annotations_actionPerformed(null); // update the display of the annotation
+                                       // settings
     try
     {
       jbInit();
@@ -245,7 +265,7 @@ public class Preferences extends GPreferences
    * DOCUMENT ME!
    * 
    * @param e
-   *                DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void ok_actionPerformed(ActionEvent e)
   {
@@ -281,13 +301,22 @@ public class Preferences extends GPreferences
 
     Cache.applicationProperties.setProperty("ID_ITALICS", Boolean
             .toString(idItalics.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",Boolean.toString(showUnconserved.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",Boolean.toString(showGroupConsensus.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",Boolean.toString(showGroupConservation.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",Boolean.toString(showConsensHistogram.isSelected()));
-    Cache.applicationProperties.setProperty("SHOW_CONSENSUS_PROFILE",Boolean.toString(showConsensProfile.isSelected()));
+    Cache.applicationProperties.setProperty("SHOW_UNCONSERVED", Boolean
+            .toString(showUnconserved.isSelected()));
+    Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS", Boolean
+            .toString(showGroupConsensus.isSelected()));
+    Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
+            Boolean.toString(showGroupConservation.isSelected()));
+    Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
+            Boolean.toString(showConsensHistogram.isSelected()));
+    Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO", Boolean
+            .toString(showConsensLogo.isSelected()));
     Cache.applicationProperties.setProperty("ANTI_ALIAS", Boolean
             .toString(smoothFont.isSelected()));
+    Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP", Boolean
+            .toString(showNpTooltip.isSelected()));
+    Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP", Boolean
+            .toString(showDbRefTooltip.isSelected()));
 
     Cache.applicationProperties.setProperty("WRAP_ALIGNMENT", Boolean
             .toString(wrap.isSelected()));
@@ -376,18 +405,22 @@ public class Preferences extends GPreferences
       System.setProperty("http.proxyHost", "");
       System.setProperty("http.proxyPort", "");
     }
-    Cache.setProperty("VERSION_CHECK", Boolean
-            .toString(versioncheck.isSelected()));
-    if (Cache.getProperty("USAGESTATS")!=null || usagestats.isSelected()) {
+    Cache.setProperty("VERSION_CHECK", Boolean.toString(versioncheck
+            .isSelected()));
+    if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
+    {
       // default is false - we only set this if the user has actively agreed
-      Cache.setProperty("USAGESTATS",Boolean
-            .toString(usagestats.isSelected()));
+      Cache.setProperty("USAGESTATS", Boolean.toString(usagestats
+              .isSelected()));
     }
     if (!questionnaire.isSelected())
     {
       Cache.setProperty("NOQUESTIONNAIRES", "true");
-    } else {
-      // special - made easy to edit a property file to disable questionnaires by just adding the given line
+    }
+    else
+    {
+      // special - made easy to edit a property file to disable questionnaires
+      // by just adding the given line
       Cache.removeProperty("NOQUESTIONNAIRES");
     }
     Cache.applicationProperties.setProperty("BLC_JVSUFFIX", Boolean
@@ -414,7 +447,7 @@ public class Preferences extends GPreferences
             .toString(padGaps.isSelected()));
 
     dasSource.saveProperties(Cache.applicationProperties);
-
+    wsPrefs.updateAndRefreshWsMenuConfig(false);
     Cache.saveProperties();
     try
     {
@@ -453,12 +486,13 @@ public class Preferences extends GPreferences
    * DOCUMENT ME!
    * 
    * @param e
-   *                DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void cancel_actionPerformed(ActionEvent e)
   {
     try
     {
+      wsPrefs.updateWsMenuConfig(true);
       frame.setClosed(true);
     } catch (Exception ex)
     {
@@ -469,17 +503,19 @@ public class Preferences extends GPreferences
    * DOCUMENT ME!
    * 
    * @param e
-   *                DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void annotations_actionPerformed(ActionEvent e)
   {
     conservation.setEnabled(annotations.isSelected());
     quality.setEnabled(annotations.isSelected());
     identity.setEnabled(annotations.isSelected());
-    showConsensHistogram.setEnabled(annotations.isSelected());
-    showConsensProfile.setEnabled(annotations.isSelected());
     showGroupConsensus.setEnabled(annotations.isSelected());
     showGroupConservation.setEnabled(annotations.isSelected());
+    showConsensHistogram.setEnabled(annotations.isSelected()
+            && (identity.isSelected() || showGroupConsensus.isSelected()));
+    showConsensLogo.setEnabled(annotations.isSelected()
+            && (identity.isSelected() || showGroupConsensus.isSelected()));
   }
 
   public void newLink_actionPerformed(ActionEvent e)
@@ -582,8 +618,13 @@ public class Preferences extends GPreferences
     }
 
   }
-  /* (non-Javadoc)
-   * @see jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event.ActionEvent)
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
+   * .ActionEvent)
    */
   protected void showunconserved_actionPerformed(ActionEvent e)
   {