001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.jellytools.modules.db.derby;
043:
044: import javax.swing.JTextField;
045: import org.netbeans.jellytools.Bundle;
046: import org.netbeans.jemmy.operators.JButtonOperator;
047: import org.netbeans.jemmy.operators.JDialogOperator;
048: import org.netbeans.jemmy.operators.JLabelOperator;
049: import org.netbeans.jemmy.operators.JTextFieldOperator;
050:
051: /** Class implementing all necessary methods for handling "Create Java DB Database" NbDialog.
052: *
053: * @author Martin.Schovanek@sun.com
054: * @version 1.0
055: */
056: public class CreateJavaDBDatabaseOperator extends JDialogOperator {
057:
058: /** Creates new CreateJavaDBDatabaseOperator that can handle it.
059: */
060: public CreateJavaDBDatabaseOperator() {
061: super (Bundle.getStringTrimmed(
062: "org.netbeans.modules.derby.Bundle",
063: "LBL_CreateDatabaseTitle"));
064: }
065:
066: private JLabelOperator _lblTheDatabaseNameIsEmpty;
067: private JLabelOperator _lblDatabaseName;
068: private JLabelOperator _lblUserName;
069: private JLabelOperator _lblPassword;
070: private JLabelOperator _lblDatabaseLocation;
071: private JTextFieldOperator _txtPassword;
072: private JTextFieldOperator _txtUserName;
073: private JTextFieldOperator _txtDatabaseLocation;
074: private JButtonOperator _btSettings;
075: private JTextFieldOperator _txtDatabaseName;
076: private JButtonOperator _btCancel;
077: private JButtonOperator _btOK;
078:
079: //******************************
080: // Subcomponents definition part
081: //******************************
082:
083: /** Tries to find "The database name is empty." JLabel in this dialog.
084: * @return JLabelOperator
085: */
086: public JLabelOperator lblTheDatabaseNameIsEmpty() {
087: if (_lblTheDatabaseNameIsEmpty == null) {
088: _lblTheDatabaseNameIsEmpty = new JLabelOperator(this ,
089: Bundle.getStringTrimmed(
090: "org.netbeans.modules.derby.ui.Bundle",
091: "ERR_DatabaseNameEmpty"));
092: }
093: return _lblTheDatabaseNameIsEmpty;
094: }
095:
096: /** Tries to find "Database Name:" JLabel in this dialog.
097: * @return JLabelOperator
098: */
099: public JLabelOperator lblDatabaseName() {
100: if (_lblDatabaseName == null) {
101: _lblDatabaseName = new JLabelOperator(this , Bundle
102: .getStringTrimmed(
103: "org.netbeans.modules.derby.ui.Bundle",
104: "LBL_DatabaseName"));
105: }
106: return _lblDatabaseName;
107: }
108:
109: /** Tries to find "User Name:" JLabel in this dialog.
110: * @return JLabelOperator
111: */
112: public JLabelOperator lblUserName() {
113: if (_lblUserName == null) {
114: _lblUserName = new JLabelOperator(this , Bundle
115: .getStringTrimmed(
116: "org.netbeans.modules.derby.ui.Bundle",
117: "LBL_UserName"));
118: }
119: return _lblUserName;
120: }
121:
122: /** Tries to find "Password:" JLabel in this dialog.
123: * @return JLabelOperator
124: */
125: public JLabelOperator lblPassword() {
126: if (_lblPassword == null) {
127: _lblPassword = new JLabelOperator(this , Bundle
128: .getStringTrimmed(
129: "org.netbeans.modules.derby.ui.Bundle",
130: "LBL_Password"));
131: }
132: return _lblPassword;
133: }
134:
135: /** Tries to find "Database Location:" JLabel in this dialog.
136: * @return JLabelOperator
137: */
138: public JLabelOperator lblDatabaseLocation() {
139: if (_lblDatabaseLocation == null) {
140: _lblDatabaseLocation = new JLabelOperator(this , Bundle
141: .getStringTrimmed(
142: "org.netbeans.modules.derby.ui.Bundle",
143: "LBL_DatabaseLocation"));
144: }
145: return _lblDatabaseLocation;
146: }
147:
148: /** Tries to find null JTextField in this dialog.
149: * @return JTextFieldOperator
150: */
151: public JTextFieldOperator txtPassword() {
152: if (_txtPassword == null) {
153: _txtPassword = new JTextFieldOperator(
154: (JTextField) lblPassword().getLabelFor());
155: }
156: return _txtPassword;
157: }
158:
159: /** Tries to find null JTextField in this dialog.
160: * @return JTextFieldOperator
161: */
162: public JTextFieldOperator txtUserName() {
163: if (_txtUserName == null) {
164: _txtUserName = new JTextFieldOperator(
165: (JTextField) lblUserName().getLabelFor());
166: }
167: return _txtUserName;
168: }
169:
170: /** Tries to find null JTextField in this dialog.
171: * @return JTextFieldOperator
172: */
173: public JTextFieldOperator txtDatabaseLocation() {
174: if (_txtDatabaseLocation == null) {
175: _txtDatabaseLocation = new JTextFieldOperator(
176: (JTextField) lblDatabaseLocation().getLabelFor());
177: }
178: return _txtDatabaseLocation;
179: }
180:
181: /** Tries to find "Settings..." JButton in this dialog.
182: * @return JButtonOperator
183: */
184: public JButtonOperator btSettings() {
185: if (_btSettings == null) {
186: _btSettings = new JButtonOperator(this , Bundle
187: .getStringTrimmed(
188: "org.netbeans.modules.derby.ui.Bundle",
189: "LBL_Settings"));
190: }
191: return _btSettings;
192: }
193:
194: /** Tries to find null JTextField in this dialog.
195: * @return JTextFieldOperator
196: */
197: public JTextFieldOperator txtDatabaseName() {
198: if (_txtDatabaseName == null) {
199: _txtDatabaseName = new JTextFieldOperator(
200: (JTextField) lblDatabaseName().getLabelFor());
201: }
202: return _txtDatabaseName;
203: }
204:
205: /** Tries to find "Cancel" JButton in this dialog.
206: * @return JButtonOperator
207: */
208: public JButtonOperator btCancel() {
209: if (_btCancel == null) {
210: _btCancel = new JButtonOperator(this , Bundle
211: .getStringTrimmed("org.openide.Bundle",
212: "CTL_CANCEL"));
213: }
214: return _btCancel;
215: }
216:
217: /** Tries to find "OK" JButton in this dialog.
218: * @return JButtonOperator
219: */
220: public JButtonOperator btOK() {
221: if (_btOK == null) {
222: _btOK = new JButtonOperator(this , Bundle.getStringTrimmed(
223: "org.openide.Bundle", "CTL_OK"));
224: }
225: return _btOK;
226: }
227:
228: //****************************************
229: // Low-level functionality definition part
230: //****************************************
231:
232: /** gets text for txtPassword
233: * @return String text
234: */
235: public String getPassword() {
236: return txtPassword().getText();
237: }
238:
239: /** sets text for txtPassword
240: * @param text String text
241: */
242: public void setPassword(String text) {
243: txtPassword().setText(text);
244: }
245:
246: /** types text for txtPassword
247: * @param text String text
248: */
249: public void typePassword(String text) {
250: txtPassword().typeText(text);
251: }
252:
253: /** gets text for txtUserName
254: * @return String text
255: */
256: public String getUserName() {
257: return txtUserName().getText();
258: }
259:
260: /** sets text for txtUserName
261: * @param text String text
262: */
263: public void setUserName(String text) {
264: txtUserName().setText(text);
265: }
266:
267: /** types text for txtUserName
268: * @param text String text
269: */
270: public void typeUserName(String text) {
271: txtUserName().typeText(text);
272: }
273:
274: /** gets text for txtDatabaseLocation
275: * @return String text
276: */
277: public String getDatabaseLocation() {
278: return txtDatabaseLocation().getText();
279: }
280:
281: /** sets text for txtDatabaseLocation
282: * @param text String text
283: */
284: public void setDatabaseLocation(String text) {
285: txtDatabaseLocation().setText(text);
286: }
287:
288: /** types text for txtDatabaseLocation
289: * @param text String text
290: */
291: public void typeDatabaseLocation(String text) {
292: txtDatabaseLocation().typeText(text);
293: }
294:
295: /** clicks on "Settings..." JButton
296: */
297: public void settings() {
298: btSettings().push();
299: }
300:
301: /** gets text for txtDatabaseName
302: * @return String text
303: */
304: public String getDatabaseName() {
305: return txtDatabaseName().getText();
306: }
307:
308: /** sets text for txtDatabaseName
309: * @param text String text
310: */
311: public void setDatabaseName(String text) {
312: txtDatabaseName().setText(text);
313: }
314:
315: /** types text for txtDatabaseName
316: * @param text String text
317: */
318: public void typeDatabaseName(String text) {
319: txtDatabaseName().typeText(text);
320: }
321:
322: /** clicks on "Cancel" JButton
323: */
324: public void cancel() {
325: btCancel().push();
326: }
327:
328: /** clicks on "OK" JButton
329: */
330: public void ok() {
331: btOK().push();
332: }
333:
334: //*****************************************
335: // High-level functionality definition part
336: //*****************************************
337:
338: /** Performs verification of CreateJavaDBDatabaseOperator by accessing all its components.
339: */
340: public void verify() {
341: lblTheDatabaseNameIsEmpty();
342: lblDatabaseName();
343: lblUserName();
344: lblPassword();
345: lblDatabaseLocation();
346: txtPassword();
347: txtUserName();
348: txtDatabaseLocation();
349: btSettings();
350: txtDatabaseName();
351: btCancel();
352: btOK();
353: }
354:
355: /** Performs simple test of CreateJavaDBDatabaseOperator
356: * @param args the command line arguments
357: */
358: public static void main(String args[]) {
359: new CreateJavaDBDatabaseOperator().verify();
360: System.out
361: .println("CreateJavaDBDatabaseOperator verification finished.");
362: }
363: }
|