本文整理汇总了Java中com.intellij.codeInsight.hint.HintUtil类的典型用法代码示例。如果您正苦于以下问题:Java HintUtil类的具体用法?Java HintUtil怎么用?Java HintUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HintUtil类属于com.intellij.codeInsight.hint包,在下文中一共展示了HintUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTooltip
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
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;
}
示例2: updateBalloonText
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
private void updateBalloonText() {
final Point point = myVertical ? new Point(0, myPointerValue) : new Point(myPointerValue, 0);
myLabel.setText(myTitle + ": " + Unit.formatValue(myValue, myUnit));
if (myTooltipHint == null) {
myTooltipHint = new LightweightHint(myLabel);
myTooltipHint.setCancelOnClickOutside(false);
myTooltipHint.setCancelOnOtherWindowOpen(false);
final HintHint hint = new HintHint(this, point)
.setPreferredPosition(myVertical ? Balloon.Position.atLeft : Balloon.Position.above)
.setBorderColor(Color.BLACK)
.setAwtTooltip(true)
.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD))
.setTextBg(HintUtil.INFORMATION_COLOR)
.setShowImmediately(true);
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
myTooltipHint.show(this, point.x, point.y, owner instanceof JComponent ? (JComponent)owner : null, hint);
}
else {
myTooltipHint.setLocation(new RelativePoint(this, point));
}
}
示例3: setAdText
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
@Override
public void setAdText(@NotNull final String s, int alignment) {
if (myAdComponent == null) {
myAdComponent = HintUtil.createAdComponent(s, JBUI.Borders.empty(1, 5), alignment);
JPanel wrapper = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
g.setColor(Gray._135);
g.drawLine(0, 0, getWidth(), 0);
super.paintComponent(g);
}
};
wrapper.setOpaque(false);
wrapper.setBorder(JBUI.Borders.emptyTop(1));
wrapper.add(myAdComponent, BorderLayout.CENTER);
myContent.add(wrapper, BorderLayout.SOUTH);
pack(false, true);
} else {
myAdComponent.setText(s);
myAdComponent.setHorizontalAlignment(alignment);
}
}
示例4: VcsCommitInfoBalloon
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
public VcsCommitInfoBalloon(@NotNull JTree tree) {
myTree = tree;
myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "");
myEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
myEditorPane.setEditable(false);
myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
myEditorPane.setFont(UIUtil.getToolTipFont());
myEditorPane.setBorder(HintUtil.createHintBorder());
Border margin = IdeBorderFactory.createEmptyBorder(3, 3, 3, 3);
myEditorPane.setBorder(new CompoundBorder(myEditorPane.getBorder(), margin));
myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
BrowserUtil.browse(e.getURL());
}
});
myWrapper = new Wrapper(myEditorPane);
myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myWrapper, null);
myPopupBuilder.setCancelOnClickOutside(true).setResizable(true).setMovable(true).setRequestFocus(false)
.setMinSize(new Dimension(80, 30));
}
示例5: calculateWidthIncrease
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
/**
* It's possible that we need to expand quick doc control's width in order to provide better visual representation
* (see https://youtrack.jetbrains.com/issue/IDEA-101425). This method calculates that width expand.
*
* @param buttonWidth icon button's width
* @param updatedText text which will be should at the quick doc control
* @return width increase to apply to the target quick doc control (zero if no additional width increase is required)
*/
private static int calculateWidthIncrease(int buttonWidth, String updatedText) {
int maxLineWidth = 0;
TIntArrayList lineWidths = new TIntArrayList();
for (String lineText : StringUtil.split(updatedText, "<br/>")) {
String html = HintUtil.prepareHintText(lineText, HintUtil.getInformationHint());
int width = new JLabel(html).getPreferredSize().width;
maxLineWidth = Math.max(maxLineWidth, width);
lineWidths.add(width);
}
if (!lineWidths.isEmpty()) {
int firstLineAvailableTrailingWidth = maxLineWidth - lineWidths.get(0);
if (firstLineAvailableTrailingWidth >= buttonWidth) {
return 0;
}
else {
return buttonWidth - firstLineAvailableTrailingWidth;
}
}
return 0;
}
示例6: setAdText
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
@Override
public void setAdText(@NotNull final String s, int alignment) {
if (myAdComponent == null) {
myAdComponent = HintUtil.createAdComponent(s, BorderFactory.createEmptyBorder(1, 5, 1, 5), alignment);
JPanel wrapper = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
g.setColor(Gray._135);
g.drawLine(0, 0, getWidth(), 0);
super.paintComponent(g);
}
};
wrapper.setOpaque(false);
wrapper.setBorder(new EmptyBorder(1, 0, 0, 0));
wrapper.add(myAdComponent, BorderLayout.CENTER);
myContent.add(wrapper, BorderLayout.SOUTH);
pack(false, true);
} else {
myAdComponent.setText(s);
myAdComponent.setHorizontalAlignment(alignment);
}
}
示例7: calculateWidthIncrease
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
/**
* It's possible that we need to expand quick doc control's width in order to provide better visual representation
* (see http://youtrack.jetbrains.com/issue/IDEA-101425). This method calculates that width expand.
*
* @param buttonWidth icon button's width
* @param updatedText text which will be should at the quick doc control
* @return width increase to apply to the target quick doc control (zero if no additional width increase is required)
*/
private static int calculateWidthIncrease(int buttonWidth, String updatedText) {
int maxLineWidth = 0;
TIntArrayList lineWidths = new TIntArrayList();
for (String lineText : StringUtil.split(updatedText, "<br/>")) {
String html = HintUtil.prepareHintText(lineText, HintUtil.getInformationHint());
int width = new JLabel(html).getPreferredSize().width;
maxLineWidth = Math.max(maxLineWidth, width);
lineWidths.add(width);
}
if (!lineWidths.isEmpty()) {
int firstLineAvailableTrailingWidth = maxLineWidth - lineWidths.get(0);
if (firstLineAvailableTrailingWidth >= buttonWidth) {
return 0;
}
else {
return buttonWidth - firstLineAvailableTrailingWidth;
}
}
return 0;
}
示例8: SQLPopupView
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
/**
* construct parameter table and SQL panel
*
* @param parameterClass parameter class
* @param parameters parameter list
* @param rawSqlCode SQL code
*/
public SQLPopupView(PsiClass parameterClass, Set<String> parameters, String rawSqlCode) {
this.rawSqlCode = rawSqlCode;
this.parameterClass = parameterClass;
try {
ParametersTableModel tableModel = new ParametersTableModel();
for (String parameter : parameters) {
tableModel.add(parameter, "string", "");
updateParameterValue(parameter, "");
}
paramsTable.setModel(tableModel);
textPane.setText(rawSqlCode);
textPane.setBackground(HintUtil.INFORMATION_COLOR);
}
catch (Exception e) {
textPane.setText(e.getMessage());
}
}
示例9: setAdText
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
@Override
public void setAdText(@Nonnull final String s, int alignment) {
if (myAdComponent == null) {
myAdComponent = HintUtil.createAdComponent(s, JBUI.Borders.empty(1, 5), alignment);
JPanel wrapper = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
g.setColor(Gray._135);
UIUtil.drawLine(g, 0, 0, getWidth(), 0);
super.paintComponent(g);
}
};
wrapper.setOpaque(false);
wrapper.setBorder(JBUI.Borders.emptyTop(1));
wrapper.add(myAdComponent, BorderLayout.CENTER);
myContent.add(wrapper, BorderLayout.SOUTH);
pack(false, true);
}
else {
myAdComponent.setText(s);
myAdComponent.setHorizontalAlignment(alignment);
}
}
示例10: VcsCommitInfoBalloon
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
public VcsCommitInfoBalloon(@Nonnull JTree tree) {
myTree = tree;
myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "");
myEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
myEditorPane.setEditable(false);
myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
myEditorPane.setFont(UIUtil.getToolTipFont());
myEditorPane.setBorder(HintUtil.createHintBorder());
Border margin = IdeBorderFactory.createEmptyBorder(3, 3, 3, 3);
myEditorPane.setBorder(new CompoundBorder(myEditorPane.getBorder(), margin));
myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
BrowserUtil.browse(e.getURL());
}
});
myWrapper = new Wrapper(myEditorPane);
myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myWrapper, null);
myPopupBuilder.setCancelOnClickOutside(true).setResizable(true).setMovable(true).setRequestFocus(false)
.setMinSize(new Dimension(80, 30));
}
示例11: calculateWidthIncrease
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
/**
* It's possible that we need to expand quick doc control's width in order to provide better visual representation
* (see https://youtrack.jetbrains.com/issue/IDEA-101425). This method calculates that width expand.
*
* @param buttonWidth icon button's width
* @param updatedText text which will be should at the quick doc control
* @return width increase to apply to the target quick doc control (zero if no additional width increase is required)
*/
private static int calculateWidthIncrease(int buttonWidth, String updatedText) {
int maxLineWidth = 0;
TIntArrayList lineWidths = new TIntArrayList();
for (String lineText : StringUtil.split(updatedText, "<br/>")) {
String html = HintUtil.prepareHintText(lineText, HintUtil.getInformationHint());
int width = new JLabel(html).getPreferredSize().width;
maxLineWidth = Math.max(maxLineWidth, width);
lineWidths.add(width);
}
if (!lineWidths.isEmpty()) {
int firstLineAvailableTrailingWidth = maxLineWidth - lineWidths.get(0);
if (firstLineAvailableTrailingWidth >= buttonWidth) {
return 0;
}
else {
return buttonWidth - firstLineAvailableTrailingWidth;
}
}
return 0;
}
示例12: showMessageIfNeeded
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
private void showMessageIfNeeded() {
if (myWarning != null) {
myEditor.getScrollingModel().disableAnimation();
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
myEditor.getScrollingModel().enableAnimation();
LogicalPosition hintPosition = myCaret.getLogicalPosition();
if (myWarningLocation != null) {
LogicalPosition targetPosition = myEditor.offsetToLogicalPosition(myWarningLocation.getStartOffset());
Point targetPoint = myEditor.logicalPositionToXY(targetPosition);
if (myEditor.getScrollingModel().getVisibleArea().contains(targetPoint)) {
hintPosition = targetPosition;
}
}
LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(myWarning));
Point p = HintManagerImpl.getHintPosition(hint, myEditor, hintPosition, HintManager.ABOVE);
HintManagerImpl.getInstanceImpl().showEditorHint(hint, myEditor, p, 0, 0, false);
}
}
示例13: showHint
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
private void showHint(final SimpleColoredText text, final WatchItemDescriptor descriptor) {
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
@Override
public void run() {
if(!isHintHidden()) {
JComponent component;
if (!isActiveTooltipApplicable(descriptor.getValue())) {
component = HintUtil.createInformationLabel(text);
}
else {
component = createExpandableHintComponent(text, new Runnable() {
@Override
public void run() {
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public void threadAction() {
descriptor.setRenderer(debugProcess.getAutoRenderer(descriptor));
final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return myCurrentExpression.getText();
}
});
createAndShowTree(expressionText, descriptor);
}
});
}
});
}
if (!showHint(component)) return;
if(getType() == ValueHintType.MOUSE_CLICK_HINT) {
HintUtil.createInformationLabel(text).requestFocusInWindow();
}
}
}
});
}
示例14: createNotifyHint
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
@NotNull
private static HintHint createNotifyHint(@NotNull JComponent component, @NotNull Point point, boolean above) {
return new HintHint(component, point)
.setPreferredPosition(above ? Balloon.Position.above : Balloon.Position.below)
.setAwtTooltip(true)
.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD))
.setTextBg(HintUtil.INFORMATION_COLOR)
.setShowImmediately(true);
}
示例15: showNoSuggestions
import com.intellij.codeInsight.hint.HintUtil; //导入依赖的package包/类
private void showNoSuggestions(boolean isExplicit) {
hideCurrentPopup();
if (!isExplicit) return;
final JComponent message = HintUtil.createErrorLabel(IdeBundle.message("file.chooser.completion.no.suggestions"));
final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(message, message);
builder.setRequestFocus(false).setResizable(false).setAlpha(0.1f).setFocusOwners(new Component[] {myPathTextField});
myNoSuggestionsPopup = builder.createPopup();
myNoSuggestionsPopup.showInScreenCoordinates(getField(), getLocationForCaret(myPathTextField));
}