label.vamsas_document_import_failed = Vamsas Document Import Failed
label.couldnt_locate = Couldn't locate {0}
label.url_not_found = URL not found
-label.no_link_selected = No link selected
label.new_sequence_url_link = New sequence URL link
label.cannot_edit_annotations_in_wrapped_view = Cannot edit annotations in wrapped view
label.wrapped_view_no_edit = Wrapped view - no edit
label.insert = Insert:
action.seq_id = $SEQUENCE_ID$
action.db_acc = $DB_ACCESSION$
-label.default = Default
+label.default = On Click
label.inmenu = In Menu
-label.id = ID
\ No newline at end of file
+label.id = ID
+label.urltooltip = Only one url, which must use a sequence id, can be selected for the 'On Click' option
+label.edit_sequence_url_link = Edit sequence URL link
\ No newline at end of file
label.vamsas_document_import_failed = Fallo en la importaciĆ³n del documento Vamsas
label.couldnt_locate = No se pudo localizar {0}
label.url_not_found = URL no encontrada
-label.no_link_selected = Enlace no seleccionado
label.new_sequence_url_link = Enlace a una nueva secuencia URL
label.cannot_edit_annotations_in_wrapped_view = No se pueden editar anotaciones en vista envolvente
label.wrapped_view_no_edit = Vista envolvente - no editar
label.insert = Insert:
action.seq_id = $SEQUENCE_ID$
action.db_acc = $DB_ACCESSION$
-label.default = Default
+label.default = On Click
label.inmenu = In Menu
-label.id = ID
\ No newline at end of file
+label.id = ID
+label.urltooltip = Only one url, which must use a sequence id, can be selected for the 'On Click' option
+label.edit_sequence_url_link = Edit sequence URL link
\ No newline at end of file
* <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
* <li>SEQUENCE_LINKS list of name|URL pairs for opening a url with
* $SEQUENCE_ID$</li>
+ * <li>STORED_LINKS list of name|url pairs which user has entered but are not
+ * currently used
+ * <li>DEFAULT_LINK name of single url to be used when user double clicks a
+ * sequence id (must be in SEQUENCE_LINKS or STORED_LINKS)
* <li>GROUP_LINKS list of name|URL[|<separator>] tuples - see
* jalview.utils.GroupURLLink for more info</li>
* <li>DAS_REGISTRY_URL the registry to query</li>
public static List<String> 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();
linkUrlTable.setRowSorter(sorter);
List<RowSorter.SortKey> sortKeys = new ArrayList<>();
- sortKeys.add(new RowSorter.SortKey(3,
+ UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
+ sortKeys.add(new RowSorter.SortKey(m.getDefaultColumn(),
+ SortOrder.DESCENDING));
+ sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
SortOrder.DESCENDING));
- sortKeys.add(new RowSorter.SortKey(2, SortOrder.DESCENDING));
- sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
+ sortKeys.add(new RowSorter.SortKey(m.getNameColumn(),
+ SortOrder.ASCENDING));
sorter.setSortKeys(sortKeys);
sorter.sort();
public boolean include(
Entry<? extends TableModel, ? extends Object> entry)
{
- String id = entry.getStringValue(4);
+ int col = ((UrlLinkTableModel) entry.getModel()).getIdColumn();
+ String id = entry.getStringValue(col);
return sequenceUrlLinks.isUserEntry(id);
}
};
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()));
}
});
new UrlListSelectionHandler());
// set up radio buttons
- linkUrlTable.getColumn("Default").setCellRenderer(
+ int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
+ .getDefaultColumn();
+ 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
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;
}
while (!valid)
{
if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
- MessageManager.getString("label.new_sequence_url_link"),
+ MessageManager.getString("label.edit_sequence_url_link"),
JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
{
if (link.checkValid())
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
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
+ int col = ((UrlLinkTableModel) linkUrlTable.getModel())
+ .getNameColumn();
+ if (!sequenceUrlLinks.isUserEntry((String) linkUrlTable.getModel()
+ .getValueAt(modelIndex, col)))
{
// entry is not a user-defined url and so should not be edited
// disable edit and delete buttons
editLink.setEnabled(true);
}
- // BUT it's the default url, don't allow deletion
- if ((boolean) linkUrlTable.getValueAt(index, 3))
+ // BUT if it's the default url, don't allow deletion
+ col = ((UrlLinkTableModel) linkUrlTable.getModel())
+ .getDefaultColumn();
+ if ((boolean) linkUrlTable.getValueAt(index, col))
{
deleteLink.setEnabled(false);
}
proxyPortTB.setEnabled(enabled);
}
+ /**
+ * Customer renderer for JTable: supports column of radio buttons
+ */
public class RadioButtonRenderer extends JRadioButton implements
TableCellRenderer
{
public RadioButtonRenderer()
{
setHorizontalAlignment(CENTER);
+ setToolTipText(MessageManager.getString("label.urltooltip"));
}
@Override
setBackground(table.getBackground());
setForeground(table.getForeground());
}
-
return this;
}
}
+ /**
+ * Customer cell editor for JTable: supports column of radio buttons in
+ * conjunction with renderer
+ */
public class RadioButtonEditor extends AbstractCellEditor implements
TableCellEditor
{
public RadioButtonEditor()
{
- // this.button.setHorizontalAlignment(SwingConstants.CENTER);
+ button.setHorizontalAlignment(SwingConstants.CENTER);
this.button.addActionListener(new ActionListener()
{
@Override
@Override
public boolean setDefaultUrl(String id)
{
- if (id == null)
+ /*if (id == null)
{
defaultUrl = null;
- }
+ }*/
if (selectedUrls.containsKey(id))
{
defaultUrl = id;
{
defaultUrl = id;
}
+ else
+ {
+ defaultUrl = null;
+ }
return (defaultUrl != null);
}
@Override
public boolean setDefaultUrl(String id)
{
- if (id == null)
- {
- defaultUrl = null;
- }
if (urls.containsKey(id))
{
defaultUrl = id;
}
+ else
+ {
+ defaultUrl = null;
+ }
return urls.containsKey(id);
}
package jalview.urls;
import jalview.util.MessageManager;
+import jalview.util.UrlLink;
import java.util.ArrayList;
import java.util.List;
private String id; // id is not supplied to display, but used to identify
// entries when saved
- private String name;
-
- private String url;
-
private boolean isDefault;
private boolean isSelected;
+ private UrlLink link;
+
// Headers for columns in table
private final static List<String> colNames = new ArrayList<String>()
{
public final static int ID = 4;
- public UrlLinkDisplay(String rowId, String rowName, String rowUrl,
+ public UrlLinkDisplay(String rowId, UrlLink rowLink,
boolean rowSelected, boolean rowDefault)
{
id = rowId;
- name = rowName;
- url = rowUrl;
isDefault = rowDefault;
isSelected = rowSelected;
+
+ link = rowLink;
}
// getters/setters
public String getName()
{
- return name;
+ return link.getLabel();
}
public String getUrl()
{
- return url;
+ return link.getUrlWithToken();
}
public boolean getIsDefault()
return isSelected;
}
+ public void setName(String name)
+ {
+ link.setLabel(name);
+ }
+
public void setUrl(String rowUrl)
{
- url = rowUrl;
+ link = new UrlLink(rowUrl);
}
public void setIsDefault(boolean rowDefault)
case ID:
return id;
case URL:
- return url;
+ return getUrl();
case DEFAULT:
return isDefault;
case SELECTED:
return isSelected;
case NAME:
- return name;
+ return getName();
default:
return null;
}
id = (String) value;
break;
case URL:
- url = (String) value;
+ setUrl((String) value);
break;
case DEFAULT:
isDefault = (boolean) value;
isSelected = (boolean) value;
break;
case NAME:
- name = (String) value;
+ setName((String) value);
break;
default:
// do nothing
*/
public boolean isEditable(int index)
{
- return ((index == DEFAULT) || (index == SELECTED));
+ if (index == DEFAULT)
+ {
+ // default link must be a $SEQUENCE_ID$ link
+ // so only allow editing if it is
+ return (!link.usesDBAccession());
+ }
+ else if (index == SELECTED)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
/**
package jalview.urls;
+import jalview.bin.Cache;
+import jalview.util.UrlLink;
+
import java.util.Iterator;
import java.util.List;
@Override
public void tableChanged(TableModelEvent e)
{
- // update the UrlProvider from data list
- dataProvider.setUrlData(data);
+ try
+ {
+ // update the UrlProvider from data list
+ dataProvider.setUrlData(data);
+ } catch (IllegalArgumentException ex)
+ {
+ Cache.log.error(ex.getMessage());
+ }
}
});
public int insertRow(String name, String url)
{
// add a row to the data
- UrlLinkDisplay u = new UrlLinkDisplay(name, name, url, true, false);
+ UrlLink link = new UrlLink(name, url);
+ UrlLinkDisplay u = new UrlLinkDisplay(name, link, true, false);
int index = data.size();
data.add(u);
return index;
}
+ public int getDefaultColumn()
+ {
+ return UrlLinkDisplay.DEFAULT;
+ }
+
+ public int getNameColumn()
+ {
+ return UrlLinkDisplay.NAME;
+ }
+
+ public int getIdColumn()
+ {
+ return UrlLinkDisplay.ID;
+ }
+
+ public int getUrlColumn()
+ {
+ return UrlLinkDisplay.URL;
+ }
+
+ public int getSelectedColumn()
+ {
+ return UrlLinkDisplay.SELECTED;
+ }
}
// check that the defaultUrl still exists
if (!setDefaultUrl(defaultUrlString))
{
+ // if the defaultUrl can't be found in any of the providers
+ // set up a custom default url
chooseDefaultUrl();
}
}
{
isSelected = selected;
}
- String displayLink = entry.getValue().getUrlWithToken();
- displayLinks.add(new UrlLinkDisplay(key, entry.getValue().getLabel(),
- displayLink, isSelected, isDefault));
+ displayLinks.add(new UrlLinkDisplay(key, entry.getValue(),
+ isSelected, isDefault));
}
return displayLinks;
}
}
/**
+ * Alternative constructor for separate name and link
+ *
+ * @param name
+ * @param url
+ */
+ public UrlLink(String name, String url)
+ {
+ this(name + SEP + url);
+ }
+
+ /**
* @return the url_suffix
*/
public String getUrl_suffix()
* Test that the table model is correctly initialised
* Display columns and default row are set; data provider listening event set up
*/
- @Test
+ @Test(groups = { "Functional" })
public void testInitialisation()
{
int defaultCol = 3;
/*
* Test row and column counts
*/
- @Test
+ @Test(groups = { "Functional" })
public void testCounts()
{
UrlLinkTableModel m = new UrlLinkTableModel(prov);
/*
* Test column access
*/
- @Test
+ @Test(groups = { "Functional" })
public void testColumns()
{
UrlLinkTableModel m = new UrlLinkTableModel(prov);
/*
* Test row insertion
*/
- @Test
+ @Test(groups = { "Functional" })
public void testRowInsert()
{
UrlLinkTableModel m = new UrlLinkTableModel(prov);
/*
* Test row deletion
*/
- @Test
+ @Test(groups = { "Functional" })
public void testRowDelete()
{
UrlLinkTableModel m = new UrlLinkTableModel(prov);
/*
* Test value setting and getting
*/
- @Test
+ @Test(groups = { "Functional" })
public void testValues()
{
UrlLinkTableModel m = new UrlLinkTableModel(prov);
/*
* Test cell editability
*/
- @Test
+ @Test(groups = { "Functional" })
public void testEditable()
{
UrlLinkTableModel m = new UrlLinkTableModel(prov);