JAL-2316 Adjusted unit tests. Tidied UrlLinkProviderI interface.
[jalview.git] / src / jalview / urls / CustomUrlProvider.java
index fb0d676..a178ed6 100644 (file)
@@ -27,6 +27,7 @@ import static jalview.util.UrlConstants.SEP;
 import static jalview.util.UrlConstants.SEQUENCE_ID;
 
 import jalview.util.MessageManager;
+import jalview.util.UrlConstants;
 import jalview.util.UrlLink;
 
 import java.util.ArrayList;
@@ -48,10 +49,6 @@ import java.util.Vector;
  */
 public class CustomUrlProvider extends UrlProviderImpl
 {
-
-  // minimum length of substitution in url link string
-  private static final int MIN_SUBST_LENGTH = 4;
-
   // Default sequence URL link label for SRS
   private static final String SRS_LABEL = "SRS";
 
@@ -138,12 +135,12 @@ public class CustomUrlProvider extends UrlProviderImpl
     if (urls.containsKey(SRS_LABEL))
     {
       urls.remove(SRS_LABEL);
-      urls.put(DEFAULT_LABEL, new UrlLink(DEFAULT_STRING));
+      urls.put(UrlConstants.DEFAULT_LABEL, new UrlLink(UrlConstants.DEFAULT_STRING));
     }
   }
 
   @Override
-  public Vector<String> getLinksForDisplay()
+  public Vector<String> getLinksForMenu()
   {
     Vector<String> links = new Vector<String>();
     Iterator<Map.Entry<String, UrlLink>> it = urls.entrySet().iterator();
@@ -243,40 +240,6 @@ public class CustomUrlProvider extends UrlProviderImpl
   }
 
   @Override
-  public void setUrlLinks(Vector<String> names, Vector<String> urlstrings)
-  {
-    HashMap<String, UrlLink> newurls = new HashMap<String, UrlLink>();
-
-    // should check that lists are same length but this function is likely
-    // to change once the Preferences dialog is rebuilt
-
-    for (int i = 0; i < names.size(); ++i)
-    {
-      // don't allow MIRIAM ids as custom url names (as the links will overwrite
-      // each other)
-      // unlikely user would try to do this, but...
-      if (isMiriamId(names.elementAt(i)))
-      {
-        throw new IllegalArgumentException(MessageManager.formatMessage(
-                "exception.url_cannot_have_miriam_id", names.elementAt(i)));
-      }
-      // don't allow duplicate key names as entries will be overwritten
-      if (newurls.containsKey(names.elementAt(i)))
-      {
-        throw new IllegalArgumentException(MessageManager.formatMessage(
-                "exception.url_cannot_have_duplicate_id",
-                names.elementAt(i)));
-      }
-      newurls.put(names.elementAt(i), new UrlLink(names.elementAt(i) + SEP
-              + urlstrings.elementAt(i)));
-    }
-
-    // don't update until we're sure this set is ok
-    urls = newurls;
-
-  }
-
-  @Override
   public void setUrlData(List<UrlLinkDisplay> links)
   {
     HashMap<String, UrlLink> newurls = new HashMap<String, UrlLink>();
@@ -320,12 +283,12 @@ public class CustomUrlProvider extends UrlProviderImpl
   {
     // unilaterally set the default id to the EMBL_EBI link
     
-    if (!urls.containsKey(DEFAULT_LABEL))
+    if (!urls.containsKey(UrlConstants.DEFAULT_LABEL))
     {
-      urls.put(DEFAULT_LABEL, new UrlLink(DEFAULT_STRING));
+      urls.put(UrlConstants.DEFAULT_LABEL, new UrlLink(UrlConstants.DEFAULT_STRING));
     }
-    defaultUrl = DEFAULT_LABEL;
-    return DEFAULT_LABEL;
+    defaultUrl = UrlConstants.DEFAULT_LABEL;
+    return UrlConstants.DEFAULT_LABEL;
   }
 
 }