public void setTreeModel(DefaultTreeModel treeModel) { myTreeModel = treeModel; if (children == null) return; for (Object aChildren : children) { AbstractTreeNode node = (AbstractTreeNode) aChildren; node.setTreeModel(treeModel); } }
public void setTree(JTree tree) { myTree = tree; if (children == null) return; for (Object aChildren : children) { AbstractTreeNode node = (AbstractTreeNode) aChildren; node.setTree(tree); } }
private VirtualFile[] getVirtualFileArray() { ArrayList<VirtualFile> result = new ArrayList<VirtualFile>(); TreePath[] selectionPaths = myTree.getSelectionPaths(); if (selectionPaths != null) { for (TreePath selectionPath : selectionPaths) { AbstractTreeNode treeNode = (AbstractTreeNode) selectionPath.getLastPathComponent(); result.addAll(treeNode.getVirtualFiles()); } } return VfsUtil.toVirtualFileArray(result); }
@Nullable private File[] getFileArray() { ArrayList<File> result = new ArrayList<File>(); TreePath[] selectionPaths = myTree.getSelectionPaths(); if (selectionPaths != null) { for (TreePath selectionPath : selectionPaths) { AbstractTreeNode treeNode = (AbstractTreeNode) selectionPath.getLastPathComponent(); result.addAll(treeNode.getFiles()); } } if (result.isEmpty()) return null; return result.toArray(new File[result.size()]); }
public static Object extractUserObject(DefaultMutableTreeNode node) { Object userObject = node.getUserObject(); Object element = null; if (userObject instanceof AbstractTreeNode) { AbstractTreeNode descriptor = (AbstractTreeNode) userObject; element = descriptor.getValue(); } else if (userObject instanceof NodeDescriptor) { NodeDescriptor descriptor = (NodeDescriptor) userObject; element = descriptor.getElement(); if (element instanceof AbstractTreeNode) { element = ((AbstractTreeNode) element).getValue(); } } else if (userObject != null) { element = userObject; } return element; }
protected boolean acceptFilter( @Nullable Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) { boolean apply = false; if (children != null && filter != null) { for (Iterator it = children.iterator(); it.hasNext(); ) { AbstractTreeNode node = (AbstractTreeNode) it.next(); if (node.acceptFilter(filter, showOnlyFilteredItems)) { apply = true; } else if (showOnlyFilteredItems) { if (node instanceof Disposable) { Disposer.dispose((Disposable) node); } it.remove(); } } applyFilter(apply); } return apply; }