KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > SelectClassPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitconf.ui;
21
22 import javax.swing.JPanel JavaDoc;
23 import org.openide.explorer.ExplorerManager;
24 import org.openide.nodes.Node;
25 import java.awt.BorderLayout JavaDoc;
26 import org.openide.explorer.view.BeanTreeView;
27 import org.openide.util.NbBundle;
28 import java.beans.PropertyChangeEvent JavaDoc;
29 import java.beans.PropertyChangeListener JavaDoc;
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 JavaDoc;
34 import org.openide.nodes.AbstractNode;
35
36 /**
37  * @author Martin Grebac
38  */

39 public class SelectClassPanel extends JPanel JavaDoc implements ExplorerManager.Provider {
40     
41     private ExplorerManager manager;
42     private Node[] selectedNodes;
43     private JPanel JavaDoc panel;
44     private Project project;
45     
46     /**
47      * Creates a new instance of SelectClassPanel
48      */

49     public SelectClassPanel(Project project) {
50         initComponents();
51         this.project = project;
52         manager = new ExplorerManager();
53         manager.addPropertyChangeListener(
54         new PropertyChangeListener JavaDoc() {
55             public void propertyChange(PropertyChangeEvent JavaDoc 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 JavaDoc set = new HashSet JavaDoc();
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")); //NOI18N
78
manager.setRootContext(root);
79     }
80     
81     private void initComponents() {
82         panel = new JPanel JavaDoc();
83         setLayout(new BorderLayout JavaDoc());
84         panel.setLayout(new BorderLayout JavaDoc());
85         add(panel, BorderLayout.CENTER);
86         
87         BeanTreeView btv = new BeanTreeView();
88         btv.getAccessibleContext().
89         setAccessibleName(NbBundle.getMessage(SelectClassPanel.class,"LBL_Class_Tree")); //NOI18N
90
btv.getAccessibleContext().setAccessibleDescription
91         (NbBundle.getMessage(SelectClassPanel.class,"TTL_SelectClass")); //NOI18N
92
panel.add(btv, "Center"); //NOI18N
93
panel.validate();
94         validate();
95     }
96 }
97
Popular Tags