KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > db > derby > lib > CreateDerbyDatabaseOperator


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.test.db.derby.lib;
21
22 import org.netbeans.jemmy.operators.*;
23 import org.netbeans.jemmy.util.NameComponentChooser;
24
25 /** Class implementing all necessary methods for handling "Create Java DB Database" NbDialog.
26  *
27  * @author lg198683
28  * @version 1.0
29  */

30 public class CreateDerbyDatabaseOperator extends JDialogOperator {
31
32     /** Creates new CreateDerbyDatabase that can handle it.
33      */

34     public CreateDerbyDatabaseOperator() {
35         super("Create Java DB Database");
36     }
37
38     private JTextAreaOperator _txtJTextArea;
39     private JLabelOperator _lblDatabaseName;
40     private JLabelOperator _lblUserName;
41     private JLabelOperator _lblPassword;
42     private JLabelOperator _lblDatabaseLocation;
43     private JTextFieldOperator _txtPassword;
44     private JTextFieldOperator _txtUserName;
45     private JTextFieldOperator _txtDatabaseName;
46     private JTextFieldOperator _txtDatabaseLocation;
47     private JLabelOperator _lblTheDatabaseNameIsEmpty;
48     private JButtonOperator _btOK;
49     private JButtonOperator _btCancel;
50
51
52     //******************************
53
// Subcomponents definition part
54
//******************************
55

56     /** Tries to find null JTextArea in this dialog.
57      * @return JTextAreaOperator
58      */

59     public JTextAreaOperator txtJTextArea() {
60         if (_txtJTextArea==null) {
61             _txtJTextArea = new JTextAreaOperator(this);
62         }
63         return _txtJTextArea;
64     }
65
66     /** Tries to find "Database Name:" JLabel in this dialog.
67      * @return JLabelOperator
68      */

69     public JLabelOperator lblDatabaseName() {
70         if (_lblDatabaseName==null) {
71             _lblDatabaseName = new JLabelOperator(this, "Database Name:");
72         }
73         return _lblDatabaseName;
74     }
75
76     /** Tries to find "User Name:" JLabel in this dialog.
77      * @return JLabelOperator
78      */

79     public JLabelOperator lblUserName() {
80         if (_lblUserName==null) {
81             _lblUserName = new JLabelOperator(this, "User Name:");
82         }
83         return _lblUserName;
84     }
85
86     /** Tries to find "Password:" JLabel in this dialog.
87      * @return JLabelOperator
88      */

89     public JLabelOperator lblPassword() {
90         if (_lblPassword==null) {
91             _lblPassword = new JLabelOperator(this, "Password:");
92         }
93         return _lblPassword;
94     }
95
96     /** Tries to find "Database Location:" JLabel in this dialog.
97      * @return JLabelOperator
98      */

99     public JLabelOperator lblDatabaseLocation() {
100         if (_lblDatabaseLocation==null) {
101             _lblDatabaseLocation = new JLabelOperator(this, "Database Location:");
102         }
103         return _lblDatabaseLocation;
104     }
105
106     /** Tries to find null JTextField in this dialog.
107      * @return JTextFieldOperator
108      */

109     public JTextFieldOperator txtPassword() {
110         if (_txtPassword==null) {
111             _txtPassword = new JTextFieldOperator(this);
112         }
113         return _txtPassword;
114     }
115
116     /** Tries to find null JTextField in this dialog.
117      * @return JTextFieldOperator
118      */

119     public JTextFieldOperator txtUserName() {
120         if (_txtUserName==null) {
121             _txtUserName = new JTextFieldOperator(this, 1);
122         }
123         return _txtUserName;
124     }
125
126     /** Tries to find null JTextField in this dialog.
127      * @return JTextFieldOperator
128      */

129     public JTextFieldOperator txtDatabaseName() {
130         if (_txtDatabaseName==null) {
131             _txtDatabaseName = new JTextFieldOperator(this, 2);
132         }
133         return _txtDatabaseName;
134     }
135
136     /** Tries to find null JTextField in this dialog.
137      * @return JTextFieldOperator
138      */

139     public JTextFieldOperator txtDatabaseLocation() {
140         if (_txtDatabaseLocation==null) {
141             _txtDatabaseLocation = new JTextFieldOperator(this, 3);
142         }
143         return _txtDatabaseLocation;
144     }
145
146     /** Tries to find "The database name is empty." JLabel in this dialog.
147      * @return JLabelOperator
148      */

149     public JLabelOperator lblTheDatabaseNameIsEmpty() {
150         if (_lblTheDatabaseNameIsEmpty==null) {
151             _lblTheDatabaseNameIsEmpty = new JLabelOperator(this, "The database name is empty.");
152         }
153         return _lblTheDatabaseNameIsEmpty;
154     }
155
156     /** Tries to find "OK" JButton in this dialog.
157      * @return JButtonOperator
158      */

159     public JButtonOperator btOK() {
160         if (_btOK==null) {
161             _btOK = new JButtonOperator(this, "OK");
162         }
163         return _btOK;
164     }
165
166     /** Tries to find "Cancel" JButton in this dialog.
167      * @return JButtonOperator
168      */

169     public JButtonOperator btCancel() {
170         if (_btCancel==null) {
171             _btCancel = new JButtonOperator(this, "Cancel");
172         }
173         return _btCancel;
174     }
175
176
177     //****************************************
178
// Low-level functionality definition part
179
//****************************************
180

181     /** gets text for txtJTextArea
182      * @return String text
183      */

184     public String JavaDoc getJTextArea() {
185         return txtJTextArea().getText();
186     }
187
188     /** sets text for txtJTextArea
189      * @param text String text
190      */

191     public void setJTextArea(String JavaDoc text) {
192         txtJTextArea().setText(text);
193     }
194
195     /** types text for txtJTextArea
196      * @param text String text
197      */

198     public void typeJTextArea(String JavaDoc text) {
199         txtJTextArea().typeText(text);
200     }
201
202     /** gets text for txtPassword
203      * @return String text
204      */

205     public String JavaDoc getPassword() {
206         return txtPassword().getText();
207     }
208
209     /** sets text for txtPassword
210      * @param text String text
211      */

212     public void setPassword(String JavaDoc text) {
213         txtPassword().setText(text);
214     }
215
216     /** types text for txtPassword
217      * @param text String text
218      */

219     public void typePassword(String JavaDoc text) {
220         txtPassword().typeText(text);
221     }
222
223     /** gets text for txtUserName
224      * @return String text
225      */

226     public String JavaDoc getUserName() {
227         return txtUserName().getText();
228     }
229
230     /** sets text for txtUserName
231      * @param text String text
232      */

233     public void setUserName(String JavaDoc text) {
234         txtUserName().setText(text);
235     }
236
237     /** types text for txtUserName
238      * @param text String text
239      */

240     public void typeUserName(String JavaDoc text) {
241         txtUserName().typeText(text);
242     }
243
244     /** gets text for txtDatabaseName
245      * @return String text
246      */

247     public String JavaDoc getDatabaseName() {
248         return txtDatabaseName().getText();
249     }
250
251     /** sets text for txtDatabaseName
252      * @param text String text
253      */

254     public void setDatabaseName(String JavaDoc text) {
255         txtDatabaseName().setText(text);
256     }
257
258     /** types text for txtDatabaseName
259      * @param text String text
260      */

261     public void typeDatabaseName(String JavaDoc text) {
262         txtDatabaseName().typeText(text);
263     }
264
265     /** gets text for txtDatabaseLocation
266      * @return String text
267      */

268     public String JavaDoc getDatabaseLocation() {
269         return txtDatabaseLocation().getText();
270     }
271
272     /** sets text for txtDatabaseLocation
273      * @param text String text
274      */

275     public void setDatabaseLocation(String JavaDoc text) {
276         txtDatabaseLocation().setText(text);
277     }
278
279     /** types text for txtDatabaseLocation
280      * @param text String text
281      */

282     public void typeDatabaseLocation(String JavaDoc text) {
283         txtDatabaseLocation().typeText(text);
284     }
285
286     /** clicks on "OK" JButton
287      */

288     public void ok() {
289         btOK().push();
290     }
291
292     /** clicks on "Cancel" JButton
293      */

294     public void cancel() {
295         btCancel().push();
296     }
297
298
299     //*****************************************
300
// High-level functionality definition part
301
//*****************************************
302

303     /** Performs verification of CreateDerbyDatabase by accessing all its components.
304      */

305     public void verify() {
306         txtJTextArea();
307         lblDatabaseName();
308         lblUserName();
309         lblPassword();
310         lblDatabaseLocation();
311         txtPassword();
312         txtUserName();
313         txtDatabaseName();
314         txtDatabaseLocation();
315         lblTheDatabaseNameIsEmpty();
316         btOK();
317         btCancel();
318     }
319
320     /** Performs simple test of CreateDerbyDatabase
321     * @param args the command line arguments
322     */

323     public static void main(String JavaDoc args[]) {
324         new CreateDerbyDatabaseOperator().verify();
325         System.out.println("Create Java DB Database verification finished.");
326     }
327 }
328
329
Popular Tags