Java Code Examples for com.intellij.ide.util.treeView.AbstractTreeNode#setParent()
The following examples show how to use
com.intellij.ide.util.treeView.AbstractTreeNode#setParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BreakpointsFavoriteListProvider.java From consulo with Apache License 2.0 | 6 votes |
private void replicate(DefaultMutableTreeNode source, AbstractTreeNode destination, final List<AbstractTreeNode<Object>> destinationChildren) { final ArrayList<AbstractTreeNode<Object>> copyChildren = new ArrayList<AbstractTreeNode<Object>>(); AbstractTreeNode<Object> copy = new AbstractTreeNode<Object>(myProject, source.getUserObject()) { @Nonnull @Override public Collection<? extends AbstractTreeNode> getChildren() { return copyChildren; } @Override protected void update(PresentationData presentation) { } }; for (int i = 0; i < source.getChildCount(); i++) { final TreeNode treeNode = source.getChildAt(i); if (treeNode instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode sourceChild = (DefaultMutableTreeNode)treeNode; replicate(sourceChild, copy, copyChildren); } } if (checkNavigatable(copy)) { destinationChildren.add(copy); copy.setParent(destination); } }
Example 2
Source File: DirectoryCoverageViewExtension.java From consulo with Apache License 2.0 | 5 votes |
@Override public List<AbstractTreeNode> getChildrenNodes(AbstractTreeNode node) { List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>(); if (node instanceof CoverageListNode) { final Object val = node.getValue(); if (val instanceof PsiFile) return Collections.emptyList(); final PsiDirectory psiDirectory = (PsiDirectory)val; final PsiDirectory[] subdirectories = ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory[]>() { @Override public PsiDirectory[] compute() { return psiDirectory.getSubdirectories(); } }); for (PsiDirectory subdirectory : subdirectories) { children.add(new CoverageListNode(getProject(), subdirectory, getSuitesBundle(), getStateBean())); } final PsiFile[] psiFiles = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() { @Override public PsiFile[] compute() { return psiDirectory.getFiles(); } }); for (PsiFile psiFile : psiFiles) { children.add(new CoverageListNode(getProject(), psiFile, getSuitesBundle(), getStateBean())); } for (AbstractTreeNode childNode : children) { childNode.setParent(node); } } return children; }
Example 3
Source File: CoverageListRootNode.java From consulo with Apache License 2.0 | 5 votes |
private List<AbstractTreeNode> getTopLevelPackages(CoverageSuitesBundle bundle, CoverageViewManager.StateBean stateBean, Project project) { if (myTopLevelPackages == null) { myTopLevelPackages = bundle.getCoverageEngine().createCoverageViewExtension(project, bundle, stateBean).createTopLevelNodes(); for (AbstractTreeNode abstractTreeNode : myTopLevelPackages) { abstractTreeNode.setParent(this); } } return myTopLevelPackages; }
Example 4
Source File: BookmarksFavoriteListProvider.java From consulo with Apache License 2.0 | 5 votes |
private void updateChildren() { if (myProject.isDisposed()) return; myChildren.clear(); List<Bookmark> bookmarks = myBookmarkManager.getValidBookmarks(); for (final Bookmark bookmark : bookmarks) { AbstractTreeNode<Bookmark> child = new AbstractTreeNode<Bookmark>(myProject, bookmark) { @Nonnull @Override public Collection<? extends AbstractTreeNode> getChildren() { return Collections.emptyList(); } @Override public boolean canNavigate() { return bookmark.canNavigate(); } @Override public boolean canNavigateToSource() { return bookmark.canNavigateToSource(); } @Override public void navigate(boolean requestFocus) { bookmark.navigate(requestFocus); } @Override protected void update(PresentationData presentation) { presentation.setPresentableText(bookmark.toString()); presentation.setIcon(bookmark.getIcon()); } }; child.setParent(myNode); myChildren.add(child); } myFavoritesManager.fireListeners(getListName(myProject)); }
Example 5
Source File: FavoritesTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
private static boolean traverseDepth(final AbstractTreeNode node, final TreeUtil.Traverse traverse) { if (!traverse.accept(node)) return false; final Collection<? extends AbstractTreeNode> children = node.getChildren(); for (AbstractTreeNode child : children) { child.setParent(node); if (!traverseDepth(child, traverse)) return false; } return true; }
Example 6
Source File: FavoritesListNode.java From consulo with Apache License 2.0 | 5 votes |
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<AbstractTreeNode>(); processUrls(project, children, childList, node); for (AbstractTreeNode treeNode : childList) { ((ProjectViewNodeWithChildrenList)node).addChild(treeNode); } } } } catch (Exception ignored) { } } }
Example 7
Source File: CachingChildrenTreeNode.java From consulo with Apache License 2.0 | 5 votes |
protected void setChildren(Collection<AbstractTreeNode> children) { clearChildren(); for (AbstractTreeNode node : children) { myChildren.add((CachingChildrenTreeNode)node); node.setParent(this); } }
Example 8
Source File: ProjectViewNodeWithChildrenList.java From consulo with Apache License 2.0 | 4 votes |
public void addChild(final AbstractTreeNode node) { myChildren.add(node); node.setParent(this); }