From 79523fafa37144a18c9dd8116696bf9c2717d730 Mon Sep 17 00:00:00 2001 From: kiramt Date: Tue, 31 Oct 2017 10:00:52 +0000 Subject: [PATCH] JAL-2756 update for new EBI https link --- src/jalview/gui/Desktop.java | 2 +- src/jalview/urls/CustomUrlProvider.java | 14 ++++++++++++++ src/jalview/util/UrlConstants.java | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 2d1ba12..128481c 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -2338,7 +2338,7 @@ public class Desktop extends jalview.jbgui.GDesktop { String link = li.next(); if (link.contains(SEQUENCE_ID) - && !link.equals(UrlConstants.DEFAULT_STRING)) + && !UrlConstants.isDefaultString(link)) { check = true; int barPos = link.indexOf("|"); diff --git a/src/jalview/urls/CustomUrlProvider.java b/src/jalview/urls/CustomUrlProvider.java index 0d5ef99..86d5660 100644 --- a/src/jalview/urls/CustomUrlProvider.java +++ b/src/jalview/urls/CustomUrlProvider.java @@ -160,10 +160,24 @@ public class CustomUrlProvider extends UrlProviderImpl */ private void upgradeOldLinks(HashMap urls) { + boolean upgrade = false; // upgrade old SRS link if (urls.containsKey(SRS_LABEL)) { urls.remove(SRS_LABEL); + upgrade = true; + } + // upgrade old EBI link - easier just to remove and re-add than faffing + // around checking exact url + if (urls.containsKey(UrlConstants.DEFAULT_LABEL)) + { + // note because this is called separately for selected and nonselected + // urls, the default url will not always be present + urls.remove(UrlConstants.DEFAULT_LABEL); + upgrade = true; + } + if (upgrade) + { UrlLink link = new UrlLink(UrlConstants.DEFAULT_STRING); link.setLabel(UrlConstants.DEFAULT_LABEL); urls.put(UrlConstants.DEFAULT_LABEL, link); diff --git a/src/jalview/util/UrlConstants.java b/src/jalview/util/UrlConstants.java index d6ece8d..e5cfaee 100644 --- a/src/jalview/util/UrlConstants.java +++ b/src/jalview/util/UrlConstants.java @@ -57,10 +57,20 @@ public class UrlConstants public static final String DEFAULT_STRING = DEFAULT_LABEL + "|https://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$"; + private static final String COLON = ":"; + /* * not instantiable */ private UrlConstants() { } + + public static boolean isDefaultString(String link) + { + String sublink = link.substring(link.indexOf(COLON) + 1); + String subdefault = DEFAULT_STRING + .substring(DEFAULT_STRING.indexOf(COLON) + 1); + return sublink.equalsIgnoreCase(subdefault); + } } -- 1.7.10.2