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.modules.visualweb.gravy.dataconnectivity;
043:
044: import org.netbeans.jemmy.operators.JButtonOperator;
045: import org.netbeans.jemmy.operators.JComboBoxOperator;
046: import org.netbeans.jemmy.operators.JTextFieldOperator;
047: import org.netbeans.jemmy.JemmyException;
048: import org.netbeans.jellytools.Bundle;
049: import org.netbeans.jellytools.NbDialogOperator;
050:
051: /**
052: * This class implements test functionality for "Add Data Source" dialog
053: */
054: public class AddDataSourceOperator extends NbDialogOperator {
055: private JButtonOperator _btEdit, _btTestConnection, _btAdd,
056: _btSelectTable;
057: private JComboBoxOperator _cboServerType, _cboURL;
058: private JTextFieldOperator _txtDSName, _txtDBName, _txtHostName,
059: _txtUser, _txtPassword, _txtValidationTable;
060:
061: /**
062: * Creates new instance of this class.
063: */
064: public AddDataSourceOperator() {
065: super (getBundleString("New Database Connection"));
066: }
067:
068: /**
069: * Initializes (if necessary) and returns an object JButtonOperator
070: * for the dialog button "Configure".
071: * @return the appropriate object JButtonOperator
072: */
073: public JButtonOperator btEdit() {
074: if (_btEdit == null) {
075: _btEdit = new JButtonOperator(this ,
076: getBundleString("LBL_CONFIGURE"));
077: }
078: return _btEdit;
079: }
080:
081: /**
082: * Initializes (if necessary) and returns an object JButtonOperator
083: * for the dialog button "Connection".
084: * @return the appropriate object JButtonOperator
085: */
086: public JButtonOperator btTestConnection() {
087: if (_btTestConnection == null) {
088: _btTestConnection = new JButtonOperator(this ,
089: getBundleString("TEST_CONNECTION"));
090: }
091: return _btTestConnection;
092: }
093:
094: /**
095: * Initializes (if necessary) and returns an object JButtonOperator
096: * for the dialog button "Add".
097: * @return the appropriate object JButtonOperator
098: */
099: public JButtonOperator btAdd() {
100: if (_btAdd == null) {
101: _btAdd = new JButtonOperator(this , getBundleString("ADD"));
102: }
103: return _btAdd;
104: }
105:
106: /**
107: * Initializes (if necessary) and returns an object JButtonOperator
108: * for the dialog button "Select".
109: * @return the appropriate object JButtonOperator
110: */
111: public JButtonOperator btSelectTable() {
112: if (_btSelectTable == null) {
113: _btSelectTable = new JButtonOperator(this ,
114: getBundleString("SelectValTable_SelectBtn_label"));
115: }
116: return _btSelectTable;
117: }
118:
119: /**
120: * Initializes (if necessary) and returns an object JComboBoxOperator
121: * for the dialog drop-down list "Server Type".
122: * @return the appropriate object JComboBoxOperator
123: */
124: public JComboBoxOperator cboServerType() {
125: if (_cboServerType == null) {
126: _cboServerType = new JComboBoxOperator(this );
127: }
128: return _cboServerType;
129: }
130:
131: /**
132: * Initializes (if necessary) and returns an object JComboBoxOperator
133: * for the dialog drop-down list "URL".
134: * @return the appropriate object JComboBoxOperator
135: */
136: public JComboBoxOperator cboURL() {
137: if (_cboURL == null) {
138: _cboURL = new JComboBoxOperator(this , 1);
139: }
140: return _cboURL;
141: }
142:
143: /**
144: * Initializes (if necessary) and returns an object JTextFieldOperator
145: * for the dialog text field "Datasource Name".
146: * @return the appropriate object JTextFieldOperator
147: */
148: public JTextFieldOperator txtDSName() {
149: if (_txtDSName == null) {
150: _txtDSName = new JTextFieldOperator(this , 4);
151: }
152: return _txtDSName;
153: }
154:
155: /**
156: * Initializes (if necessary) and returns an object JTextFieldOperator
157: * for the dialog text field "Database Name".
158: * @return the appropriate object JTextFieldOperator
159: */
160: public JTextFieldOperator txtDBName() {
161: if (_txtDBName == null) {
162: _txtDBName = new JTextFieldOperator(this , 0);
163: }
164: return _txtDBName;
165: }
166:
167: /**
168: * Initializes (if necessary) and returns an object JTextFieldOperator
169: * for the dialog text field "Host Name".
170: * @return the appropriate object JTextFieldOperator
171: */
172: public JTextFieldOperator txtHostName() {
173: if (_txtHostName == null) {
174: _txtHostName = new JTextFieldOperator(this , 1);
175: }
176: return _txtHostName;
177: }
178:
179: /**
180: * Initializes (if necessary) and returns an object JTextFieldOperator
181: * for the dialog text field "User".
182: * @return the appropriate object JTextFieldOperator
183: */
184: public JTextFieldOperator txtUser() {
185: if (_txtUser == null) {
186: _txtUser = new JTextFieldOperator(this , 2);
187: }
188: return _txtUser;
189: }
190:
191: /**
192: * Initializes (if necessary) and returns an object JTextFieldOperator
193: * for the dialog text field "Password".
194: * @return the appropriate object JTextFieldOperator
195: */
196: public JTextFieldOperator txtPassword() {
197: if (_txtPassword == null) {
198: _txtPassword = new JTextFieldOperator(this , 3);
199: }
200: return _txtPassword;
201: }
202:
203: /**
204: * Initializes (if necessary) and returns an object JTextFieldOperator
205: * for the dialog text field "Validation Table".
206: * @return the appropriate object JTextFieldOperator
207: */
208: public JTextFieldOperator txtValidationTable() {
209: if (_txtValidationTable == null) {
210: _txtValidationTable = new JTextFieldOperator(this , 7);
211: }
212: return _txtValidationTable;
213: }
214:
215: /**
216: * Initializes all necessary controls.
217: */
218: public void verify() {
219: btOK();
220: btCancel();
221: // btHelp();
222: // btEdit();
223: // btTestConnection();
224: // btSelectTable();
225: // txtDSName();
226: // txtDBName();
227: // txtHostName();
228: txtPassword();
229: cboURL();
230: txtUser();
231: // txtValidationTable();
232: cboServerType();
233: }
234:
235: /**
236: * Finds in a bundle file and returns an actual text of control component.
237: * @param p_text string-key corresponding to required control component.
238: * @return actual text of control component
239: */
240: public static String getBundleString(String p_text) {
241: /* System.out.println("Getting bundle for " + p_text);
242: try {
243: return Bundle.getStringTrimmed("org.netbeans.modules.visualweb.dataconnectivity.ui.Bundle", p_text);
244: } catch (JemmyException e) {}
245: return null;
246: */
247: //stub
248: return p_text;
249: }
250: }
|