1 19 package org.netbeans.modules.websvc.core.dev.wizard; 20 21 import java.awt.BorderLayout ; 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.beans.PropertyChangeSupport ; 25 import javax.swing.JPanel ; 26 import javax.swing.tree.TreeSelectionModel ; 27 import org.openide.explorer.ExplorerManager; 28 import org.openide.explorer.view.BeanTreeView; 29 import org.openide.nodes.Node; 30 31 32 36 public class NodeDisplayPanel extends JPanel implements ExplorerManager.Provider { 37 private PropertyChangeSupport pcs = new PropertyChangeSupport (this); 38 private ExplorerManager manager = new ExplorerManager(); 39 40 41 public NodeDisplayPanel(Node rootNode) { 42 BeanTreeView btv = new BeanTreeView(); 43 btv.setRootVisible(false); 44 btv.setDefaultActionAllowed(false); 45 btv.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); 46 manager.setRootContext(rootNode); 47 Node[] rootChildren = rootNode.getChildren().getNodes(); 48 for (int i = 0; i < rootChildren.length; i++) { 49 btv.expandNode(rootChildren[i]); 50 } 51 manager.addPropertyChangeListener( 52 new PropertyChangeListener () { 53 public void propertyChange(PropertyChangeEvent pce) { 54 firePropertyChange(); 55 } 56 }); 57 setLayout(new BorderLayout ()); 58 add(btv, BorderLayout.CENTER); 59 btv.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(NodeDisplayPanel.class, "ACSD_NodeTreeView")); 60 btv.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NodeDisplayPanel.class, "ACSD_NodeTreeView")); 61 } 62 63 public void addPropertyChangeListener(PropertyChangeListener l) { 64 pcs.addPropertyChangeListener(l); 65 } 66 67 private void firePropertyChange() { 68 pcs.firePropertyChange(ExplorerManager.PROP_NODE_CHANGE, null, null); 69 } 70 71 public Node[] getSelectedNodes() { 72 return manager.getSelectedNodes(); 73 } 74 75 public ExplorerManager getExplorerManager() { 76 return manager; 77 } 78 79 } 80 | Popular Tags |