IDEA-304224 Add warning hint color to render warning hints.

GitOrigin-RevId: c6f51f57fc2b42911abaa80d86805675a88be4fc
This commit is contained in:
Piotr Tomiak
2022-10-20 10:10:02 +02:00
committed by intellij-monorepo-bot
parent af8067dec3
commit ed6284ab67
3 changed files with 27 additions and 1 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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),