IDEA-198728: deprecate Tree.textForeground and use Tree.foreground instead

This commit is contained in:
Sergey Malenkov
2018-10-24 22:18:49 +03:00
parent de795732f5
commit 6c278cbb94
27 changed files with 74 additions and 62 deletions
@@ -96,9 +96,8 @@ public class ExternalSystemActionUtil {
return baseComponent;
}
final Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();
Color background = selected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeTextBackground();
Color foreground = UIUtil.getTreeForeground(selected, hasFocus);
Color background = UIUtil.getTreeBackground(selected, hasFocus);
panel.add(baseComponent, BorderLayout.CENTER);
panel.setBackground(background);
@@ -122,10 +122,10 @@ public class NotificationMessageElement extends NavigatableMessageElement {
}
else {
if (selected) {
StyleConstants.setForeground(style, hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground());
StyleConstants.setForeground(style, hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeForeground());
}
else {
StyleConstants.setForeground(style, UIUtil.getTreeTextForeground());
StyleConstants.setForeground(style, UIUtil.getTreeForeground());
}
}
@@ -33,7 +33,7 @@ public class UsageTreeColorsScheme {
}
public EditorColorsScheme getScheme() {
return EditorColorsUtil.getColorSchemeForBackground(UIUtil.getTreeTextBackground());
return EditorColorsUtil.getColorSchemeForBackground(UIUtil.getTreeBackground());
}
}
@@ -432,7 +432,7 @@ public abstract class OptionTreeWithPreviewPanel extends CustomizableLanguageCod
button.setBackground(UIUtil.getTreeSelectionBackground());
}
else {
button.setForeground(UIUtil.getTreeTextForeground());
button.setForeground(UIUtil.getTreeForeground());
button.setBackground(tree.getBackground());
}
@@ -450,7 +450,7 @@ public abstract class OptionTreeWithPreviewPanel extends CustomizableLanguageCod
myLabel.setBackground(UIUtil.getTreeSelectionBackground());
}
else {
myLabel.setForeground(UIUtil.getTreeTextForeground());
myLabel.setForeground(UIUtil.getTreeForeground());
myLabel.setBackground(tree.getBackground());
}
@@ -50,7 +50,7 @@ public class ArrangementColorsProviderImpl implements ArrangementColorsProvider
myColorsAware = colorsAware;
// Default settings.
myDefaultNormalAttributes.setForegroundColor(UIUtil.getTreeTextForeground());
myDefaultNormalAttributes.setForegroundColor(UIUtil.getTreeForeground());
myDefaultNormalAttributes.setBackgroundColor(UIUtil.getPanelBackground());
myDefaultSelectedAttributes.setForegroundColor(UIUtil.getTreeSelectionForeground());
myDefaultSelectedAttributes.setBackgroundColor(UIUtil.getTreeSelectionBackground());
@@ -161,8 +161,8 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
final Component rendererComponent =
treeCellRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (rendererComponent instanceof SimpleColoredComponent) {
final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
final Color fg = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeForeground();
Color bg = UIUtil.getTreeBackground(selected, true);
Color fg = UIUtil.getTreeForeground(selected, true);
if (selected) {
for (SimpleColoredComponent.ColoredIterator it = ((SimpleColoredComponent)rendererComponent).iterator(); it.hasNext(); ) {
it.next();
@@ -70,7 +70,7 @@ public abstract class IntentionSettingsTree {
CheckedTreeNode node = (CheckedTreeNode)value;
SimpleTextAttributes attributes = node.getUserObject() instanceof IntentionActionMetaData ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
final String text = getNodeText(node);
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
Color background = UIUtil.getTreeBackground(selected, true);
UIUtil.changeBackGround(this, background);
if (text != null) {
SearchUtil.appendFragments(myFilter != null ? myFilter.getFilter() : null,
@@ -110,7 +110,7 @@ public class PostfixTemplatesCheckboxTree extends CheckboxTree implements Dispos
if (!(value instanceof CheckedTreeNode)) return;
CheckedTreeNode node = (CheckedTreeNode)value;
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
Color background = UIUtil.getTreeBackground(selected, true);
PostfixTemplateCheckedTreeNode templateNode = ObjectUtils.tryCast(node, PostfixTemplateCheckedTreeNode.class);
SimpleTextAttributes attributes;
if (templateNode != null) {
@@ -308,9 +308,9 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
myCheckbox.setSelected(descriptor.isChecked());
myCheckbox.setBackground(UIUtil.getTreeTextBackground());
setBackground(selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground());
final Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();
myCheckbox.setBackground(UIUtil.getTreeBackground());
setBackground(UIUtil.getTreeBackground(selected, true));
Color foreground = UIUtil.getTreeForeground(selected, true);
setForeground(foreground);
myCheckbox.setForeground(foreground);
myLabel.setForeground(foreground);
@@ -379,7 +379,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
private ContentPanel createContentPanel(JComponent component) {
final ContentPanel panel = new ContentPanel();
panel.setBackground(UIUtil.getTreeTextBackground());
panel.setBackground(UIUtil.getTreeBackground());
panel.add(component, BorderLayout.CENTER);
return panel;
}
@@ -35,11 +35,10 @@ public abstract class InspectionsConfigTreeRenderer extends DefaultTreeRenderer
InspectionConfigTreeNode node = (InspectionConfigTreeNode)value;
boolean reallyHasFocus = ((TreeTableTree)tree).getTreeTable().hasFocus();
final Color background = selected ? (reallyHasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground())
: UIUtil.getTreeTextBackground();
Color background = UIUtil.getTreeBackground(selected, reallyHasFocus);
UIUtil.changeBackGround(component, background);
Color foreground =
selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting() ? PlatformColors.BLUE : UIUtil.getTreeTextForeground();
selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting() ? PlatformColors.BLUE : UIUtil.getTreeForeground();
int style = SimpleTextAttributes.STYLE_PLAIN;
String hint = null;
@@ -59,7 +59,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
else if (WideSelectionTreeUI.isWideSelection(tree)) {
setPaintFocusBorder(false);
if (selected) {
setBackground(hasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground());
setBackground(UIUtil.getTreeSelectionBackground(hasFocus));
}
else {
setBackground(null);
@@ -145,12 +145,12 @@ public abstract class GroupedElementsRenderer {
@Override
protected Color getBackground() {
return UIUtil.getTreeTextBackground();
return UIUtil.getTreeBackground();
}
@Override
protected Color getForeground() {
return UIUtil.getTreeTextForeground();
return UIUtil.getTreeForeground();
}
}
@@ -213,7 +213,7 @@ public class HighlightableComponent extends JComponent implements Accessible {
paintHighlightsForeground = false;
}
else {
bgColor = myEnforcedBackground == null ? UIUtil.getTreeTextBackground() : myEnforcedBackground;
bgColor = myEnforcedBackground == null ? UIUtil.getTreeBackground() : myEnforcedBackground;
fgColor = getForeground();
paintHighlightsBackground = isOpaque();
paintHighlightsForeground = true;
@@ -47,7 +47,7 @@ public final class SpeedSearchUtil {
Iterable<TextRange> ranges = speedSearch == null ? null : speedSearch.matchingFragments(coloredComponent.getCharSequence(mainTextOnly).toString());
Iterator<TextRange> rangesIterator = ranges != null ? ranges.iterator() : null;
if (rangesIterator == null || !rangesIterator.hasNext()) return;
Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
Color bg = UIUtil.getTreeBackground(selected, true);
SimpleColoredComponent.ColoredIterator coloredIterator = coloredComponent.iterator();
TextRange range = rangesIterator.next();
@@ -90,7 +90,7 @@ public final class SpeedSearchUtil {
final Iterable<TextRange> fragments = speedSearch.matchingFragments(text);
if (fragments != null) {
final Color fg = attributes.getFgColor();
final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
Color bg = UIUtil.getTreeBackground(selected, true);
final int style = attributes.getStyle();
final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg);
final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH);
@@ -101,7 +101,7 @@ public abstract class SimpleNode extends PresentableNodeDescriptor implements Co
Icon oldIcon = getIcon();
List<ColoredFragment> oldFragments = new ArrayList<>(presentation.getColoredText());
myColor = UIUtil.getTreeTextForeground();
myColor = UIUtil.getTreeForeground();
updateFileStatus();
doUpdate();
@@ -185,7 +185,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
@Override
public Color getBackground() {
return isBackgroundSet() ? super.getBackground() : UIUtil.getTreeTextBackground();
return isBackgroundSet() ? super.getBackground() : UIUtil.getTreeBackground();
}
@Override
@@ -621,7 +621,7 @@ public class ActionsTree {
}
}
if (!myHaveLink) {
Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
Color background = UIUtil.getTreeBackground(selected, true);
SearchUtil.appendFragments(myFilter, text, SimpleTextAttributes.STYLE_PLAIN, foreground, background, this);
if (actionId != null && myPaintInternalInfo) {
String pluginName = myPluginNames.get(actionId);
@@ -640,8 +640,8 @@ public abstract class FinderRecursivePanel<T> extends OnePixelSplitter implement
boolean isSelected,
boolean cellHasFocus) {
mySelected = isSelected;
myForeground = UIUtil.getTreeTextForeground();
mySelectionForeground = cellHasFocus ? list.getSelectionForeground() : UIUtil.getTreeTextForeground();
myForeground = UIUtil.getTreeForeground();
mySelectionForeground = cellHasFocus ? list.getSelectionForeground() : UIUtil.getTreeForeground();
clear();
setFont(UIUtil.getListFont());
@@ -664,7 +664,7 @@ public abstract class FinderRecursivePanel<T> extends OnePixelSplitter implement
// ignore
}
Color bg = isSelected ? UIUtil.getTreeSelectionBackground(cellHasFocus) : UIUtil.getTreeTextBackground();
Color bg = UIUtil.getTreeBackground(isSelected, cellHasFocus);
if (!isSelected) {
VirtualFile file = getContainingFile(t);
Color bgColor = file == null ? null : getFileBackgroundColor(myProject, file);
@@ -126,7 +126,7 @@ public abstract class MultilineTreeCellRenderer extends JComponent implements Ac
fgColor = UIUtil.getTreeSelectionForeground();
}
else{
bgColor = UIUtil.getTreeTextBackground();
bgColor = UIUtil.getTreeBackground();
fgColor = getForeground();
}
@@ -145,7 +145,7 @@ public class TreeExpandableItemsHandler extends AbstractExpandableItemsHandler<I
rComponent.setBackground(UIUtil.getTreeSelectionBackground(myComponent.hasFocus()));
}
else {
Color bg = UIUtil.getTreeTextBackground();
Color bg = UIUtil.getTreeBackground();
if (myComponent instanceof Tree && ((Tree)myComponent).isFileColorsEnabled()) {
TreePath path = myComponent.getPathForRow(key);
Color color = path == null ? null : ((Tree)myComponent).getFileColorForPath(path);
@@ -39,9 +39,9 @@ public class BegCellRenderer extends JLabel implements TreeCellRenderer, ListCel
setClosedIcon(UIManager.getIcon("Tree.closedIcon"));
setOpenIcon(UIManager.getIcon("Tree.openIcon"));
setSelectionForeground(UIUtil.getTreeSelectionForeground());
setTextForeground(UIUtil.getTreeTextForeground());
setTextForeground(UIUtil.getTreeForeground());
setSelectionBackground(UIUtil.getTreeSelectionBackground());
setTextBackground(UIUtil.getTreeTextBackground());
setTextBackground(UIUtil.getTreeBackground());
setSelectionBorderColor(UIUtil.getTreeSelectionBorderColor());
Object obj1 = UIManager.get("Tree.drawsFocusBorderAroundIcon");
myDrawsFocusBorderAroundIcon = obj1 != null && ((Boolean)obj1).booleanValue();
@@ -287,8 +287,8 @@ public class ExistingTemplatesComponent {
final Object userObject = treeNode.getUserObject();
if (userObject == null) return;
final Color background = selected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeTextBackground();
final Color foreground = selected && hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();
Color background = UIUtil.getTreeBackground(selected, hasFocus);
Color foreground = UIUtil.getTreeForeground(selected, hasFocus);
final String text;
final int style;
@@ -1751,6 +1751,23 @@ public class JBUI {
public static final JBValue SELECTION_HEIGHT = new JBValue.UIInteger("TabbedPane.tabSelectionHeight", 3);
}
public static final class Tree {
public static Color background(boolean selected, boolean focused) {
if (!selected) return UIManager.getColor("Tree.background");
if (focused) return UIManager.getColor("Tree.selectionBackground");
Color background = UIManager.getColor("Tree.selectionInactiveBackground");
return background != null ? background : UIUtil.getTreeUnfocusedSelectionBackground();
}
public static Color foreground(boolean selected, boolean focused) {
if (!selected) return UIManager.getColor("Tree.foreground");
if (focused) return UIManager.getColor("Tree.selectionForeground");
Color foreground = UIManager.getColor("Tree.selectionInactiveForeground");
return foreground != null ? foreground : UIManager.getColor("Tree.foreground");
}
}
//todo #UX-1 maybe move to popup
public static class BigPopup {
public static Color headerBackground() {
@@ -395,7 +395,7 @@ public class UIUtil {
}
};
private static final Color UNFOCUSED_SELECTION_COLOR = Gray._212;
private static final Color UNFOCUSED_SELECTION_COLOR = new JBColor(0xD4D4D4, 0x0D293E);
private static final Color ACTIVE_HEADER_COLOR = JBColor.namedColor("HeaderColor.active", 0xa0bad5);
private static final Color INACTIVE_HEADER_COLOR = JBColor.namedColor("HeaderColor.inactive", Gray._128);
private static final Color BORDER_COLOR = JBColor.namedColor("Borders.color", new JBColor(Gray._192, Gray._50));
@@ -1147,16 +1147,18 @@ public class UIUtil {
return UIManager.getColor("TableHeader.background");
}
@Deprecated
public static Color getTreeTextForeground() {
return UIManager.getColor("Tree.textForeground");
return getTreeForeground();
}
public static Color getTreeSelectionBackground() {
return UIManager.getColor("Tree.selectionBackground");
return JBUI.CurrentTheme.Tree.background(true, true);
}
@Deprecated
public static Color getTreeTextBackground() {
return UIManager.getColor("Tree.textBackground");
return getTreeBackground();
}
public static Color getListSelectionForeground() {
@@ -1209,18 +1211,15 @@ public class UIUtil {
}
public static Color getTreeSelectionForeground() {
return UIManager.getColor("Tree.selectionForeground");
return JBUI.CurrentTheme.Tree.foreground(true, true);
}
public static Color getTreeForeground(boolean selected, boolean hasFocus) {
if (!selected) {
return getTreeForeground();
}
Color fg = UIManager.getColor("Tree.selectionInactiveForeground");
if (!hasFocus && fg != null) {
return fg;
}
return getTreeSelectionForeground();
public static Color getTreeForeground(boolean selected, boolean focused) {
return JBUI.CurrentTheme.Tree.foreground(selected, focused);
}
public static Color getTreeBackground(boolean selected, boolean focused) {
return JBUI.CurrentTheme.Tree.background(selected, focused);
}
/**
@@ -1344,11 +1343,11 @@ public class UIUtil {
}
public static Color getTreeBackground() {
return UIManager.getColor("Tree.background");
return JBUI.CurrentTheme.Tree.background(false, true);
}
public static Color getTreeForeground() {
return UIManager.getColor("Tree.foreground");
return JBUI.CurrentTheme.Tree.foreground(false, true);
}
public static Color getTableFocusCellBackground() {
@@ -1360,7 +1359,7 @@ public class UIUtil {
}
public static Color getListUnfocusedSelectionBackground() {
return new JBColor(UNFOCUSED_SELECTION_COLOR, new Color(13, 41, 62));
return UNFOCUSED_SELECTION_COLOR;
}
public static Color getListSelectionBackground(boolean focused) {
@@ -1368,12 +1367,11 @@ public class UIUtil {
}
public static Color getTreeSelectionBackground(boolean focused) {
return focused ? getTreeSelectionBackground() : getTreeUnfocusedSelectionBackground();
return JBUI.CurrentTheme.Tree.background(true, focused);
}
public static Color getTreeUnfocusedSelectionBackground() {
Color background = getTreeTextBackground();
return ColorUtil.isDark(background) ? new JBColor(Gray._30, new Color(13, 41, 62)) : UNFOCUSED_SELECTION_COLOR;
return UNFOCUSED_SELECTION_COLOR;
}
public static Color getTableUnfocusedSelectionBackground() {
@@ -84,9 +84,8 @@ public class MavenUIUtil {
return baseComponent;
}
final Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();
Color background = selected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeTextBackground();
Color foreground = UIUtil.getTreeForeground(selected, hasFocus);
Color background = UIUtil.getTreeBackground(selected, hasFocus);
panel.add(baseComponent, BorderLayout.CENTER);
panel.setBackground(background);
@@ -150,7 +150,7 @@ public abstract class AbstractTableView<T> extends JPanel implements TypeSafeDat
final boolean empty = messages.length == 0;
final String tooltipText = TooltipUtils.getTooltipText(messages);
if (myEmptyPane != null) {
myEmptyPane.getComponent().setBackground(empty ? UIUtil.getTreeTextBackground() : BaseControl.ERROR_BACKGROUND);
myEmptyPane.getComponent().setBackground(empty ? UIUtil.getTreeBackground() : BaseControl.ERROR_BACKGROUND);
myEmptyPane.getComponent().setToolTipText(tooltipText);
}
final JViewport viewport = (JViewport)myTable.getParent();