KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > junit > wizards > ClassChooserPanel


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 2004 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.junit.wizards;
21
22 import java.awt.FlowLayout JavaDoc;
23 import java.awt.GridBagConstraints JavaDoc;
24 import java.awt.GridBagLayout JavaDoc;
25 import java.awt.Insets JavaDoc;
26 import java.util.ResourceBundle JavaDoc;
27 import javax.accessibility.AccessibleContext JavaDoc;
28 import javax.swing.BorderFactory JavaDoc;
29 import javax.swing.Box JavaDoc;
30 import javax.swing.BoxLayout JavaDoc;
31 import javax.swing.JLabel JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33 import javax.swing.JTextField JavaDoc;
34 import javax.swing.UIManager JavaDoc;
35 import javax.swing.border.CompoundBorder JavaDoc;
36 import javax.swing.border.EmptyBorder JavaDoc;
37 import javax.swing.border.MatteBorder JavaDoc;
38 import org.netbeans.api.project.Project;
39 import org.netbeans.api.project.ProjectUtils;
40 import org.netbeans.modules.junit.SizeRestrictedPanel;
41 import org.openide.awt.Mnemonics;
42 import org.openide.explorer.view.BeanTreeView;
43 import org.openide.explorer.view.TreeView;
44 import org.openide.loaders.DataObject;
45 import org.openide.util.NbBundle;
46
47 /**
48  *
49  * @author Marian Petras
50  */

51 public class ClassChooserPanel extends JPanel JavaDoc {
52
53     /** label displaying the project name */
54     private JLabel JavaDoc lblProjectName;
55     /** text field displaying name of a selected class to test */
56     private JTextField JavaDoc tfClassToTest;
57     /** text field displaying name of a test class for the selected class */
58     private JTextField JavaDoc tfTestClass;
59     /** text field displaying name of a test class file */
60     private JTextField JavaDoc tfTestFile;
61     
62     /** Creates a new instance of ClassChooserPanel */
63     ClassChooserPanel(Project project) {
64         super();
65         
66         /* Get necessary information: */
67         String JavaDoc projectName = ProjectUtils.getInformation(project)
68                              .getDisplayName();
69         
70         /* Create UI components: */
71         ResourceBundle JavaDoc bundle = NbBundle.getBundle(ClassChooserPanel.class);
72         
73         JLabel JavaDoc lblProject = new JLabel JavaDoc();
74         JLabel JavaDoc lblClassToTest = new JLabel JavaDoc();
75         JLabel JavaDoc lblTestClass = new JLabel JavaDoc();
76         JLabel JavaDoc lblTestFile = new JLabel JavaDoc();
77         
78         Mnemonics.setLocalizedText(lblProject,
79                                    bundle.getString("LBL_Project")); //NOI18N
80
Mnemonics.setLocalizedText(lblClassToTest,
81                                    bundle.getString("LBL_ClassToTest"));//NOI18N
82
Mnemonics.setLocalizedText(lblTestClass,
83                                    bundle.getString("LBL_TestClass")); //NOI18N
84
Mnemonics.setLocalizedText(lblTestFile,
85                                    bundle.getString("LBL_TestFile")); //NOI18N
86

87         lblProjectName = new JLabel JavaDoc(projectName);
88         tfClassToTest = new JTextField JavaDoc();
89         tfTestClass = new JTextField JavaDoc();
90         tfTestFile = new JTextField JavaDoc();
91         
92         tfClassToTest.setEditable(false);
93         tfTestClass.setEditable(false);
94         tfTestFile.setEditable(false);
95         
96         lblProject.setLabelFor(lblProjectName);
97         lblClassToTest.setLabelFor(tfClassToTest);
98         lblTestClass.setLabelFor(tfTestClass);
99         lblTestFile.setLabelFor(tfTestFile);
100         
101         TreeView treeView = new BeanTreeView();
102         treeView.setBorder(BorderFactory.createEmptyBorder());
103
104         AccessibleContext JavaDoc accessCtx;
105         accessCtx = treeView.getAccessibleContext();
106         accessCtx.setAccessibleName(
107                 bundle.getString("AD_Name_ChooseClassToTest")); //NOI18N
108
accessCtx.setAccessibleDescription(
109                 bundle.getString("AD_Descr_ChooseClassToTest")); //NOI18N
110
//PENDING - add accessible descriptions also to other components
111

112         /* set layout of the components: */
113         JPanel JavaDoc projectNamePanel = new SizeRestrictedPanel(false, true);
114         projectNamePanel.setLayout(new FlowLayout JavaDoc(FlowLayout.LEADING, 12, 0));
115         projectNamePanel.add(lblProject);
116         projectNamePanel.add(lblProjectName);
117         projectNamePanel.setBorder(new CompoundBorder JavaDoc(
118                 new MatteBorder JavaDoc(0, 0, 1, 0,
119                                 UIManager.getDefaults()
120                                         .getColor("Label.foreground")), //NOI18N
121
new EmptyBorder JavaDoc(0, 0, 12, 0)));
122         
123         JPanel JavaDoc selectionInfoPanel = new SizeRestrictedPanel(false, true);
124         setLayout(new GridBagLayout JavaDoc());
125         
126         GridBagConstraints JavaDoc gbc = new GridBagConstraints JavaDoc();
127         gbc.anchor = GridBagConstraints.WEST;
128         
129         gbc.gridy = 0;
130         
131         gbc.weightx = 0.0f;
132         gbc.insets = new Insets JavaDoc(0, 0, 6, 12);
133         selectionInfoPanel.add(lblClassToTest, gbc);
134         
135         gbc.weightx = 1.0f;
136         gbc.insets = new Insets JavaDoc(0, 0, 6, 0);
137         selectionInfoPanel.add(tfClassToTest, gbc);
138         
139         gbc.gridy++;
140         
141         gbc.weightx = 0.0f;
142         gbc.insets = new Insets JavaDoc(0, 0, 6, 12);
143         selectionInfoPanel.add(lblTestClass, gbc);
144         
145         gbc.weightx = 1.0f;
146         gbc.insets = new Insets JavaDoc(0, 0, 6, 0);
147         selectionInfoPanel.add(tfTestClass, gbc);
148         
149         gbc.gridy++;
150         
151         gbc.weightx = 0.0f;
152         gbc.insets = new Insets JavaDoc(0, 0, 0, 12);
153         selectionInfoPanel.add(lblTestFile, gbc);
154         
155         gbc.weightx = 1.0f;
156         gbc.insets = new Insets JavaDoc(0, 0, 0, 0);
157         selectionInfoPanel.add(tfTestFile, gbc);
158         
159         setLayout(new BoxLayout JavaDoc(this, BoxLayout.Y_AXIS));
160         add(projectNamePanel);
161         add(Box.createVerticalStrut(18));
162         add(treeView);
163         add(Box.createVerticalStrut(12));
164         add(selectionInfoPanel);
165     }
166     
167     /**
168      */

169     DataObject[] getSelectedClasses() {
170         //PENDING
171
return null;
172     }
173     
174 }
175
Popular Tags