mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert: [show usage] gray a bit repeated files (94baf71372)
This commit is contained in:
@@ -16,9 +16,7 @@
|
||||
|
||||
package com.intellij.find.actions;
|
||||
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
@@ -27,8 +25,6 @@ import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchUtil;
|
||||
import com.intellij.usageView.UsageTreeColors;
|
||||
import com.intellij.usageView.UsageTreeColorsScheme;
|
||||
import com.intellij.usages.TextChunk;
|
||||
import com.intellij.usages.Usage;
|
||||
import com.intellij.usages.UsageGroup;
|
||||
@@ -42,7 +38,6 @@ import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
@@ -109,11 +104,8 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
panel.setBackground(panelBackground);
|
||||
panel.setForeground(panelForeground);
|
||||
|
||||
VirtualFile file = getFile(usage);
|
||||
VirtualFile prevFile = findPrevFile(list, row, column);
|
||||
|
||||
if (column == 0) {
|
||||
appendGroupText(list, (GroupNode)usageNode.getParent(), panel, fileBgColor, isSelected, Comparing.equal(file, prevFile));
|
||||
appendGroupText(list, (GroupNode)usageNode.getParent(), panel, fileBgColor, isSelected);
|
||||
return panel;
|
||||
}
|
||||
else if (usage != ShowUsagesAction.MORE_USAGES_SEPARATOR && usage != ShowUsagesAction.USAGES_OUTSIDE_SCOPE_SEPARATOR) {
|
||||
@@ -144,14 +136,6 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile findPrevFile(@NotNull JTable table, int row, int column) {
|
||||
if (row <= 0) return null;
|
||||
Object prev = table.getValueAt(row - 1, column);
|
||||
UsageNode usageNode = prev instanceof UsageNode ? (UsageNode)prev : null;
|
||||
return getFile(usageNode == null ? null : usageNode.getUsage());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SimpleTextAttributes getAttributes(boolean isSelected, Color fileBgColor, Color bg, Color fg, TextChunk chunk) {
|
||||
SimpleTextAttributes background = chunk.getSimpleAttributesIgnoreBackground();
|
||||
@@ -211,8 +195,7 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
return component;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static SimpleTextAttributes deriveAttributesWithColor(@NotNull SimpleTextAttributes attributes, @Nullable Color fileBgColor) {
|
||||
private static SimpleTextAttributes deriveAttributesWithColor(SimpleTextAttributes attributes, Color fileBgColor) {
|
||||
if (fileBgColor != null) {
|
||||
attributes = attributes.derive(-1,null, fileBgColor,null);
|
||||
}
|
||||
@@ -225,7 +208,7 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
fileBgColor = UIUtil.getListSelectionBackground();
|
||||
}
|
||||
else {
|
||||
VirtualFile virtualFile = getFile(usage);
|
||||
VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null;
|
||||
if (virtualFile != null) {
|
||||
Project project = myUsageView.getProject();
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
|
||||
@@ -238,28 +221,16 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
return fileBgColor;
|
||||
}
|
||||
|
||||
private static VirtualFile getFile(@Nullable Usage usage) {
|
||||
return usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null;
|
||||
}
|
||||
|
||||
private void appendGroupText(@NotNull JTable table,
|
||||
@Nullable GroupNode node,
|
||||
@NotNull JPanel panel,
|
||||
@Nullable Color fileBgColor,
|
||||
boolean isSelected,
|
||||
boolean sameFile) {
|
||||
private void appendGroupText(JTable table, final GroupNode node, JPanel panel, Color fileBgColor, boolean isSelected) {
|
||||
UsageGroup group = node == null ? null : node.getGroup();
|
||||
if (group == null) return;
|
||||
GroupNode parentGroup = (GroupNode)node.getParent();
|
||||
appendGroupText(table, parentGroup, panel, fileBgColor, isSelected, sameFile);
|
||||
appendGroupText(table, parentGroup, panel, fileBgColor, isSelected);
|
||||
if (node.canNavigateToSource()) {
|
||||
SimpleColoredComponent renderer = new SimpleColoredComponent();
|
||||
renderer.setIcon(group.getIcon(false));
|
||||
TextAttributes attributes = UsageTreeColorsScheme.getInstance().getScheme().getAttributes(UsageTreeColors.USAGE_LOCATION);
|
||||
SimpleTextAttributes attr = sameFile && !isSelected
|
||||
? SimpleTextAttributes.fromTextAttributes(attributes)
|
||||
: SimpleTextAttributes.REGULAR_ATTRIBUTES;
|
||||
renderer.append(group.getText(myUsageView), deriveAttributesWithColor(attr, fileBgColor));
|
||||
SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
|
||||
renderer.append(group.getText(myUsageView), attributes);
|
||||
renderer.setBorder(null);
|
||||
SpeedSearchUtil.applySpeedSearchHighlighting(table, renderer, false, isSelected);
|
||||
panel.add(renderer);
|
||||
|
||||
Reference in New Issue
Block a user