Search in sources :

Example 1 with ClassTreeNode

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

the class FormNode method getChildren.

private static Collection<BasePsiNode<? extends PsiElement>> getChildren(final Project project, final Form form, final ViewSettings settings) {
    final Set<BasePsiNode<? extends PsiElement>> children = new LinkedHashSet<>();
    children.add(new ClassTreeNode(project, form.getClassToBind(), settings));
    for (PsiFile formBoundToClass : form.getFormFiles()) {
        children.add(new PsiFileNode(project, formBoundToClass, settings));
    }
    return children;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PsiFileNode(com.intellij.ide.projectView.impl.nodes.PsiFileNode) PsiFile(com.intellij.psi.PsiFile) BasePsiNode(com.intellij.ide.projectView.impl.nodes.BasePsiNode) PsiElement(com.intellij.psi.PsiElement) ClassTreeNode(com.intellij.ide.projectView.impl.nodes.ClassTreeNode)

Example 2 with ClassTreeNode

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

the class TreeJavaClassChooserDialog method getSelectedFromTreeUserObject.

@Override
@Nullable
protected PsiClass getSelectedFromTreeUserObject(DefaultMutableTreeNode node) {
    Object userObject = node.getUserObject();
    if (!(userObject instanceof ClassTreeNode))
        return null;
    ClassTreeNode descriptor = (ClassTreeNode) userObject;
    return descriptor.getPsiClass();
}
Also used : ClassTreeNode(com.intellij.ide.projectView.impl.nodes.ClassTreeNode) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ClassTreeNode

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

the class ClassesTreeStructureProvider method modify.

@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
    ArrayList<AbstractTreeNode> result = new ArrayList<>();
    for (final AbstractTreeNode child : children) {
        Object o = child.getValue();
        if (o instanceof PsiClassOwner && !(o instanceof ServerPageFile)) {
            final ViewSettings settings1 = ((ProjectViewNode) parent).getSettings();
            final PsiClassOwner classOwner = (PsiClassOwner) o;
            final VirtualFile file = classOwner.getVirtualFile();
            if (!(classOwner instanceof PsiCompiledElement)) {
                //do not show duplicated items if jar file contains classes and sources
                final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
                if (file != null && fileIndex.isInLibrarySource(file)) {
                    final PsiElement originalElement = classOwner.getOriginalElement();
                    if (originalElement instanceof PsiFile) {
                        PsiFile classFile = (PsiFile) originalElement;
                        final VirtualFile virtualClassFile = classFile.getVirtualFile();
                        if (virtualClassFile != null && fileIndex.isInLibraryClasses(virtualClassFile) && !classOwner.getManager().areElementsEquivalent(classOwner, classFile) && classOwner.getManager().areElementsEquivalent(classOwner.getContainingDirectory(), classFile.getContainingDirectory())) {
                            continue;
                        }
                    }
                }
            }
            if (fileInRoots(file)) {
                PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass[]>() {

                    @Override
                    public PsiClass[] compute() {
                        try {
                            return classOwner.getClasses();
                        } catch (IndexNotReadyException e) {
                            return PsiClass.EMPTY_ARRAY;
                        }
                    }
                });
                if (classes.length == 1 && !(classes[0] instanceof SyntheticElement) && (file == null || file.getNameWithoutExtension().equals(classes[0].getName()))) {
                    result.add(new ClassTreeNode(myProject, classes[0], settings1));
                } else {
                    result.add(new PsiClassOwnerTreeNode(classOwner, settings1));
                }
                continue;
            }
        }
        result.add(child);
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) ViewSettings(com.intellij.ide.projectView.ViewSettings) ClassTreeNode(com.intellij.ide.projectView.impl.nodes.ClassTreeNode) ProjectViewNode(com.intellij.ide.projectView.ProjectViewNode) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ClassTreeNode

use of com.intellij.ide.projectView.impl.nodes.ClassTreeNode in project intellij by bazelbuild.

the class BlazeJavaSyncStatusClassNodeDecorator method decorate.

@Override
public void decorate(ProjectViewNode node, PresentationData data) {
    if (!(node instanceof ClassTreeNode)) {
        return;
    }
    PsiClass psiClass = ((ClassTreeNode) node).getPsiClass();
    if (psiClass == null) {
        return;
    }
    PsiFile psiFile = psiClass.getContainingFile();
    if (psiFile == null) {
        return;
    }
    VirtualFile virtualFile = psiFile.getVirtualFile();
    if (virtualFile == null) {
        return;
    }
    Project project = node.getProject();
    if (SyncStatusHelper.isUnsynced(project, virtualFile)) {
        data.clearText();
        data.addText(psiClass.getName(), SimpleTextAttributes.GRAY_ATTRIBUTES);
        data.addText(" (unsynced)", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) PsiClass(com.intellij.psi.PsiClass) PsiFile(com.intellij.psi.PsiFile) ClassTreeNode(com.intellij.ide.projectView.impl.nodes.ClassTreeNode)

Aggregations

ClassTreeNode (com.intellij.ide.projectView.impl.nodes.ClassTreeNode)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)1 ViewSettings (com.intellij.ide.projectView.ViewSettings)1 BasePsiNode (com.intellij.ide.projectView.impl.nodes.BasePsiNode)1 PsiFileNode (com.intellij.ide.projectView.impl.nodes.PsiFileNode)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 Project (com.intellij.openapi.project.Project)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1