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.jellytools.NbDialogOperator;
045: import org.netbeans.jellytools.Bundle;
046: import org.netbeans.jemmy.JemmyException;
047: import org.netbeans.jemmy.operators.JButtonOperator;
048: import org.netbeans.jemmy.operators.JTextFieldOperator;
049: import org.netbeans.jemmy.operators.JListOperator;
050:
051: /**
052: * This class is used as abstract ancestor of classes ExportDataSourcesOperator
053: * and ImportDataSourcesOperator.
054: */
055: public abstract class ExportImportDataSourcesOperator extends
056: NbDialogOperator {
057:
058: /**
059: * This constructor is used by inherited classes for
060: * creation of their new instances.
061: */
062: public ExportImportDataSourcesOperator(String p_title) {
063: super (p_title);
064: }
065:
066: private JButtonOperator _btSelectAll;
067: private JButtonOperator _btClear;
068: private JButtonOperator _btBrowse;
069: private JTextFieldOperator _txtDSName;
070: private JTextFieldOperator _txtValidationQuery;
071: private JTextFieldOperator _txtDriverClass;
072: private JTextFieldOperator _txtUser;
073: private JTextFieldOperator _txtPassword;
074: private JTextFieldOperator _txtURL;
075: private JTextFieldOperator _txtFileName;
076: private JListOperator _lstDataSources;
077:
078: /**
079: * Initializes (if necessary) and returns an object JButtonOperator
080: * for the dialog button "Select All".
081: * @return the appropriate object JButtonOperator
082: */
083: public JButtonOperator btSelectAll() {
084: if (_btSelectAll == null) {
085: _btSelectAll = new JButtonOperator(this ,
086: getBundleString("SCHEMA_SELECT_ALL_BTN_LABEL"));
087: }
088: return _btSelectAll;
089: }
090:
091: /**
092: * Initializes (if necessary) and returns an object JButtonOperator
093: * for the dialog button "Clear".
094: * @return the appropriate object JButtonOperator
095: */
096: public JButtonOperator btClear() {
097: if (_btClear == null) {
098: _btClear = new JButtonOperator(this ,
099: getBundleString("SCHEMA_CLEAR_BTN_LABEL"));
100: }
101: return _btClear;
102: }
103:
104: /**
105: * Initializes (if necessary) and returns an object JButtonOperator
106: * for the dialog button "Browse".
107: * @return the appropriate object JButtonOperator
108: */
109: public JButtonOperator btBrowse() {
110: if (_btBrowse == null) {
111: _btBrowse = new JButtonOperator(this ,
112: getBundleString("BROWSE_BUTTON_LABEL"));
113: }
114: return _btBrowse;
115: }
116:
117: /**
118: * Initializes (if necessary) and returns an object JTextFieldOperator
119: * for the dialog text field "Datasource Name".
120: * @return the appropriate object JTextFieldOperator
121: */
122: public JTextFieldOperator txtDSName() {
123: if (_txtDSName == null) {
124: _txtDSName = new JTextFieldOperator(this , 2);
125: }
126: return _txtDSName;
127: }
128:
129: /**
130: * Initializes (if necessary) and returns an object JTextFieldOperator
131: * for the dialog text field "Validation Query".
132: * @return the appropriate object JTextFieldOperator
133: */
134: public JTextFieldOperator txtValidationQuery() {
135: if (_txtValidationQuery == null) {
136: _txtValidationQuery = new JTextFieldOperator(this , 1);
137: }
138: return _txtValidationQuery;
139: }
140:
141: /**
142: * Initializes (if necessary) and returns an object JTextFieldOperator
143: * for the dialog text field "Driver Class".
144: * @return the appropriate object JTextFieldOperator
145: */
146: public JTextFieldOperator txtDriverClass() {
147: if (_txtDriverClass == null) {
148: _txtDriverClass = new JTextFieldOperator(this , 0);
149: }
150: return _txtDriverClass;
151: }
152:
153: /**
154: * Initializes (if necessary) and returns an object JTextFieldOperator
155: * for the dialog text field "User".
156: * @return the appropriate object JTextFieldOperator
157: */
158: public JTextFieldOperator txtUser() {
159: if (_txtUser == null) {
160: _txtUser = new JTextFieldOperator(this , 3);
161: }
162: return _txtUser;
163: }
164:
165: /**
166: * Initializes (if necessary) and returns an object JTextFieldOperator
167: * for the dialog text field "Password".
168: * @return the appropriate object JTextFieldOperator
169: */
170: public JTextFieldOperator txtPassword() {
171: if (_txtPassword == null) {
172: _txtPassword = new JTextFieldOperator(this , 4);
173: }
174: return _txtPassword;
175: }
176:
177: /**
178: * Initializes (if necessary) and returns an object JTextFieldOperator
179: * for the dialog text field "Database URL".
180: * @return the appropriate object JTextFieldOperator
181: */
182: public JTextFieldOperator txtURL() {
183: if (_txtURL == null) {
184: _txtURL = new JTextFieldOperator(this , 5);
185: }
186: return _txtURL;
187: }
188:
189: /**
190: * Initializes (if necessary) and returns an object JTextFieldOperator
191: * for the dialog text field "File Name".
192: * @return the appropriate object JTextFieldOperator
193: */
194: public JTextFieldOperator txtFileName() {
195: if (_txtFileName == null) {
196: _txtFileName = new JTextFieldOperator(this , 2);
197: }
198: return _txtFileName;
199: }
200:
201: /**
202: * Initializes (if necessary) and returns an object JListOperator
203: * for the dialog list "Data Sources".
204: * @return the appropriate object JListOperator
205: */
206: public JListOperator lstDataSources() {
207: if (_lstDataSources == null) {
208: _lstDataSources = new JListOperator(this );
209: }
210: return _lstDataSources;
211: }
212:
213: /**
214: * Initializes all necessary controls.
215: */
216: public void verify() {
217: btOK();
218: btCancel();
219: btHelp();
220: btSelectAll();
221: btClear();
222: btBrowse();
223: txtDSName();
224: txtDriverClass();
225: txtUser();
226: txtPassword();
227: txtURL();
228: txtValidationQuery();
229: txtFileName();
230: lstDataSources();
231: }
232:
233: /**
234: * Finds in a bundle file and returns an actual text of control component.
235: * @param p_text string-key corresponding to required control component.
236: * @return actual text of control component
237: */
238: public static String getBundleString(String p_text) {
239: System.out.println("Getting bundle for " + p_text);
240: try {
241: return Bundle
242: .getStringTrimmed(
243: "org.netbeans.modules.visualweb.dataconnectivity.ui.Bundle",
244: p_text);
245: } catch (JemmyException e) {
246: }
247: return null;
248: }
249:
250: }
|