add colored speed search for AbstractFileTreeTable
authorSergey Ignatov <sergey.ignatov@jetbrains.com>
Wed, 27 Jan 2016 20:05:26 +0000 (23:05 +0300)
committerSergey Ignatov <sergey.ignatov@jetbrains.com>
Wed, 27 Jan 2016 20:06:42 +0000 (23:06 +0300)
platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java

index 221236c7af3723303659209bc376ecb4e7905ea5..185757dca543b6183ff4c5617f542478b1a64679 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,10 @@ import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.vfs.VfsUtilCore;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileFilter;
 import com.intellij.openapi.vfs.VfsUtilCore;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileFilter;
+import com.intellij.ui.SimpleColoredComponent;
 import com.intellij.ui.TableUtil;
 import com.intellij.ui.TreeTableSpeedSearch;
 import com.intellij.ui.TableUtil;
 import com.intellij.ui.TreeTableSpeedSearch;
+import com.intellij.ui.speedSearch.SpeedSearchUtil;
 import com.intellij.ui.treeStructure.treetable.TreeTable;
 import com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer;
 import com.intellij.ui.treeStructure.treetable.TreeTableModel;
 import com.intellij.ui.treeStructure.treetable.TreeTable;
 import com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer;
 import com.intellij.ui.treeStructure.treetable.TreeTableModel;
@@ -101,24 +103,29 @@ public class AbstractFileTreeTable<T> extends TreeTable {
     final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
     getTree().setCellRenderer(new DefaultTreeCellRenderer() {
       @Override
     final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
     getTree().setCellRenderer(new DefaultTreeCellRenderer() {
       @Override
-      public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded,
-                                                    final boolean leaf, final int row, final boolean hasFocus) {
-        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+      public Component getTreeCellRendererComponent(JTree tree, 
+                                                    Object value, 
+                                                    boolean sel, 
+                                                    boolean expanded,
+                                                    boolean leaf, 
+                                                    int row, 
+                                                    boolean hasFocus) {
+        SimpleColoredComponent c = new SimpleColoredComponent();
         if (value instanceof ProjectRootNode) {
         if (value instanceof ProjectRootNode) {
-          setText(getProjectNodeText());
-          setIcon(AllIcons.Nodes.Project);
-          return this;
-        }
-        FileNode fileNode = (FileNode)value;
-        VirtualFile file = fileNode.getObject();
-        setText(fileNode.getParent() instanceof FileNode ? file.getName() : file.getPresentableUrl());
-        if (file.isDirectory()) {
-          setIcon(fileIndex.isExcluded(file) ? AllIcons.Modules.ExcludeRoot : PlatformIcons.DIRECTORY_CLOSED_ICON);
+          c.append(getProjectNodeText());
+          c.setIcon(AllIcons.Nodes.Project);
         }
         else {
         }
         else {
-          setIcon(IconUtil.getIcon(file, 0, null));
+          FileNode fileNode = (FileNode)value;
+          VirtualFile file = fileNode.getObject();
+          c.append(fileNode.getParent() instanceof FileNode ? file.getName() : file.getPresentableUrl());
+          Icon icon = file.isDirectory() 
+                      ? fileIndex.isExcluded(file) ? AllIcons.Modules.ExcludeRoot
+                                                   : PlatformIcons.DIRECTORY_CLOSED_ICON : IconUtil.getIcon(file, 0, null);
+          c.setIcon(icon);
         }
         }
-        return this;
+        SpeedSearchUtil.applySpeedSearchHighlighting(AbstractFileTreeTable.this, c, false, selected);
+        return c;
       }
     });
     getTableHeader().setReorderingAllowed(false);
       }
     });
     getTableHeader().setReorderingAllowed(false);