From e28c177257d5611ef8e1dfbc9dd0b84651e33c5a Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 24 Apr 2012 15:10:21 +0200 Subject: [PATCH] fix grey bg --- .../ide/projectView/impl/ProjectViewTree.java | 7 ++++-- .../intellij/ui/ComponentWithFileColors.java | 23 +++++++++++++++++++ .../intellij/ui/SimpleColoredComponent.java | 6 ++++- .../com/intellij/ui/treeStructure/Tree.java | 10 ++++---- 4 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/ui/ComponentWithFileColors.java diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewTree.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewTree.java index 124e7ae11b42..98de9e954a42 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewTree.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewTree.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -45,6 +45,7 @@ public abstract class ProjectViewTree extends DnDAwareTree { cellRenderer.setOpaque(false); cellRenderer.setIconOpaque(false); setCellRenderer(cellRenderer); + cellRenderer.setTransparentIconBackground(true); setOpaque(false); } @@ -66,6 +67,8 @@ public abstract class ProjectViewTree extends DnDAwareTree { @Override protected void paintComponent(Graphics g) { + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); if (isFileColorsEnabled()) { paintFileColorGutter(g); } @@ -74,7 +77,7 @@ public abstract class ProjectViewTree extends DnDAwareTree { } @Override - protected boolean isFileColorsEnabled() { + public boolean isFileColorsEnabled() { return FileColorManagerImpl._isEnabled() && FileColorManagerImpl._isEnabledForProjectView(); } diff --git a/platform/platform-api/src/com/intellij/ui/ComponentWithFileColors.java b/platform/platform-api/src/com/intellij/ui/ComponentWithFileColors.java new file mode 100644 index 000000000000..1448e9ae92ed --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/ComponentWithFileColors.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2012 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.ui; + +/** + * @author Konstantin Bulenkov + */ +public interface ComponentWithFileColors { + boolean isFileColorsEnabled(); +} diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index d43d97a5cc58..7fb68fdfd301 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -636,6 +636,10 @@ public class SimpleColoredComponent extends JComponent implements Accessible { return myTransparentIconBackground; } + public void setTransparentIconBackground(boolean transparentIconBackground) { + myTransparentIconBackground = transparentIconBackground; + } + private static int getTextBaseLine(FontMetrics metrics, final int height) { return (height - metrics.getHeight()) / 2 + metrics.getAscent(); } diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java index 9753066c297c..ce554a30b2fe 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -21,10 +21,7 @@ import com.intellij.openapi.ui.Queryable; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.impl.content.GraphicsConfig; -import com.intellij.ui.ComponentWithExpandableItems; -import com.intellij.ui.ExpandableItemsHandler; -import com.intellij.ui.ExpandableItemsHandlerFactory; -import com.intellij.ui.LoadingNode; +import com.intellij.ui.*; import com.intellij.util.ReflectionUtil; import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.ComponentWithEmptyText; @@ -48,7 +45,8 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Map; -public class Tree extends JTree implements ComponentWithEmptyText, ComponentWithExpandableItems, Autoscroll, Queryable { +public class Tree extends JTree implements ComponentWithEmptyText, ComponentWithExpandableItems, Autoscroll, Queryable, + ComponentWithFileColors { private StatusText myEmptyText; private ExpandableItemsHandler myExpandableItemsHandler; @@ -132,7 +130,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith return true; } - protected boolean isFileColorsEnabled() { + public boolean isFileColorsEnabled() { return false; }