How do I show my node’s properties in the Properties view?
Note: These pages are being reviewed.
I want to have the properties of my custom nodes displayed in the Properties view when they are selected in my tree view. How do I go about doing that?
Listen for changes in the selected nodes in the [http://bits.netbeans.org/dev/javadoc/org-openide-explorer/org/openide/explorer/ExplorerManager.html ExplorerManager
], and set the activatedNodes
property on the parent [[DevFaqWindowsTopComponent| TopComponent
]] which contains your tree view:
public class MyComponent extends TopComponent implements PropertyChangeListener {
private ExplorerManager explorerManager;
public MyComponent() {
explorerManager = new ExplorerManager();
explorerManager.addPropertyChangeListener(this);
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == explorerManager &&
ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
setActivatedNodes(explorerManager.getSelectedNodes());
}
}
}
Note that the example above is not a complete TopComponent
implementation with a tree view and nodes. It is simply demonstrating how to have the selected node’s properties shown in the Properties view.