IDEA-199540: fix default list renderer to support unfocused state

This commit is contained in:
Sergey Malenkov
2018-10-05 14:37:19 +03:00
parent 546d0a2ce2
commit 7952cf5332
2 changed files with 7 additions and 1 deletions
@@ -21,6 +21,7 @@ import com.intellij.ide.fileTemplates.FileTemplateUtil;
import com.intellij.ui.ListSpeedSearch;
import com.intellij.ui.components.JBList;
import com.intellij.util.Function;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -51,7 +52,7 @@ abstract class FileTemplateTabAsList extends FileTemplateTab {
private class MyListCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
super.getListCellRendererComponent(list, value, index, isSelected, false);
Icon icon = null;
if (value instanceof FileTemplate) {
FileTemplate template = (FileTemplate) value;
@@ -73,6 +74,7 @@ abstract class FileTemplateTabAsList extends FileTemplateTab {
}
}
setIcon(icon);
if (isSelected) setBackground(UIUtil.getListSelectionBackground(cellHasFocus));
return this;
}
}
@@ -1363,6 +1363,10 @@ public class UIUtil {
return new JBColor(UNFOCUSED_SELECTION_COLOR, new Color(13, 41, 62));
}
public static Color getListSelectionBackground(boolean focused) {
return focused ? getListSelectionBackground() : getListUnfocusedSelectionBackground();
}
public static Color getTreeSelectionBackground(boolean focused) {
return focused ? getTreeSelectionBackground() : getTreeUnfocusedSelectionBackground();
}