mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
foreground and background are methods in JBColor
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ public class LookupElementPresentation {
|
||||
private String myItemText;
|
||||
private String myTypeText;
|
||||
private boolean myStrikeout;
|
||||
private Color myItemTextForeground = JBColor.foreground;
|
||||
private Color myItemTextForeground = JBColor.foreground();
|
||||
private boolean myItemTextBold;
|
||||
private boolean myItemTextUnderlined;
|
||||
private boolean myTypeGrayed;
|
||||
|
||||
@@ -40,7 +40,7 @@ class ParameterInfoComponent extends JPanel{
|
||||
private final OneElementComponent[] myPanels;
|
||||
|
||||
private static final Color BACKGROUND_COLOR = HintUtil.INFORMATION_COLOR;
|
||||
private static final Color FOREGROUND_COLOR = JBColor.foreground;
|
||||
private static final Color FOREGROUND_COLOR = JBColor.foreground();
|
||||
// private static final Color DISABLED_BACKGROUND_COLOR = HintUtil.INFORMATION_COLOR;
|
||||
private static final Color DISABLED_FOREGROUND_COLOR = Gray._128;
|
||||
private static final Color HIGHLIGHTED_BORDER_COLOR = new JBColor(new Color(231, 254, 234), Gray._100);
|
||||
|
||||
@@ -54,13 +54,13 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
private final FontMetrics myNormalMetrics;
|
||||
private final FontMetrics myBoldMetrics;
|
||||
|
||||
public static final Color BACKGROUND_COLOR = new JBColor(new Color(235, 244, 254), JBColor.background);
|
||||
private static final Color FOREGROUND_COLOR = JBColor.foreground;
|
||||
public static final Color BACKGROUND_COLOR = new JBColor(new Color(235, 244, 254), JBColor.background());
|
||||
private static final Color FOREGROUND_COLOR = JBColor.foreground();
|
||||
private static final Color GRAYED_FOREGROUND_COLOR = new JBColor(Gray._160, Gray._110);
|
||||
private static final Color SELECTED_BACKGROUND_COLOR = new Color(0, 82, 164);
|
||||
private static final Color SELECTED_NON_FOCUSED_BACKGROUND_COLOR = new JBColor(new Color(110, 142, 162), new Color(85, 88, 90));
|
||||
private static final Color SELECTED_FOREGROUND_COLOR = new JBColor(JBColor.WHITE, JBColor.foreground);
|
||||
private static final Color SELECTED_GRAYED_FOREGROUND_COLOR = new JBColor(JBColor.WHITE, JBColor.foreground);
|
||||
private static final Color SELECTED_FOREGROUND_COLOR = new JBColor(JBColor.WHITE, JBColor.foreground());
|
||||
private static final Color SELECTED_GRAYED_FOREGROUND_COLOR = new JBColor(JBColor.WHITE, JBColor.foreground());
|
||||
|
||||
static final Color PREFIX_FOREGROUND_COLOR = new JBColor(new Color(176, 0, 176), new Color(209, 122, 214));
|
||||
private static final Color SELECTED_PREFIX_FOREGROUND_COLOR = new JBColor(new Color(249, 236, 204), new Color(209, 122, 214));
|
||||
@@ -346,7 +346,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
}
|
||||
|
||||
myTypeLabel.setBackground(sampleBackground);
|
||||
myTypeLabel.setForeground(presentation.isTypeGrayed() ? getGrayedForeground(selected) : item instanceof EmptyLookupItem ? JBColor.foreground : foreground);
|
||||
myTypeLabel.setForeground(presentation.isTypeGrayed() ? getGrayedForeground(selected) : item instanceof EmptyLookupItem ? JBColor.foreground() : foreground);
|
||||
return used;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
|
||||
addListeners();
|
||||
|
||||
mySortingLabel.setBorder(new LineBorder(new JBColor(Color.LIGHT_GRAY, JBColor.background)));
|
||||
mySortingLabel.setBorder(new LineBorder(new JBColor(Color.LIGHT_GRAY, JBColor.background())));
|
||||
mySortingLabel.setOpaque(true);
|
||||
new ChangeLookupSorting().installOn(mySortingLabel);
|
||||
updateSorting();
|
||||
|
||||
+2
-2
@@ -296,7 +296,7 @@ public class IncrementalSearchHandler {
|
||||
data.label.setForeground(JBColor.RED);
|
||||
}
|
||||
else {
|
||||
data.label.setForeground(JBColor.foreground);
|
||||
data.label.setForeground(JBColor.foreground());
|
||||
if (matchLength > 0) {
|
||||
TextAttributes attributes = editor.getColorsScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
|
||||
data.segmentHighlighter = editor.getMarkupModel()
|
||||
@@ -327,7 +327,7 @@ public class IncrementalSearchHandler {
|
||||
public MyLabel(String text) {
|
||||
super(text);
|
||||
this.setBackground(HintUtil.INFORMATION_COLOR);
|
||||
this.setForeground(JBColor.foreground);
|
||||
this.setForeground(JBColor.foreground());
|
||||
this.setOpaque(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ public class Bookmark implements Navigatable {
|
||||
g.setColor(JBColor.GRAY);
|
||||
g.drawRect(x, y, getIconWidth() - 2, getIconHeight());
|
||||
|
||||
g.setColor(JBColor.foreground);
|
||||
g.setColor(JBColor.foreground());
|
||||
final Font oldFont = g.getFont();
|
||||
g.setFont(MNEMONIC_FONT);
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ public class CommanderPanel extends JPanel {
|
||||
myParentTitle = new MyTitleLabel(myTitlePanel);
|
||||
myParentTitle.setText(" ");
|
||||
myParentTitle.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
|
||||
myParentTitle.setForeground(JBColor.foreground);
|
||||
myParentTitle.setForeground(JBColor.foreground());
|
||||
myParentTitle.setUI(new RightAlignedLabelUI());
|
||||
final JPanel panel1 = new JPanel(new BorderLayout());
|
||||
panel1.setOpaque(false);
|
||||
@@ -392,7 +392,7 @@ public class CommanderPanel extends JPanel {
|
||||
LOG.assertTrue(color != null);
|
||||
myTitlePanel.setBackground(color);
|
||||
myTitlePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, color.brighter(), color.darker()));
|
||||
myParentTitle.setForeground(JBColor.foreground);
|
||||
myParentTitle.setForeground(JBColor.foreground());
|
||||
}
|
||||
final int[] selectedIndices = myList.getSelectedIndices();
|
||||
if (selectedIndices.length == 0 && myList.getModel().getSize() > 0) {
|
||||
|
||||
@@ -765,7 +765,7 @@ public class DependenciesPanel extends JPanel implements Disposable, DataProvide
|
||||
}
|
||||
});
|
||||
final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString()+ "</html>");
|
||||
pane.setForeground(JBColor.foreground);
|
||||
pane.setForeground(JBColor.foreground());
|
||||
pane.setBackground(HintUtil.INFORMATION_COLOR);
|
||||
pane.setOpaque(true);
|
||||
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ReplacePromptDialog extends DialogWrapper {
|
||||
}
|
||||
JLabel label = new JLabel(getMessage());
|
||||
label.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 10));
|
||||
label.setForeground(JBColor.foreground);
|
||||
label.setForeground(JBColor.foreground());
|
||||
panel.add(label, BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ public class FileColorConfigurationEditDialog extends DialogWrapper {
|
||||
@Override
|
||||
public Color getForeground() {
|
||||
if (getModel().isSelected()) {
|
||||
return JBColor.foreground;
|
||||
return JBColor.foreground();
|
||||
} else if (getModel().isRollover()) {
|
||||
return JBColor.GRAY;
|
||||
} else {
|
||||
|
||||
@@ -53,6 +53,6 @@ public enum DirDiffOperation {
|
||||
case EQUAL:
|
||||
case NONE:
|
||||
}
|
||||
return JBColor.foreground;
|
||||
return JBColor.foreground();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JBTabbedPane extends JTabbedPane implements HierarchyListener {
|
||||
getTabComponentAt(getSelectedIndex()).setForeground(Color.WHITE);
|
||||
}
|
||||
if (previousSelectedIndex != -1 && getTabComponentAt(previousSelectedIndex) != null) {
|
||||
getTabComponentAt(previousSelectedIndex).setForeground(JBColor.foreground);
|
||||
getTabComponentAt(previousSelectedIndex).setForeground(JBColor.foreground());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HintUtil {
|
||||
public static final Color QUESTION_COLOR = new JBColor(new Color(181, 208, 251), new Color(55, 108, 137));
|
||||
public static final Color ERROR_COLOR = new JBColor(new Color(255, 220, 220), new Color(0x781732));
|
||||
|
||||
public static final Color QUESTION_UNDERSCORE_COLOR = JBColor.foreground;
|
||||
public static final Color QUESTION_UNDERSCORE_COLOR = JBColor.foreground();
|
||||
|
||||
private HintUtil() {
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class HintUtil {
|
||||
|
||||
if (!hintHint.isAwtTooltip()) {
|
||||
label.setBorder(createHintBorder());
|
||||
label.setForeground(JBColor.foreground);
|
||||
label.setForeground(JBColor.foreground());
|
||||
label.setFont(getBoldFont());
|
||||
label.setBackground(INFORMATION_COLOR);
|
||||
label.setOpaque(true);
|
||||
@@ -109,7 +109,7 @@ public class HintUtil {
|
||||
|
||||
public static JComponent createQuestionLabel(String text) {
|
||||
HintHint hintHint = new HintHint().setTextBg(QUESTION_COLOR)
|
||||
.setTextFg(JBColor.foreground)
|
||||
.setTextFg(JBColor.foreground())
|
||||
.setFont(getBoldFont())
|
||||
.setAwtTooltip(true);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class HintUtil {
|
||||
|
||||
if (!hintHint.isAwtTooltip()) {
|
||||
label.setBorder(createHintBorder());
|
||||
label.setForeground(JBColor.foreground);
|
||||
label.setForeground(JBColor.foreground());
|
||||
label.setFont(getBoldFont());
|
||||
label.setBackground(QUESTION_COLOR);
|
||||
label.setOpaque(true);
|
||||
@@ -132,7 +132,7 @@ public class HintUtil {
|
||||
|
||||
highlighted.setIcon(icon);
|
||||
highlighted.setBackground(INFORMATION_COLOR);
|
||||
highlighted.setForeground(JBColor.foreground);
|
||||
highlighted.setForeground(JBColor.foreground());
|
||||
highlighted.setFont(getBoldFont());
|
||||
text.appendToComponent(highlighted);
|
||||
|
||||
@@ -144,7 +144,7 @@ public class HintUtil {
|
||||
|
||||
public static JComponent createErrorLabel(String text) {
|
||||
HintHint hintHint = new HintHint().setTextBg(ERROR_COLOR)
|
||||
.setTextFg(JBColor.foreground)
|
||||
.setTextFg(JBColor.foreground())
|
||||
.setFont(getBoldFont())
|
||||
.setAwtTooltip(true);
|
||||
HintLabel label = new HintLabel();
|
||||
@@ -154,7 +154,7 @@ public class HintUtil {
|
||||
if (!hintHint.isAwtTooltip()) {
|
||||
label.setBorder(createHintBorder()
|
||||
);
|
||||
label.setForeground(JBColor.foreground);
|
||||
label.setForeground(JBColor.foreground());
|
||||
label.setFont(getBoldFont());
|
||||
label.setBackground(ERROR_COLOR);
|
||||
label.setOpaque(true);
|
||||
|
||||
@@ -600,7 +600,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
}
|
||||
|
||||
public static void setColors(JComponent pane) {
|
||||
pane.setForeground(JBColor.foreground);
|
||||
pane.setForeground(JBColor.foreground());
|
||||
pane.setBackground(HintUtil.INFORMATION_COLOR);
|
||||
pane.setOpaque(true);
|
||||
}
|
||||
|
||||
@@ -18,22 +18,131 @@ package com.intellij.ui;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@SuppressWarnings("UseJBColor")
|
||||
public class JBColor extends Color {
|
||||
|
||||
private static boolean DARK = UIUtil.isUnderDarcula();
|
||||
|
||||
private final Color darkColor;
|
||||
|
||||
public JBColor(int rgb, int darkRGB) {
|
||||
super(isDark() ? darkRGB : rgb);
|
||||
this(new Color(rgb), new Color(darkRGB));
|
||||
}
|
||||
|
||||
public JBColor(Color regular, Color dark) {
|
||||
super(isDark() ? dark.getRGB() : regular.getRGB(), (isDark() ? dark : regular).getAlpha() != 255);
|
||||
super(regular.getRGB(), regular.getAlpha() != 255);
|
||||
darkColor = dark;
|
||||
}
|
||||
|
||||
private static boolean isDark() {
|
||||
return UIUtil.isUnderDarcula();
|
||||
public static void setDark(boolean dark) {
|
||||
DARK = dark;
|
||||
}
|
||||
|
||||
Color getDarkVariant() {
|
||||
return darkColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRed() {
|
||||
return DARK ? getDarkVariant().getRed() : super.getRed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGreen() {
|
||||
return DARK ? getDarkVariant().getGreen() : super.getGreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlue() {
|
||||
return DARK ? getDarkVariant().getBlue() : super.getBlue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlpha() {
|
||||
return DARK ? getDarkVariant().getAlpha() : super.getAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGB() {
|
||||
return DARK ? getDarkVariant().getRGB() : super.getRGB();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color brighter() {
|
||||
return new JBColor(super.brighter(), getDarkVariant().brighter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color darker() {
|
||||
return new JBColor(super.darker(), getDarkVariant().darker());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return DARK ? getDarkVariant().hashCode() : super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return DARK ? getDarkVariant().equals(obj) : super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return DARK ? getDarkVariant().toString() : super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getRGBComponents(float[] compArray) {
|
||||
return DARK ? getDarkVariant().getRGBComponents(compArray) : super.getRGBComponents(compArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getRGBColorComponents(float[] compArray) {
|
||||
return DARK ? getDarkVariant().getRGBColorComponents(compArray) : super.getRGBComponents(compArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getComponents(float[] compArray) {
|
||||
return DARK ? getDarkVariant().getComponents(compArray) : super.getComponents(compArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getColorComponents(float[] compArray) {
|
||||
return DARK ? getDarkVariant().getColorComponents(compArray) : super.getColorComponents(compArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getComponents(ColorSpace cspace, float[] compArray) {
|
||||
return DARK ? getDarkVariant().getComponents(cspace, compArray) : super.getComponents(cspace, compArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getColorComponents(ColorSpace cspace, float[] compArray) {
|
||||
return DARK ? getDarkVariant().getColorComponents(cspace, compArray) : super.getColorComponents(cspace, compArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorSpace getColorSpace() {
|
||||
return DARK ? getDarkVariant().getColorSpace() : super.getColorSpace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized PaintContext createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, AffineTransform xform, RenderingHints hints) {
|
||||
return DARK ? getDarkVariant().createContext(cm, r, r2d, xform, hints) : super.createContext(cm, r, r2d, xform, hints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return DARK ? getDarkVariant().getTransparency() : super.getTransparency();
|
||||
}
|
||||
|
||||
public final static JBColor red = new JBColor(Color.red, DarculaColors.RED);
|
||||
@@ -42,10 +151,20 @@ public class JBColor extends Color {
|
||||
public final static JBColor blue = new JBColor(Color.blue, DarculaColors.BLUE);
|
||||
public final static JBColor BLUE = blue;
|
||||
|
||||
public final static JBColor white = new JBColor(Color.white, UIUtil.getListBackground());
|
||||
public final static JBColor white = new JBColor(Color.white, UIUtil.getListBackground()) {
|
||||
@Override
|
||||
Color getDarkVariant() {
|
||||
return UIUtil.getListBackground();
|
||||
}
|
||||
};
|
||||
public final static JBColor WHITE = white;
|
||||
|
||||
public final static JBColor black = new JBColor(Color.black, UIUtil.getListForeground());
|
||||
public final static JBColor black = new JBColor(Color.black, UIUtil.getListForeground()) {
|
||||
@Override
|
||||
Color getDarkVariant() {
|
||||
return UIUtil.getListForeground();
|
||||
}
|
||||
};
|
||||
public final static JBColor BLACK = black;
|
||||
|
||||
public final static JBColor gray = new JBColor(Gray._128, Gray._128);
|
||||
@@ -75,9 +194,7 @@ public class JBColor extends Color {
|
||||
public final static Color cyan = new JBColor(Color.cyan, new Color(0, 137, 137));
|
||||
public final static Color CYAN = cyan;
|
||||
|
||||
public static Color foreground = UIUtil.getLabelForeground();
|
||||
public static Color FOREGROUND = foreground;
|
||||
public static Color foreground() {return UIUtil.getLabelForeground();}
|
||||
|
||||
public static Color background = UIUtil.getListBackground();
|
||||
public static Color BACKGROUND = background;
|
||||
public static Color background() {return UIUtil.getListBackground();}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TitlePanel extends CaptionPanel {
|
||||
if (UIUtil.isUnderAquaLookAndFeel()) {
|
||||
myLabel.setFont(myLabel.getFont().deriveFont(12f));
|
||||
}
|
||||
myLabel.setForeground(JBColor.foreground);
|
||||
myLabel.setForeground(JBColor.foreground());
|
||||
myLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
myLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||
myLabel.setBorder(new EmptyBorder(1, 2, 2, 2));
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class ClientPropertiesProperty extends ReadOnlyProperty {
|
||||
myTf.setText(UIDesignerBundle.message("client.properties.configure"));
|
||||
myTf.getTextField().setEditable(false);
|
||||
myTf.getTextField().setBorder(null);
|
||||
myTf.getTextField().setForeground(JBColor.foreground);
|
||||
myTf.getTextField().setForeground(JBColor.foreground());
|
||||
myTf.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showClientPropertiesDialog();
|
||||
|
||||
@@ -195,7 +195,7 @@ public class XPathAppComponent implements ApplicationComponent, JDOMExternalizab
|
||||
label.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.WHITE, Gray._128),
|
||||
BorderFactory.createEmptyBorder(3, 5, 3, 5)));
|
||||
label.setForeground(JBColor.foreground);
|
||||
label.setForeground(JBColor.foreground());
|
||||
label.setBackground(HintUtil.INFORMATION_COLOR);
|
||||
label.setOpaque(true);
|
||||
label.setFont(label.getFont().deriveFont(Font.BOLD));
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ErrorableTableCellRenderer<T extends DomElement> extends DefaultTab
|
||||
}
|
||||
else if (warningProblems.size() > 0) {
|
||||
component.setBackground(BaseControl.WARNING_BACKGROUND);
|
||||
if(isSelected) component.setForeground(JBColor.foreground);
|
||||
if(isSelected) component.setForeground(JBColor.foreground());
|
||||
}
|
||||
|
||||
final List<DomElementProblemDescriptor> errorDescriptors =
|
||||
|
||||
Reference in New Issue
Block a user