Java Code Examples for org.openide.explorer.view.BeanTreeView#expandNode()

The following examples show how to use org.openide.explorer.view.BeanTreeView#expandNode() . 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: PlatformsCustomizer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void expandAllNodes (BeanTreeView btv, Node node, ExplorerManager mgr, JavaPlatform platform) {
    btv.expandNode (node);
    Children ch = node.getChildren();
    if ( ch == Children.LEAF ) {
        if (platform != null && platform.equals(node.getLookup().lookup(JavaPlatform.class))) {
            try {
                mgr.setSelectedNodes (new Node[] {node});
            } catch (PropertyVetoException e) {
                //Ignore it
            }
        }
        return;
    }
    Node nodes[] = ch.getNodes( true );
    for ( int i = 0; i < nodes.length; i++ ) {
        expandAllNodes( btv, nodes[i], mgr, platform);
    }

}
 
Example 2
Source File: NodeDisplayPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates a new instance of NodeDisplayPanel */
public NodeDisplayPanel(Node rootNode) {
    BeanTreeView btv = new BeanTreeView();
    btv.setRootVisible(false);
    btv.setDefaultActionAllowed(false);
    btv.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    manager.setRootContext(rootNode);
    Node[] rootChildren = rootNode.getChildren().getNodes();
    for (int i = 0; i < rootChildren.length; i++) {
        btv.expandNode(rootChildren[i]);
    }
    manager.addPropertyChangeListener(
    new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent pce) {
            firePropertyChange();
        }
    });
    setLayout(new BorderLayout());
    add(btv, BorderLayout.CENTER);
    btv.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(NodeDisplayPanel.class, "ACSD_PortNodeTreeView"));
    btv.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NodeDisplayPanel.class, "ACSD_PortNodeTreeView"));
}
 
Example 3
Source File: BrowseFolders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void expandFirstLevel(BeanTreeView btv) {
    
    Node root = manager.getRootContext();
    Children ch = root.getChildren();
    if ( ch == Children.LEAF ) {
        return;
    }
    Node nodes[] = ch.getNodes(true);

    btv.expandNode(root);
    for ( int i = 0; i < nodes.length; i++ ) {            
        btv.expandNode( nodes[i] );
        if ( i == 0 ) {
            try {
                manager.setSelectedNodes( new Node[] { nodes[i] } );
            }
            catch ( java.beans.PropertyVetoException e ) {
                // No selection for some reason
            }
        }
    }
}
 
Example 4
Source File: SdksCustomizer.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private static void expandAllNodes(BeanTreeView btv, Node node, ExplorerManager mgr, AndroidSdk platform) {
    btv.expandNode(node);
    Children ch = node.getChildren();
    if (ch == Children.LEAF) {
        if (platform != null && platform.equals(node.getLookup().lookup(AndroidSdk.class))) {
            try {
                mgr.setSelectedNodes(new Node[]{node});
            } catch (PropertyVetoException e) {
                //Ignore it
            }
        }
        return;
    }
    Node nodes[] = ch.getNodes(true);
    for (int i = 0; i < nodes.length; i++) {
        expandAllNodes(btv, nodes[i], mgr, platform);
    }

}
 
Example 5
Source File: LibrariesCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void expandAllNodes (BeanTreeView btv, Node node) {
    btv.expandNode (node);
    Children ch = node.getChildren();
    if ( ch == Children.LEAF ) {            
        return;
    }
    Node nodes[] = ch.getNodes( true );
    for ( int i = 0; i < nodes.length; i++ ) {
        expandAllNodes( btv, nodes[i]);
    }

}
 
Example 6
Source File: CSSStylesDocumentPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the tree view.
 */
private void initTreeView() {
    treeView = new BeanTreeView() {
        {
            MouseAdapter listener = createTreeMouseListener();
            tree.addMouseListener(listener);
            tree.addMouseMotionListener(listener);
            tree.setCellRenderer(createTreeCellRenderer(tree.getCellRenderer()));
        }

        @Override
        public void expandAll() {
            // The original expandAll() doesn't work for us as it doesn't
            // seem to wait for the calculation of sub-nodes.
            Node root = manager.getRootContext();
            expandAll(root);
            // The view attempts to scroll to the expanded node
            // and it does it with a delay. Hence, simple calls like
            // tree.scrollRowToVisible(0) have no effect (are overriden
            // later) => the dummy collapse and expansion attempts
            // to work around that and keep the root node visible.
            collapseNode(root);
            expandNode(root);
        }
        /**
         * Expands the whole sub-tree under the specified node.
         *
         * @param node root node of the sub-tree that should be expanded.
         */
        private void expandAll(Node node) {
            treeView.expandNode(node);
            for (Node subNode : node.getChildren().getNodes(true)) {
                if (!subNode.isLeaf()) {
                    expandAll(subNode);
                }
            }
        }
    };
    treeView.setAllowedDragActions(DnDConstants.ACTION_NONE);
    treeView.setAllowedDropActions(DnDConstants.ACTION_NONE);
    treeView.setRootVisible(false);
    add(treeView, BorderLayout.CENTER);
}
 
Example 7
Source File: DocumentViewPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the tree view.
 */
private void initTreeView() {
    treeView = new BeanTreeView() {
        {
            tree.setCellRenderer(createTreeCellRenderer(tree.getCellRenderer()));
        }

        @Override
        public void expandAll() {
            // The original expandAll() doesn't work for us as it doesn't
            // seem to wait for the calculation of sub-nodes.
            Node root = manager.getRootContext();
            expandAll(root);
            // The view attempts to scroll to the expanded node
            // and it does it with a delay. Hence, simple calls like
            // tree.scrollRowToVisible(0) have no effect (are overriden
            // later) => the dummy collapse and expansion attempts
            // to work around that and keep the root node visible.
            collapseNode(root);
            expandNode(root);
        }

        /**
         * Expands the whole sub-tree under the specified node.
         *
         * @param node root node of the sub-tree that should be expanded.
         */
        private void expandAll(Node node) {
            treeView.expandNode(node);
            for (Node subNode : node.getChildren().getNodes(true)) {
                if (!subNode.isLeaf()) {
                    expandAll(subNode);
                }
            }
        }
    };
    treeView.setAllowedDragActions(DnDConstants.ACTION_NONE);
    treeView.setAllowedDropActions(DnDConstants.ACTION_NONE);
    treeView.setRootVisible(false);
    add(treeView, BorderLayout.CENTER);
}