From: gmungoc Date: Wed, 31 Jan 2018 11:28:03 +0000 (+0000) Subject: JAL-2792 added tooltip to menu items in case of truncation X-Git-Tag: Release_2_11_0~64 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5e749685c5b63bde433a897f3c7316faa16a4460;p=jalview.git JAL-2792 added tooltip to menu items in case of truncation --- diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 97d051b..0cf7ef4 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -550,24 +550,27 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener { desc = String.format("%s %d-%d", sf.getType(), start, end); } + String tooltip = desc; String description = sf.getDescription(); if (description != null) { description = StringUtils.stripHtmlTags(description); - if (description.length() <= 6) + if (description.length() > 12) { - desc = desc + " " + description; + desc = desc + " " + description.substring(0, 12) + ".."; } else { - desc = desc + " " + description.substring(0, 6) + ".."; + desc = desc + " " + description; } + tooltip = tooltip + " " + description; } if (sf.getFeatureGroup() != null) { - desc = desc + " (" + sf.getFeatureGroup() + ")"; + tooltip = tooltip + (" (" + sf.getFeatureGroup() + ")"); } JMenuItem item = new JMenuItem(desc); + item.setToolTipText(tooltip); item.addActionListener(new ActionListener() { @Override