Example usage for com.intellij.openapi.ui NamedConfigurable getIcon

List of usage examples for com.intellij.openapi.ui NamedConfigurable getIcon

Introduction

In this page you can find the example usage for com.intellij.openapi.ui NamedConfigurable getIcon.

Prototype

@Nullable
    public Icon getIcon(boolean expanded) 

Source Link

Usage

From source file:com.android.tools.idea.gradle.structure.configurables.PsModuleCellRenderer.java

License:Apache License

@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {
    if (value instanceof MasterDetailsComponent.MyNode) {
        MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode) value;

        NamedConfigurable namedConfigurable = node.getConfigurable();
        if (namedConfigurable == null) {
            return;
        }//w  w w .  j a v  a 2 s.c o  m

        setIcon(namedConfigurable.getIcon(expanded));
        setToolTipText(null);
        setFont(getTreeFont());

        SimpleTextAttributes textAttributes = REGULAR_ATTRIBUTES;
        if (node.isDisplayInBold()) {
            textAttributes = REGULAR_BOLD_ATTRIBUTES;
        } else if (namedConfigurable instanceof BaseNamedConfigurable) {
            PsModule module = ((BaseNamedConfigurable) namedConfigurable).getEditableObject();
            List<PsIssue> issues = myContext.getAnalyzerDaemon().getIssues().findIssues(module,
                    IssuesByTypeAndTextComparator.INSTANCE);
            setToolTipText(getTooltipText(issues, true));

            if (!issues.isEmpty()) {
                PsIssue issue = issues.get(0);
                Color waveColor = issue.getSeverity().getColor();
                textAttributes = textAttributes.derive(STYLE_WAVED, null, null, waveColor);
            }
        }

        append(node.getDisplayName(), textAttributes);
    }
}