JAL-2756 update for new EBI https link
authorkiramt <k.mourao@dundee.ac.uk>
Tue, 31 Oct 2017 10:00:52 +0000 (10:00 +0000)
committerkiramt <k.mourao@dundee.ac.uk>
Tue, 31 Oct 2017 10:00:52 +0000 (10:00 +0000)
src/jalview/gui/Desktop.java
src/jalview/urls/CustomUrlProvider.java
src/jalview/util/UrlConstants.java

index 2d1ba12..128481c 100644 (file)
@@ -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("|");
index 0d5ef99..86d5660 100644 (file)
@@ -160,10 +160,24 @@ public class CustomUrlProvider extends UrlProviderImpl
    */
   private void upgradeOldLinks(HashMap<String, UrlLink> 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);
index d6ece8d..e5cfaee 100644 (file)
@@ -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);
+  }
 }