X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=a0a7511aa888aaa465cfb3ef71d72e7673903839;hb=b5667f39acdf309cd92881b73edfda591e0acaf4;hp=ad3bfb57e9a2767f2b38610ecf4c140399ca4373;hpb=3c2d7328e3d4d086c0649b88102de8da259ffb6c;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index ad3bfb5..a0a7511 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -24,7 +24,9 @@ import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; import jalview.gui.Help.HelpId; import jalview.gui.StructureViewer.ViewerType; +import jalview.hmmer.HmmerCommand; import jalview.io.BackupFiles; +import jalview.io.BackupFilesPresetEntry; import jalview.io.FileFormatI; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; @@ -37,6 +39,7 @@ import jalview.urls.UrlLinkTableModel; import jalview.urls.api.UrlProviderFactoryI; import jalview.urls.api.UrlProviderI; import jalview.urls.desktop.DesktopUrlProviderFactory; +import jalview.util.FileUtils; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.util.UrlConstants; @@ -49,6 +52,8 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.awt.event.MouseEvent; import java.io.File; import java.util.ArrayList; @@ -59,6 +64,7 @@ import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.RowFilter; import javax.swing.RowSorter; @@ -82,6 +88,15 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager; */ public class Preferences extends GPreferences { + // suggested list delimiter character + public static final String COMMA = ","; + + public static final String HMMSEARCH_SEQCOUNT = "HMMSEARCH_SEQCOUNT"; + + public static final String HMMINFO_GLOBAL_BACKGROUND = "HMMINFO_GLOBAL_BACKGROUND"; + + public static final String HMMALIGN_TRIM_TERMINI = "HMMALIGN_TRIM_TERMINI"; + public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME"; public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA"; @@ -103,6 +118,12 @@ 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 CYGWIN_PATH = "CYGWIN_PATH"; + + public static final String HMMSEARCH_DBS = "HMMSEARCH_DBS"; public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS"; @@ -204,6 +225,63 @@ public class Preferences extends GPreferences frame.setMinimumSize(new Dimension(width, height)); /* + * Set HMMER tab defaults + */ + hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false)); + if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false)) + { + hmmerBackgroundUniprot.setSelected(true); + } + else + { + hmmerBackgroundAlignment.setSelected(true); + } + hmmerSequenceCount + .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT)); + hmmerPath.setText(Cache.getProperty(HMMER_PATH)); + hmmerPath.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + validateHmmerPath(); + } + }); + hmmerPath.addFocusListener(new FocusAdapter() + { + @Override + public void focusLost(FocusEvent e) + { + validateHmmerPath(); + } + }); + if (cygwinPath != null) + { + String path = Cache.getProperty(CYGWIN_PATH); + if (path == null) + { + path = FileUtils.getPathTo("bash"); + } + cygwinPath.setText(path); + cygwinPath.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + validateCygwinPath(); + } + }); + cygwinPath.addFocusListener(new FocusAdapter() + { + @Override + public void focusLost(FocusEvent e) + { + validateCygwinPath(); + } + }); + } + + /* * Set Visual tab defaults */ seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true)); @@ -226,6 +304,9 @@ public class Preferences extends GPreferences Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true)); showConsensLogo .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false)); + showInformationHistogram.setSelected( + Cache.getDefault("SHOW_INFORMATION_HISTOGRAM", true)); + showHMMLogo.setSelected(Cache.getDefault("SHOW_HMM_LOGO", false)); showNpTooltip .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true)); showDbRefTooltip @@ -326,7 +407,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. @@ -613,6 +694,10 @@ public class Preferences extends GPreferences Boolean.toString(showConsensHistogram.isSelected())); Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO", Boolean.toString(showConsensLogo.isSelected())); + Cache.applicationProperties.setProperty("SHOW_INFORMATION_HISTOGRAM", + Boolean.toString(showConsensHistogram.isSelected())); + Cache.applicationProperties.setProperty("SHOW_HMM_LOGO", + Boolean.toString(showHMMLogo.isSelected())); Cache.applicationProperties.setProperty("ANTI_ALIAS", Boolean.toString(smoothFont.isSelected())); Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA, @@ -659,6 +744,42 @@ public class Preferences extends GPreferences maxColour.getBackground()); /* + * Save HMMER settings + */ + Cache.applicationProperties.setProperty(HMMALIGN_TRIM_TERMINI, + Boolean.toString(hmmrTrimTermini.isSelected())); + Cache.applicationProperties.setProperty(HMMINFO_GLOBAL_BACKGROUND, + Boolean.toString(hmmerBackgroundUniprot.isSelected())); + Cache.applicationProperties.setProperty(HMMSEARCH_SEQCOUNT, + hmmerSequenceCount.getText()); + Cache.setOrRemove(HMMER_PATH, hmmerPath.getText()); + if (cygwinPath != null) + { + Cache.setOrRemove(CYGWIN_PATH, cygwinPath.getText()); + } + AlignFrame[] frames = Desktop.getAlignFrames(); + if (frames != null && frames.length > 0) + { + for (AlignFrame f : frames) + { + f.updateHMMERStatus(); + } + } + + hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false)); + if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false)) + { + hmmerBackgroundUniprot.setSelected(true); + } + else + { + hmmerBackgroundAlignment.setSelected(true); + } + hmmerSequenceCount + .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT)); + hmmerPath.setText(Cache.getProperty(HMMER_PATH)); + + /* * Save Overview settings */ Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground()); @@ -805,22 +926,25 @@ public class Preferences extends GPreferences /* * Save Backups settings */ - Cache.applicationProperties.setProperty(BackupFiles.CONFIRM_DELETE_OLD, - Boolean.toString(backupfilesConfirmDelete.isSelected())); Cache.applicationProperties.setProperty(BackupFiles.ENABLED, Boolean.toString(enableBackupFiles.isSelected())); - Cache.applicationProperties.setProperty(BackupFiles.NO_MAX, - Boolean.toString(backupfilesKeepAll.isSelected())); - Cache.applicationProperties.setProperty(BackupFiles.REVERSE_ORDER, - Boolean.toString(suffixReverse.isSelected())); - Cache.applicationProperties.setProperty(BackupFiles.SUFFIX, - suffixTemplate.getText()); - Cache.applicationProperties.setProperty(BackupFiles.ROLL_MAX, - Integer.toString(getSpinnerInt(backupfilesRollMaxSpinner, 4))); - Cache.applicationProperties.setProperty(BackupFiles.SUFFIX_DIGITS, - Integer.toString(getSpinnerInt(suffixDigitsSpinner, 3))); - Cache.applicationProperties.setProperty(BackupFiles.NS+"_PRESET", - Integer.toString(getComboIntStringKey(backupfilesPresetsCombo))); + 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(); @@ -921,6 +1045,8 @@ public class Preferences extends GPreferences && (identity.isSelected() || showGroupConsensus.isSelected())); showConsensLogo.setEnabled(annotations.isSelected() && (identity.isSelected() || showGroupConsensus.isSelected())); + showInformationHistogram.setEnabled(annotations.isSelected()); + showHMMLogo.setEnabled(annotations.isSelected()); } @Override @@ -1144,7 +1270,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); } @@ -1202,6 +1328,57 @@ public class Preferences extends GPreferences } return true; } + + /** + * Returns true if the given text field contains a path to a folder that + * contains an executable with the given name, else false (after showing a + * warning dialog). The executable name will be tried with .exe appended if not + * found. + * + * @param textField + * @param executable + */ + protected boolean validateExecutablePath(JTextField textField, String executable) + { + String folder = textField.getText().trim(); + + if (FileUtils.getExecutable(executable, folder) != null) + { + return true; + } + if (folder.length() > 0) + { + JvOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager.formatMessage("label.executable_not_found", + executable), + MessageManager.getString("label.invalid_folder"), + JvOptionPane.ERROR_MESSAGE); + } + return false; + } + + /** + * Checks if a file can be executed + * + * @param path + * the path to the file + * @return + */ + public boolean canExecute(String path) + { + File file = new File(path); + if (!file.canExecute()) + { + file = new File(path + ".exe"); + { + if (!file.canExecute()) + { + return false; + } + } + } + return true; + } /** * If Chimera is selected, check it can be found on default or user-specified @@ -1250,6 +1427,18 @@ public class Preferences extends GPreferences } } + @Override + protected void validateHmmerPath() + { + validateExecutablePath(hmmerPath, HmmerCommand.HMMBUILD); + } + + @Override + protected void validateCygwinPath() + { + validateExecutablePath(cygwinPath, "run"); + } + public class OptionsParam { private String name;