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);
}
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));
}
}
}
}
}
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);
}
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;
}
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));
}
Aggregations