X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=c8fef96f847e03f8ece4b6f51141f5ec211f3b20;hb=46406ae21c62b964714ce136c9d692985c17211d;hp=efe1ed6584fc5dcbfc406744cb3d41172a891bb3;hpb=e63a4d52c27252dfb83efeeee1bda6c89b6dddec;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index efe1ed6..c8fef96 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -22,17 +22,26 @@ 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.io.FileFormatI; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; import jalview.jbgui.GPreferences; import jalview.jbgui.GSequenceLink; -import jalview.schemes.ColourSchemeProperty; -import jalview.urls.DesktopUrlProviderFactory; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ColourSchemes; +import jalview.schemes.ResidueColourScheme; import jalview.urls.UrlLinkTableModel; -import jalview.urls.UrlProviderFactoryI; -import jalview.urls.UrlProviderI; +import jalview.urls.api.UrlProviderFactoryI; +import jalview.urls.api.UrlProviderI; +import jalview.urls.desktop.DesktopUrlProviderFactory; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.util.UrlConstants; @@ -49,12 +58,12 @@ 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.JOptionPane; import javax.swing.JPanel; import javax.swing.ListSelectionModel; import javax.swing.RowFilter; @@ -100,11 +109,15 @@ 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"; public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE"; + public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY"; + private static final int MIN_FONT_SIZE = 1; private static final int MAX_FONT_SIZE = 30; @@ -128,11 +141,19 @@ public class Preferences extends GPreferences public static List groupURLLinks; static { - String inMenuString = Cache.getDefault("SEQUENCE_LINKS", - UrlConstants.DEFAULT_STRING); + // get links selected to be in the menu (SEQUENCE_LINKS) + // and links entered by the user but not selected (STORED_LINKS) + String inMenuString = Cache.getDefault("SEQUENCE_LINKS", ""); String notInMenuString = Cache.getDefault("STORED_LINKS", ""); String defaultUrl = Cache.getDefault("DEFAULT_URL", UrlConstants.DEFAULT_LABEL); + + // if both links lists are empty, add the DEFAULT_URL link + // otherwise we assume the default link is in one of the lists + if (inMenuString.isEmpty() && notInMenuString.isEmpty()) + { + inMenuString = UrlConstants.DEFAULT_STRING; + } UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl, inMenuString, notInMenuString); sequenceUrlLinks = factory.createUrlProvider(); @@ -143,7 +164,7 @@ public class Preferences extends GPreferences * .properties file as '|' separated strings */ - groupURLLinks = new ArrayList(); + groupURLLinks = new ArrayList<>(); } JInternalFrame frame; @@ -187,6 +208,34 @@ public class Preferences extends GPreferences frame.setMinimumSize(new Dimension(width, height)); /* + * Set HMMER tab defaults + */ + trimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false)); + isHMMERInstalled + .setSelected(Cache.getDefault("HMMER_INSTALLED", false)); + if (Cache.getDefault("USE_UNIPROT", false)) + { + uniprot.setSelected(true); + } + else + { + alignment.setSelected(true); + } + numberOfSequencesToKeepField + .setText(Cache.getProperty("SEQUENCES_TO_KEEP")); + installationLocation.setEnabled(isHMMERInstalled.isSelected()); + hmmerPath.setEnabled(isHMMERInstalled.isSelected()); + hmmerPath.setText(Cache.getProperty(HMMER_PATH)); + hmmerPath.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + validateHMMERPath(); + } + }); + + /* * Set Visual tab defaults */ seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true)); @@ -200,6 +249,7 @@ public class Preferences extends GPreferences openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false)); 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( @@ -208,6 +258,9 @@ public class Preferences extends GPreferences "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", @@ -276,12 +329,16 @@ public class Preferences extends GPreferences /* * Set Colours tab defaults */ - for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++) + protColour.addItem(ResidueColourScheme.NONE); + nucColour.addItem(ResidueColourScheme.NONE); + for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes()) { - protColour.addItem(ColourSchemeProperty.getColourName(i)); - nucColour.addItem(ColourSchemeProperty.getColourName(i)); + String name = cs.getSchemeName(); + protColour.addItem(name); + nucColour.addItem(name); } - String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None"); + String oldProp = Cache.getDefault(DEFAULT_COLOUR, + ResidueColourScheme.NONE); String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null); protColour.setSelectedItem(newProp != null ? newProp : oldProp); newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null); @@ -337,10 +394,13 @@ public class Preferences extends GPreferences linkUrlTable.setRowSorter(sorter); List sortKeys = new ArrayList<>(); - sortKeys.add(new RowSorter.SortKey(3, + UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel(); + sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(), SortOrder.DESCENDING)); - sortKeys.add(new RowSorter.SortKey(2, SortOrder.DESCENDING)); - sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING)); + sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(), + SortOrder.DESCENDING)); + sortKeys.add(new RowSorter.SortKey(m.getNameColumn(), + SortOrder.ASCENDING)); sorter.setSortKeys(sortKeys); sorter.sort(); @@ -366,8 +426,7 @@ public class Preferences extends GPreferences public boolean include( Entry entry) { - String id = entry.getStringValue(4); - return sequenceUrlLinks.isUserEntry(id); + return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry); } }; @@ -389,24 +448,26 @@ public class Preferences extends GPreferences filterTB.getDocument().addDocumentListener(new DocumentListener() { + String caseInsensitiveFlag = "(?i)"; + @Override public void changedUpdate(DocumentEvent e) { - sorter.setRowFilter(RowFilter.regexFilter("(?i)" + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + filterTB.getText())); } @Override public void removeUpdate(DocumentEvent e) { - sorter.setRowFilter(RowFilter.regexFilter("(?i)" + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + filterTB.getText())); } @Override public void insertUpdate(DocumentEvent e) { - sorter.setRowFilter(RowFilter.regexFilter("(?i)" + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + filterTB.getText())); } }); @@ -416,9 +477,12 @@ public class Preferences extends GPreferences new UrlListSelectionHandler()); // set up radio buttons - linkUrlTable.getColumn("Default").setCellRenderer( + int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel()) + .getPrimaryColumn(); + String onClickName = linkUrlTable.getColumnName(onClickCol); + linkUrlTable.getColumn(onClickName).setCellRenderer( new RadioButtonRenderer()); - linkUrlTable.getColumn("Default") + linkUrlTable.getColumn(onClickName) .setCellEditor(new RadioButtonEditor()); // get boolean columns and resize those to min possible @@ -444,8 +508,6 @@ public class Preferences extends GPreferences useProxy.setSelected(Cache.getDefault("USE_PROXY", false)); useProxy_actionPerformed(); // make sure useProxy is correctly initialised - proxyServerTB.setEnabled(useProxy.isSelected()); - proxyPortTB.setEnabled(useProxy.isSelected()); proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", "")); proxyPortTB.setText(Cache.getDefault("PROXY_PORT", "")); @@ -553,6 +615,8 @@ public class Preferences extends GPreferences Boolean.toString(idItalics.isSelected())); Cache.applicationProperties.setProperty("SHOW_UNCONSERVED", Boolean.toString(showUnconserved.isSelected())); + Cache.applicationProperties.setProperty(SHOW_OCCUPANCY, + Boolean.toString(showOccupancy.isSelected())); Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS", Boolean.toString(showGroupConsensus.isSelected())); Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION", @@ -561,6 +625,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, @@ -607,6 +675,44 @@ 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, + 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)); + AlignFrame[] frames = Desktop.getAlignFrames(); + boolean hmmerStatus = hmmerFunctioning && hmmerInstalled ? true : false; + for (AlignFrame frame : frames) + { + frame.updateHMMERStatus(hmmerStatus); + } + + + 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")); + hmmerPath.setText(Cache.getProperty(HMMER_PATH)); + + /* * Save Structure settings */ Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN, @@ -661,7 +767,7 @@ public class Preferences extends GPreferences } Cache.applicationProperties.setProperty("DEFAULT_URL", - sequenceUrlLinks.getDefaultUrlId()); + sequenceUrlLinks.getPrimaryUrlId()); Cache.applicationProperties.setProperty("USE_PROXY", Boolean.toString(useProxy.isSelected())); @@ -763,6 +869,14 @@ public class Preferences extends GPreferences structureTab.requestFocusInWindow(); return false; } + if (isHMMERInstalled.isSelected()) + { + if (!validateHMMER()) + { + hmmerTab.requestFocusInWindow(); + return false; + } + } return true; } @@ -773,18 +887,22 @@ public class Preferences extends GPreferences } + @Override + protected boolean validateHMMER() + { + return validateHMMERPath(); + + } + /** * DOCUMENT ME! */ @Override public void startupFileTextfield_mouseClicked() { - JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF", - "PIR", "BLC", "Jalview" }, - jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); + JalviewFileChooser chooser = JalviewFileChooser.forRead( + Cache.getProperty("LAST_DIRECTORY"), fileFormat); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.select_startup_file")); @@ -793,8 +911,12 @@ public class Preferences extends GPreferences if (value == JalviewFileChooser.APPROVE_OPTION) { - jalview.bin.Cache.applicationProperties.setProperty( - "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat()); + FileFormatI format = chooser.getSelectedFormat(); + if (format != null) + { + Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT", + format.getName()); + } startupFileTextfield.setText(chooser.getSelectedFile() .getAbsolutePath()); } @@ -831,12 +953,15 @@ public class Preferences extends GPreferences conservation.setEnabled(annotations.isSelected()); quality.setEnabled(annotations.isSelected()); identity.setEnabled(annotations.isSelected()); + showOccupancy.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())); + showInformationHistogram.setEnabled(annotations.isSelected()); + showHMMLogo.setEnabled(annotations.isSelected()); } @Override @@ -846,15 +971,24 @@ public class Preferences extends GPreferences boolean valid = false; while (!valid) { - if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link, + if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link, MessageManager.getString("label.new_sequence_url_link"), - JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION) + JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION) { if (link.checkValid()) { - ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow( - link.getName(), link.getURL()); - valid = true; + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isUniqueName(link.getName())) + { + ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow( + link.getName(), link.getURL()); + valid = true; + } + else + { + link.notifyDuplicate(); + continue; + } } } else @@ -872,29 +1006,41 @@ public class Preferences extends GPreferences int index = linkUrlTable.getSelectedRow(); if (index == -1) { - // no row was selected - JOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString("label.no_link_selected"), - MessageManager.getString("label.no_link_selected"), - JOptionPane.WARNING_MESSAGE); + // button no longer enabled if row is not selected + Cache.log.debug("Edit with no row selected in linkUrlTable"); return; } - link.setName(linkUrlTable.getValueAt(index, 0).toString()); - link.setURL(linkUrlTable.getValueAt(index, 1).toString()); + int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel()) + .getNameColumn(); + int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel()) + .getUrlColumn(); + String oldName = linkUrlTable.getValueAt(index, nameCol).toString(); + link.setName(oldName); + link.setURL(linkUrlTable.getValueAt(index, urlCol).toString()); boolean valid = false; while (!valid) { - if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link, - MessageManager.getString("label.new_sequence_url_link"), - JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION) + if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link, + MessageManager.getString("label.edit_sequence_url_link"), + JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION) { if (link.checkValid()) { - linkUrlTable.setValueAt(link.getName(), index, 0); - linkUrlTable.setValueAt(link.getURL(), index, 1); - valid = true; + if ((oldName.equals(link.getName())) + || (((UrlLinkTableModel) linkUrlTable.getModel()) + .isUniqueName(link.getName()))) + { + linkUrlTable.setValueAt(link.getName(), index, nameCol); + linkUrlTable.setValueAt(link.getURL(), index, urlCol); + valid = true; + } + else + { + link.notifyDuplicate(); + continue; + } } } else @@ -911,11 +1057,8 @@ public class Preferences extends GPreferences int modelIndex = -1; if (index == -1) { - // no row is selected - JOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString("label.no_link_selected"), - MessageManager.getString("label.no_link_selected"), - JOptionPane.WARNING_MESSAGE); + // button no longer enabled if row is not selected + Cache.log.debug("Delete with no row selected in linkUrlTable"); return; } else @@ -1006,10 +1149,10 @@ public class Preferences extends GPreferences } } catch (NumberFormatException x) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager .getString("warn.user_defined_width_requirements"), MessageManager.getString("label.invalid_id_column_width"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); userIdWidth.setText(""); } } @@ -1032,15 +1175,180 @@ public class Preferences extends GPreferences File f = new File(chimeraPath.getText()); if (!f.canExecute()) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.invalid_chimera_path"), MessageManager.getString("label.invalid_name"), - JOptionPane.ERROR_MESSAGE); + JvOptionPane.ERROR_MESSAGE); return false; } } return true; } + + /** + * Returns true if hmmer path contains the necessary valid executables, else + * show an error dialog (if showing dialog). + */ + private boolean validateHMMERPath(boolean showDialog) + { + int missing = 0; + String message = ""; + String folder = hmmerPath.getText().trim(); + 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; + } + + /** + * 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; + } + + /** + * 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 @@ -1071,13 +1379,13 @@ public class Preferences extends GPreferences if (!found) { String[] options = { "OK", "Help" }; - int showHelp = JOptionPane.showInternalOptionDialog( + int showHelp = JvOptionPane.showInternalOptionDialog( Desktop.desktop, JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.chimera_missing")), - "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, + "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE, null, options, options[0]); - if (showHelp == JOptionPane.NO_OPTION) + if (showHelp == JvOptionPane.NO_OPTION) { try { @@ -1163,26 +1471,25 @@ public class Preferences extends GPreferences } int modelIndex = linkUrlTable.convertRowIndexToModel(index); - // determine if the new selection is a custom url or not - if (!sequenceUrlLinks.isUserEntry((String) linkUrlTable -.getModel() - .getValueAt(modelIndex, 4))) // KM TODO do this better + // enable/disable edit and delete link buttons + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isRowDeletable(modelIndex)) { - // entry is not a user-defined url and so should not be edited - // disable edit and delete buttons - deleteLink.setEnabled(false); - editLink.setEnabled(false); + deleteLink.setEnabled(true); } else { - deleteLink.setEnabled(true); - editLink.setEnabled(true); + deleteLink.setEnabled(false); } - // BUT it's the default url, don't allow deletion - if ((boolean) linkUrlTable.getValueAt(index, 3)) + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isRowEditable(modelIndex)) { - deleteLink.setEnabled(false); + editLink.setEnabled(true); + } + else + { + editLink.setEnabled(false); } } }