X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPreferences.java;h=3259909f6805c98cee95942e15f3056444001c8c;hb=f37c3fd4fe12799de498de5f397252e9f457fee9;hp=c8fef96f847e03f8ece4b6f51141f5ec211f3b20;hpb=ef660a21d6304c84f215341a9a29e112c82119fd;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index c8fef96..3259909 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -22,14 +22,9 @@ package jalview.gui; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; -import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.HiddenMarkovModel; -import jalview.datamodel.Sequence; -import jalview.datamodel.SequenceI; import jalview.gui.Help.HelpId; import jalview.gui.StructureViewer.ViewerType; -import jalview.hmmer.HMMBuildThread; +import jalview.hmmer.HmmerCommand; import jalview.io.FileFormatI; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; @@ -42,6 +37,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; @@ -54,17 +50,19 @@ 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; import java.util.List; -import java.util.Scanner; import javax.help.HelpSetException; 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; @@ -88,6 +86,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"; @@ -112,12 +119,24 @@ public class Preferences extends GPreferences 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"; public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE"; 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"; + + public static final String GAP_COLOUR = "GAP_COLOUR"; + + public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR"; + private static final int MIN_FONT_SIZE = 1; private static final int MAX_FONT_SIZE = 30; @@ -210,30 +229,59 @@ public class Preferences extends GPreferences /* * Set HMMER tab defaults */ - trimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false)); - isHMMERInstalled - .setSelected(Cache.getDefault("HMMER_INSTALLED", false)); - if (Cache.getDefault("USE_UNIPROT", false)) + hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false)); + if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false)) { - uniprot.setSelected(true); + hmmerBackgroundUniprot.setSelected(true); } else { - alignment.setSelected(true); + hmmerBackgroundAlignment.setSelected(true); } - numberOfSequencesToKeepField - .setText(Cache.getProperty("SEQUENCES_TO_KEEP")); - installationLocation.setEnabled(isHMMERInstalled.isSelected()); - hmmerPath.setEnabled(isHMMERInstalled.isSelected()); + hmmerSequenceCount + .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT)); hmmerPath.setText(Cache.getProperty(HMMER_PATH)); hmmerPath.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - validateHMMERPath(); + 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 @@ -250,21 +298,21 @@ public class Preferences extends GPreferences showUnconserved .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false)); showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, 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)); + 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)); 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.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", - true)); + showNpTooltip + .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true)); + showDbRefTooltip + .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true)); String[] fonts = java.awt.GraphicsEnvironment .getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); @@ -284,12 +332,12 @@ public class Preferences extends GPreferences fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif")); fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10")); - fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN - + "")); + fontStyleCB.setSelectedItem( + Cache.getDefault("FONT_STYLE", Font.PLAIN + "")); smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false)); - scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, - false)); + scaleProteinToCdna + .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false)); idItalics.setSelected(Cache.getDefault("ID_ITALICS", true)); @@ -343,10 +391,25 @@ public class Preferences extends GPreferences protColour.setSelectedItem(newProp != null ? newProp : oldProp); newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null); nucColour.setSelectedItem(newProp != null ? newProp : oldProp); - minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", - Color.orange)); - maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", - Color.red)); + minColour.setBackground( + Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange)); + maxColour.setBackground( + Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red)); + + /* + * Set overview panel defaults + */ + gapColour.setBackground( + Cache.getDefaultColour(GAP_COLOUR, + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP)); + hiddenColour.setBackground( + Cache.getDefaultColour(HIDDEN_COLOUR, + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN)); + 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. @@ -359,8 +422,8 @@ public class Preferences extends GPreferences addSecondaryStructure.setEnabled(structSelected); addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false)); addTempFactor.setEnabled(structSelected); - structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY, - ViewerType.JMOL.name())); + structViewer.setSelectedItem( + Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name())); chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, "")); chimeraPath.addActionListener(new ActionListener() { @@ -399,12 +462,12 @@ public class Preferences extends GPreferences SortOrder.DESCENDING)); sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(), SortOrder.DESCENDING)); - sortKeys.add(new RowSorter.SortKey(m.getNameColumn(), - SortOrder.ASCENDING)); + sortKeys.add( + new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING)); sorter.setSortKeys(sortKeys); sorter.sort(); - + // set up filtering ActionListener onReset; onReset = new ActionListener() @@ -453,35 +516,35 @@ public class Preferences extends GPreferences @Override public void changedUpdate(DocumentEvent e) { - sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag - + filterTB.getText())); + sorter.setRowFilter(RowFilter + .regexFilter(caseInsensitiveFlag + filterTB.getText())); } @Override public void removeUpdate(DocumentEvent e) { - sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag - + filterTB.getText())); + sorter.setRowFilter(RowFilter + .regexFilter(caseInsensitiveFlag + filterTB.getText())); } @Override public void insertUpdate(DocumentEvent e) { - sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag - + filterTB.getText())); + sorter.setRowFilter(RowFilter + .regexFilter(caseInsensitiveFlag + filterTB.getText())); } }); // set up list selection functionality - linkUrlTable.getSelectionModel().addListSelectionListener( - new UrlListSelectionHandler()); + linkUrlTable.getSelectionModel() + .addListSelectionListener(new UrlListSelectionHandler()); // set up radio buttons int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel()) .getPrimaryColumn(); String onClickName = linkUrlTable.getColumnName(onClickCol); - linkUrlTable.getColumn(onClickName).setCellRenderer( - new RadioButtonRenderer()); + linkUrlTable.getColumn(onClickName) + .setCellRenderer(new RadioButtonRenderer()); linkUrlTable.getColumn(onClickName) .setCellEditor(new RadioButtonEditor()); @@ -491,8 +554,8 @@ public class Preferences extends GPreferences if (linkUrlTable.getModel().getColumnClass(column) .equals(Boolean.class)) { - TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn( - column); + TableColumn tableColumn = linkUrlTable.getColumnModel() + .getColumn(column); int preferredWidth = tableColumn.getMinWidth(); TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0, @@ -542,8 +605,10 @@ public class Preferences extends GPreferences autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false)); userIdWidth.setEnabled(!autoIdWidth.isSelected()); userIdWidthlabel.setEnabled(!autoIdWidth.isSelected()); - Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH"); + Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH"); userIdWidth.setText(wi == null ? "" : wi.toString()); + // TODO: refactor to use common enum via FormatAdapter and allow extension + // for new flat file formats blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true)); clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true)); fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true)); @@ -552,14 +617,14 @@ public class Preferences extends GPreferences pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true)); pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true)); modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false)); - embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", - true)); + embbedBioJSON + .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true)); /* * Set Editing tab defaults */ - autoCalculateConsCheck.setSelected(Cache.getDefault( - "AUTO_CALC_CONSENSUS", true)); + autoCalculateConsCheck + .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true)); padGaps.setSelected(Cache.getDefault("PAD_GAPS", false)); sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false)); @@ -601,15 +666,15 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("SHOW_IDENTITY", Boolean.toString(identity.isSelected())); - Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB - .getSelectedItem().toString()); + Cache.applicationProperties.setProperty("GAP_SYMBOL", + gapSymbolCB.getSelectedItem().toString()); - Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB - .getSelectedItem().toString()); - Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB - .getSelectedItem().toString()); - Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB - .getSelectedItem().toString()); + Cache.applicationProperties.setProperty("FONT_NAME", + fontNameCB.getSelectedItem().toString()); + Cache.applicationProperties.setProperty("FONT_STYLE", + fontStyleCB.getSelectedItem().toString()); + Cache.applicationProperties.setProperty("FONT_SIZE", + fontSizeCB.getSelectedItem().toString()); Cache.applicationProperties.setProperty("ID_ITALICS", Boolean.toString(idItalics.isSelected())); @@ -646,8 +711,8 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE", Boolean.toString(startupCheckbox.isSelected())); - Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby - .getSelectedItem().toString()); + Cache.applicationProperties.setProperty("SORT_ALIGNMENT", + sortby.getSelectedItem().toString()); // convert description of sort order to enum name for save SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder @@ -659,16 +724,16 @@ public class Preferences extends GPreferences } final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0; - Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean - .valueOf(showAutocalcFirst).toString()); + Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, + Boolean.valueOf(showAutocalcFirst).toString()); /* * Save Colours settings */ - Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour - .getSelectedItem().toString()); - Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour - .getSelectedItem().toString()); + Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, + protColour.getSelectedItem().toString()); + Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, + nucColour.getSelectedItem().toString()); Cache.setColourProperty("ANNOTATIONCOLOUR_MIN", minColour.getBackground()); Cache.setColourProperty("ANNOTATIONCOLOUR_MAX", @@ -677,42 +742,50 @@ public class Preferences extends GPreferences /* * 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, - hmmerPath.getText()); - boolean hmmerInstalled = isHMMERInstalled.isSelected(); - Cache.applicationProperties.setProperty("HMMER_INSTALLED", - Boolean.toString(hmmerInstalled)); - boolean hmmerFunctioning = validateHMMERPath(false); - Cache.applicationProperties.setProperty("HMMER_FUNCTIONING", - Boolean.toString(hmmerFunctioning)); + 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(); - boolean hmmerStatus = hmmerFunctioning && hmmerInstalled ? true : false; - for (AlignFrame frame : frames) + if (frames != null && frames.length > 0) { - frame.updateHMMERStatus(hmmerStatus); + for (AlignFrame f : frames) + { + f.updateHMMERStatus(); + } } - - trimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false)); - if (Cache.getDefault("USE_UNIPROT", false)) + hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false)); + if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false)) { - uniprot.setSelected(true); + hmmerBackgroundUniprot.setSelected(true); } else { - alignment.setSelected(true); + hmmerBackgroundAlignment.setSelected(true); } - numberOfSequencesToKeepField - .setText(Cache.getProperty("SEQUENCES_TO_KEEP")); + hmmerSequenceCount + .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT)); hmmerPath.setText(Cache.getProperty(HMMER_PATH)); /* + * 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, @@ -723,8 +796,8 @@ public class Preferences extends GPreferences Boolean.toString(useRnaView.isSelected())); Cache.applicationProperties.setProperty(STRUCT_FROM_PDB, Boolean.toString(structFromPdb.isSelected())); - Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer - .getSelectedItem().toString()); + Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, + structViewer.getSelectedItem().toString()); Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText()); Cache.applicationProperties.setProperty("MAP_WITH_SIFTS", Boolean.toString(siftsMapping.isSelected())); @@ -831,7 +904,7 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH", Boolean.toString(autoIdWidth.isSelected())); userIdWidth_actionPerformed(); - Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH", + Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH", userIdWidth.getText()); /* @@ -869,14 +942,6 @@ public class Preferences extends GPreferences structureTab.requestFocusInWindow(); return false; } - if (isHMMERInstalled.isSelected()) - { - if (!validateHMMER()) - { - hmmerTab.requestFocusInWindow(); - return false; - } - } return true; } @@ -887,13 +952,6 @@ public class Preferences extends GPreferences } - @Override - protected boolean validateHMMER() - { - return validateHMMERPath(); - - } - /** * DOCUMENT ME! */ @@ -901,11 +959,11 @@ public class Preferences extends GPreferences public void startupFileTextfield_mouseClicked() { String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); - JalviewFileChooser chooser = JalviewFileChooser.forRead( - Cache.getProperty("LAST_DIRECTORY"), fileFormat); + JalviewFileChooser chooser = JalviewFileChooser + .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat); chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle(MessageManager - .getString("label.select_startup_file")); + chooser.setDialogTitle( + MessageManager.getString("label.select_startup_file")); int value = chooser.showOpenDialog(this); @@ -917,8 +975,8 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT", format.getName()); } - startupFileTextfield.setText(chooser.getSelectedFile() - .getAbsolutePath()); + startupFileTextfield + .setText(chooser.getSelectedFile().getAbsolutePath()); } } @@ -973,15 +1031,16 @@ public class Preferences extends GPreferences { if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link, MessageManager.getString("label.new_sequence_url_link"), - JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION) + JvOptionPane.OK_CANCEL_OPTION, -1, + null) == JvOptionPane.OK_OPTION) { if (link.checkValid()) { if (((UrlLinkTableModel) linkUrlTable.getModel()) .isUniqueName(link.getName())) { - ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow( - link.getName(), link.getURL()); + ((UrlLinkTableModel) linkUrlTable.getModel()) + .insertRow(link.getName(), link.getURL()); valid = true; } else @@ -1024,7 +1083,8 @@ public class Preferences extends GPreferences { if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link, MessageManager.getString("label.edit_sequence_url_link"), - JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION) + JvOptionPane.OK_CANCEL_OPTION, -1, + null) == JvOptionPane.OK_OPTION) { if (link.checkValid()) { @@ -1070,13 +1130,12 @@ public class Preferences extends GPreferences ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex); } - @Override public void defaultBrowser_mouseClicked(MouseEvent e) { JFileChooser chooser = new JFileChooser("."); - chooser.setDialogTitle(MessageManager - .getString("label.select_default_browser")); + chooser.setDialogTitle( + MessageManager.getString("label.select_default_browser")); int value = chooser.showOpenDialog(this); @@ -1133,6 +1192,63 @@ public class Preferences extends GPreferences } @Override + public void gapColour_actionPerformed(JPanel gap) + { + if (!useLegacyGap.isSelected()) + { + Color col = JColorChooser.showDialog(this, + MessageManager.getString("label.select_gap_colour"), + gapColour.getBackground()); + if (col != null) + { + gap.setBackground(col); + } + gap.repaint(); + } + } + + @Override + public void hiddenColour_actionPerformed(JPanel hidden) + { + Color col = JColorChooser.showDialog(this, + MessageManager.getString("label.select_hidden_colour"), + hiddenColour.getBackground()); + if (col != null) + { + hidden.setBackground(col); + } + hidden.repaint(); + } + + @Override + protected void useLegacyGaps_actionPerformed(ActionEvent e) + { + boolean enabled = useLegacyGap.isSelected(); + if (enabled) + { + gapColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP); + } + else + { + gapColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP); + } + gapColour.setEnabled(!enabled); + gapLabel.setEnabled(!enabled); + } + + @Override + protected void resetOvDefaults_actionPerformed(ActionEvent e) + { + useLegacyGap.setSelected(false); + useLegacyGaps_actionPerformed(null); + showHiddenAtStart.setSelected(true); + hiddenColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN); + } + + @Override protected void userIdWidth_actionPerformed() { try @@ -1149,8 +1265,9 @@ public class Preferences extends GPreferences } } catch (NumberFormatException x) { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager - .getString("warn.user_defined_width_requirements"), + JvOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager + .getString("warn.user_defined_width_requirements"), MessageManager.getString("label.invalid_id_column_width"), JvOptionPane.WARNING_MESSAGE); userIdWidth.setText(""); @@ -1186,94 +1303,31 @@ public class Preferences extends GPreferences } /** - * Returns true if hmmer path contains the necessary valid executables, else - * show an error dialog (if showing dialog). + * 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 */ - private boolean validateHMMERPath(boolean showDialog) + protected boolean validateExecutablePath(JTextField textField, String executable) { - int missing = 0; - String message = ""; - String folder = hmmerPath.getText().trim(); + String folder = textField.getText().trim(); + + if (FileUtils.getExecutable(executable, folder) != null) + { + return true; + } if (folder.length() > 0) { - File f = new File(folder); - if (!f.exists()) - { - if (showDialog) - { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString("label.folder_not_exists"), - MessageManager.getString("label.invalid_folder"), - JvOptionPane.ERROR_MESSAGE); - } - return false; - } - AlignmentI alignment = new Alignment( - new SequenceI[] - { new Sequence("test", "WLWL", 0, 3) }); - if (canExecute(folder + "/hmmbuild")) - { - validateHMMBuild(alignment); - } - else - { - message += MessageManager.getString("label.hmmbuild_not_found") - + "\n"; - missing++; - } - - - if (canExecute(folder + "/hmmalign")) - { - - } - else - { - message += MessageManager.getString("label.hmmalign_not_found") - + "\n"; - missing++; - } - - - if (canExecute(folder + "/hmmsearch")) - { - - } - else - { - message += MessageManager.getString("label.hmmsearch_not_found") - + "\n"; - missing++; - } - } - - if (missing > 0) - { - if (missing < 3) - { - if (showDialog) - { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, message, - MessageManager.getString("label.invalid_folder"), - JvOptionPane.ERROR_MESSAGE); - } - return false; - } - else - { - if (showDialog) - { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString("label.no_binaries"), - MessageManager.getString("label.invalid_folder"), - JvOptionPane.ERROR_MESSAGE); - } - - return false; - } - } - - return true; + JvOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager.formatMessage("label.executable_not_found", + executable), + MessageManager.getString("label.invalid_folder"), + JvOptionPane.ERROR_MESSAGE); + } + return false; } /** @@ -1300,57 +1354,6 @@ public class Preferences extends GPreferences } /** - * Runs hmmbuild to check if it is working. While doing this it parses the - * version of HMMER. - * - * @param frame - * @return - */ - public boolean validateHMMBuild(AlignmentI alignment) - { - HMMBuildThread hmmbuild = new HMMBuildThread(alignment); - hmmbuild.hmmbuildWaitTillComplete(); - SequenceI hmmSeq = alignment.getSequenceAt(1); - HiddenMarkovModel hmm; - if (hmmSeq.isHMMConsensusSequence() && hmmSeq.getHMM() != null) - { - hmm = hmmSeq.getHMM(); - - if (hmm.getNumberOfSymbols() < 1) - { - return false; - } - } - else - { - return false; - } - - String header = hmm.getFileHeader(); - if (header == null) - { - return false; - } - else - { - Scanner scanner = new Scanner(header); - scanner.next(); - String string = scanner.next(); - String version = string.substring(1); - Cache.setProperty("HMMER_VERSION", version); - scanner.close(); - - } - return true; - } - - - private boolean validateHMMERPath() - { - return validateHMMERPath(true); - } - - /** * If Chimera is selected, check it can be found on default or user-specified * path, if not show a warning/help dialog. */ @@ -1379,8 +1382,7 @@ public class Preferences extends GPreferences if (!found) { String[] options = { "OK", "Help" }; - int showHelp = JvOptionPane.showInternalOptionDialog( - Desktop.desktop, + int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop, JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.chimera_missing")), "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE, @@ -1398,6 +1400,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; @@ -1452,7 +1466,7 @@ public class Preferences extends GPreferences return name.hashCode() + code.hashCode(); } } - + private class UrlListSelectionHandler implements ListSelectionListener { @@ -1492,5 +1506,5 @@ public class Preferences extends GPreferences editLink.setEnabled(false); } } -} + } }