Search in sources :

Example 1 with ProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement in project intellij-community by JetBrains.

the class AddLibraryToModuleDependenciesAction method update.

@Override
public void update(AnActionEvent e) {
    final ProjectStructureElement element = myConfigurable.getSelectedElement();
    boolean visible = false;
    if (element instanceof LibraryProjectStructureElement) {
        final LibraryEx library = (LibraryEx) ((LibraryProjectStructureElement) element).getLibrary();
        visible = !LibraryEditingUtil.getSuitableModules(ModuleStructureConfigurable.getInstance(myProject), library.getKind(), library).isEmpty();
    }
    e.getPresentation().setVisible(visible);
}
Also used : LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement) ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)

Example 2 with ProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement in project intellij-community by JetBrains.

the class BaseStructureConfigurable method init.

public void init(StructureConfigurableContext context) {
    myContext = context;
    myContext.getDaemonAnalyzer().addListener(new ProjectStructureDaemonAnalyzerListener() {

        @Override
        public void problemsChanged(@NotNull ProjectStructureElement element) {
            if (!myTree.isShowing())
                return;
            myTree.revalidate();
            myTree.repaint();
        }
    });
}
Also used : ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) ProjectStructureDaemonAnalyzerListener(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzerListener)

Example 3 with ProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement in project intellij-community by JetBrains.

the class FindUsagesInProjectStructureActionBase method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final ProjectStructureElement selected = getSelectedElement();
    if (selected == null)
        return;
    final Collection<ProjectStructureElementUsage> usages = getContext().getDaemonAnalyzer().getUsages(selected);
    if (usages.isEmpty()) {
        Messages.showInfoMessage(myParentComponent, FindBundle.message("find.usage.view.no.usages.text"), FindBundle.message("find.pointcut.applications.not.found.title"));
        return;
    }
    RelativePoint point = getPointToShowResults();
    final ProjectStructureElementUsage[] usagesArray = usages.toArray(new ProjectStructureElementUsage[usages.size()]);
    Arrays.sort(usagesArray, (o1, o2) -> o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName()));
    BaseListPopupStep<ProjectStructureElementUsage> step = new BaseListPopupStep<ProjectStructureElementUsage>(ProjectBundle.message("dependencies.used.in.popup.title"), usagesArray) {

        @Override
        public PopupStep onChosen(final ProjectStructureElementUsage selected, final boolean finalChoice) {
            selected.getPlace().navigate();
            return FINAL_CHOICE;
        }

        @NotNull
        @Override
        public String getTextFor(ProjectStructureElementUsage value) {
            return value.getPresentableName();
        }

        @Override
        public Icon getIconFor(ProjectStructureElementUsage selection) {
            return selection.getIcon();
        }
    };
    new ListPopupImpl(step) {

        @Override
        protected ListCellRenderer getListElementRenderer() {
            return new ListCellRendererWithRightAlignedComponent<ProjectStructureElementUsage>() {

                @Override
                protected void customize(ProjectStructureElementUsage value) {
                    setLeftText(value.getPresentableName());
                    setIcon(value.getIcon());
                    setRightForeground(Color.GRAY);
                    setRightText(value.getPresentableLocationInElement());
                }
            };
        }
    }.show(point);
}
Also used : ProjectStructureElementUsage(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 4 with ProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement 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)

Example 5 with ProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement in project intellij-community by JetBrains.

the class BaseStructureConfigurable method reset.

@Override
public void reset() {
    myUiDisposed = false;
    if (!myWasTreeInitialized) {
        initTree();
        myTree.setShowsRootHandles(false);
        loadTree();
    } else {
        super.disposeUIResources();
        myTree.setShowsRootHandles(false);
        loadTree();
    }
    for (ProjectStructureElement element : getProjectStructureElements()) {
        myContext.getDaemonAnalyzer().queueUpdate(element);
    }
    super.reset();
}
Also used : ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement)

Aggregations

ProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement)8 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)2 Library (com.intellij.openapi.roots.libraries.Library)2 LibraryProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)2 ProjectStructureElementUsage (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 Module (com.intellij.openapi.module.Module)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)1 LibraryEditorListener (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener)1 ProjectConfigurationProblem (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectConfigurationProblem)1 ProjectStructureDaemonAnalyzer (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer)1 ProjectStructureDaemonAnalyzerListener (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzerListener)1 ProjectStructureProblemDescription (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription)1 ProjectStructureProblemsHolderImpl (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemsHolderImpl)1 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)1 NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)1 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)1 InvalidArtifact (com.intellij.packaging.impl.artifacts.InvalidArtifact)1 JBColor (com.intellij.ui.JBColor)1