diff --git a/platform/ide-core/resources/messages/OptionsBundle.properties b/platform/ide-core/resources/messages/OptionsBundle.properties index 3fe6e9770359..298c4fb39133 100644 --- a/platform/ide-core/resources/messages/OptionsBundle.properties +++ b/platform/ide-core/resources/messages/OptionsBundle.properties @@ -144,6 +144,7 @@ options.general.color.descriptor.popups.documentation=Popups and Hints//Document options.general.color.descriptor.popups.lookup=Popups and Hints//Completion options.general.color.descriptor.popups.information=Popups and Hints//Information hint options.general.color.descriptor.popups.question=Popups and Hints//Question hint +options.general.color.descriptor.popups.warning=Popups and Hints//Warning hint options.general.color.descriptor.popups.error=Popups and Hints//Error hint options.general.color.descriptor.popups.hint_border=Popups and Hints//Hint border options.general.color.descriptor.popups.recent.locations.selection=Popups and Hints//Recent locations selection diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintUtil.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintUtil.java index e983c9a18576..393ee886dfb3 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintUtil.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintUtil.java @@ -47,9 +47,10 @@ public final class HintUtil { public static final ColorKey INFORMATION_COLOR_KEY = ColorKey.createColorKey("INFORMATION_HINT", INFORMATION_COLOR); public static final ColorKey QUESTION_COLOR_KEY = ColorKey.createColorKey("QUESTION_HINT", new JBColor(0xb5d0fb, 0x376c89)); + public static final ColorKey WARNING_COLOR_KEY = ColorKey.createColorKey("WARNING_HINT", new JBColor(0xfff8dc, 0x665014)); public static final ColorKey ERROR_COLOR_KEY = ColorKey.createColorKey("ERROR_HINT", ERROR_COLOR); /** - * Border color for tooltips with {@link #INFORMATION_COLOR_KEY}, {@link #QUESTION_COLOR_KEY} and {@link #ERROR_COLOR_KEY} + * Border color for tooltips with {@link #INFORMATION_COLOR_KEY}, {@link #QUESTION_COLOR_KEY}, {@link #WARNING_COLOR_KEY} and {@link #ERROR_COLOR_KEY} */ public static final ColorKey HINT_BORDER_COLOR_KEY = ColorKey.createColorKey("HINT_BORDER", new JBColor(0xC9CCD6, 0x5A5D63)); @@ -68,6 +69,10 @@ public final class HintUtil { return notNull(getGlobalOrDefaultColor(QUESTION_COLOR_KEY), QUESTION_COLOR_KEY.getDefaultColor()); } + public static @NotNull Color getWarningColor() { + return notNull(getGlobalOrDefaultColor(WARNING_COLOR_KEY), WARNING_COLOR_KEY.getDefaultColor()); + } + public static @NotNull Color getErrorColor() { return notNull(getGlobalOrDefaultColor(ERROR_COLOR_KEY), ERROR_COLOR_KEY.getDefaultColor()); } @@ -173,6 +178,25 @@ public final class HintUtil { return createErrorLabel(text, null, null); } + public static JComponent createWarningLabel(@NotNull @HintText String text, + @Nullable HyperlinkListener hyperlinkListener, + @Nullable MouseListener mouseListener) { + Color bg = getWarningColor(); + HintHint hintHint = new HintHint() + .setBorderColor(getHintBorderColor()) + .setTextBg(bg) + .setTextFg(JBColor.foreground()) + .setFont(getBoldFont()) + .setAwtTooltip(true); + HintLabel label = createLabel(text, null, bg, hintHint); + configureLabel(label, hyperlinkListener, mouseListener, null); + return label; + } + + public static @NotNull JComponent createWarningLabel(@NotNull @HintText String text) { + return createWarningLabel(text, null, null); + } + @ApiStatus.Internal public static @NotNull HintLabel createLabel(@HintText String text, @Nullable Icon icon, @NotNull Color color, @NotNull HintHint hintHint) { HintLabel label = new HintLabel(); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java b/platform/platform-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java index cc053319821f..c7c6af05ab57 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java @@ -169,6 +169,7 @@ public class GeneralColorsPage implements ColorSettingsPage, InspectionColorSett new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.popups.lookup"), Lookup.LOOKUP_COLOR, ColorDescriptor.Kind.BACKGROUND), new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.popups.information"), HintUtil.INFORMATION_COLOR_KEY, ColorDescriptor.Kind.BACKGROUND), new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.popups.question"), HintUtil.QUESTION_COLOR_KEY, ColorDescriptor.Kind.BACKGROUND), + new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.popups.warning"), HintUtil.WARNING_COLOR_KEY, ColorDescriptor.Kind.BACKGROUND), new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.popups.error"), HintUtil.ERROR_COLOR_KEY, ColorDescriptor.Kind.BACKGROUND), new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.popups.hint_border"), HintUtil.HINT_BORDER_COLOR_KEY, ColorDescriptor.Kind.BACKGROUND), new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.popups.recent.locations.selection"), HintUtil.RECENT_LOCATIONS_SELECTION_KEY, ColorDescriptor.Kind.BACKGROUND),