From 5e749685c5b63bde433a897f3c7316faa16a4460 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 31 Jan 2018 11:28:03 +0000 Subject: [PATCH] JAL-2792 added tooltip to menu items in case of truncation --- src/jalview/gui/PopupMenu.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 -- 1.7.10.2