From b82a11099963661dba5ee0d78ef762767751083d Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 18 Nov 2014 14:11:39 +0000 Subject: [PATCH] JAL-1582 quicker tooltip on service presets (and code formatting). --- src/jalview/ws/jws2/MsaWSClient.java | 86 ++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 9ddc69a..fd01777 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -20,19 +20,28 @@ */ package jalview.ws.jws2; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentView; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.JvSwingUtils; +import jalview.util.MessageManager; +import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.WsParamSetI; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.List; -import javax.swing.*; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.ToolTipManager; -import jalview.datamodel.*; -import jalview.gui.*; import compbio.data.msa.MsaWS; import compbio.metadata.Argument; -import jalview.util.MessageManager; -import jalview.ws.jws2.jabaws2.Jws2Instance; -import jalview.ws.params.WsParamSetI; /** * DOCUMENT ME! @@ -98,20 +107,23 @@ public class MsaWSClient extends Jws2Client if (!(sh.service instanceof MsaWS)) { // redundant at mo - but may change - JOptionPane - .showMessageDialog( - Desktop.desktop, - MessageManager.formatMessage("label.service_called_is_not_msa_service", new String[]{sh.serviceType}), - MessageManager.getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(Desktop.desktop, MessageManager + .formatMessage("label.service_called_is_not_msa_service", + new String[] + { sh.serviceType }), MessageManager + .getString("label.internal_jalview_error"), + JOptionPane.WARNING_MESSAGE); return; } server = (MsaWS) sh.service; if ((wsInfo = setWebService(sh, false)) == null) { - JOptionPane.showMessageDialog(Desktop.desktop, - MessageManager.formatMessage("label.msa_service_is_unknown", new String[]{sh.serviceType}), - MessageManager.getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(Desktop.desktop, MessageManager + .formatMessage("label.msa_service_is_unknown", new String[] + { sh.serviceType }), MessageManager + .getString("label.internal_jalview_error"), + JOptionPane.WARNING_MESSAGE); return; } @@ -273,13 +285,49 @@ public class MsaWSClient extends Jws2Client "label.run_with_preset_params", new String[] { calcName })); + final int showToolTipFor = ToolTipManager.sharedInstance() + .getDismissDelay(); for (final WsParamSetI preset : presets) { - final JMenuItem methodR = new JMenuItem(preset.getName()); - methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "

" - + (preset.isModifiable() ? MessageManager.getString("label.user_preset") - : MessageManager.getString("label.service_preset")) + "
" - + preset.getDescription() + "

")); + final JMenuItem methodR = new JMenuItem(preset.getName()) + { + @Override + protected void finalize() throws Throwable + { + // failsafe to ensure tooltip hover time is restored + ToolTipManager.sharedInstance().setDismissDelay( + showToolTipFor); + super.finalize(); + } + }; + final int QUICK_TOOLTIP = 1500; + // JAL-1582 shorten tooltip display time in these menu items as + // they can obscure other options + methodR.addMouseListener(new MouseAdapter() + { + @Override + public void mouseEntered(MouseEvent e) + { + ToolTipManager.sharedInstance().setDismissDelay( + QUICK_TOOLTIP); + } + + @Override + public void mouseExited(MouseEvent e) + { + ToolTipManager.sharedInstance().setDismissDelay(showToolTipFor); + } + + }); + methodR.setToolTipText(JvSwingUtils.wrapTooltip( + true, + "

" + + (preset.isModifiable() ? MessageManager + .getString("label.user_preset") + : MessageManager + .getString("label.service_preset")) + + "
" + preset.getDescription() + + "

")); methodR.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) -- 1.7.10.2