What is an Explorer view?
An explorer view is a GUI component which can display a Node and (optionally) its child nodes. While Nodes are, by definition, a tree structure, explorer views are much more than just JTrees. Here is a list of the components available:
- BeanTreeView - the classic tree view, as seen in the Projects and Files tabs in the IDE
- ListView - a JList based node view component - you can see it in the right hand list in
- ChoiceView - a ComboBox based explorer view - older versions of the NetBeans IDE used this to display a list of methods in the editor toolbar
- ContextTreeView - like a BeanTreeView, but sets its manager's explorered context. The "master" part of a master-detail component that uses two views.
- MenuView - a JMenu view of a Node and its children
- TableView - an Explorer view displaying nodes in a table.
- TreeTableView - a TreeTable view of a Node and its children, in which the left column of the table is a tree of nodes, and the other columns display/edit a specified set of properties of those nodes
- OutlineView - replacement for TreeTableView
- IconView - a view similar to that of the left pane in Windows Explorer - a table of equidistant icons. Not currently used anywhere in the IDE's UI.
- PropertySheetView - doesn't show Nodes per-se at all, but rather, shows a property sheet for editing a Node's properties
With the exception of PropertySheetView, all of these classes live in the package org.openide.explorer.view (sources in openide/explorer in NetBeans' CVS).
An explorer view's content is controlled by its ExplorerManager - you don't set the root node directly on the view component, you use its manager. This is so that more than one view can share a single manager, to do master-detail views (for example, the first page of the New Project wizard is one such view - the right hand panel displays children of the left hand panel's selection).
There are a number of advantages to using Nodes and Explorer Views
- it is possible to create a rich UI with very little UI code
- they integrate well with standard menu/toolbar actions that are sensitive to selection
- they contain convenient and well tested features (start randomly typing in a tree or list view - a little popup will appear and search for a matching node)
- there is a lot of logic built into NetBeans for creating Nodes simply and easily, for example, from any POJO JavaBean and persisting the things they represent, so you can do a lot with very little code by using Nodes and Explorer Views
A common usage is to get a Node for some folder on disk or in the configuration filesystem, optionally create a FilterNode to filter out some child nodes of it or its children, and display that.