blob: d6b5bcba808671b3540cc070c0a601028f43d3d5 [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.
//
= DevFaqWhatIsANode
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqWhatIsANode
:description: Apache NetBeans wiki DevFaqWhatIsANode
:toc: left
:toc-title:
:syntax: true
=== 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 link:DevFaqDataObject.asciidoc[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 `java.beans.FeatureDescriptor`.
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 link:DevFaqWindowsTopComponent.asciidoc[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 link:DevFaqLookup.asciidoc[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` 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 link:DevFaqNodeSubclass.asciidoc[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 link:http://wiki.netbeans.org/DevFaqWhatIsANode[http://wiki.netbeans.org/DevFaqWhatIsANode] ,
that was last modified by NetBeans user Admin
on 2009-11-06T16:05:15Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.