X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=8b4f85f274aa4ec0cab360fd9a7edecf66fae6f8;hb=5ce879f136eba981bd2eccc6a2649e0c3a430b33;hp=b57b951b89dc730f137940821b0f31ba9bb4806c;hpb=2332cc49df69d7b21359814e3b847609a7cd61e6;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index b57b951..8b4f85f 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -20,27 +20,30 @@ */ package jalview.gui; -import static jalview.util.UrlConstants.EMBLEBI_STRING; -import static jalview.util.UrlConstants.OLD_EMBLEBI_STRING; -import static jalview.util.UrlConstants.SEQUENCE_ID; -import static jalview.util.UrlConstants.SEQUENCE_NAME; -import static jalview.util.UrlConstants.SRS_STRING; - import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; import jalview.gui.Help.HelpId; import jalview.gui.StructureViewer.ViewerType; +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.schemes.ColourSchemeI; +import jalview.schemes.ColourSchemes; +import jalview.schemes.ResidueColourScheme; +import jalview.urls.UrlLinkTableModel; +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; import jalview.ws.sifts.SiftsSettings; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; @@ -49,15 +52,24 @@ import java.awt.event.MouseEvent; import java.io.File; import java.util.ArrayList; import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; 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; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; import ext.edu.ucsf.rbvi.strucviz2.StructureManager; @@ -95,6 +107,8 @@ public class Preferences extends GPreferences 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; @@ -103,7 +117,9 @@ public class Preferences extends GPreferences * Holds name and link separated with | character. Sequence ID must be * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$ */ - public static Vector sequenceURLLinks; + public static UrlProviderI sequenceUrlLinks; + + public static UrlLinkTableModel dataModel; /** * Holds name and link separated with | character. Sequence IDS and Sequences @@ -116,57 +132,32 @@ public class Preferences extends GPreferences public static List groupURLLinks; static { - String string = Cache.getDefault("SEQUENCE_LINKS", EMBLEBI_STRING); - sequenceURLLinks = new Vector(); - - try - { - StringTokenizer st = new StringTokenizer(string, "|"); - while (st.hasMoreElements()) - { - String name = st.nextToken(); - String url = st.nextToken(); - // check for '|' within a regex - int rxstart = url.indexOf("$" + SEQUENCE_ID + "$"); - if (rxstart == -1) - { - rxstart = url.indexOf("$" + SEQUENCE_NAME + "$"); - } - while (rxstart == -1 && url.indexOf("/=$") == -1) - { - url = url + "|" + st.nextToken(); - } - sequenceURLLinks.addElement(name + "|" + url); - } - } catch (Exception ex) + // 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()) { - System.out.println(ex + "\nError parsing sequence links"); - } - { - // upgrade old SRS link - int srsPos = sequenceURLLinks.indexOf(SRS_STRING); - if (srsPos > -1) - { - sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos); - } - // upgrade old EMBL-EBI link - int emblPos = sequenceURLLinks.indexOf(OLD_EMBLEBI_STRING); - if (emblPos > -1) - { - sequenceURLLinks.setElementAt(EMBLEBI_STRING, emblPos); - } + inMenuString = UrlConstants.DEFAULT_STRING; } + UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl, + inMenuString, notInMenuString); + sequenceUrlLinks = factory.createUrlProvider(); + dataModel = new UrlLinkTableModel(sequenceUrlLinks); /** * TODO: reformulate groupURL encoding so two or more can be stored in the * .properties file as '|' separated strings */ - groupURLLinks = new ArrayList(); + groupURLLinks = new ArrayList<>(); } - Vector nameLinks, urlLinks; - JInternalFrame frame; DasSourceBrowser dasSource; @@ -221,6 +212,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( @@ -229,6 +221,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", @@ -297,12 +292,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); @@ -350,20 +349,128 @@ public class Preferences extends GPreferences /* * Set Connections tab defaults */ - nameLinks = new Vector(); - urlLinks = new Vector(); - for (int i = 0; i < sequenceURLLinks.size(); i++) + + // set up sorting + linkUrlTable.setModel(dataModel); + final TableRowSorter sorter = new TableRowSorter<>( + linkUrlTable.getModel()); + linkUrlTable.setRowSorter(sorter); + List sortKeys = new ArrayList<>(); + + UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel(); + sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(), + SortOrder.DESCENDING)); + sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(), + SortOrder.DESCENDING)); + sortKeys.add(new RowSorter.SortKey(m.getNameColumn(), + SortOrder.ASCENDING)); + + sorter.setSortKeys(sortKeys); + sorter.sort(); + + // set up filtering + ActionListener onReset; + onReset = new ActionListener() { - String link = sequenceURLLinks.elementAt(i).toString(); - nameLinks.addElement(link.substring(0, link.indexOf("|"))); - urlLinks.addElement(link.substring(link.indexOf("|") + 1)); - } + @Override + public void actionPerformed(ActionEvent e) + { + filterTB.setText(""); + sorter.setRowFilter(RowFilter.regexFilter("")); + } - updateLinkData(); + }; + doReset.addActionListener(onReset); + + // filter to display only custom urls + final RowFilter customUrlFilter = new RowFilter() + { + @Override + public boolean include( + Entry entry) + { + return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry); + } + }; + + final TableRowSorter customSorter = new TableRowSorter<>( + linkUrlTable.getModel()); + customSorter.setRowFilter(customUrlFilter); + + ActionListener onCustomOnly; + onCustomOnly = new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + filterTB.setText(""); + sorter.setRowFilter(customUrlFilter); + } + }; + userOnly.addActionListener(onCustomOnly); + + filterTB.getDocument().addDocumentListener(new DocumentListener() + { + String caseInsensitiveFlag = "(?i)"; + + @Override + public void changedUpdate(DocumentEvent e) + { + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + + filterTB.getText())); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + + filterTB.getText())); + } + + @Override + public void insertUpdate(DocumentEvent e) + { + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + + filterTB.getText())); + } + }); + + // set up list selection functionality + 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) + .setCellEditor(new RadioButtonEditor()); + + // get boolean columns and resize those to min possible + for (int column = 0; column < linkUrlTable.getColumnCount(); column++) + { + if (linkUrlTable.getModel().getColumnClass(column) + .equals(Boolean.class)) + { + TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn( + column); + int preferredWidth = tableColumn.getMinWidth(); + + TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0, + column); + Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column); + int cwidth = c.getPreferredSize().width + + linkUrlTable.getIntercellSpacing().width; + preferredWidth = Math.max(preferredWidth, cwidth); + + tableColumn.setPreferredWidth(preferredWidth); + } + } useProxy.setSelected(Cache.getDefault("USE_PROXY", false)); - proxyServerTB.setEnabled(useProxy.isSelected()); - proxyPortTB.setEnabled(useProxy.isSelected()); + useProxy_actionPerformed(); // make sure useProxy is correctly initialised proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", "")); proxyPortTB.setText(Cache.getDefault("PROXY_PORT", "")); @@ -471,6 +578,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", @@ -479,6 +588,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, @@ -555,27 +668,32 @@ public class Preferences extends GPreferences jalview.util.BrowserLauncher.resetBrowser(); - if (nameLinks.size() > 0) + // save user-defined and selected links + String menuLinks = sequenceUrlLinks.writeUrlsAsString(true); + if (menuLinks.isEmpty()) + { + Cache.applicationProperties.remove("SEQUENCE_LINKS"); + } + else { - StringBuffer links = new StringBuffer(); - sequenceURLLinks = new Vector(); - for (int i = 0; i < nameLinks.size(); i++) - { - sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|" - + urlLinks.elementAt(i)); - links.append(sequenceURLLinks.elementAt(i).toString()); - links.append("|"); - } - // remove last "|" - links.setLength(links.length() - 1); Cache.applicationProperties.setProperty("SEQUENCE_LINKS", - links.toString()); + menuLinks.toString()); + } + + String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false); + if (nonMenuLinks.isEmpty()) + { + Cache.applicationProperties.remove("STORED_LINKS"); } else { - Cache.applicationProperties.remove("SEQUENCE_LINKS"); + Cache.applicationProperties.setProperty("STORED_LINKS", + nonMenuLinks.toString()); } + Cache.applicationProperties.setProperty("DEFAULT_URL", + sequenceUrlLinks.getPrimaryUrlId()); + Cache.applicationProperties.setProperty("USE_PROXY", Boolean.toString(useProxy.isSelected())); @@ -692,12 +810,9 @@ public class Preferences extends GPreferences @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")); @@ -706,8 +821,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()); } @@ -744,32 +863,42 @@ 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 public void newLink_actionPerformed(ActionEvent e) { - GSequenceLink link = new GSequenceLink(); 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()) { - nameLinks.addElement(link.getName()); - urlLinks.addElement(link.getURL()); - updateLinkData(); - valid = true; + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isUniqueName(link.getName())) + { + ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow( + link.getName(), link.getURL()); + valid = true; + } + else + { + link.notifyDuplicate(); + continue; + } } } else @@ -784,36 +913,46 @@ public class Preferences extends GPreferences { GSequenceLink link = new GSequenceLink(); - int index = linkNameList.getSelectedIndex(); + int index = linkUrlTable.getSelectedRow(); if (index == -1) { - 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(nameLinks.elementAt(index).toString()); - link.setURL(urlLinks.elementAt(index).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()) { - nameLinks.setElementAt(link.getName(), index); - urlLinks.setElementAt(link.getURL(), index); - updateLinkData(); - 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 { break; @@ -824,26 +963,24 @@ public class Preferences extends GPreferences @Override public void deleteLink_actionPerformed(ActionEvent e) { - int index = linkNameList.getSelectedIndex(); + int index = linkUrlTable.getSelectedRow(); + int modelIndex = -1; if (index == -1) { - 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; } - nameLinks.removeElementAt(index); - urlLinks.removeElementAt(index); - updateLinkData(); - } + else + { + modelIndex = linkUrlTable.convertRowIndexToModel(index); + } - void updateLinkData() - { - linkNameList.setListData(nameLinks); - linkURLList.setListData(urlLinks); + // make sure we use the model index to delete, and not the table index + ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex); } + @Override public void defaultBrowser_mouseClicked(MouseEvent e) { @@ -922,10 +1059,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(""); } } @@ -948,10 +1085,10 @@ 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; } } @@ -987,13 +1124,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 { @@ -1060,4 +1197,45 @@ public class Preferences extends GPreferences return name.hashCode() + code.hashCode(); } } + + private class UrlListSelectionHandler implements ListSelectionListener + { + + @Override + public void valueChanged(ListSelectionEvent e) + { + ListSelectionModel lsm = (ListSelectionModel) e.getSource(); + + int index = lsm.getMinSelectionIndex(); + if (index == -1) + { + // no selection, so disable delete/edit buttons + editLink.setEnabled(false); + deleteLink.setEnabled(false); + return; + } + int modelIndex = linkUrlTable.convertRowIndexToModel(index); + + // enable/disable edit and delete link buttons + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isRowDeletable(modelIndex)) + { + deleteLink.setEnabled(true); + } + else + { + deleteLink.setEnabled(false); + } + + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isRowEditable(modelIndex)) + { + editLink.setEnabled(true); + } + else + { + editLink.setEnabled(false); + } + } +} }