Skip to content

DevFaqExpandAndSelectSpecificNode

Antonio Vieiro edited this page Jan 25, 2018 · 1 revision

DevFaqExpandAndSelectSpecificNode

How do I make a particular node visible in the Explorer, and maybe select it?

In general you cannot. See issue #7551.

If you created the Explorer view (e.g. you created a BeanTreeView or similar and put it in a Swing panel of some sort) then you can use [http://www.netbeans.org/download/dev/javadoc/org-openide-explorer/org/openide/explorer/ExplorerManager.html#setSelectedNodes(org.openide.nodes.Node[ ExplorerManager.setSelectedNodes])] and more rarely TreeView.expandNode to display a given node in your tree (The node must be a descendant of the current root node. You cannot construct a new "similar" Node and hope to select it).

If you did not create the Explorer view then there is no reliable way to find it. However you might try scanning`TopComponent.Registry.getOpened()` for instances of ExplorerManager.Provider and looking for appropriate nodes that way. Such tricks must be done with care - the fact that you can find the component to do this does not imply that the author of the component intends that it be there forever, remain of the same type, continue implementing ExplorerManager.Provider or anything else. Check nulls, check casts, be prepared for it not to work on future versions.

In the particular case of making a new file wizard, you can and should ask for the file(s) you create to be selected when the wizard finishes, simply by returning them from WizardDescriptor.InstantiatingIterator.instantiate()


Applies to: NetBeans 5.0, 5.5, 6.x

Apache Migration Information

The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.

This page was exported from http://wiki.netbeans.org/DevFaqExpandAndSelectSpecificNode , that was last modified by NetBeans user Admin on 2009-11-06T15:41:05Z.

NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.

Clone this wiki locally