blob: be036544bdbcbf5fc23046bfc97041ae613970ad [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.
-->
===What is a Node?===
Nodes are presentation objects. They have actions, properties and localized display names - they are the place where the architecture meets the human. Nodes typically wrap some model object and provide human-readable names, icons, etc. They are at the heart of a lot of NetBeans selection and user interface systems.
Nodes are a generic tree structure. A common use for them is to display [[DevFaqDataObject | DataObject ]]s to the user - to represent the user's files visually. Each node has a Children object that can supply a list of child nodes. Nodes are not visual components, and they do not subclass TreeNode from the JDK - they are more related to the JavaBeans specification, subclassing <tt>java.beans.FeatureDescriptor</tt>.
Nodes are displayed in ''explorer views''. The Explorer API provides a number of Swing components which take a Node and can display that node and its children - in trees, lists, tree tables, etc. The property sheet is also an Explorer view - Nodes have properties, which are key-value pairs with localized names.
Generally Nodes should ''represent'' not ''be'' the objects the user is interacting with - if you are putting huge amounts of logic in your Node class, you're probably doing something wrong.
Nodes form the basis of global selection in NetBeans - each [[DevFaqWindowsTopComponent | component in a tab in the ui ]] has an "activated Node". The system globally tracks what component has focus, and each component typically offers some node as the currently selected node (which can change when the user clicks, etc.).
A Node has a [[DevFaqLookup | Lookup ]] which you can ask for objects your code is actually interested in. You never get the selected node and then cast it to some specific Node subclass and do things to that; the real model objects should be available from the Node's Lookup. This helps to future-proof your code - you can have another module provide the same objects your client code is interested in from ''its</tt> Node's lookup, and the client code never has to change - it's just looking for any Node that has what it needs.''
Read about [[DevFaqNodeSubclass | how to implement your own Nodes ]]
===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/DevFaqWhatIsANode ,
that was last modified by NetBeans user Admin
on 2009-11-06T16:05:15Z.