From a1bf90058be8be92554ecbc5868982dcdbed5a80 Mon Sep 17 00:00:00 2001 From: kiramt Date: Thu, 15 Dec 2016 17:52:48 +0000 Subject: [PATCH] JAL-2316 Changes following review. --- examples/exampleFeatures.txt | 2 +- resources/lang/Messages.properties | 2 +- resources/lang/Messages_es.properties | 2 +- src/jalview/appletgui/APopupMenu.java | 2 +- src/jalview/appletgui/IdPanel.java | 9 +++-- src/jalview/gui/Desktop.java | 4 +-- src/jalview/gui/IdPanel.java | 8 ++--- src/jalview/gui/Preferences.java | 6 ++-- src/jalview/urls/CustomUrlProvider.java | 36 ++++++++++---------- src/jalview/urls/IdentifiersUrlProvider.java | 24 ++++++------- src/jalview/urls/UrlLinkDisplay.java | 26 +++++++------- src/jalview/urls/UrlLinkTableModel.java | 32 ++++++++--------- src/jalview/urls/UrlProvider.java | 32 ++++++++--------- src/jalview/urls/UrlProviderImpl.java | 22 ++++++------ src/jalview/urls/api/UrlProviderI.java | 35 ++++++++++--------- src/jalview/ws/{ => utils}/UrlDownloadClient.java | 4 +-- .../jalview/urls/AppletUrlProviderFactoryTest.java | 8 ++--- test/jalview/urls/CustomUrlProviderTest.java | 14 ++++---- .../urls/DesktopUrlProviderFactoryTest.java | 7 ++-- test/jalview/urls/IdentifiersUrlProviderTest.java | 14 ++++---- test/jalview/urls/UrlLinkDisplayTest.java | 12 +++---- test/jalview/urls/UrlLinkTableModelTest.java | 4 +-- test/jalview/urls/UrlProviderTest.java | 17 +++++---- .../ws/{ => utils}/UrlDownloadClientTest.java | 2 +- 24 files changed, 160 insertions(+), 164 deletions(-) rename src/jalview/ws/{ => utils}/UrlDownloadClient.java (97%) rename test/jalview/ws/{ => utils}/UrlDownloadClientTest.java (98%) diff --git a/examples/exampleFeatures.txt b/examples/exampleFeatures.txt index 2de9817..83dc4b1 100755 --- a/examples/exampleFeatures.txt +++ b/examples/exampleFeatures.txt @@ -1,5 +1,5 @@ ST-TURN-IIL blue|255,0,255|absolute|20.0|95.0|below|66.0 -GAMMA-TURN-CLASSIC red|0,255,255|20.0|95.0|below|66.0 +GAMMA-TURN-CLASSIC lightGray|0,255,255|20.0|95.0|below|66.0 BETA-TURN-IR 9a6a94 BETA-TURN-IL d6a6ca BETA-BULGE 1dc451 diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 7833903..295dec4 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1282,7 +1282,7 @@ action.showall = Show All label.insert = Insert: action.seq_id = $SEQUENCE_ID$ action.db_acc = $DB_ACCESSION$ -label.default = On Click +label.primary = On Click label.inmenu = In Menu label.id = ID label.urltooltip = Only one url, which must use a sequence id, can be selected for the 'On Click' option diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 88fb0a4..1ed7ab0 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -1283,7 +1283,7 @@ action.showall = Show All label.insert = Insert: action.seq_id = $SEQUENCE_ID$ action.db_acc = $DB_ACCESSION$ -label.default = On Click +label.primary = On Click label.inmenu = In Menu label.id = ID label.urltooltip = Only one url, which must use a sequence id, can be selected for the 'On Click' option diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 015734f..a1670ea 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -196,7 +196,7 @@ public class APopupMenu extends java.awt.PopupMenu implements Menu menu1 = new Menu(); public APopupMenu(AlignmentPanel apanel, final SequenceI seq, - Vector links) + List links) { // ///////////////////////////////////////////////////////// // If this is activated from the sequence panel, the user may want to diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index 4e7c9cd..cc021f5 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -37,7 +37,6 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.HashMap; import java.util.List; -import java.util.Vector; public class IdPanel extends Panel implements MouseListener, MouseMotionListener @@ -222,8 +221,8 @@ public class IdPanel extends Panel implements MouseListener, String id = sq.getName(); // get the default url with the sequence details filled in - String url = urlProvider.getDefaultUrl(id); - String target = urlProvider.getDefaultTarget(id); + String url = urlProvider.getPrimaryUrl(id); + String target = urlProvider.getPrimaryTarget(id); try { alignPanel.alignFrame.showURL(url, target); @@ -284,7 +283,7 @@ public class IdPanel extends Panel implements MouseListener, // build a new links menu based on the current links + any non-positional // features - Vector nlinks = urlProvider.getLinksForMenu(); + List nlinks = urlProvider.getLinksForMenu(); SequenceFeature sf[] = sq == null ? null : sq.getSequenceFeatures(); for (int sl = 0; sf != null && sl < sf.length; sl++) @@ -295,7 +294,7 @@ public class IdPanel extends Panel implements MouseListener, { for (int l = 0, lSize = sf[sl].links.size(); l < lSize; l++) { - nlinks.addElement(sf[sl].links.elementAt(l)); + nlinks.add(sf[sl].links.elementAt(l)); } } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index b4b41a3..5363999 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -43,8 +43,8 @@ import jalview.util.MessageManager; import jalview.util.Platform; import jalview.util.UrlConstants; import jalview.viewmodel.AlignmentViewport; -import jalview.ws.UrlDownloadClient; import jalview.ws.params.ParamManager; +import jalview.ws.utils.UrlDownloadClient; import java.awt.BorderLayout; import java.awt.Color; @@ -2316,7 +2316,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements { // check what the actual links are - if it's just the default don't // bother with the warning - Vector links = Preferences.sequenceUrlLinks + List links = Preferences.sequenceUrlLinks .getLinksForMenu(); // only need to check links if there is one with a diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index e326a7a..6ae19f0 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -36,9 +36,7 @@ import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.util.List; -import java.util.Vector; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; @@ -200,7 +198,7 @@ public class IdPanel extends JPanel implements MouseListener, int seq = alignPanel.getSeqPanel().findSeq(e); String id = av.getAlignment().getSequenceAt(seq).getName(); - String url = Preferences.sequenceUrlLinks.getDefaultUrl(id); + String url = Preferences.sequenceUrlLinks.getPrimaryUrl(id); try { @@ -328,7 +326,7 @@ public class IdPanel extends JPanel implements MouseListener, Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq2); // build a new links menu based on the current links + any non-positional // features - Vector nlinks = Preferences.sequenceUrlLinks.getLinksForMenu(); + List nlinks = Preferences.sequenceUrlLinks.getLinksForMenu(); SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures(); if (sfs != null) { @@ -340,7 +338,7 @@ public class IdPanel extends JPanel implements MouseListener, { for (int l = 0, lSize = sf.links.size(); l < lSize; l++) { - nlinks.addElement(sf.links.elementAt(l)); + nlinks.add(sf.links.elementAt(l)); } } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 00b2a38..c5bff31 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -346,7 +346,7 @@ public class Preferences extends GPreferences List sortKeys = new ArrayList<>(); UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel(); - sortKeys.add(new RowSorter.SortKey(m.getDefaultColumn(), + sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(), SortOrder.DESCENDING)); sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(), SortOrder.DESCENDING)); @@ -429,7 +429,7 @@ public class Preferences extends GPreferences // set up radio buttons int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel()) - .getDefaultColumn(); + .getPrimaryColumn(); String onClickName = linkUrlTable.getColumnName(onClickCol); linkUrlTable.getColumn(onClickName).setCellRenderer( new RadioButtonRenderer()); @@ -676,7 +676,7 @@ public class Preferences extends GPreferences } Cache.applicationProperties.setProperty("DEFAULT_URL", - sequenceUrlLinks.getDefaultUrlId()); + sequenceUrlLinks.getPrimaryUrlId()); Cache.applicationProperties.setProperty("USE_PROXY", Boolean.toString(useProxy.isSelected())); diff --git a/src/jalview/urls/CustomUrlProvider.java b/src/jalview/urls/CustomUrlProvider.java index dae9ccd..0471e4b 100644 --- a/src/jalview/urls/CustomUrlProvider.java +++ b/src/jalview/urls/CustomUrlProvider.java @@ -199,22 +199,22 @@ public class CustomUrlProvider extends UrlProviderImpl } @Override - public boolean setDefaultUrl(String id) + public boolean setPrimaryUrl(String id) { if (selectedUrls.containsKey(id)) { - defaultUrl = id; + primaryUrl = id; } else if (nonselectedUrls.containsKey(id)) { - defaultUrl = id; + primaryUrl = id; } else { - defaultUrl = null; + primaryUrl = null; } - return (defaultUrl != null); + return (primaryUrl != null); } @Override @@ -249,26 +249,26 @@ public class CustomUrlProvider extends UrlProviderImpl } @Override - public String getDefaultUrl(String seqid) + public String getPrimaryUrl(String seqid) { - String result = super.getDefaultUrl(seqid, selectedUrls); + String result = super.getPrimaryUrl(seqid, selectedUrls); if (result == null) { - result = super.getDefaultUrl(seqid, nonselectedUrls); + result = super.getPrimaryUrl(seqid, nonselectedUrls); } return result; } @Override - public String getDefaultUrlId() + public String getPrimaryUrlId() { - return defaultUrl; + return primaryUrl; } @Override - public String getDefaultTarget(String seqid) + public String getPrimaryTarget(String seqid) { - return selectedUrls.get(defaultUrl).getTarget(); + return selectedUrls.get(primaryUrl).getTarget(); } @Override @@ -302,10 +302,10 @@ public class CustomUrlProvider extends UrlProviderImpl unselurls.put(link.getId(), new UrlLink(link.getName() + SEP + link.getUrl())); } - // sort out default and selected ids - if (link.getIsDefault()) + // sort out primary and selected ids + if (link.getIsPrimary()) { - setDefaultUrl(link.getId()); + setPrimaryUrl(link.getId()); } } @@ -315,16 +315,16 @@ public class CustomUrlProvider extends UrlProviderImpl } @Override - public String chooseDefaultUrl() + public String choosePrimaryUrl() { - // unilaterally set the default id to the EMBL_EBI link + // unilaterally set the primary id to the EMBL_EBI link if ((!nonselectedUrls.containsKey(UrlConstants.DEFAULT_LABEL)) && (!selectedUrls.containsKey(UrlConstants.DEFAULT_LABEL))) { selectedUrls.put(UrlConstants.DEFAULT_LABEL, new UrlLink( UrlConstants.DEFAULT_STRING)); } - defaultUrl = UrlConstants.DEFAULT_LABEL; + primaryUrl = UrlConstants.DEFAULT_LABEL; return UrlConstants.DEFAULT_LABEL; } diff --git a/src/jalview/urls/IdentifiersUrlProvider.java b/src/jalview/urls/IdentifiersUrlProvider.java index 6c01f97..51d181d 100644 --- a/src/jalview/urls/IdentifiersUrlProvider.java +++ b/src/jalview/urls/IdentifiersUrlProvider.java @@ -128,19 +128,19 @@ public class IdentifiersUrlProvider extends UrlProviderImpl } // reset defaultUrl in case it is no longer selected - setDefaultUrl(defaultUrl); + setPrimaryUrl(primaryUrl); } @Override - public boolean setDefaultUrl(String id) + public boolean setPrimaryUrl(String id) { if (urls.containsKey(id)) { - defaultUrl = id; + primaryUrl = id; } else { - defaultUrl = null; + primaryUrl = null; } return urls.containsKey(id); @@ -205,9 +205,9 @@ public class IdentifiersUrlProvider extends UrlProviderImpl { selectedUrls.add(link.getId()); } - if (link.getIsDefault()) + if (link.getIsPrimary()) { - setDefaultUrl(link.getId()); + setPrimaryUrl(link.getId()); } } } @@ -215,25 +215,25 @@ public class IdentifiersUrlProvider extends UrlProviderImpl } @Override - public String getDefaultUrl(String seqid) + public String getPrimaryUrl(String seqid) { - return super.getDefaultUrl(seqid, urls); + return super.getPrimaryUrl(seqid, urls); } @Override - public String getDefaultUrlId() + public String getPrimaryUrlId() { - return defaultUrl; + return primaryUrl; } @Override - public String getDefaultTarget(String seqid) + public String getPrimaryTarget(String seqid) { return null; } @Override - public String chooseDefaultUrl() + public String choosePrimaryUrl() { return null; } diff --git a/src/jalview/urls/UrlLinkDisplay.java b/src/jalview/urls/UrlLinkDisplay.java index 2582f90..5991d76 100644 --- a/src/jalview/urls/UrlLinkDisplay.java +++ b/src/jalview/urls/UrlLinkDisplay.java @@ -39,7 +39,7 @@ public class UrlLinkDisplay private String id; // id is not supplied to display, but used to identify // entries when saved - private boolean isDefault; + private boolean isPrimary; private boolean isSelected; @@ -52,7 +52,7 @@ public class UrlLinkDisplay add(MessageManager.formatMessage("label.name")); add(MessageManager.formatMessage("label.url")); add(MessageManager.formatMessage("label.inmenu")); - add(MessageManager.formatMessage("label.default")); + add(MessageManager.formatMessage("label.primary")); add(MessageManager.formatMessage("label.id")); } }; @@ -64,7 +64,7 @@ public class UrlLinkDisplay public final static int SELECTED = 2; - public final static int DEFAULT = 3; + public final static int PRIMARY = 3; public final static int ID = 4; @@ -72,7 +72,7 @@ public class UrlLinkDisplay boolean rowSelected, boolean rowDefault) { id = rowId; - isDefault = rowDefault; + isPrimary = rowDefault; isSelected = rowSelected; link = rowLink; @@ -94,9 +94,9 @@ public class UrlLinkDisplay return link.getUrlWithToken(); } - public boolean getIsDefault() + public boolean getIsPrimary() { - return isDefault; + return isPrimary; } public boolean getIsSelected() @@ -116,7 +116,7 @@ public class UrlLinkDisplay public void setIsDefault(boolean rowDefault) { - isDefault = rowDefault; + isPrimary = rowDefault; } public void setIsSelected(boolean rowSelected) @@ -132,8 +132,8 @@ public class UrlLinkDisplay return id; case URL: return getUrl(); - case DEFAULT: - return isDefault; + case PRIMARY: + return isPrimary; case SELECTED: return isSelected; case NAME: @@ -153,8 +153,8 @@ public class UrlLinkDisplay case URL: setUrl((String) value); break; - case DEFAULT: - isDefault = (boolean) value; + case PRIMARY: + isPrimary = (boolean) value; break; case SELECTED: isSelected = (boolean) value; @@ -176,9 +176,9 @@ public class UrlLinkDisplay */ public boolean isEditable(int index) { - if (index == DEFAULT) + if (index == PRIMARY) { - // default link must not be a $DB_ACCESSION$ link + // primary link must not be a $DB_ACCESSION$ link // so only allow editing if it is not return (!link.usesDBAccession()); } diff --git a/src/jalview/urls/UrlLinkTableModel.java b/src/jalview/urls/UrlLinkTableModel.java index bda92cc..71f7640 100644 --- a/src/jalview/urls/UrlLinkTableModel.java +++ b/src/jalview/urls/UrlLinkTableModel.java @@ -52,8 +52,8 @@ public class UrlLinkTableModel extends AbstractTableModel // list of columns to display in table in correct order private List displayColumns; - // row in table which is currently the default - private int defaultRow; + // row in table which is currently the primary + private int primaryRow; /** * UrlLinkTableModel constructor @@ -74,18 +74,18 @@ public class UrlLinkTableModel extends AbstractTableModel data = baseData.getLinksForTable(); displayColumns = UrlLinkDisplay.getDisplayColumnNames(); - // find the default row - defaultRow = 0; + // find the primary row + primaryRow = 0; Iterator it = data.iterator(); while (it.hasNext()) { - if (it.next().getIsDefault()) + if (it.next().getIsPrimary()) { break; } else { - defaultRow++; + primaryRow++; } } @@ -163,24 +163,24 @@ public class UrlLinkTableModel extends AbstractTableModel { // to delete, row must be a user entered row, and not the default row return (dataProvider.isUserEntry(data.get(rowIndex).getId()) && !data - .get(rowIndex).getIsDefault()); + .get(rowIndex).getIsPrimary()); } @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - if (columnIndex == UrlLinkDisplay.DEFAULT) + if (columnIndex == UrlLinkDisplay.PRIMARY) { // Default url column: exactly one row must always be true - if (rowIndex != defaultRow) + if (rowIndex != primaryRow) { // selected row is not currently the default // set the current default to false - data.get(defaultRow).setValue(columnIndex, false); - fireTableRowsUpdated(defaultRow, defaultRow); + data.get(primaryRow).setValue(columnIndex, false); + fireTableRowsUpdated(primaryRow, primaryRow); // set the default to be the selected row - defaultRow = rowIndex; + primaryRow = rowIndex; data.get(rowIndex).setValue(columnIndex, aValue); fireTableRowsUpdated(rowIndex, rowIndex); @@ -211,9 +211,9 @@ public class UrlLinkTableModel extends AbstractTableModel data.remove(rowIndex); // update default row - if (defaultRow > rowIndex) + if (primaryRow > rowIndex) { - defaultRow--; + primaryRow--; } // fire update which will update data source @@ -233,9 +233,9 @@ public class UrlLinkTableModel extends AbstractTableModel return index; } - public int getDefaultColumn() + public int getPrimaryColumn() { - return UrlLinkDisplay.DEFAULT; + return UrlLinkDisplay.PRIMARY; } public int getNameColumn() diff --git a/src/jalview/urls/UrlProvider.java b/src/jalview/urls/UrlProvider.java index 19fa196..bd01e89 100644 --- a/src/jalview/urls/UrlProvider.java +++ b/src/jalview/urls/UrlProvider.java @@ -63,11 +63,11 @@ public class UrlProvider implements UrlProviderI { // if the defaultUrl can't be found in any of the providers // set up a custom default url - chooseDefaultUrl(); + choosePrimaryUrl(); } else { - setDefaultUrl(defaultUrlString); + setPrimaryUrl(defaultUrlString); } } @@ -78,7 +78,7 @@ public class UrlProvider implements UrlProviderI { for (UrlProviderI p : providers) { - if (p.getClass().equals(CustomUrlProvider.class)) + if (p instanceof CustomUrlProvider) { return p; } @@ -90,12 +90,12 @@ public class UrlProvider implements UrlProviderI } @Override - public boolean setDefaultUrl(String id) + public boolean setPrimaryUrl(String id) { boolean outcome = false; for (UrlProviderI p : providers) { - if (p.setDefaultUrl(id)) + if (p.setPrimaryUrl(id)) { outcome = true; } @@ -180,18 +180,18 @@ public class UrlProvider implements UrlProviderI } @Override - public String getDefaultUrl(String seqid) + public String getPrimaryUrl(String seqid) { String link = null; for (UrlProviderI p : providers) { - if (p.getDefaultUrl(seqid) == null) + if (p.getPrimaryUrl(seqid) == null) { continue; } else { - link = p.getDefaultUrl(seqid); + link = p.getPrimaryUrl(seqid); break; } } @@ -199,18 +199,18 @@ public class UrlProvider implements UrlProviderI } @Override - public String getDefaultUrlId() + public String getPrimaryUrlId() { String id = null; for (UrlProviderI p : providers) { - if (p.getDefaultUrlId() == null) + if (p.getPrimaryUrlId() == null) { continue; } else { - id = p.getDefaultUrlId(); + id = p.getPrimaryUrlId(); break; } } @@ -218,18 +218,18 @@ public class UrlProvider implements UrlProviderI } @Override - public String getDefaultTarget(String seqid) + public String getPrimaryTarget(String seqid) { String target = null; for (UrlProviderI p : providers) { - if (p.getDefaultTarget(seqid) == null) + if (p.getPrimaryTarget(seqid) == null) { continue; } else { - target = p.getDefaultTarget(seqid); + target = p.getPrimaryTarget(seqid); break; } } @@ -237,10 +237,10 @@ public class UrlProvider implements UrlProviderI } @Override - public String chooseDefaultUrl() + public String choosePrimaryUrl() { // choose a custom url default - return customProvider.chooseDefaultUrl(); + return customProvider.choosePrimaryUrl(); } @Override diff --git a/src/jalview/urls/UrlProviderImpl.java b/src/jalview/urls/UrlProviderImpl.java index 87e40c6..c1a57ca 100644 --- a/src/jalview/urls/UrlProviderImpl.java +++ b/src/jalview/urls/UrlProviderImpl.java @@ -44,36 +44,36 @@ public abstract class UrlProviderImpl implements UrlProviderI private static final Pattern MIRIAM_PATTERN = Pattern .compile("^MIR:\\d{8}$"); - protected String defaultUrl; + protected String primaryUrl; - protected String getDefaultUrl(String seqid, HashMap urls) + protected String getPrimaryUrl(String seqid, HashMap urls) { if (seqid.length() < MIN_SUBST_LENGTH) { return null; } - else if (defaultUrl == null) + else if (primaryUrl == null) { return null; } - else if (!urls.containsKey(defaultUrl)) + else if (!urls.containsKey(primaryUrl)) { return null; } else { String url = null; - UrlLink urlLink = urls.get(defaultUrl); - String[] defaultUrls = urlLink.makeUrls(seqid, true); - if (defaultUrls == null || defaultUrls[0] == null - || defaultUrls[0].length() < MIN_SUBST_LENGTH) + UrlLink urlLink = urls.get(primaryUrl); + String[] primaryUrls = urlLink.makeUrls(seqid, true); + if (primaryUrls == null || primaryUrls[0] == null + || primaryUrls[0].length() < MIN_SUBST_LENGTH) { url = null; } else { // just take first URL made from regex - url = defaultUrls[1]; + url = primaryUrls[1]; } return url; } @@ -93,7 +93,7 @@ public abstract class UrlProviderImpl implements UrlProviderI for (Entry entry : urls.entrySet()) { String key = entry.getKey(); - boolean isDefault = (key.equals(defaultUrl)); + boolean isPrimary = (key.equals(primaryUrl)); boolean isSelected; if (selectedUrls != null) { @@ -104,7 +104,7 @@ public abstract class UrlProviderImpl implements UrlProviderI isSelected = selected; } displayLinks.add(new UrlLinkDisplay(key, entry.getValue(), - isSelected, isDefault)); + isSelected, isPrimary)); } return displayLinks; } diff --git a/src/jalview/urls/api/UrlProviderI.java b/src/jalview/urls/api/UrlProviderI.java index 50e2b78..728d9be 100644 --- a/src/jalview/urls/api/UrlProviderI.java +++ b/src/jalview/urls/api/UrlProviderI.java @@ -23,7 +23,6 @@ package jalview.urls.api; import jalview.urls.UrlLinkDisplay; import java.util.List; -import java.util.Vector; /** * Methods for providing consistent access to up-to-date URLs @@ -38,7 +37,7 @@ public interface UrlProviderI * Get names and urls in the UrlProvider as strings for display * */ - Vector getLinksForMenu(); + List getLinksForMenu(); /** * Get names and urls as strings for display @@ -52,38 +51,40 @@ public interface UrlProviderI void setUrlData(List links); /** - * Get the link for the default URL + * Get the link for the primary URL * * @seqid sequence id for which to build link - * @return link for the default URL + * @return link for the primary URL */ - String getDefaultUrl(String seqid); + String getPrimaryUrl(String seqid); /** - * Get the default URL id + * Get the primary URL id * - * @return id for default URL + * @return id for primary URL */ - String getDefaultUrlId(); + String getPrimaryUrlId(); /** - * Get the target of the link for the default URL + * Get the target of the link for the primary URL * * @seqid sequence id for which to build link - * @return target of link for the default URL + * @return target of link for the primary URL */ - String getDefaultTarget(String seqid); + String getPrimaryTarget(String seqid); /** - * Set the default URL + * Set the primary URL: if only one URL can be used, this URL is the one which + * should be chosen, e.g. provides the URL to be used on double-click of a + * sequence id * * @param id - * the id of the URL to set as default + * the id of the URL to set as primary * @return true if setting is successful * @throws IllegalArgumentException * if id does not exist as a url in the UrlProvider */ - boolean setDefaultUrl(String id) throws IllegalArgumentException; + boolean setPrimaryUrl(String id) throws IllegalArgumentException; /** * Test if UrlProvider contains a url @@ -102,12 +103,12 @@ public interface UrlProviderI String writeUrlsAsString(boolean selected); /** - * Choose the default URL in the event of the selected default being + * Choose the primary URL in the event of the selected primary being * unavailable * - * @return id of chosen default url + * @return id of chosen primary url */ - String chooseDefaultUrl(); + String choosePrimaryUrl(); /** * Determine if id is for a user-defined URL diff --git a/src/jalview/ws/UrlDownloadClient.java b/src/jalview/ws/utils/UrlDownloadClient.java similarity index 97% rename from src/jalview/ws/UrlDownloadClient.java rename to src/jalview/ws/utils/UrlDownloadClient.java index 4787c26..86e3f76 100644 --- a/src/jalview/ws/UrlDownloadClient.java +++ b/src/jalview/ws/utils/UrlDownloadClient.java @@ -19,7 +19,7 @@ * The Jalview Authors are detailed in the 'AUTHORS' file. */ -package jalview.ws; +package jalview.ws.utils; import java.io.FileOutputStream; import java.io.IOException; @@ -39,7 +39,7 @@ public class UrlDownloadClient } /** - * Download persistent database URLs from identifiers.org + * Download and save a file from a URL * * @param urlstring * url to download from, as string diff --git a/test/jalview/urls/AppletUrlProviderFactoryTest.java b/test/jalview/urls/AppletUrlProviderFactoryTest.java index f679490..5e0c622 100644 --- a/test/jalview/urls/AppletUrlProviderFactoryTest.java +++ b/test/jalview/urls/AppletUrlProviderFactoryTest.java @@ -53,8 +53,8 @@ public class AppletUrlProviderFactoryTest { UrlProviderI prov = factory.createUrlProvider(); // default url correctly set - Assert.assertEquals(prov.getDefaultUrlId(), "Test2"); - Assert.assertEquals(prov.getDefaultUrl("FER_CAPAN"), + Assert.assertEquals(prov.getPrimaryUrlId(), "Test2"); + Assert.assertEquals(prov.getPrimaryUrl("FER_CAPAN"), defaultUrl.replace("$SEQUENCE_ID$", "FER_CAPAN")); @@ -68,14 +68,14 @@ public class AppletUrlProviderFactoryTest { Assert.assertEquals(allLinks.get(0).getName(), "Test1"); Assert.assertEquals(allLinks.get(0).getUrl(), "http://identifiers.org/uniprot/$DB_ACCESSION$"); - Assert.assertFalse(allLinks.get(0).getIsDefault()); + Assert.assertFalse(allLinks.get(0).getIsPrimary()); Assert.assertTrue(allLinks.get(0).getIsSelected()); // second link set correctly Assert.assertEquals(allLinks.get(1).getId(), "Test2"); Assert.assertEquals(allLinks.get(1).getName(), "Test2"); Assert.assertEquals(allLinks.get(1).getUrl(), defaultUrl); - Assert.assertTrue(allLinks.get(1).getIsDefault()); + Assert.assertTrue(allLinks.get(1).getIsPrimary()); Assert.assertTrue(allLinks.get(1).getIsSelected()); } } diff --git a/test/jalview/urls/CustomUrlProviderTest.java b/test/jalview/urls/CustomUrlProviderTest.java index 853167b..f9ed893 100644 --- a/test/jalview/urls/CustomUrlProviderTest.java +++ b/test/jalview/urls/CustomUrlProviderTest.java @@ -102,24 +102,24 @@ public class CustomUrlProviderTest unselectedList); // default url can be set - assertTrue(customProv.setDefaultUrl("ANOTHER")); + assertTrue(customProv.setPrimaryUrl("ANOTHER")); // supplied replacement id must be more than 4 chars - String result = customProv.getDefaultUrl("123"); + String result = customProv.getPrimaryUrl("123"); assertEquals(null, result); // default url can be retrieved given a sequence id - result = customProv.getDefaultUrl("seqid"); + result = customProv.getPrimaryUrl("seqid"); assertEquals("http://test/tseqid", result); // if there is no default url it sets the default to null - assertFalse(customProv.setDefaultUrl("No default")); - result = customProv.getDefaultUrl("testid"); + assertFalse(customProv.setPrimaryUrl("No default")); + result = customProv.getPrimaryUrl("testid"); assertEquals(null, result); // choosing the default picks the DEFAULT_STRING option - customProv.chooseDefaultUrl(); - result = customProv.getDefaultUrl("seqid"); + customProv.choosePrimaryUrl(); + result = customProv.getPrimaryUrl("seqid"); assertEquals( UrlConstants.DEFAULT_STRING.split("\\|")[1].split("\\$")[0] + "seqid", diff --git a/test/jalview/urls/DesktopUrlProviderFactoryTest.java b/test/jalview/urls/DesktopUrlProviderFactoryTest.java index a114f68..f4bed2e 100644 --- a/test/jalview/urls/DesktopUrlProviderFactoryTest.java +++ b/test/jalview/urls/DesktopUrlProviderFactoryTest.java @@ -28,7 +28,6 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.List; -import java.util.Vector; import org.testng.Assert; import org.testng.annotations.BeforeMethod; @@ -84,11 +83,11 @@ public class DesktopUrlProviderFactoryTest UrlProviderI prov = factory.createUrlProvider(); // default url correctly set - Assert.assertEquals(prov.getDefaultUrlId(), "Test1"); - Assert.assertEquals(prov.getDefaultUrl("FER_CAPAN"), + Assert.assertEquals(prov.getPrimaryUrlId(), "Test1"); + Assert.assertEquals(prov.getPrimaryUrl("FER_CAPAN"), defaultUrl.replace("$SEQUENCE_ID$", "FER_CAPAN")); - Vector menulinks = prov.getLinksForMenu(); + List menulinks = prov.getLinksForMenu(); List allLinks = prov.getLinksForTable(); // 8 links in provider - 4 from id file, 4 custom links diff --git a/test/jalview/urls/IdentifiersUrlProviderTest.java b/test/jalview/urls/IdentifiersUrlProviderTest.java index 3010ea2..107dcda 100644 --- a/test/jalview/urls/IdentifiersUrlProviderTest.java +++ b/test/jalview/urls/IdentifiersUrlProviderTest.java @@ -151,23 +151,23 @@ public class IdentifiersUrlProviderTest UrlProviderI idProv = new IdentifiersUrlProvider(idList); // initially no default - assertEquals(null, idProv.getDefaultUrl("seqid")); + assertEquals(null, idProv.getPrimaryUrl("seqid")); // set and then retrieve default - assertTrue(idProv.setDefaultUrl("MIR:00000005")); + assertTrue(idProv.setPrimaryUrl("MIR:00000005")); assertEquals("http://identifiers.org/uniprot/seqid", - idProv.getDefaultUrl("seqid")); + idProv.getPrimaryUrl("seqid")); // ids less than length 4 return null assertEquals(null, - idProv.getDefaultUrl("123")); + idProv.getPrimaryUrl("123")); // attempt to set bad default - assertFalse(idProv.setDefaultUrl("MIR:00001234")); + assertFalse(idProv.setPrimaryUrl("MIR:00001234")); // default set to null (as default should have been set elsewhere) - assertEquals(null, idProv.getDefaultUrl("seqid")); + assertEquals(null, idProv.getPrimaryUrl("seqid")); // chooseDefaultUrl not implemented for IdentifiersUrlProvider - assertEquals(null, idProv.chooseDefaultUrl()); + assertEquals(null, idProv.choosePrimaryUrl()); } } diff --git a/test/jalview/urls/UrlLinkDisplayTest.java b/test/jalview/urls/UrlLinkDisplayTest.java index 5172304..2a773b0 100644 --- a/test/jalview/urls/UrlLinkDisplayTest.java +++ b/test/jalview/urls/UrlLinkDisplayTest.java @@ -24,7 +24,7 @@ public class UrlLinkDisplayTest { "http://identifiers.org/$DB_ACCESSION$"); UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false); - Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.DEFAULT)); + Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.PRIMARY)); Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test"); Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Url"); Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED)); @@ -42,7 +42,7 @@ public class UrlLinkDisplayTest { "http://identifiers.org/$DB_ACCESSION$"); UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false); - Assert.assertFalse(u.isEditable(UrlLinkDisplay.DEFAULT)); + Assert.assertFalse(u.isEditable(UrlLinkDisplay.PRIMARY)); Assert.assertTrue(u.isEditable(UrlLinkDisplay.SELECTED)); Assert.assertFalse(u.isEditable(UrlLinkDisplay.ID)); Assert.assertFalse(u.isEditable(UrlLinkDisplay.URL)); @@ -52,7 +52,7 @@ public class UrlLinkDisplayTest { "http://myurl/$SEQUENCE_ID$"); UrlLinkDisplay v = new UrlLinkDisplay("Test", vlink, false, false); - Assert.assertTrue(v.isEditable(UrlLinkDisplay.DEFAULT)); + Assert.assertTrue(v.isEditable(UrlLinkDisplay.PRIMARY)); Assert.assertTrue(v.isEditable(UrlLinkDisplay.SELECTED)); Assert.assertFalse(v.isEditable(UrlLinkDisplay.ID)); Assert.assertFalse(v.isEditable(UrlLinkDisplay.URL)); @@ -96,15 +96,15 @@ public class UrlLinkDisplayTest { "http://identifiers.org/$DB_ACCESSION$"); UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false); - Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.DEFAULT)); + Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.PRIMARY)); Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED)); Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Url"); Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test"); Assert.assertEquals(u.getValue(UrlLinkDisplay.URL), "http://identifiers.org/$DB_ACCESSION$"); - u.setValue(UrlLinkDisplay.DEFAULT, true); - Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.DEFAULT)); + u.setValue(UrlLinkDisplay.PRIMARY, true); + Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.PRIMARY)); u.setValue(UrlLinkDisplay.SELECTED, true); Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.SELECTED)); diff --git a/test/jalview/urls/UrlLinkTableModelTest.java b/test/jalview/urls/UrlLinkTableModelTest.java index 141c8fa..e5086fd 100644 --- a/test/jalview/urls/UrlLinkTableModelTest.java +++ b/test/jalview/urls/UrlLinkTableModelTest.java @@ -160,7 +160,7 @@ public class UrlLinkTableModelTest { Assert.assertEquals(m.getColumnName(2), MessageManager.formatMessage("label.inmenu")); Assert.assertEquals(m.getColumnName(3), - MessageManager.formatMessage("label.default")); + MessageManager.formatMessage("label.primary")); // check column classes Assert.assertEquals(m.getColumnClass(0), String.class); @@ -258,7 +258,7 @@ public class UrlLinkTableModelTest { Assert.assertTrue(prov.writeUrlsAsString(true).contains(m.getValueAt(7,0) + SEP + "urlchanged")); Assert.assertTrue(prov.writeUrlsAsString(false).contains( (String) m.getValueAt(8, 0))); - Assert.assertEquals(prov.getDefaultUrl("seqid"), m.getValueAt(6, 1) + Assert.assertEquals(prov.getPrimaryUrl("seqid"), m.getValueAt(6, 1) .toString().replace(DELIM + SEQUENCE_ID + DELIM, "seqid")); } diff --git a/test/jalview/urls/UrlProviderTest.java b/test/jalview/urls/UrlProviderTest.java index 3b52c03..be40c81 100644 --- a/test/jalview/urls/UrlProviderTest.java +++ b/test/jalview/urls/UrlProviderTest.java @@ -9,7 +9,6 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.List; -import java.util.Vector; import org.testng.Assert; import org.testng.annotations.BeforeMethod; @@ -70,11 +69,11 @@ public class UrlProviderTest { UrlConstants.DEFAULT_STRING.length()); // chooses EMBL url when default Url id does not exist in provided url lists - Assert.assertEquals(prov.getDefaultUrlId(), UrlConstants.DEFAULT_LABEL); - Assert.assertEquals(prov.getDefaultUrl("FER_CAPAN"), + Assert.assertEquals(prov.getPrimaryUrlId(), UrlConstants.DEFAULT_LABEL); + Assert.assertEquals(prov.getPrimaryUrl("FER_CAPAN"), emblUrl.replace("$SEQUENCE_ID$", "FER_CAPAN")); - Vector menulinks = prov.getLinksForMenu(); + List menulinks = prov.getLinksForMenu(); List allLinks = prov.getLinksForTable(); // 9 links in provider - 4 from id file, 4 custom links, 1 additional @@ -102,12 +101,12 @@ public class UrlProviderTest { public void testSetDefaultUrl() { // set custom url as default - Assert.assertTrue(prov.setDefaultUrl("Test1")); - Assert.assertEquals(prov.getDefaultUrlId(), "Test1"); + Assert.assertTrue(prov.setPrimaryUrl("Test1")); + Assert.assertEquals(prov.getPrimaryUrlId(), "Test1"); // set identifiers url as default - Assert.assertTrue(prov.setDefaultUrl("MIR:00000011")); - Assert.assertEquals(prov.getDefaultUrlId(), "MIR:00000011"); + Assert.assertTrue(prov.setPrimaryUrl("MIR:00000011")); + Assert.assertEquals(prov.getPrimaryUrlId(), "MIR:00000011"); } @Test( @@ -116,6 +115,6 @@ public class UrlProviderTest { public void testSetDefaultUrlWrongly() { // don't allow default to be a non-key - prov.setDefaultUrl("not-a-key"); + prov.setPrimaryUrl("not-a-key"); } } diff --git a/test/jalview/ws/UrlDownloadClientTest.java b/test/jalview/ws/utils/UrlDownloadClientTest.java similarity index 98% rename from test/jalview/ws/UrlDownloadClientTest.java rename to test/jalview/ws/utils/UrlDownloadClientTest.java index 90470f5..2bd8dd0 100644 --- a/test/jalview/ws/UrlDownloadClientTest.java +++ b/test/jalview/ws/utils/UrlDownloadClientTest.java @@ -18,7 +18,7 @@ * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ -package jalview.ws; +package jalview.ws.utils; import java.io.File; import java.io.IOException; -- 1.7.10.2