From a4934bec020d9d80ccc0059e7cf198f8ba5a314d Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 26 Mar 2010 12:18:16 +0000 Subject: [PATCH] more efficient group URL generation. --- src/jalview/gui/PopupMenu.java | 43 +++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 457638a..341aac2 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -632,13 +632,14 @@ public class PopupMenu extends JPopupMenu } // and try and make the groupURL! - Object[] urlset = urlLink.makeUrls(ids,seqstr, "FromJalview"+System.currentTimeMillis(),false); + Object[] urlset = urlLink.makeUrlStubs(ids,seqstr, "FromJalview"+System.currentTimeMillis(),false); if (urlset!=null) { - System.out.println(urlLink.getGroupURLType() +" "+((String[])urlset[3])[0]); + int type = urlLink.getGroupURLType() & 3; + //System.out.println(urlLink.getGroupURLType() +" "+((String[])urlset[3])[0]); // first two bits ofurlLink type bitfield are sequenceids and sequences // TODO: FUTURE: ensure the groupURL menu structure can be generalised - addshowLink(linkMenus[urlLink.getGroupURLType() & 3], label + "("+(usingNames ? "Names" : ltarget)+")", ((String[])urlset[3])[0]); + addshowLink(linkMenus[type], label + (((type & 1)==1) ? ("("+(usingNames ? "Names" : ltarget)+")") : ""), urlLink, urlset); addMenu = true; } } @@ -688,7 +689,37 @@ public class PopupMenu extends JPopupMenu 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("open URL ("+urlgenerator.getUrl_prefix()+"..) ("+urlgenerator.getNumberInvolved(urlstub)+" seqs)"); // TODO: put in info about what is being sent. + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + new Thread(new Runnable() + { + public void run() + { + showLink(urlgenerator.constructFrom(urlstub)); + } + + }).start(); + } + }); + + linkMenu.add(item); + } /** * DOCUMENT ME! * @@ -1376,12 +1407,13 @@ public class PopupMenu extends JPopupMenu sg.setName(dialog.getName()); sg.setDescription(dialog.getDescription()); + refresh(); } /** - * DOCUMENT ME! + * Get selection group - adding it to the alignment if necessary. * - * @return DOCUMENT ME! + * @return sequence group to operate on */ SequenceGroup getGroup() { @@ -1552,6 +1584,7 @@ public class PopupMenu extends JPopupMenu } ap.av.hideSequence(hseqs); + // refresh(); TODO: ? needed ? ap.av.sendSelection(); } -- 1.7.10.2