import jalview.commands.*;
import jalview.datamodel.*;
import jalview.schemes.*;
+import jalview.util.UrlLink;
import jalview.io.AppletFormatAdapter;
public class APopupMenu
for (int i = 0; i < links.size(); i++)
{
link = links.elementAt(i).toString();
- final String target = link.substring(0, link.indexOf("|"));
-
- final String url;
+ UrlLink urlLink = new UrlLink(link);
+ if (!urlLink.isValid())
+ {
+ System.err.println(urlLink.getInvalidMessage());
+ continue;
+ }
+ final String target = urlLink.getTarget(); // link.substring(0, link.indexOf("|"));
+ final String label = urlLink.getLabel();
+ if (urlLink.isDynamic())
+ {
+ // collect matching db-refs
+ DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new String[]{target});
+ // collect id string too
+ String id = seq.getName();
+ if (dbr!=null)
+ {
+ for (int r=0;r<dbr.length; r++)
+ {
+ if (id!=null && dbr[r].getAccessionId().equals(id))
+ {
+ // suppress duplicate link creation for the bare sequence ID string with this link
+ id = null;
+ }
+ // create Bare ID link for this RUL
+ String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(), true);
+ if (urls!=null)
+ {
+ for (int u=0; u<urls.length; u+=2)
+ {
+ addshowLink(linkMenu, label+"|"+urls[u],urls[u+1]);
+ }
+ }
+ }
+ }
+ if (id!=null)
+ {
+ // create Bare ID link for this RUL
+ String[] urls = urlLink.makeUrls(id, true);
+ if (urls!=null)
+ {
+ for (int u=0; u<urls.length; u+=2)
+ {
+ addshowLink(linkMenu, label,urls[u+1]);
+ }
+ }
+ // addshowLink(linkMenu, target, url_pref + id + url_suff);
+ }
+ } else {
+ addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1));
+ }
+ /*final String url;
+
if (link.indexOf("$SEQUENCE_ID$") > -1)
{
// Substitute SEQUENCE_ID string and any matching database reference accessions
}
} else {
addshowLink(linkMenu, target, link.substring(link.lastIndexOf("|")+1));
- }
+ } */
}
if (seq != null)