- ;
- if (!urlLink.isValid())
- {
- Cache.log.error(urlLink.getInvalidMessage());
- continue;
- }
- final String label = urlLink.getLabel();
- boolean usingNames = false;
- // Now see which parts of the group apply for this URL
- String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
- Object[] idset = commonDbrefs.get(ltarget.toUpperCase());
- String[] seqstr, ids; // input to makeUrl
- if (idset != null)
- {
- int numinput = ((int[]) idset[0])[0];
- String[] allids = ((String[]) idset[1]);
- seqstr = new String[numinput];
- ids = new String[numinput];
- for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
- {
- if (allids[sq] != null)
- {
- ids[idcount] = allids[sq];
- seqstr[idcount++] = idandseqs[1][sq];
- }
- }
- }
- else
- {
- // just use the id/seq set
- seqstr = idandseqs[1];
- ids = idandseqs[0];
- usingNames = true;
- }
- // and try and make the groupURL!
-
- Object[] urlset = null;
- try
- {
- urlset = urlLink.makeUrlStubs(ids, seqstr,
- "FromJalview" + System.currentTimeMillis(), false);
- } catch (UrlStringTooLongException e)
- {
- }
- if (urlset != null)
- {
- int type = urlLink.getGroupURLType() & 3;
- // first two bits ofurlLink type bitfield are sequenceids and sequences
- // TODO: FUTURE: ensure the groupURL menu structure can be generalised
- addshowLink(linkMenus[type], label
- + (((type & 1) == 1) ? ("("
- + (usingNames ? "Names" : ltarget) + ")") : ""),
- urlLink, urlset);
- addMenu = true;
- }
- }
- if (addMenu)
- {
- groupLinksMenu = new JMenu(
- MessageManager.getString("action.group_link"));
- for (int m = 0; m < linkMenus.length; m++)
- {
- if (linkMenus[m] != null
- && linkMenus[m].getMenuComponentCount() > 0)
- {
- groupLinksMenu.add(linkMenus[m]);
- }
- }
-
- groupMenu.add(groupLinksMenu);
- }
- }
-
- private void addshowLinks(JMenu linkMenu, Collection<List<String>> linkset)
- {
- for (List<String> linkstrset : linkset)
- {
- // split linkstr into label and url
- addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
- }
- }
-
- /**
- * add a show URL menu item to the given linkMenu
- *
- * @param linkMenu
- * @param label
- * - menu label string
- * @param url
- * - url to open
- */
- private void addshowLink(JMenu linkMenu, String label, final String url)
- {
- JMenuItem item = new JMenuItem(label);
- item.setToolTipText(MessageManager.formatMessage(
- "label.open_url_param", new Object[] { url }));
- item.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- new Thread(new Runnable()
- {
-
- @Override
- public void run()
- {
- showLink(url);
- }
-
- }).start();
- }
- });
-
- linkMenu.add(item);
- }
-
- /**
- * add a late bound groupURL item to the given linkMenu
- *
- * @param linkMenu
- * @param label
- * - menu label string
- * @param urlgenerator
- * GroupURLLink used to generate URL
- * @param urlstub
- * Object array returned from the makeUrlStubs function.
- */
- private void addshowLink(JMenu linkMenu, String label,
- final GroupUrlLink urlgenerator, final Object[] urlstub)
- {
- JMenuItem item = new JMenuItem(label);
- item.setToolTipText(MessageManager.formatMessage(
- "label.open_url_seqs_param",
- new Object[] { urlgenerator.getUrl_prefix(),
- urlgenerator.getNumberInvolved(urlstub) }));
- // TODO: put in info about what is being sent.
- item.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)