-
- JMenu linkMenu = new JMenu("Link");
- Vector linkset = new Vector();
- for (int i = 0; i < links.size(); i++)
- {
- String link = links.elementAt(i).toString();
- UrlLink urlLink = null;
- try
- {
- urlLink = new UrlLink(link);
- } catch (Exception foo)
- {
- jalview.bin.Cache.log.error("Exception for URLLink '" + link
- + "'", foo);
- continue;
- }
- ;
- if (!urlLink.isValid())
- {
- jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
- continue;
- }
- final String label = urlLink.getLabel();
- if (urlLink.isDynamic())
- {
-
- // collect matching db-refs
- DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq
- .getDBRef(), new String[]
- { urlLink.getTarget() });
- // collect id string too
- String id = seq.getName();
- String descr = seq.getDescription();
- if (descr!=null && descr.length()<1)
- {
- descr = null;
- }
-
- 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)
- {
- if (!linkset.contains(urls[u]+"|"+urls[u+1]))
- {
- linkset.addElement(urls[u]+"|"+urls[u+1]);
- 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)
- {
- if (!linkset.contains(urls[u]+"|"+urls[u+1]))
- {
- linkset.addElement(urls[u]+"|"+urls[u+1]);
- addshowLink(linkMenu, label, urls[u + 1]);
- }
- }
- }
- }
- // Create urls from description but only for URL links which are regex links
- if (descr != null && urlLink.getRegexReplace()!=null)
- {
- // create link for this URL from description where regex matches
- String[] urls = urlLink.makeUrls(descr, true);
- if (urls != null)
- {
- for (int u = 0; u < urls.length; u += 2)
- {
- if (!linkset.contains(urls[u]+"|"+urls[u+1]))
- {
- linkset.addElement(urls[u]+"|"+urls[u+1]);
- addshowLink(linkMenu, label, urls[u + 1]);
- }
- }
- }
- }
- }
- else
- {
- if (!linkset.contains(label+"|"+urlLink.getUrl_prefix()))
- {
- linkset.addElement(label+"|"+urlLink.getUrl_prefix());
- // Add a non-dynamic link
- addshowLink(linkMenu, label, urlLink.getUrl_prefix());
- }
- }
- }
- if (sequence != null)
- {
- sequenceMenu.add(linkMenu);
- }
- else