Search in sources :

Example 1 with ProjectViewProjectNode

use of com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode 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)

Aggregations

ProjectViewProjectNode (com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 Project (com.intellij.openapi.project.Project)1 Course (com.jetbrains.edu.learning.courseFormat.Course)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1