JAL-2629 add HMMER tab in preferences menu
[jalview.git] / src / jalview / gui / Preferences.java
index 8b4f85f..c25fc2f 100755 (executable)
@@ -102,6 +102,8 @@ public class Preferences extends GPreferences
   public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
 
   public static final String CHIMERA_PATH = "CHIMERA_PATH";
+  
+  public static final String HMMER_PATH = "HMMER_PATH";
 
   public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
 
@@ -199,6 +201,22 @@ public class Preferences extends GPreferences
     frame.setMinimumSize(new Dimension(width, height));
 
     /*
+     * Set HMMER tab defaults
+     */
+    trimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false));
+    if (Cache.getDefault("USE_UNIPROT", false))
+    {
+      uniprot.setSelected(true);
+    }
+    else
+    {
+      alignment.setSelected(true);
+    }
+    numberOfSequencesToKeepField
+            .setText(Cache.getProperty("SEQUENCES_TO_KEEP"));
+    installationLocationField.setText(Cache.getProperty(HMMER_PATH));
+
+    /*
      * Set Visual tab defaults
      */
     seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
@@ -638,6 +656,30 @@ public class Preferences extends GPreferences
             maxColour.getBackground());
 
     /*
+     * Save HMMER settings
+     */
+    Cache.applicationProperties.setProperty("TRIM_TERMINI",
+            Boolean.toString(trimTermini.isSelected()));
+    Cache.applicationProperties.setProperty("USE_UNIPROT",
+            Boolean.toString(uniprot.isSelected()));
+    Cache.applicationProperties.setProperty("SEQUENCES_TO_KEEP",
+            numberOfSequencesToKeepField.getText());
+    Cache.applicationProperties.setProperty(HMMER_PATH,
+            installationLocationField.getText());
+    trimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false));
+    if (Cache.getDefault("USE_UNIPROT", false))
+    {
+      uniprot.setSelected(true);
+    }
+    else
+    {
+      alignment.setSelected(true);
+    }
+    numberOfSequencesToKeepField
+            .setText(Cache.getProperty("SEQUENCES_TO_KEEP"));
+    installationLocationField.setText(Cache.getProperty(HMMER_PATH));
+
+    /*
      * Save Structure settings
      */
     Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
@@ -1094,6 +1136,28 @@ public class Preferences extends GPreferences
     }
     return true;
   }
+  
+  /**
+   * Returns true if hmmer path contains the necessary valid executables, else show an error
+   * dialog.
+   */
+  private boolean validateHMMERPath()
+  {
+    String path = Cache.getProperty("HMMERPATH");
+    if (path.length() > 0)
+    {
+      File f = new File(path);
+      if (!f.canExecute())
+      {
+        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+                MessageManager.getString("label.invalid_hmmer_folder"),
+                MessageManager.getString("Invalid folder"),
+                JvOptionPane.ERROR_MESSAGE);
+        return false;
+      }
+    }
+    return true;
+  }
 
   /**
    * If Chimera is selected, check it can be found on default or user-specified