mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
highlight file colors in scopes view (IDEA-90905)
This commit is contained in:
@@ -29,6 +29,7 @@ import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.ui.JBTreeWithHintProvider;
|
||||
import com.intellij.ui.tabs.FileColorManagerImpl;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -116,7 +117,7 @@ public abstract class ProjectViewTree extends JBTreeWithHintProvider {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Color getColorForObject(Object object, Project project, @NotNull NullableFunction<Object, PsiElement> converter) {
|
||||
public static Color getColorForObject(Object object, Project project, @NotNull Function<Object, PsiElement> converter) {
|
||||
Color color = null;
|
||||
final PsiElement psi = converter.fun(object);
|
||||
if (psi != null) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.ide.projectView.ProjectViewNodeDecorator;
|
||||
import com.intellij.ide.projectView.impl.AbstractProjectViewPane;
|
||||
import com.intellij.ide.projectView.impl.ModuleGroup;
|
||||
import com.intellij.ide.projectView.impl.ProjectViewPane;
|
||||
import com.intellij.ide.projectView.impl.ProjectViewTree;
|
||||
import com.intellij.ide.scopeView.nodes.BasePsiNode;
|
||||
import com.intellij.ide.ui.customization.CustomizationUtil;
|
||||
import com.intellij.ide.util.DeleteHandler;
|
||||
@@ -67,6 +68,7 @@ import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.EditSourceOnDoubleClickHandler;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.OpenSourceUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
@@ -101,13 +103,24 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
private final IdeView myIdeView = new MyIdeView();
|
||||
private final MyPsiTreeChangeAdapter myPsiTreeChangeAdapter = new MyPsiTreeChangeAdapter();
|
||||
|
||||
private final DnDAwareTree myTree = new DnDAwareTree();
|
||||
private final DnDAwareTree myTree = new DnDAwareTree(){
|
||||
@Override
|
||||
public boolean isFileColorsEnabled() {
|
||||
return ProjectViewTree.isFileColorsEnabledFor(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Color getFileColorFor(DefaultMutableTreeNode node) {
|
||||
return ProjectViewTree.getColorForObject(((PackageDependenciesNode)node).getPsiElement(), myProject, Function.ID);
|
||||
}
|
||||
};
|
||||
private final Project myProject;
|
||||
private FileTreeModelBuilder myBuilder;
|
||||
|
||||
private String CURRENT_SCOPE_NAME;
|
||||
|
||||
private TreeExpansionMonitor myTreeExpansionMonitor;
|
||||
private TreeExpansionMonitor<PackageDependenciesNode> myTreeExpansionMonitor;
|
||||
private CopyPasteDelegator myCopyPasteDelegator;
|
||||
private final MyDeletePSIElementProvider myDeletePSIElementProvider = new MyDeletePSIElementProvider();
|
||||
private final ModuleDeleteProvider myDeleteModuleProvider = new ModuleDeleteProvider();
|
||||
|
||||
@@ -345,9 +345,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
if (component instanceof LoadingNode && pathObjects.length > 1) {
|
||||
component = pathObjects[pathObjects.length - 2];
|
||||
}
|
||||
final Object object = ((DefaultMutableTreeNode)component).getUserObject();
|
||||
|
||||
Color color = getFileColorFor(object);
|
||||
Color color = getFileColorFor(((DefaultMutableTreeNode)component));
|
||||
if (color != null) {
|
||||
g.setColor(color);
|
||||
g.fillRect(0, bounds.y, getWidth(), bounds.height);
|
||||
@@ -373,6 +372,11 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Color getFileColorFor(DefaultMutableTreeNode node) {
|
||||
return getFileColorFor(node.getUserObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processKeyEvent(KeyEvent e) {
|
||||
super.processKeyEvent(e);
|
||||
|
||||
Reference in New Issue
Block a user