Search in sources :

Example 11 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.

the class RepositoryTreeNode method setAlienChildren.

public void setAlienChildren(final List<TreeNode> children, final NodeLoadState oldState) {
    myChildren.clear();
    for (TreeNode child : children) {
        if (child instanceof RepositoryTreeNode) {
            ((RepositoryTreeNode) child).setParentNode(this);
            myChildren.add(child);
            myChildrenLoadState = oldState;
        } else if (child instanceof SimpleTextNode) {
            SimpleTextNode node = (SimpleTextNode) child;
            myChildren.add(new SimpleTextNode(node.getText(), node.isError()));
            myChildrenLoadState = oldState;
        }
    }
    myModel.reload(this);
}
Also used : TreeNode(javax.swing.tree.TreeNode)

Example 12 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.

the class KeepingExpandedExpander method onBeforeRefresh.

public void onBeforeRefresh(final RepositoryTreeNode node) {
    mySelectionExpander.onBeforeRefresh(node);
    myThirdLevel = new HashMap<>();
    myExpanded = new ArrayList<>();
    final Enumeration<TreeNode> children = node.children();
    while (children.hasMoreElements()) {
        final TreeNode treeNode = children.nextElement();
        if (treeNode instanceof RepositoryTreeNode) {
            final RepositoryTreeNode repositoryNode = (RepositoryTreeNode) treeNode;
            final List<TreeNode> thirdLevelChildren = repositoryNode.getAllAlreadyLoadedChildren();
            final String nodeName = repositoryNode.getSVNDirEntry().getName();
            if (!thirdLevelChildren.isEmpty()) {
                final boolean selfExpanded = myBrowser.isExpanded(repositoryNode);
                myThirdLevel.put(nodeName, new ChildrenData(selfExpanded, thirdLevelChildren, repositoryNode.getChildrenLoadState()));
                if (selfExpanded) {
                    myExpanded.addAll(myBrowser.getExpandedSubTree(repositoryNode));
                }
            }
        }
    }
}
Also used : RepositoryTreeNode(org.jetbrains.idea.svn.dialogs.RepositoryTreeNode) TreeNode(javax.swing.tree.TreeNode) RepositoryTreeNode(org.jetbrains.idea.svn.dialogs.RepositoryTreeNode)

Example 13 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.

the class KeepingExpandedExpander method onAfterRefresh.

public void onAfterRefresh(final RepositoryTreeNode node) {
    final Enumeration<TreeNode> children = node.children();
    while (children.hasMoreElements()) {
        final RepositoryTreeNode treeNode = (RepositoryTreeNode) children.nextElement();
        final String name = treeNode.getSVNDirEntry().getName();
        final ChildrenData thirdLevelLoaded = myThirdLevel.get(name);
        if (thirdLevelLoaded != null) {
            treeNode.setAlienChildren(thirdLevelLoaded.getChildren(), thirdLevelLoaded.getChildrenState());
            if (thirdLevelLoaded.isExpanded()) {
                myBrowser.expandNode(treeNode);
            }
        }
    }
    for (TreeNode expandedNode : myExpanded) {
        myBrowser.expandNode(expandedNode);
    }
    mySelectionExpander.onAfterRefresh(node);
}
Also used : RepositoryTreeNode(org.jetbrains.idea.svn.dialogs.RepositoryTreeNode) TreeNode(javax.swing.tree.TreeNode) RepositoryTreeNode(org.jetbrains.idea.svn.dialogs.RepositoryTreeNode)

Example 14 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.

the class RepositoryBrowserComponent method getExpandedSubTree.

public Collection<TreeNode> getExpandedSubTree(@NotNull final TreeNode treeNode) {
    final TreeNode[] pathToNode = ((RepositoryTreeModel) myRepositoryTree.getModel()).getPathToRoot(treeNode);
    final Enumeration<TreePath> expanded = myRepositoryTree.getExpandedDescendants(new TreePath(pathToNode));
    final List<TreeNode> result = new ArrayList<>();
    if (expanded != null) {
        while (expanded.hasMoreElements()) {
            final TreePath treePath = expanded.nextElement();
            result.add((TreeNode) treePath.getLastPathComponent());
        }
    }
    return result;
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) ArrayList(java.util.ArrayList)

Example 15 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.

the class RepositoryBrowserComponent method setSelectedNode.

public void setSelectedNode(@NotNull final TreeNode node) {
    final TreeNode[] pathNodes = ((RepositoryTreeModel) myRepositoryTree.getModel()).getPathToRoot(node);
    myRepositoryTree.setSelectionPath(new TreePath(pathNodes));
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode)

Aggregations

TreeNode (javax.swing.tree.TreeNode)149 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)74 TreePath (javax.swing.tree.TreePath)56 Nullable (org.jetbrains.annotations.Nullable)20 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)12 ArrayList (java.util.ArrayList)10 Enumeration (java.util.Enumeration)10 NotNull (org.jetbrains.annotations.NotNull)10 MutableTreeNode (javax.swing.tree.MutableTreeNode)8 JTree (javax.swing.JTree)7 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)6 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)4 Project (com.intellij.openapi.project.Project)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 CheckedTreeNode (com.intellij.ui.CheckedTreeNode)4 Tree (com.intellij.ui.treeStructure.Tree)4 Point (java.awt.Point)4 File (java.io.File)4 AllIcons (com.intellij.icons.AllIcons)3 Pair (com.intellij.openapi.util.Pair)3