ScopeView: inline method for icon updating

This commit is contained in:
Sergey Malenkov
2018-04-06 17:57:13 +03:00
parent c295270bfb
commit f1f8fddbfb
@@ -583,7 +583,17 @@ public final class ScopeViewTreeModel extends BaseTreeModel<AbstractTreeNode> im
String title = getTitle();
presentation.setPresentableText(title != null ? title : toString());
Icon icon = getIcon();
presentation.setIcon(icon != null ? icon : getFileIcon(node));
if (icon == null && node.isValid()) {
VirtualFile file = node.getVirtualFile();
if (file.isDirectory()) {
AbstractTreeNode parent = getParent();
icon = getFolderIcon(node, null, parent == null ? null : parent.getIcon());
}
else {
icon = file.getFileType().getIcon();
}
}
presentation.setIcon(icon);
decorate(presentation);
}
@@ -1037,15 +1047,6 @@ public final class ScopeViewTreeModel extends BaseTreeModel<AbstractTreeNode> im
return index == null ? null : index.getModuleForFile(file);
}
@Nullable
private static Icon getFileIcon(@NotNull ProjectFileNode node) {
if (!node.isValid()) return null;
VirtualFile file = node.getVirtualFile();
return file.isDirectory()
? getFolderIcon(node, null, null)
: file.getFileType().getIcon();
}
@NotNull
private static Icon getFolderIcon(@NotNull ProjectFileNode node, @Nullable PsiElement element, @Nullable Icon parent) {
if (parent == AllIcons.Nodes.Package) return parent;