From a124e525dece0edc422cd2f8888d03ea14f65f15 Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 9 Sep 2010 15:33:03 +0000 Subject: [PATCH] wrap tooltips and revise layout (JAL-644) --- src/jalview/util/GroupUrlLink.java | 13 +++++ src/jalview/ws/EnfinEnvision2OneWay.java | 86 ++++++++++++++++++++---------- 2 files changed, 72 insertions(+), 27 deletions(-) diff --git a/src/jalview/util/GroupUrlLink.java b/src/jalview/util/GroupUrlLink.java index 27b81d4..ef32e99 100644 --- a/src/jalview/util/GroupUrlLink.java +++ b/src/jalview/util/GroupUrlLink.java @@ -25,6 +25,7 @@ import java.util.Vector; public class GroupUrlLink { + /** * Helper class based on the UrlLink class which enables URLs to be * constructed from sequences or IDs associated with a group of sequences. URL @@ -68,6 +69,18 @@ public class GroupUrlLink { "SEQUENCEIDS", "SEQUENCES", "DATASETID" }; } } + /** + * test for GroupURLType bitfield (with default tokens) + */ + public static final int SEQUENCEIDS = 1; + /** + * test for GroupURLType bitfield (with default tokens) + */ + public static final int SEQUENCES = 2; + /** + * test for GroupURLType bitfield (with default tokens) + */ + public static final int DATASETID = 4; // private int idseg = -1, seqseg = -1; diff --git a/src/jalview/ws/EnfinEnvision2OneWay.java b/src/jalview/ws/EnfinEnvision2OneWay.java index 53d5b4a..ae2792c 100644 --- a/src/jalview/ws/EnfinEnvision2OneWay.java +++ b/src/jalview/ws/EnfinEnvision2OneWay.java @@ -23,6 +23,7 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.Desktop; +import jalview.gui.JvSwingUtils; import jalview.util.GroupUrlLink; import java.awt.Component; @@ -35,6 +36,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.util.Hashtable; +import java.util.Map; import java.util.Vector; import javax.swing.JMenu; @@ -281,7 +283,7 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements * Object array returned from the makeUrlStubs function. */ private void addshowLink(JMenu linkMenu, String label, String descr, - final GroupUrlLink urlgenerator, final Object[] urlstub) + String dbname, final GroupUrlLink urlgenerator, final Object[] urlstub) { Component[] jmi = linkMenu.getMenuComponents(); for (int i = 0; i < jmi.length; i++) @@ -293,10 +295,20 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements return; } } + boolean seqsorids = (urlgenerator.getGroupURLType() & urlgenerator.SEQUENCEIDS) == 0; + int i = urlgenerator.getNumberInvolved(urlstub); JMenuItem item = new JMenuItem(label); - item.setToolTipText("Submit (" - + urlgenerator.getNumberInvolved(urlstub) - + " seqs) to workflow: " + descr); + // + if (dbname==null || dbname.trim().length()==0) + { + dbname = ""; + } + item.setToolTipText("" + + JvSwingUtils.wrapTooltip("Submit " + i + " " + + dbname +" " + + (seqsorids ? "sequence" : "sequence id") + (i > 1 ? "s" : "") + + + " to
" + descr) + ""); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) @@ -388,10 +400,6 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements // sequence only URLs // ID/regex match URLs JMenu groupLinksMenu = new JMenu("Group Link"); - JMenu[] linkMenus = new JMenu[] - { null, new JMenu("IDS"), new JMenu("Sequences"), - new JMenu("IDS and Sequences") }; // three types of url that might be - // created. String[][] idandseqs = GroupUrlLink.formStrings(seqs); Hashtable commonDbrefs = new Hashtable(); for (int sq = 0; sq < seqs.length; sq++) @@ -453,12 +461,12 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements } } // now create group links for all distinct ID/sequence sets. - boolean addMenu = false; // indicates if there are any group links to give - // to user + Hashtable gurlMenus = new Hashtable(); for (int i = 0; i < groupURLLinks.size(); i++) { String link = groupURLLinks.elementAt(i).toString(); String descr = groupURLdescr.elementAt(i).toString(); + // boolean specialCase = // additionalPar.elementAt(i).toString().equals(BACKGROUND); GroupUrlLink urlLink = null; @@ -478,6 +486,18 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements continue; } final String label = urlLink.getLabel(); + // create/recover the sub menus that might be populated for this link. + JMenu[] wflinkMenus = gurlMenus.get(label); + if (wflinkMenus == null) + { + // three types of url that might be + // created. + wflinkMenus = new JMenu[] + { null, new JMenu("IDS"), new JMenu("Sequences"), + new JMenu("IDS and Sequences") }; + gurlMenus.put(label, wflinkMenus); + } + boolean usingNames = false; // Now see which parts of the group apply for this URL String ltarget; @@ -500,30 +520,35 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements seqstr[idcount++] = idandseqs[1][sq]; } } - addMenu = addMenu - | createAndAddLinks(linkMenus, false, urlLink, label, - ltarget, descr, ids, seqstr); + createAndAddLinks(wflinkMenus, false, urlLink, ltarget, null, + descr, ids, seqstr); } } // also do names only. seqstr = idandseqs[1]; ids = idandseqs[0]; - addMenu = addMenu - | createAndAddLinks(linkMenus, true, urlLink, label, "Names", - descr, ids, seqstr); + createAndAddLinks(wflinkMenus, true, urlLink, "Any", null, descr, + ids, seqstr); } - if (addMenu) + boolean anyadded = false; // indicates if there are any group links to give + // to user + for (Map.Entry menues : gurlMenus.entrySet()) { - groupLinksMenu = new JMenu("Group Links"); - for (int m = 0; m < linkMenus.length; m++) + JMenu grouplinkset = new JMenu(menues.getKey()); + JMenu[] wflinkMenus = menues.getValue(); + for (int m = 0; m < wflinkMenus.length; m++) { - if (linkMenus[m] != null - && linkMenus[m].getMenuComponentCount() > 0) + if (wflinkMenus[m] != null + && wflinkMenus[m].getMenuComponentCount() > 0) { - groupLinksMenu.add(linkMenus[m]); + anyadded = true; + grouplinkset.add(wflinkMenus[m]); } } - + groupLinksMenu.add(grouplinkset); + } + if (anyadded) + { return groupLinksMenu; } return null; @@ -542,10 +567,17 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements // +" "+((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[type], label - + " " - + (usingNames ? (((type & 1) == 1) ? "(Names)" : "") : ("(" - + ltarget + ")")), descr, urlLink, urlset); + addshowLink( + linkMenus[type], + label + + " " + + (ltarget == null ? (((type & 1) == 1 ? "ID" + : "Sequence") + (urlLink + .getNumberInvolved(urlset) > 1 ? "s" : "")) + : (usingNames ? (((type & 1) == 1) ? "(Names)" + : "") + : ("(" + ltarget + ")"))), descr, + usingNames ? null : label, urlLink, urlset); return true; } return false; -- 1.7.10.2