Search in sources :

Example 1 with ViewSettings

use of com.intellij.ide.projectView.ViewSettings in project intellij-community by JetBrains.

the class AbstractTreeStructureBase method getChildElements.

@Override
public Object[] getChildElements(Object element) {
    LOG.assertTrue(element instanceof AbstractTreeNode, element != null ? element.getClass().getName() : null);
    AbstractTreeNode<?> treeNode = (AbstractTreeNode) element;
    Collection<? extends AbstractTreeNode> elements = treeNode.getChildren();
    List<TreeStructureProvider> providers = getProvidersDumbAware();
    if (!providers.isEmpty()) {
        ViewSettings settings = treeNode instanceof SettingsProvider ? ((SettingsProvider) treeNode).getSettings() : ViewSettings.DEFAULT;
        for (TreeStructureProvider provider : providers) {
            try {
                elements = provider.modify(treeNode, (Collection<AbstractTreeNode>) elements, settings);
            } catch (ProcessCanceledException e) {
                throw e;
            } catch (Exception e) {
                LOG.error(e);
            }
        }
    }
    for (AbstractTreeNode node : elements) {
        node.setParent(treeNode);
    }
    return ArrayUtil.toObjectArray(elements);
}
Also used : SettingsProvider(com.intellij.ide.projectView.SettingsProvider) ViewSettings(com.intellij.ide.projectView.ViewSettings) Collection(java.util.Collection) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) TreeStructureProvider(com.intellij.ide.projectView.TreeStructureProvider) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 2 with ViewSettings

use of com.intellij.ide.projectView.ViewSettings in project intellij-community by JetBrains.

the class FavoritesTreeStructure method getChildElements.

@Override
public Object[] getChildElements(Object element) {
    if (!(element instanceof AbstractTreeNode)) {
        return ArrayUtil.EMPTY_OBJECT_ARRAY;
    }
    final AbstractTreeNode favTreeElement = (AbstractTreeNode) element;
    try {
        if (!(element instanceof FavoritesListNode)) {
            Object[] elements = super.getChildElements(favTreeElement);
            if (elements.length > 0)
                return elements;
            ViewSettings settings = favTreeElement instanceof SettingsProvider ? ((SettingsProvider) favTreeElement).getSettings() : ViewSettings.DEFAULT;
            return ArrayUtil.toObjectArray(myNonProjectProvider.modify(favTreeElement, new ArrayList<>(), settings));
        }
        final List<AbstractTreeNode> result = new ArrayList<>();
        final FavoritesListNode listNode = (FavoritesListNode) element;
        if (listNode.getProvider() != null) {
            return ArrayUtil.toObjectArray(listNode.getChildren());
        }
        final Collection<AbstractTreeNode> roots = FavoritesListNode.getFavoritesRoots(myProject, listNode.getName(), listNode);
        for (AbstractTreeNode<?> abstractTreeNode : roots) {
            final Object value = abstractTreeNode.getValue();
            if (value == null)
                continue;
            if (value instanceof PsiElement && !((PsiElement) value).isValid())
                continue;
            if (value instanceof SmartPsiElementPointer && ((SmartPsiElementPointer) value).getElement() == null)
                continue;
            boolean invalid = false;
            for (FavoriteNodeProvider nodeProvider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, myProject)) {
                if (nodeProvider.isInvalidElement(value)) {
                    invalid = true;
                    break;
                }
            }
            if (invalid)
                continue;
            result.add(abstractTreeNode);
        }
        //}
        return ArrayUtil.toObjectArray(result);
    } catch (Exception e) {
        LOGGER.error(e);
    }
    return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
Also used : ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) ViewSettings(com.intellij.ide.projectView.ViewSettings) SettingsProvider(com.intellij.ide.projectView.SettingsProvider) SmartPsiElementPointer(com.intellij.psi.SmartPsiElementPointer) PsiElement(com.intellij.psi.PsiElement)

Example 3 with ViewSettings

use of com.intellij.ide.projectView.ViewSettings in project android by JetBrains.

the class AndroidViewProjectNode method getChildren.

@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
    Project project = getProject();
    assert project != null;
    ViewSettings settings = getSettings();
    // add a node for every module
    // TODO: make this conditional on getSettings().isShowModules(), otherwise collapse them all at the root
    List<Module> modules = Arrays.asList(ModuleManager.getInstance(project).getModules());
    List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(modules.size());
    for (Module module : modules) {
        if (isRootModuleWithNoSources(module)) {
            // If we detect such a module, then we don't show it..
            continue;
        }
        AndroidFacet androidFacet = AndroidFacet.getInstance(module);
        NdkFacet ndkFacet = NdkFacet.getInstance(module);
        if (androidFacet != null && androidFacet.getAndroidModel() != null) {
            children.add(new AndroidModuleNode(project, module, settings, myProjectViewPane));
        } else if (ndkFacet != null && ndkFacet.getNdkModuleModel() != null) {
            children.add(new NdkModuleNode(project, module, settings));
        } else {
            children.add(new NonAndroidModuleNode(project, module, settings));
        }
    }
    // are still visible. See https://code.google.com/p/android/issues/detail?id=76564
    if (children.isEmpty() && isBuildWithGradle(project) && GradleSyncState.getInstance(project).lastSyncFailed()) {
        PsiDirectory dir = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
        if (dir != null) {
            children.add(new PsiDirectoryNode(project, dir, settings));
        }
    }
    if (isBuildWithGradle(project)) {
        children.add(new AndroidBuildScriptsGroupNode(project, settings));
    }
    ExternalBuildFilesGroupNode externalBuildFilesNode = new ExternalBuildFilesGroupNode(project, settings);
    if (!externalBuildFilesNode.getChildren().isEmpty()) {
        children.add(externalBuildFilesNode);
    }
    return children;
}
Also used : ViewSettings(com.intellij.ide.projectView.ViewSettings) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ViewSettings

use of com.intellij.ide.projectView.ViewSettings in project intellij-community by JetBrains.

the class MvcProjectViewPane method createStructure.

@Override
protected ProjectAbstractTreeStructureBase createStructure() {
    final Project project = myProject;
    final String id = getId();
    return new ProjectTreeStructure(project, id) {

        @Override
        public boolean isHideEmptyMiddlePackages() {
            return myViewState.hideEmptyMiddlePackages;
        }

        @Override
        protected AbstractTreeNode createRoot(final Project project, ViewSettings settings) {
            return new MvcProjectNode(project, this, myDescriptor);
        }
    };
}
Also used : Project(com.intellij.openapi.project.Project) ViewSettings(com.intellij.ide.projectView.ViewSettings)

Example 5 with ViewSettings

use of com.intellij.ide.projectView.ViewSettings in project intellij-community by JetBrains.

the class MvcModuleNode method getChildren.

@Override
@NotNull
public Collection<? extends AbstractTreeNode> getChildren() {
    final List<AbstractTreeNode> nodesList = new ArrayList<>();
    final Module module = getValue();
    final ViewSettings viewSettings = getSettings();
    final VirtualFile root = myDescriptor.getFramework().findAppRoot(module);
    if (root == null) {
        return Collections.emptyList();
    }
    myDescriptor.fillModuleChildren(nodesList, module, viewSettings, root);
    return nodesList;
}
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) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ViewSettings (com.intellij.ide.projectView.ViewSettings)7 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)5 ArrayList (java.util.ArrayList)4 NotNull (org.jetbrains.annotations.NotNull)4 SettingsProvider (com.intellij.ide.projectView.SettingsProvider)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)1 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)1 TreeStructureProvider (com.intellij.ide.projectView.TreeStructureProvider)1 ClassTreeNode (com.intellij.ide.projectView.impl.nodes.ClassTreeNode)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 PsiFileNode (com.intellij.ide.projectView.impl.nodes.PsiFileNode)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1