Search in sources :

Example 1 with IdeTooltipManager

use of com.intellij.ide.IdeTooltipManager in project intellij-community by JetBrains.

the class UIUtil method createCompleteMatchInfo.

@NotNull
public static JComponent createCompleteMatchInfo(final Producer<Configuration> configurationProducer) {
    final JLabel completeMatchInfo = new JLabel(AllIcons.RunConfigurations.Variables);
    final Point location = completeMatchInfo.getLocation();
    final JLabel label = new JLabel(SSRBundle.message("complete.match.variable.tooltip.message", SSRBundle.message("no.constraints.specified.tooltip.message")));
    final IdeTooltip tooltip = new IdeTooltip(completeMatchInfo, location, label);
    tooltip.setPreferredPosition(Balloon.Position.atRight).setCalloutShift(6).setHint(true).setExplicitClose(true);
    completeMatchInfo.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            final Configuration configuration = configurationProducer.produce();
            if (configuration == null) {
                return;
            }
            final MatchOptions matchOptions = configuration.getMatchOptions();
            final MatchVariableConstraint constraint = getOrAddVariableConstraint(Configuration.CONTEXT_VAR_NAME, configuration);
            if (isTarget(Configuration.CONTEXT_VAR_NAME, matchOptions)) {
                constraint.setPartOfSearchResults(true);
            }
            label.setText(SSRBundle.message("complete.match.variable.tooltip.message", getShortParamString(constraint)));
            final IdeTooltipManager tooltipManager = IdeTooltipManager.getInstance();
            tooltipManager.show(tooltip, true);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            IdeTooltipManager.getInstance().hide(tooltip);
        }
    });
    return completeMatchInfo;
}
Also used : MouseEvent(java.awt.event.MouseEvent) ReplaceConfiguration(com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration) IdeTooltipManager(com.intellij.ide.IdeTooltipManager) MouseAdapter(java.awt.event.MouseAdapter) IdeTooltip(com.intellij.ide.IdeTooltip) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IdeTooltip (com.intellij.ide.IdeTooltip)1 IdeTooltipManager (com.intellij.ide.IdeTooltipManager)1 ReplaceConfiguration (com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 NotNull (org.jetbrains.annotations.NotNull)1