Example usage for com.intellij.openapi.roots.ui ModifiableCellAppearanceEx setIcon

List of usage examples for com.intellij.openapi.roots.ui ModifiableCellAppearanceEx setIcon

Introduction

In this page you can find the example usage for com.intellij.openapi.roots.ui ModifiableCellAppearanceEx setIcon.

Prototype

void setIcon(@Nullable Icon icon);

Source Link

Usage

From source file:com.intellij.ide.structureView.impl.StructureNodeRenderer.java

License:Apache License

public static CellAppearanceEx forNodeDescriptorInTree(Object node, boolean expanded) {
    NodeDescriptor descriptor = getNodeDescriptor(node);
    if (descriptor == null)
        return FileAppearanceService.getInstance().empty();
    String name = descriptor.toString();
    Object psiElement = descriptor.getElement();
    ModifiableCellAppearanceEx result;
    if (psiElement instanceof PsiElement && !((PsiElement) psiElement).isValid()) {
        result = CompositeAppearance.single(name);
    } else {//  w w w  .j av a 2 s. co m
        PsiClass psiClass = getContainingClass(psiElement);
        if (isInheritedMember(node, psiClass) && psiClass != null) {
            CompositeAppearance.DequeEnd ending = new CompositeAppearance().getEnding();
            ending.addText(name, applyDeprecation(psiElement, SimpleTextAttributes.DARK_TEXT));
            ending.addComment(psiClass.getName(),
                    applyDeprecation(psiClass, SimpleTextAttributes.GRAY_ATTRIBUTES));
            result = ending.getAppearance();
        } else {
            SimpleTextAttributes textAttributes = applyDeprecation(psiElement,
                    SimpleTextAttributes.REGULAR_ATTRIBUTES);
            result = CompositeAppearance.single(name, textAttributes);
        }
    }

    result.setIcon(descriptor.getIcon());
    return result;
}