コード例 #1
0
 public void setTreeModel(DefaultTreeModel treeModel) {
   myTreeModel = treeModel;
   if (children == null) return;
   for (Object aChildren : children) {
     AbstractTreeNode node = (AbstractTreeNode) aChildren;
     node.setTreeModel(treeModel);
   }
 }
コード例 #2
0
 public void setTree(JTree tree) {
   myTree = tree;
   if (children == null) return;
   for (Object aChildren : children) {
     AbstractTreeNode node = (AbstractTreeNode) aChildren;
     node.setTree(tree);
   }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 @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()]);
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 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;
 }