KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jellytools > modules > junit > dialogs > CreateTestsDialogOperator


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

19
20 package org.netbeans.jellytools.modules.junit.dialogs;
21
22 import java.io.PrintStream JavaDoc;
23 import org.netbeans.jellytools.Bundle;
24 import org.netbeans.jellytools.NbDialogOperator;
25 import org.netbeans.jemmy.operators.*;
26
27 /** Class implementing all necessary methods for handling "Create Tests" NbDialog.
28  *
29  * @author dave
30  * @version 1.0
31  */

32 public class CreateTestsDialogOperator extends NbDialogOperator {
33
34     /** Creates new CreateTestsDialogOperator that can handle it.
35      */

36     public CreateTestsDialogOperator() {
37         super(Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.Title"));
38     }
39
40     private JLabelOperator _lblFileSystem;
41     private JComboBoxOperator _cboFileSystem;
42     private JLabelOperator _lblSuiteClassTemplate;
43     private JLabelOperator _lblTestClass;
44     private JComboBoxOperator _cboSuiteClassTemplate;
45     public static final String JavaDoc ITEM_SIMPLEJUNITTEST = "SimpleJUnitTest";
46     private JComboBoxOperator _cboTestClass;
47     private JCheckBoxOperator _cbPublicMethods;
48     private JCheckBoxOperator _cbProtectedMethods;
49     private JCheckBoxOperator _cbPackageMethods;
50     private JCheckBoxOperator _cbComments;
51     private JCheckBoxOperator _cbDefaultBodies;
52     private JCheckBoxOperator _cbJavaDoc;
53     private JCheckBoxOperator _cbIncludeExceptionClasses;
54     private JCheckBoxOperator _cbIncludeAbstractClasses;
55     private JCheckBoxOperator _cbGenerateSuites;
56     private JCheckBoxOperator _cbIncludePackagePrivateClasses;
57     private JCheckBoxOperator _cbShowCreateTestsConfigurationDialog;
58
59
60     //******************************
61
// Subcomponents definition part
62
//******************************
63

64     /** Tries to find "File System:" JLabel in this dialog.
65      * @return JLabelOperator
66      */

67     public JLabelOperator lblFileSystem() {
68         if (_lblFileSystem==null) {
69             _lblFileSystem = new JLabelOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.lblFileSystem.text"));
70         }
71         return _lblFileSystem;
72     }
73
74     /** Tries to find null JComboBox in this dialog.
75      * @return JComboBoxOperator
76      */

77     public JComboBoxOperator cboFileSystem() {
78         if (_cboFileSystem==null) {
79             _cboFileSystem = new JComboBoxOperator(this);
80         }
81         return _cboFileSystem;
82     }
83
84     /** Tries to find "Suite Class Template:" JLabel in this dialog.
85      * @return JLabelOperator
86      */

87     public JLabelOperator lblSuiteClass() {
88         if (_lblSuiteClassTemplate==null) {
89             _lblSuiteClassTemplate = new JLabelOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.lblSuiteClass.text"));
90         }
91         return _lblSuiteClassTemplate;
92     }
93
94     /** Tries to find "Test Class:" JLabel in this dialog.
95      * @return JLabelOperator
96      */

97     public JLabelOperator lblTestClass() {
98         if (_lblTestClass==null) {
99             _lblTestClass = new JLabelOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.lblTestClass.text"));
100         }
101         return _lblTestClass;
102     }
103
104     /** Tries to find null JComboBox in this dialog.
105      * @return JComboBoxOperator
106      */

107     public JComboBoxOperator cboSuiteClass() {
108         if (_cboSuiteClassTemplate==null) {
109             _cboSuiteClassTemplate = new JComboBoxOperator(this, 1);
110         }
111         return _cboSuiteClassTemplate;
112     }
113
114     /** Tries to find null JComboBox in this dialog.
115      * @return JComboBoxOperator
116      */

117     public JComboBoxOperator cboTestClass() {
118         if (_cboTestClass==null) {
119             _cboTestClass = new JComboBoxOperator(this, 2);
120         }
121         return _cboTestClass;
122     }
123
124     /** Tries to find " Public Methods" JCheckBox in this dialog.
125      * @return JCheckBoxOperator
126      */

127     public JCheckBoxOperator cbPublicMethods() {
128         if (_cbPublicMethods==null) {
129             _cbPublicMethods = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkPublic.text"));
130         }
131         return _cbPublicMethods;
132     }
133
134     /** Tries to find " Protected Methods" JCheckBox in this dialog.
135      * @return JCheckBoxOperator
136      */

137     public JCheckBoxOperator cbProtectedMethods() {
138         if (_cbProtectedMethods==null) {
139             _cbProtectedMethods = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkProtected.text"));
140         }
141         return _cbProtectedMethods;
142     }
143
144     /** Tries to find " Package Methods" JCheckBox in this dialog.
145      * @return JCheckBoxOperator
146      */

147     public JCheckBoxOperator cbPackageMethods() {
148         if (_cbPackageMethods==null) {
149             _cbPackageMethods = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkPackage.text"));
150         }
151         return _cbPackageMethods;
152     }
153
154     /** Tries to find " Comments" JCheckBox in this dialog.
155      * @return JCheckBoxOperator
156      */

157     public JCheckBoxOperator cbComments() {
158         if (_cbComments==null) {
159             _cbComments = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkComments.text"));
160         }
161         return _cbComments;
162     }
163
164     /** Tries to find " Default Bodies" JCheckBox in this dialog.
165      * @return JCheckBoxOperator
166      */

167     public JCheckBoxOperator cbDefaultBodies() {
168         if (_cbDefaultBodies==null) {
169             _cbDefaultBodies = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkContent.text"));
170         }
171         return _cbDefaultBodies;
172     }
173
174     /** Tries to find " JavaDoc" JCheckBox in this dialog.
175      * @return JCheckBoxOperator
176      */

177     public JCheckBoxOperator cbJavaDoc() {
178         if (_cbJavaDoc==null) {
179             _cbJavaDoc = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkJavaDoc.text"));
180         }
181         return _cbJavaDoc;
182     }
183
184     /** Tries to find " Include Exception Classes" JCheckBox in this dialog.
185      * @return JCheckBoxOperator
186      */

187     public JCheckBoxOperator cbIncludeExceptionClasses() {
188         if (_cbIncludeExceptionClasses==null) {
189             _cbIncludeExceptionClasses = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkExceptions.text"));
190         }
191         return _cbIncludeExceptionClasses;
192     }
193
194     /** Tries to find " Include Abstract Classes" JCheckBox in this dialog.
195      * @return JCheckBoxOperator
196      */

197     public JCheckBoxOperator cbIncludeAbstractClasses() {
198         if (_cbIncludeAbstractClasses==null) {
199             _cbIncludeAbstractClasses = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkAbstractImpl.text"));
200         }
201         return _cbIncludeAbstractClasses;
202     }
203
204     /** Tries to find " Generate Suites" JCheckBox in this dialog.
205      * @return JCheckBoxOperator
206      */

207     public JCheckBoxOperator cbGenerateSuites() {
208         if (_cbGenerateSuites==null) {
209             _cbGenerateSuites = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkGenerateSuites.text"));
210         }
211         return _cbGenerateSuites;
212     }
213
214     /** Tries to find " Include Package Private Classes" JCheckBox in this dialog.
215      * @return JCheckBoxOperator
216      */

217     public JCheckBoxOperator cbIncludePackagePrivateClasses() {
218         if (_cbIncludePackagePrivateClasses==null) {
219             _cbIncludePackagePrivateClasses = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkPackagePrivateClasses.text"));
220         }
221         return _cbIncludePackagePrivateClasses;
222     }
223
224     /** Tries to find " Show Create Tests Configuration Dialog" JCheckBox in this dialog.
225      * @return JCheckBoxOperator
226      */

227     public JCheckBoxOperator cbShowCreateTestsConfigurationDialog() {
228         if (_cbShowCreateTestsConfigurationDialog==null) {
229             _cbShowCreateTestsConfigurationDialog = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkEnabled.text"));
230         }
231         return _cbShowCreateTestsConfigurationDialog;
232     }
233
234
235     //****************************************
236
// Low-level functionality definition part
237
//****************************************
238

239     /** returns selected item for cboFileSystem
240      * @return String item
241      */

242     public String JavaDoc getSelectedFileSystem() {
243         return cboFileSystem().getSelectedItem().toString();
244     }
245
246     /** selects item for cboFileSystem
247      * @param item String item
248      */

249     public void selectFileSystem(String JavaDoc item) {
250         cboFileSystem().selectItem(item);
251     }
252
253     /** types text for cboFileSystem
254      * @param text String text
255      */

256     public void typeFileSystem(String JavaDoc text) {
257         cboFileSystem().typeText(text);
258     }
259
260     /** returns selected item for cboSuiteClassTemplate
261      * @return String item
262      */

263     public String JavaDoc getSelectedSuiteClass() {
264         return cboSuiteClass().getSelectedItem().toString();
265     }
266
267     /** selects item for cboSuiteClassTemplate
268      * @param item String item
269      */

270     public void selectSuiteClass(String JavaDoc item) {
271         cboSuiteClass().selectItem(item);
272     }
273
274     /** types text for cboSuiteClassTemplate
275      * @param text String text
276      */

277     public void typeSuiteClass(String JavaDoc text) {
278         cboSuiteClass().typeText(text);
279     }
280
281     /** returns selected item for cboTestClass
282      * @return String item
283      */

284     public String JavaDoc getSelectedTestClass() {
285         return cboTestClass().getSelectedItem().toString();
286     }
287
288     /** selects item for cboTestClass
289      * @param item String item
290      */

291     public void selectTestClass(String JavaDoc item) {
292         cboTestClass().selectItem(item);
293     }
294
295     /** types text for cboTestClass
296      * @param text String text
297      */

298     public void typeTestClass(String JavaDoc text) {
299         cboTestClass().typeText(text);
300     }
301
302     /** checks or unchecks given JCheckBox
303      * @param state boolean requested state
304      */

305     public void checkPublicMethods(boolean state) {
306         if (cbPublicMethods().isSelected()!=state) {
307             cbPublicMethods().push();
308         }
309     }
310
311     /** checks or unchecks given JCheckBox
312      * @param state boolean requested state
313      */

314     public void checkProtectedMethods(boolean state) {
315         if (cbProtectedMethods().isSelected()!=state) {
316             cbProtectedMethods().push();
317         }
318     }
319
320     /** checks or unchecks given JCheckBox
321      * @param state boolean requested state
322      */

323     public void checkPackageMethods(boolean state) {
324         if (cbPackageMethods().isSelected()!=state) {
325             cbPackageMethods().push();
326         }
327     }
328
329     /** checks or unchecks given JCheckBox
330      * @param state boolean requested state
331      */

332     public void checkComments(boolean state) {
333         if (cbComments().isSelected()!=state) {
334             cbComments().push();
335         }
336     }
337
338     /** checks or unchecks given JCheckBox
339      * @param state boolean requested state
340      */

341     public void checkDefaultBodies(boolean state) {
342         if (cbDefaultBodies().isSelected()!=state) {
343             cbDefaultBodies().push();
344         }
345     }
346
347     /** checks or unchecks given JCheckBox
348      * @param state boolean requested state
349      */

350     public void checkJavaDoc(boolean state) {
351         if (cbJavaDoc().isSelected()!=state) {
352             cbJavaDoc().push();
353         }
354     }
355
356     /** checks or unchecks given JCheckBox
357      * @param state boolean requested state
358      */

359     public void checkIncludeExceptionClasses(boolean state) {
360         if (cbIncludeExceptionClasses().isSelected()!=state) {
361             cbIncludeExceptionClasses().push();
362         }
363     }
364
365     /** checks or unchecks given JCheckBox
366      * @param state boolean requested state
367      */

368     public void checkIncludeAbstractClasses(boolean state) {
369         if (cbIncludeAbstractClasses().isSelected()!=state) {
370             cbIncludeAbstractClasses().push();
371         }
372     }
373
374     /** checks or unchecks given JCheckBox
375      * @param state boolean requested state
376      */

377     public void checkGenerateSuites(boolean state) {
378         if (cbGenerateSuites().isSelected()!=state) {
379             cbGenerateSuites().push();
380         }
381     }
382
383     /** checks or unchecks given JCheckBox
384      * @param state boolean requested state
385      */

386     public void checkIncludePackagePrivateClasses(boolean state) {
387         if (cbIncludePackagePrivateClasses().isSelected()!=state) {
388             cbIncludePackagePrivateClasses().push();
389         }
390     }
391
392     /** checks or unchecks given JCheckBox
393      * @param state boolean requested state
394      */

395     public void checkShowCreateTestsConfigurationDialog(boolean state) {
396         if (cbShowCreateTestsConfigurationDialog().isSelected()!=state) {
397             cbShowCreateTestsConfigurationDialog().push();
398         }
399     }
400
401
402     //*****************************************
403
// High-level functionality definition part
404
//*****************************************
405

406     /** Performs verification of CreateTestsDialogOperator by accessing all its components.
407      */

408     public void verify() {
409         lblFileSystem();
410         cboFileSystem();
411         lblSuiteClass();
412         lblTestClass();
413         cboSuiteClass();
414         cboTestClass();
415         cbPublicMethods();
416         cbProtectedMethods();
417         cbPackageMethods();
418         cbComments();
419         cbDefaultBodies();
420         cbJavaDoc();
421         cbIncludeExceptionClasses();
422         cbIncludeAbstractClasses();
423         cbGenerateSuites();
424         cbIncludePackagePrivateClasses();
425         cbShowCreateTestsConfigurationDialog();
426     }
427
428     /** Performs simple test of CreateTestsDialogOperator
429     * @param args the command line arguments
430     */

431     public static void main(String JavaDoc args[]) {
432         new CreateTestsDialogOperator().verify();
433         System.out.println("CreateTestsDialogOperator verification finished.");
434     }
435
436     public void dumpAll (PrintStream JavaDoc out, String JavaDoc fs) {
437         Object JavaDoc o = cboFileSystem().getSelectedItem();
438         String JavaDoc str = (o != null) ? o.toString () : "<NULL_VALUE>";
439         if (str.startsWith (fs))
440             str = "<TARGET_FS>" + str.substring (fs.length ());
441         out.println ("FileSystem: " + str);
442         out.println ("SuiteClass: " + cboSuiteClass().getSelectedItem());
443         out.println ("TestClass: " + cboTestClass().getSelectedItem());
444         out.println ("PublicMethod: " + cbPublicMethods().isSelected());
445         out.println ("ProtectedMethod: " + cbProtectedMethods().isSelected());
446         out.println ("PackageMethod: " + cbPackageMethods().isSelected());
447         out.println ("IncludeAbstract: " + cbIncludeAbstractClasses().isSelected());
448         out.println ("IncludeException: " + cbIncludeExceptionClasses().isSelected());
449         out.println ("IncludePackagePrivateClass: " + cbIncludePackagePrivateClasses().isSelected());
450         out.println ("Comments: " + cbComments().isSelected());
451         out.println ("JavaDoc: " + cbJavaDoc().isSelected());
452         out.println ("DefaultBodies: " + cbDefaultBodies().isSelected());
453         out.println ("GenerateSuites: " + cbGenerateSuites().isSelected());
454         out.println ("ShowDialog: " + cbShowCreateTestsConfigurationDialog().isSelected());
455     }
456
457 }
458
Popular Tags