blob: c485a8e963ed4f45a49f7865052eebd17362e205 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqExpandAndSelectSpecificNode
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqExpandAndSelectSpecificNode
:description: Apache NetBeans wiki DevFaqExpandAndSelectSpecificNode
:toc: left
:toc-title:
:syntax: true
=== How do I make a particular node visible in the Explorer, and maybe select it?
In general you cannot. See link:http://www.netbeans.org/nonav/issues/show_bug.cgi?id=7551[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 `[link:http://www.netbeans.org/download/dev/javadoc/org-openide-explorer/org/openide/explorer/ExplorerManager.html#setSelectedNodes(org.openide.nodes.Node[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 `link:http://www.netbeans.org/download/dev/javadoc/org-openide-explorer/org/openide/explorer/view/TreeView.html#expandNode(org.openide.nodes.Node)[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`link:http://www.netbeans.org/download/dev/javadoc/org-openide-windows/org/openide/windows/TopComponent.Registry.html#getOpened()[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 `link:http://www.netbeans.org/download/dev/javadoc/org-openide-dialogs/org/openide/WizardDescriptor.InstantiatingIterator.html#instantiate()[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 link:http://wiki.netbeans.org/DevFaqExpandAndSelectSpecificNode[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-02-07, and needs to be reviewed.