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;
}
Aggregations