com.intellij.codeInsight.hint.HintUtil Java Examples
The following examples show how to use
com.intellij.codeInsight.hint.HintUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterReloadManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private LightweightHint showEditorHint(@NotNull Editor editor, String message, boolean isError) { final AtomicReference<LightweightHint> ref = new AtomicReference<>(); ApplicationManager.getApplication().invokeAndWait(() -> { final JComponent component = isError ? HintUtil.createErrorLabel(message) : HintUtil.createInformationLabel(message); final LightweightHint hint = new LightweightHint(component); ref.set(hint); HintManagerImpl.getInstanceImpl().showEditorHint( hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING | HintManager.HIDE_BY_OTHER_HINT, isError ? 0 : 3000, false); }); return ref.get(); }
Example #2
Source File: FlutterReloadManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private LightweightHint showEditorHint(@NotNull Editor editor, String message, boolean isError) { final AtomicReference<LightweightHint> ref = new AtomicReference<>(); ApplicationManager.getApplication().invokeAndWait(() -> { final JComponent component = isError ? HintUtil.createErrorLabel(message) : HintUtil.createInformationLabel(message); final LightweightHint hint = new LightweightHint(component); ref.set(hint); HintManagerImpl.getInstanceImpl().showEditorHint( hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING | HintManager.HIDE_BY_OTHER_HINT, isError ? 0 : 3000, false); }); return ref.get(); }
Example #3
Source File: SlideComponent.java From consulo with Apache License 2.0 | 6 votes |
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)); } }
Example #4
Source File: VcsCommitInfoBalloon.java From consulo with Apache License 2.0 | 6 votes |
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)); }
Example #5
Source File: CommentByBlockCommentHandler.java From consulo with Apache License 2.0 | 6 votes |
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); } }
Example #6
Source File: CtrlMouseHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private HighlightersSet installHighlighterSet(@Nonnull Info info, @Nonnull EditorEx editor, boolean highlighterOnly) { editor.getContentComponent().addKeyListener(myEditorKeyListener); editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener); if (info.isNavigatable()) { editor.setCustomCursor(CtrlMouseHandler.class, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } List<RangeHighlighter> highlighters = new ArrayList<>(); if (!highlighterOnly || info.isNavigatable()) { TextAttributes attributes = info.isNavigatable() ? EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR) : new TextAttributes(null, HintUtil.getInformationColor(), null, null, Font.PLAIN); for (TextRange range : info.getRanges()) { TextAttributes attr = NavigationUtil.patchAttributesColor(attributes, range, editor); final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.HYPERLINK, attr, HighlighterTargetArea.EXACT_RANGE); highlighters.add(highlighter); } } return new HighlightersSet(highlighters, editor, info); }
Example #7
Source File: ShowUsagesAction.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
@NotNull private JComponent createHintComponent(@NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
Example #8
Source File: FileTextFieldImpl.java From consulo with Apache License 2.0 | 5 votes |
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)); }
Example #9
Source File: BigPopupUI.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private JLabel createHint() { String hint = getInitialHint(); JLabel hintLabel = HintUtil.createAdComponent(hint, JBUI.CurrentTheme.BigPopup.advertiserBorder(), SwingConstants.LEFT); hintLabel.setForeground(JBUI.CurrentTheme.BigPopup.advertiserForeground()); hintLabel.setBackground(JBUI.CurrentTheme.BigPopup.advertiserBackground()); hintLabel.setOpaque(true); Dimension size = hintLabel.getPreferredSize(); size.height = JBUIScale.scale(17); hintLabel.setPreferredSize(size); return hintLabel; }
Example #10
Source File: DependenciesPanel.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(final AnActionEvent e) { @NonNls final String delim = " -> "; final StringBuffer buf = new StringBuffer(); processDependencies(getSelectedScope(myLeftTree), getSelectedScope(myRightTree), new Processor<List<PsiFile>>() { @Override public boolean process(final List<PsiFile> path) { if (buf.length() > 0) buf.append("<br>"); buf.append(StringUtil.join(path, new Function<PsiFile, String>() { @Override public String fun(final PsiFile psiFile) { return psiFile.getName(); } }, delim)); return true; } }); final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, XmlStringUtil.wrapInHtml(buf)); pane.setForeground(JBColor.foreground()); pane.setBackground(HintUtil.INFORMATION_COLOR); pane.setOpaque(true); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane); final Dimension dimension = pane.getPreferredSize(); scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20)); scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20)); JBPopupFactory.getInstance().createComponentPopupBuilder(scrollPane, pane).setTitle("Dependencies") .setMovable(true).createPopup().showInBestPositionFor(e.getDataContext()); }
Example #11
Source File: FindUsagesManager.java From consulo with Apache License 2.0 | 5 votes |
private static void showEditorHint(String message, final Editor editor) { JComponent component = HintUtil.createInformationLabel(message); final LightweightHint hint = new LightweightHint(component); HintManagerImpl.getInstanceImpl() .showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example #12
Source File: ShowUsagesAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private JComponent createHintComponent(@Nonnull String text, @Nonnull final FindUsagesHandler handler, @Nonnull final RelativePoint popupPosition, final Editor editor, @Nonnull final Runnable cancelAction, final int maxUsages, @Nonnull final FindUsagesOptions options, boolean isWarning) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); if (isWarning) { label.setBackground(MessageType.WARNING.getPopupBackground()); } InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = () -> searchEverywhere(options, handler, editor, popupPosition, maxUsages); super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
Example #13
Source File: SelectOccurrencesActionHandler.java From consulo with Apache License 2.0 | 5 votes |
protected static void showHint(final Editor editor) { String message = FindBundle.message("select.next.occurence.not.found.message"); final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message)); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example #14
Source File: CodeInsightUtilBase.java From consulo with Apache License 2.0 | 5 votes |
public static void showReadOnlyViewWarning(Editor editor) { if (ApplicationManager.getApplication().isHeadlessEnvironment()) return; JComponent component = HintUtil.createInformationLabel("This view is read-only"); final LightweightHint hint = new LightweightHint(component); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example #15
Source File: FileInEditorProcessor.java From consulo with Apache License 2.0 | 5 votes |
public static void showHint(@Nonnull Editor editor, @Nonnull String info, @Nullable HyperlinkListener hyperlinkListener) { JComponent component = HintUtil.createInformationLabel(info, hyperlinkListener, null, null); LightweightHint hint = new LightweightHint(component); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example #16
Source File: NavigationGutterIconRenderer.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) { final List<PsiElement> list = getTargetElements(); if (list.isEmpty()) { if (myEmptyText != null) { if (event != null) { final JComponent label = HintUtil.createErrorLabel(myEmptyText); label.setBorder(IdeBorderFactory.createEmptyBorder(2, 7, 2, 7)); JBPopupFactory.getInstance().createBalloonBuilder(label) .setFadeoutTime(3000) .setFillColor(HintUtil.ERROR_COLOR) .createBalloon() .show(new RelativePoint(event), Balloon.Position.above); } } return; } if (list.size() == 1) { PsiNavigateUtil.navigate(list.iterator().next()); } else { if (event != null) { final JBPopup popup = NavigationUtil.getPsiElementPopup(PsiUtilCore.toPsiElementArray(list), myCellRenderer.compute(), myPopupTitle); popup.show(new RelativePoint(event)); } } }
Example #17
Source File: QuickDocUtil.java From consulo with Apache License 2.0 | 5 votes |
@Contract("_, _, _, null -> null") public static String inferLinkFromFullDocumentation(@Nonnull DocumentationProvider provider, PsiElement element, PsiElement originalElement, @Nullable String navigationInfo) { if (navigationInfo != null) { String fqn = element instanceof PsiQualifiedNamedElement ? ((PsiQualifiedNamedElement)element).getQualifiedName() : null; String fullText = provider.generateDoc(element, originalElement); return HintUtil.prepareHintText(DocPreviewUtil.buildPreview(navigationInfo, fqn, fullText), HintUtil.getInformationHint()); } return null; }
Example #18
Source File: DebuggerUIUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void showValuePopup(@Nonnull XFullValueEvaluator evaluator, @Nonnull MouseEvent event, @Nonnull Project project, @Nullable Editor editor) { EditorTextField textArea = new TextViewer("Evaluating...", project); textArea.setBackground(HintUtil.INFORMATION_COLOR); final FullValueEvaluationCallbackImpl callback = new FullValueEvaluationCallbackImpl(textArea); evaluator.startEvaluation(callback); Dimension size = DimensionService.getInstance().getSize(FULL_VALUE_POPUP_DIMENSION_KEY, project); if (size == null) { Dimension frameSize = TargetAWT.to(WindowManager.getInstance().getWindow(project)).getSize(); size = new Dimension(frameSize.width / 2, frameSize.height / 2); } textArea.setPreferredSize(size); JBPopup popup = createValuePopup(project, textArea, callback); if (editor == null) { Rectangle bounds = new Rectangle(event.getLocationOnScreen(), size); ScreenUtil.fitToScreenVertical(bounds, 5, 5, true); if (size.width != bounds.width || size.height != bounds.height) { size = bounds.getSize(); textArea.setPreferredSize(size); } popup.showInScreenCoordinates(event.getComponent(), bounds.getLocation()); } else { popup.showInBestPositionFor(editor); } }
Example #19
Source File: AbstractValueHint.java From consulo with Apache License 2.0 | 5 votes |
protected JComponent createExpandableHintComponent(final SimpleColoredText text, final Runnable expand) { final JComponent component = HintUtil.createInformationLabel(text, IconUtil.getAddIcon()); addClickListenerToHierarchy(component, new ClickListener() { @Override public boolean onClick(@Nonnull MouseEvent event, int clickCount) { if (myCurrentHint != null) { myCurrentHint.hide(); } expand.run(); return true; } }); return component; }
Example #20
Source File: AbstractPopup.java From consulo with Apache License 2.0 | 5 votes |
public void setWarning(@Nonnull String text) { JBLabel label = new JBLabel(text, AllIcons.General.BalloonWarning, SwingConstants.CENTER); label.setOpaque(true); Color color = HintUtil.getInformationColor(); label.setBackground(color); label.setBorder(BorderFactory.createLineBorder(color, 3)); myHeaderPanel.add(label, BorderLayout.SOUTH); }
Example #21
Source File: AbstractPopup.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setAdText(@Nonnull final String s, int alignment) { if (myAdComponent == null) { myAdComponent = HintUtil.createAdComponent(s, JBUI.CurrentTheme.Advertiser.border(), alignment); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.setOpaque(false); wrapper.add(myAdComponent, BorderLayout.CENTER); myContent.add(wrapper, BorderLayout.SOUTH); pack(false, true); } else { myAdComponent.setText(s); myAdComponent.setHorizontalAlignment(alignment); } }
Example #22
Source File: DiffRequestProcessor.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static HintHint createNotifyHint(@Nonnull JComponent component, @Nonnull 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); }
Example #23
Source File: ShowUsagesAction.java From dagger-intellij-plugin with Apache License 2.0 | 5 votes |
@NotNull private JComponent createHintComponent(@NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
Example #24
Source File: InputPanel.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void showDecisionEventToolTip(Editor editor, int offset, HintManagerImpl hintMgr, String msg) { int flags = HintManager.HIDE_BY_ANY_KEY| HintManager.HIDE_BY_TEXT_CHANGE| HintManager.HIDE_BY_SCROLLING; int timeout = 0; // default? JComponent infoLabel = HintUtil.createInformationLabel(msg); LightweightHint hint = new LightweightHint(infoLabel); final LogicalPosition pos = editor.offsetToLogicalPosition(offset); final Point p = HintManagerImpl.getHintPosition(hint, editor, pos, HintManager.ABOVE); hintMgr.showEditorHint(hint, editor, p, flags, timeout, false); }
Example #25
Source File: JSGraphQLQueryContextHighlightVisitor.java From js-graphql-intellij-plugin with MIT License | 5 votes |
/** * Shows a query context hint under the current caret position. * The hint hides after a few seconds or when the user interacts with the editor */ private static void showQueryContextHint(Editor editor, String hintText) { final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); final JComponent label = HintUtil.createInformationLabel(hintText); final LightweightHint lightweightHint = new LightweightHint(label); final Point hintPosition = hintManager.getHintPosition(lightweightHint, editor, HintManager.UNDER); hintManager.showEditorHint(lightweightHint, editor, hintPosition, 0, 2000, false, HintManager.UNDER); }
Example #26
Source File: IncrementalSearchHandler.java From consulo with Apache License 2.0 | 4 votes |
public MyLabel(String text) { super(text); this.setBackground(HintUtil.INFORMATION_COLOR); this.setForeground(JBColor.foreground()); this.setOpaque(true); }
Example #27
Source File: CtrlMouseHandler.java From consulo with Apache License 2.0 | 4 votes |
private void addHighlighterAndShowHint(@Nonnull Info info, @Nonnull DocInfo docInfo, @Nonnull EditorEx editor) { if (myDisposed || editor.isDisposed()) return; if (myHighlighter != null) { if (!info.isSimilarTo(myHighlighter.getStoredInfo())) { disposeHighlighter(); } else { // highlighter already set if (info.isNavigatable()) { editor.setCustomCursor(CtrlMouseHandler.class, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } return; } } if (!info.isValid(editor.getDocument()) || !info.isNavigatable() && docInfo.text == null) { return; } boolean highlighterOnly = EditorSettingsExternalizable.getInstance().isShowQuickDocOnMouseOverElement() && DocumentationManager.getInstance(myProject).getDocInfoHint() != null; myHighlighter = installHighlighterSet(info, editor, highlighterOnly); if (highlighterOnly || docInfo.text == null) return; HyperlinkListener hyperlinkListener = docInfo.docProvider == null ? null : new QuickDocHyperlinkListener(docInfo.docProvider, info.myElementAtPointer); Ref<Consumer<? super String>> newTextConsumerRef = new Ref<>(); JComponent component = HintUtil.createInformationLabel(docInfo.text, hyperlinkListener, null, newTextConsumerRef); component.setBorder(JBUI.Borders.empty(6, 6, 5, 6)); final LightweightHint hint = new LightweightHint(wrapInScrollPaneIfNeeded(component, editor)); myHint = hint; hint.addHintListener(__ -> myHint = null); showHint(hint, editor); Consumer<? super String> newTextConsumer = newTextConsumerRef.get(); if (newTextConsumer != null) { updateOnPsiChanges(hint, info, newTextConsumer, docInfo.text, editor); } }
Example #28
Source File: ChangeListDetailsAction.java From consulo with Apache License 2.0 | 4 votes |
public static void showDetailsPopup(final Project project, final CommittedChangeList changeList) { StringBuilder detailsBuilder = new StringBuilder("<html><head>"); detailsBuilder.append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())).append("</head><body>"); final AbstractVcs vcs = changeList.getVcs(); CachingCommittedChangesProvider provider = null; if (vcs != null) { provider = vcs.getCachingCommittedChangesProvider(); if (provider != null && provider.getChangelistTitle() != null) { detailsBuilder.append(provider.getChangelistTitle()).append(" #").append(changeList.getNumber()).append("<br>"); } } @NonNls String committer = "<b>" + changeList.getCommitterName() + "</b>"; detailsBuilder.append(VcsBundle.message("changelist.details.committed.format", committer, DateFormatUtil.formatPrettyDateTime(changeList.getCommitDate()))); detailsBuilder.append("<br>"); if (provider != null) { final CommittedChangeList originalChangeList; if (changeList instanceof ReceivedChangeList) { originalChangeList = ((ReceivedChangeList) changeList).getBaseList(); } else { originalChangeList = changeList; } for(ChangeListColumn column: provider.getColumns()) { if (ChangeListColumn.isCustom(column)) { String value = column.getValue(originalChangeList).toString(); if (value.length() == 0) { value = "<none>"; } detailsBuilder.append(column.getTitle()).append(": ").append(XmlStringUtil.escapeString(value)).append("<br>"); } } } detailsBuilder.append(IssueLinkHtmlRenderer.formatTextWithLinks(project, changeList.getComment())); detailsBuilder.append("</body></html>"); JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, detailsBuilder.toString()); editorPane.setEditable(false); editorPane.setBackground(HintUtil.INFORMATION_COLOR); editorPane.select(0, 0); editorPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(editorPane); final JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(scrollPane, editorPane) .setDimensionServiceKey(project, "changelist.details.popup", false) .setResizable(true) .setMovable(true) .setRequestFocus(true) .setTitle(VcsBundle.message("changelist.details.title")) .createPopup(); hint.showInBestPositionFor(DataManager.getInstance().getDataContext()); }
Example #29
Source File: RecentLocationsRenderer.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static Color getBackgroundColor(@Nonnull EditorColorsScheme colorsScheme, boolean selected) { return selected ? HintUtil.getRecentLocationsSelectionColor(colorsScheme) : colorsScheme.getDefaultBackground(); }
Example #30
Source File: SingleInspectionProfilePanel.java From consulo with Apache License 2.0 | 4 votes |
private String toHTML(String text) { final HintHint hintHint = new HintHint(myBrowser, new Point(0, 0)); hintHint.setFont(UIUtil.getLabelFont()); return HintUtil.prepareHintText(text, hintHint); }