From cbc3aa02bf6f8483fe218189f83b30febd1c0501 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Mon, 28 Mar 2011 18:22:33 +0400 Subject: [PATCH] unmatched arguments to singnature tooltip text -- the red color is back --- .../codeInsight/hint/LineTooltipRenderer.java | 3 +- .../src/com/intellij/ide/Html.java | 39 +++++++++++++++++++ .../com/intellij/ide/IdeTooltipManager.java | 18 +++++++-- 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/ide/Html.java diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java index 307a4131d42a..28fb33f0c50d 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.hint; import com.intellij.ide.BrowserUtil; +import com.intellij.ide.Html; import com.intellij.ide.IdeTooltipManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -75,7 +76,7 @@ public class LineTooltipRenderer extends ComparableObject.Impl implements Toolti final JComponent editorComponent = editor.getComponent(); final JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane(); - final JEditorPane pane = IdeTooltipManager.initPane(myText, hintHint, layeredPane); + final JEditorPane pane = IdeTooltipManager.initPane(new Html(myText).setKeepFont(true), hintHint, layeredPane); hintHint.setContentActive(isActiveHtml(myText)); if (!hintHint.isAwtTooltip()) { correctLocation(editor, pane, p, alignToRight, expanded, myCurrentWidth); diff --git a/platform/platform-impl/src/com/intellij/ide/Html.java b/platform/platform-impl/src/com/intellij/ide/Html.java new file mode 100644 index 000000000000..b972a84aadfb --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/Html.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide; + +public class Html { + + private String myText; + private boolean myKeepFont = false; + + public Html(String text) { + myText = text; + } + + public String getText() { + return myText; + } + + public Html setKeepFont(boolean keepFont) { + myKeepFont = keepFont; + return this; + } + + public boolean isKeepFont() { + return myKeepFont; + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java index 9de45783e797..fd407c1f8cc8 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java @@ -445,10 +445,15 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener } + public static JEditorPane initPane(@NonNls String text, final HintHint hintHint, @Nullable final JLayeredPane layeredPane) { + return initPane(new Html(text), hintHint, layeredPane); + } + + public static JEditorPane initPane(@NonNls Html html, final HintHint hintHint, @Nullable final JLayeredPane layeredPane) { final Ref prefSize = new Ref(null); - String htmlBody = getHtmlBody(text); - text = "" + + String htmlBody = getHtmlBody(html); + String text = "" + UIUtil.getCssFontDeclaration(hintHint.getTextFont(), hintHint.getTextForeground(), hintHint.getLinkForeground(), hintHint.getUlImg()) + "" + htmlBody + @@ -568,7 +573,12 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(0, 5, 0, 5))); } - public static String getHtmlBody(@NonNls String text) { + public static String getHtmlBody(String text) { + return getHtmlBody(new Html(text)); + } + + public static String getHtmlBody(Html html) { + String text = html.getText(); String result = text; if (!text.startsWith("")) { result = text.replaceAll("\n", "
"); @@ -590,7 +600,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener - return result.replaceAll("", "").replaceAll("", ""); + return html.isKeepFont() ? result : result.replaceAll("", "").replaceAll("", ""); } @NotNull