From dcb5c016175444939cd741c3ca261fa22b9cbed6 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 25 Apr 2012 01:30:12 +0200 Subject: [PATCH] file colors in commit dialog --- .../src/misc/registry.properties | 3 +- .../vcs/changes/ui/ChangesTreeList.java | 33 +++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 8f689e9f476e..116ed60b3c15 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -217,4 +217,5 @@ ide.goto.implementation.show.interfaces=false ide.goto.implementation.show.interfaces.description=Whether to show sub-interfaces when invoking Goto Implementation (Ctrl+Alt+B) on an interface ide.open.editors.asynchronously=true -ide.open.editors.asynchronously.description=Prepare editors in background thread \ No newline at end of file +ide.open.editors.asynchronously.description=Prepare editors in background thread +file.colors.in.commit.dialog=false \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java index 5097a9aec8e0..943e25373473 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java @@ -26,12 +26,15 @@ import com.intellij.openapi.util.EmptyRunnable; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.FilePathImpl; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ChangesUtil; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.*; import com.intellij.ui.components.JBList; @@ -104,6 +107,29 @@ public abstract class ChangesTreeList extends JPanel { final int checkboxWidth = new JCheckBox().getPreferredSize().width; myTree = new Tree(ChangesBrowserNode.create(myProject, ROOT)) { + + @Override + public boolean isFileColorsEnabled() { + return Registry.is("file.colors.in.commit.dialog") + && FileColorManager.getInstance(project).isEnabled() + && FileColorManager.getInstance(project).isEnabledForProjectView(); + } + + @Override + protected Color getFileColorFor(Object object) { + VirtualFile file = null; + if (object instanceof FilePathImpl) { + file = LocalFileSystem.getInstance().findFileByPath(((FilePathImpl)object).getPath()); + } else if (object instanceof Change) { + file = ((Change)object).getVirtualFile(); + } + + if (file != null) { + return FileColorManager.getInstance(project).getFileColor(file); + } + return super.getFileColorFor(object); + } + public Dimension getPreferredScrollableViewportSize() { Dimension size = super.getPreferredScrollableViewportSize(); size = new Dimension(size.width + 10, size.height); @@ -133,7 +159,7 @@ public abstract class ChangesTreeList extends JPanel { myTree.setRootVisible(false); myTree.setShowsRootHandles(true); - + myTree.setOpaque(false); myTree.setCellRenderer(new MyTreeCellRenderer()); new TreeSpeedSearch(myTree, new Convertor() { public String convert(TreePath o) { @@ -667,6 +693,7 @@ public abstract class ChangesTreeList extends JPanel { } add(myTextRenderer, BorderLayout.CENTER); + setOpaque(false); } public Component getTreeCellRendererComponent(JTree tree, @@ -683,9 +710,11 @@ public abstract class ChangesTreeList extends JPanel { } else { setBackground(null); myCheckBox.setBackground(null); + myCheckBox.setOpaque(false); } - + myTextRenderer.setOpaque(false); + myTextRenderer.setTransparentIconBackground(true); myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (myShowCheckboxes) { ChangesBrowserNode node = (ChangesBrowserNode)value;