JAL-2792 added tooltip to menu items in case of truncation
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 31 Jan 2018 11:28:03 +0000 (11:28 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 31 Jan 2018 11:28:03 +0000 (11:28 +0000)
src/jalview/gui/PopupMenu.java

index 97d051b..0cf7ef4 100644 (file)
@@ -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