Search in sources :

Example 1 with PsiDirectoryNode

use of com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode in project intellij-community by JetBrains.

the class StudyTreeStructureProvider method modify.

@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
    Project project = parent.getProject();
    if (project == null || !shouldModify(project)) {
        return children;
    }
    Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
        return children;
    }
    Collection<AbstractTreeNode> modifiedNodes = new ArrayList<>();
    for (AbstractTreeNode node : children) {
        if (parent instanceof ProjectViewProjectNode && node instanceof PsiDirectoryNode) {
            modifiedNodes.add(createCourseNode(project, node, settings, course));
            continue;
        }
        if (parent instanceof StudyDirectoryNode) {
            AbstractTreeNode modifiedNode = ((StudyDirectoryNode) parent).modifyChildNode(node);
            if (modifiedNode != null) {
                modifiedNodes.add(modifiedNode);
            }
        }
    }
    return modifiedNodes;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectViewProjectNode(com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) Course(com.jetbrains.edu.learning.courseFormat.Course) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PsiDirectoryNode

use of com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode in project android by JetBrains.

the class ModuleNodeIconDecorator method decorate.

@Override
public void decorate(ProjectViewNode node, PresentationData data) {
    if (!(node instanceof PsiDirectoryNode)) {
        return;
    }
    final PsiDirectoryNode psiDirectoryNode = (PsiDirectoryNode) node;
    PsiDirectory psiDirectory = psiDirectoryNode.getValue();
    assert psiDirectory != null;
    Project project = psiDirectory.getProject();
    if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID)) {
        return;
    }
    VirtualFile folder = psiDirectory.getVirtualFile();
    Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(folder);
    if (module != null) {
        if (isModuleDir(module, folder)) {
            data.setIcon(getModuleIcon(module));
        } else if (isSourceRoot(folder, project)) {
            TestArtifactSearchScopes testScopes = TestArtifactSearchScopes.get(module);
            if (testScopes != null && testScopes.isAndroidTestSource(folder)) {
                data.setIcon(AndroidIcons.AndroidTestRoot);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) TestArtifactSearchScopes(com.android.tools.idea.testartifacts.scopes.TestArtifactSearchScopes) PsiDirectory(com.intellij.psi.PsiDirectory) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) Module(com.intellij.openapi.module.Module)

Example 3 with PsiDirectoryNode

use of com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode in project intellij-plugins by JetBrains.

the class DartNodeDecorator method decorate.

@Override
public void decorate(@NotNull final ProjectViewNode node, @NotNull final PresentationData presentation) {
    if (node instanceof PsiFileNode || node instanceof PsiDirectoryNode) {
        final VirtualFile nodeFile = node.getVirtualFile();
        final Project project = node.getProject();
        if (nodeFile != null && project != null && DartAnalysisServerService.getInstance(project).isFileWithErrors(nodeFile)) {
            presentation.setAttributesKey(CodeInsightColors.ERRORS_ATTRIBUTES);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) PsiFileNode(com.intellij.ide.projectView.impl.nodes.PsiFileNode) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)

Example 4 with PsiDirectoryNode

use of com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode in project android by JetBrains.

the class AndroidSourceTypeNode method annotateWithSourceProvider.

private Collection<AbstractTreeNode> annotateWithSourceProvider(Collection<AbstractTreeNode> directoryChildren) {
    List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(directoryChildren.size());
    for (AbstractTreeNode child : directoryChildren) {
        if (child instanceof PsiDirectoryNode) {
            PsiDirectory directory = ((PsiDirectoryNode) child).getValue();
            children.add(new AndroidPsiDirectoryNode(myProject, directory, getSettings(), findSourceProvider(directory.getVirtualFile())));
        } else if (child instanceof PsiFileNode) {
            PsiFile file = ((PsiFileNode) child).getValue();
            children.add(new AndroidPsiFileNode(myProject, file, getSettings(), findSourceProvider(file.getVirtualFile())));
        } else {
            children.add(child);
        }
    }
    return children;
}
Also used : PsiFileNode(com.intellij.ide.projectView.impl.nodes.PsiFileNode) PsiDirectory(com.intellij.psi.PsiDirectory) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) PsiFile(com.intellij.psi.PsiFile)

Example 5 with PsiDirectoryNode

use of com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode in project android by JetBrains.

the class ResourceMergerTreeStructureProvider method modify.

@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
    if (!ApplicationManager.getApplication().isInternal()) {
        return children;
    }
    if (parent instanceof PsiDirectoryNode) {
        PsiDirectory directory = ((PsiDirectoryNode) parent).getValue();
        if (!directory.getName().equals("res")) {
            return children;
        }
        Module module = ModuleUtil.findModuleForPsiElement(directory);
        AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet == null) {
            return children;
        }
        return mergeResourceDirectories(children, settings);
    }
    return children;
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)20 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 PsiDirectory (com.intellij.psi.PsiDirectory)10 NotNull (org.jetbrains.annotations.NotNull)10 Project (com.intellij.openapi.project.Project)8 ArrayList (java.util.ArrayList)6 Module (com.intellij.openapi.module.Module)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 PsiFileNode (com.intellij.ide.projectView.impl.nodes.PsiFileNode)3 PresentationData (com.intellij.ide.projectView.PresentationData)2 NamedLibraryElementNode (com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode)2 AndroidProject (com.android.builder.model.AndroidProject)1 ResourceFolderType (com.android.resources.ResourceFolderType)1 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)1 TestArtifactSearchScopes (com.android.tools.idea.testartifacts.scopes.TestArtifactSearchScopes)1 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)1 ViewSettings (com.intellij.ide.projectView.ViewSettings)1 ExternalLibrariesNode (com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode)1 NamedLibraryElement (com.intellij.ide.projectView.impl.nodes.NamedLibraryElement)1