Search in sources :

Example 76 with AbstractTreeNode

use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.

the class CommanderPanel method drillDown.

public void drillDown() {
    if (topElementIsSelected()) {
        goUp();
        return;
    }
    if (getSelectedValue() == null) {
        return;
    }
    final AbstractTreeNode element = getSelectedNode();
    if (element.getChildren().isEmpty()) {
        if (!shouldDrillDownOnEmptyElement(element)) {
            navigateSelectedElement();
            return;
        }
    }
    if (myBuilder == null) {
        return;
    }
    updateHistory(false);
    myBuilder.drillDown();
    updateHistory(true);
}
Also used : AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode)

Example 77 with AbstractTreeNode

use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.

the class FavoritesListNode method processUrls.

private static void processUrls(Project project, Collection<TreeItem<Pair<AbstractUrl, String>>> urls, Collection<AbstractTreeNode> result, final AbstractTreeNode me) {
    for (TreeItem<Pair<AbstractUrl, String>> pair : urls) {
        AbstractUrl abstractUrl = pair.getData().getFirst();
        final Object[] path = abstractUrl.createPath(project);
        if (path == null || path.length < 1 || path[0] == null) {
            continue;
        }
        try {
            final String className = pair.getData().getSecond();
            @SuppressWarnings("unchecked") final Class<? extends AbstractTreeNode> nodeClass = (Class<? extends AbstractTreeNode>) Class.forName(className);
            final AbstractTreeNode node = ProjectViewNode.createTreeNode(nodeClass, project, path[path.length - 1], FavoritesManager.getInstance(project).getViewSettings());
            node.setParent(me);
            node.setIndex(result.size());
            result.add(node);
            if (node instanceof ProjectViewNodeWithChildrenList) {
                final List<TreeItem<Pair<AbstractUrl, String>>> children = pair.getChildren();
                if (children != null && !children.isEmpty()) {
                    Collection<AbstractTreeNode> childList = new ArrayList<>();
                    processUrls(project, children, childList, node);
                    for (AbstractTreeNode treeNode : childList) {
                        ((ProjectViewNodeWithChildrenList) node).addChild(treeNode);
                    }
                }
            }
        } catch (Exception e) {
            LOGGER.error(e);
        }
    }
}
Also used : TreeItem(com.intellij.util.TreeItem) AbstractUrl(com.intellij.ide.projectView.impl.AbstractUrl) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) Pair(com.intellij.openapi.util.Pair)

Example 78 with AbstractTreeNode

use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.

the class AbstractListBuilder method drillDown.

public final void drillDown() {
    final Object value = getSelectedValue();
    if (value instanceof AbstractTreeNode) {
        try {
            final AbstractTreeNode node = (AbstractTreeNode) value;
            buildList(node);
            ensureSelectionExist();
        } finally {
            updateParentTitle();
        }
    } else {
        // an element that denotes parent
        goUp();
    }
}
Also used : AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode)

Example 79 with AbstractTreeNode

use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.

the class AbstractListBuilder method buildList.

private void buildList(final AbstractTreeNode parentElement) {
    myCurrentParent = parentElement;
    Future<?> future = AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> myList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)), 200, TimeUnit.MILLISECONDS);
    final Object[] children = getChildren(parentElement);
    myModel.removeAllElements();
    if (shouldAddTopElement()) {
        myModel.addElement(new TopLevelNode(myProject, parentElement.getValue()));
    }
    for (Object aChildren : children) {
        AbstractTreeNode child = (AbstractTreeNode) aChildren;
        child.update();
    }
    if (myComparator != null) {
        Arrays.sort(children, myComparator);
    }
    for (Object aChildren : children) {
        myModel.addElement(aChildren);
    }
    boolean canceled = future.cancel(false);
    if (!canceled) {
        AppExecutorUtil.getAppExecutorService().execute(() -> myList.setCursor(Cursor.getDefaultCursor()));
    }
}
Also used : AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode)

Example 80 with AbstractTreeNode

use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.

the class AbstractListBuilder method goUp.

public final void goUp() {
    if (myCurrentParent == myShownRoot.getParent()) {
        return;
    }
    final AbstractTreeNode element = myCurrentParent.getParent();
    if (element == null) {
        return;
    }
    try {
        AbstractTreeNode oldParent = myCurrentParent;
        buildList(element);
        for (int i = 0; i < myModel.getSize(); i++) {
            if (myModel.getElementAt(i) instanceof NodeDescriptor) {
                final NodeDescriptor desc = (NodeDescriptor) myModel.getElementAt(i);
                final Object elem = desc.getElement();
                if (oldParent.equals(elem)) {
                    selectItem(i);
                    break;
                }
            }
        }
    } finally {
        updateParentTitle();
    }
}
Also used : NodeDescriptor(com.intellij.ide.util.treeView.NodeDescriptor) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode)

Aggregations

AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)150 NotNull (org.jetbrains.annotations.NotNull)69 ArrayList (java.util.ArrayList)51 VirtualFile (com.intellij.openapi.vfs.VirtualFile)40 Project (com.intellij.openapi.project.Project)33 PsiFile (com.intellij.psi.PsiFile)30 Module (com.intellij.openapi.module.Module)27 PsiDirectory (com.intellij.psi.PsiDirectory)25 PsiElement (com.intellij.psi.PsiElement)16 Nullable (org.jetbrains.annotations.Nullable)15 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)14 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)10 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)9 PsiManager (com.intellij.psi.PsiManager)9 List (java.util.List)9 PresentationData (com.intellij.ide.projectView.PresentationData)6 ViewSettings (com.intellij.ide.projectView.ViewSettings)6 PsiFileNode (com.intellij.ide.projectView.impl.nodes.PsiFileNode)6 NamedLibraryElement (com.intellij.ide.projectView.impl.nodes.NamedLibraryElement)5 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)5