1 19 20 package org.netbeans.modules.websvc.wsitconf.ui; 21 22 import javax.swing.JPanel ; 23 import org.openide.explorer.ExplorerManager; 24 import org.openide.nodes.Node; 25 import java.awt.BorderLayout ; 26 import org.openide.explorer.view.BeanTreeView; 27 import org.openide.util.NbBundle; 28 import java.beans.PropertyChangeEvent ; 29 import java.beans.PropertyChangeListener ; 30 import org.netbeans.api.project.Project; 31 import org.openide.nodes.Children; 32 import org.netbeans.spi.project.ui.LogicalViewProvider; 33 import java.util.HashSet ; 34 import org.openide.nodes.AbstractNode; 35 36 39 public class SelectClassPanel extends JPanel implements ExplorerManager.Provider { 40 41 private ExplorerManager manager; 42 private Node[] selectedNodes; 43 private JPanel panel; 44 private Project project; 45 46 49 public SelectClassPanel(Project project) { 50 initComponents(); 51 this.project = project; 52 manager = new ExplorerManager(); 53 manager.addPropertyChangeListener( 54 new PropertyChangeListener () { 55 public void propertyChange(PropertyChangeEvent pce) { 56 selectedNodes = manager.getSelectedNodes(); 57 } 58 }); 59 populateTree(); 60 } 61 62 public Node[] getSelectedNodes(){ 63 return selectedNodes; 64 } 65 66 public ExplorerManager getExplorerManager() { 67 return manager; 68 } 69 70 private void populateTree(){ 71 LogicalViewProvider lvp = (LogicalViewProvider)project.getLookup().lookup(LogicalViewProvider.class); 72 HashSet set = new HashSet (); 73 set.add(lvp.createLogicalView()); 74 Children.Array children = new Children.Array(); 75 children.add((Node[]) set.toArray(new Node[set.size()])); 76 Node root = new AbstractNode(children); 77 root.setDisplayName(NbBundle.getMessage(SelectClassPanel.class, "LBL_Select_Class")); manager.setRootContext(root); 79 } 80 81 private void initComponents() { 82 panel = new JPanel (); 83 setLayout(new BorderLayout ()); 84 panel.setLayout(new BorderLayout ()); 85 add(panel, BorderLayout.CENTER); 86 87 BeanTreeView btv = new BeanTreeView(); 88 btv.getAccessibleContext(). 89 setAccessibleName(NbBundle.getMessage(SelectClassPanel.class,"LBL_Class_Tree")); btv.getAccessibleContext().setAccessibleDescription 91 (NbBundle.getMessage(SelectClassPanel.class,"TTL_SelectClass")); panel.add(btv, "Center"); panel.validate(); 94 validate(); 95 } 96 } 97 | Popular Tags |