From 71cfc6d1dda7f91655a3f3248663440036e64d5d Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Tue, 3 Dec 2013 16:11:55 +0100 Subject: [PATCH] IDEA-116519 - Heroku Deployment facet: make the public key field more user-friendly --- .../remoteServer/util/TooltipUtil.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 platform/remote-servers/impl/src/com/intellij/remoteServer/util/TooltipUtil.java diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/TooltipUtil.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/TooltipUtil.java new file mode 100644 index 000000000000..126dee1b7b1c --- /dev/null +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/TooltipUtil.java @@ -0,0 +1,36 @@ +package com.intellij.remoteServer.util; + +import com.intellij.codeInsight.hint.HintManager; +import com.intellij.codeInsight.hint.HintUtil; +import com.intellij.icons.AllIcons; +import com.intellij.ui.HyperlinkAdapter; +import com.intellij.ui.HyperlinkLabel; +import com.intellij.ui.awt.RelativePoint; + +import javax.swing.*; +import javax.swing.event.HyperlinkEvent; + +/** + * @author michael.golubev + */ +public class TooltipUtil { + + public static HyperlinkLabel createTooltip(final String message) { + final HyperlinkLabel link = new HyperlinkLabel(""); + link.setIcon(AllIcons.General.Help_small); + link.setUseIconAsLink(true); + link.setIconTextGap(0); + link.addHyperlinkListener(new HyperlinkAdapter() { + @Override + protected void hyperlinkActivated(HyperlinkEvent e) { + final JLabel label = new JLabel(message); + label.setBorder(HintUtil.createHintBorder()); + label.setBackground(HintUtil.INFORMATION_COLOR); + label.setOpaque(true); + HintManager.getInstance() + .showHint(label, RelativePoint.getSouthEastOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1); + } + }); + return link; + } +}