Search in sources :

Example 6 with NamedConfigurable

use of com.intellij.openapi.ui.NamedConfigurable in project android by JetBrains.

the class PsModuleCellRenderer method customizeCellRenderer.

@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;
        }
        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);
    }
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent) List(java.util.List) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue)

Example 7 with NamedConfigurable

use of com.intellij.openapi.ui.NamedConfigurable in project intellij-plugins by JetBrains.

the class FlexBuildConfigurationsExtension method getFlexModuleForNode.

@Nullable
private static Module getFlexModuleForNode(@Nullable MasterDetailsComponent.MyNode node) {
    while (node != null) {
        final NamedConfigurable configurable = node.getConfigurable();
        final Object editableObject = configurable == null ? null : configurable.getEditableObject();
        if (editableObject instanceof Module && ModuleType.get((Module) editableObject) instanceof FlexModuleType) {
            return (Module) editableObject;
        }
        final TreeNode parent = node.getParent();
        node = parent instanceof MasterDetailsComponent.MyNode ? (MasterDetailsComponent.MyNode) parent : null;
    }
    return null;
}
Also used : FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) TreeNode(javax.swing.tree.TreeNode) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with NamedConfigurable

use of com.intellij.openapi.ui.NamedConfigurable in project intellij-community by JetBrains.

the class FacetStructureConfigurable method updateMultiSelection.

public boolean updateMultiSelection(final List<NamedConfigurable> selectedConfigurables, final DetailsComponent detailsComponent) {
    FacetType selectedFacetType = null;
    List<FacetEditor> facetEditors = new ArrayList<>();
    for (NamedConfigurable selectedConfigurable : selectedConfigurables) {
        if (selectedConfigurable instanceof FacetConfigurable) {
            FacetConfigurable facetConfigurable = (FacetConfigurable) selectedConfigurable;
            FacetType facetType = facetConfigurable.getEditableObject().getType();
            if (selectedFacetType != null && selectedFacetType != facetType) {
                return false;
            }
            selectedFacetType = facetType;
            facetEditors.add(facetConfigurable.getEditor());
        }
    }
    if (facetEditors.size() <= 1 || selectedFacetType == null) {
        return false;
    }
    FacetEditor[] selectedEditors = facetEditors.toArray(new FacetEditor[facetEditors.size()]);
    MultipleFacetSettingsEditor editor = selectedFacetType.createMultipleConfigurationsEditor(myProject, selectedEditors);
    if (editor == null) {
        return false;
    }
    setSelectedNode(null);
    myCurrentMultipleSettingsEditor = editor;
    detailsComponent.setText(ProjectBundle.message("multiple.facets.banner.0.1.facets", selectedEditors.length, selectedFacetType.getPresentableName()));
    detailsComponent.setContent(editor.createComponent());
    return true;
}
Also used : InvalidFacetType(com.intellij.facet.impl.invalid.InvalidFacetType) MultipleFacetSettingsEditor(com.intellij.facet.ui.MultipleFacetSettingsEditor) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) FacetEditor(com.intellij.facet.ui.FacetEditor)

Example 9 with NamedConfigurable

use of com.intellij.openapi.ui.NamedConfigurable in project intellij-community by JetBrains.

the class FacetsTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value instanceof MasterDetailsComponent.MyNode) {
        final MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode) value;
        final NamedConfigurable configurable = node.getConfigurable();
        if (configurable != null) {
            final Icon icon = configurable.getIcon(expanded);
            final boolean showSeparator = configurable instanceof FrameworkDetectionConfigurable;
            final JComponent component = configureComponent(node.getDisplayName(), null, icon, icon, selected, showSeparator, null, -1);
            myTextLabel.setOpaque(selected);
            return component;
        }
    }
    return myRendererComponent;
}
Also used : NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent)

Example 10 with NamedConfigurable

use of com.intellij.openapi.ui.NamedConfigurable in project intellij-community by JetBrains.

the class ProjectStructureElementRenderer method customizeCellRenderer.

@Override
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value instanceof MasterDetailsComponent.MyNode) {
        final MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode) value;
        final NamedConfigurable namedConfigurable = node.getConfigurable();
        if (namedConfigurable == null) {
            return;
        }
        final String displayName = node.getDisplayName();
        final Icon icon = namedConfigurable.getIcon(expanded);
        setIcon(icon);
        setToolTipText(null);
        setFont(UIUtil.getTreeFont());
        SimpleTextAttributes textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
        if (node.isDisplayInBold()) {
            textAttributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
        } else if (namedConfigurable instanceof ProjectStructureElementConfigurable) {
            final ProjectStructureElement projectStructureElement = ((ProjectStructureElementConfigurable) namedConfigurable).getProjectStructureElement();
            if (projectStructureElement != null) {
                final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer();
                final ProjectStructureProblemsHolderImpl problemsHolder = daemonAnalyzer.getProblemsHolder(projectStructureElement);
                if (problemsHolder != null && problemsHolder.containsProblems()) {
                    final boolean isUnused = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.UNUSED);
                    final boolean haveWarnings = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.WARNING);
                    final boolean haveErrors = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.ERROR);
                    Color foreground = isUnused ? UIUtil.getInactiveTextColor() : null;
                    final int style = haveWarnings || haveErrors ? SimpleTextAttributes.STYLE_WAVED : -1;
                    final Color waveColor = haveErrors ? JBColor.RED : haveWarnings ? JBColor.GRAY : null;
                    textAttributes = textAttributes.derive(style, foreground, null, waveColor);
                    setToolTipText(problemsHolder.composeTooltipMessage());
                }
                append(displayName, textAttributes);
                String description = projectStructureElement.getDescription();
                if (description != null) {
                    append(" (" + description + ")", SimpleTextAttributes.GRAY_ATTRIBUTES, false);
                }
                return;
            }
        }
        append(displayName, textAttributes);
    }
}
Also used : ProjectStructureDaemonAnalyzer(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer) ProjectStructureProblemsHolderImpl(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemsHolderImpl) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) JBColor(com.intellij.ui.JBColor) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent) ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement)

Aggregations

NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)16 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)4 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)3 Nullable (org.jetbrains.annotations.Nullable)3 InvalidFacetType (com.intellij.facet.impl.invalid.InvalidFacetType)2 ActionCallback (com.intellij.openapi.util.ActionCallback)2 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)2 TreeNode (javax.swing.tree.TreeNode)2 PsIssue (com.android.tools.idea.gradle.structure.model.PsIssue)1 FacetEditor (com.intellij.facet.ui.FacetEditor)1 MultipleFacetSettingsEditor (com.intellij.facet.ui.MultipleFacetSettingsEditor)1 FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)1 Module (com.intellij.openapi.module.Module)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 ProjectStructureDaemonAnalyzer (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer)1 ProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement)1 ProjectStructureProblemsHolderImpl (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemsHolderImpl)1 DetailsComponent (com.intellij.openapi.ui.DetailsComponent)1