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: /*
043: * EnterAbbreviation.java
044: *
045: * Created on 8/28/02 11:08 AM
046: */
047: package org.netbeans.modules.visualweb.gravy.properties.editors;
048:
049: import org.netbeans.jemmy.operators.*;
050:
051: /** Class implementing all necessary methods for handling "Enter Abbreviation" NbDialog.
052: */
053: public class EnterAbbreviation extends JDialogOperator {
054:
055: /** Creates new EnterAbbreviation that can handle it.
056: */
057: public EnterAbbreviation() {
058: super (java.util.ResourceBundle.getBundle(
059: "org.netbeans.modules.editor.options.Bundle")
060: .getString("AEP_EnterAbbrev"));
061: }
062:
063: private JLabelOperator _lblAbbreviation;
064: private JTextFieldOperator _txtAbbreviation;
065: private JLabelOperator _lblExpansion;
066: private JTextAreaOperator _txtExpansion;
067: private JButtonOperator _btOK;
068: private JButtonOperator _btCancel;
069: private JButtonOperator _btHelp;
070:
071: //******************************
072: // Subcomponents definition part
073: //******************************
074:
075: /** Tries to find "Abbreviation:" JLabel in this dialog.
076: * @return JLabelOperator
077: */
078: public JLabelOperator lblAbbreviation() {
079: if (_lblAbbreviation == null) {
080: _lblAbbreviation = new JLabelOperator(
081: this ,
082: java.util.ResourceBundle
083: .getBundle(
084: "org.netbeans.modules.editor.options.Bundle")
085: .getString("AIP_Abbrev"));
086: }
087: return _lblAbbreviation;
088: }
089:
090: /** Tries to find null JTextField in this dialog.
091: * @return JTextFieldOperator
092: */
093: public JTextFieldOperator txtAbbreviation() {
094: if (_txtAbbreviation == null) {
095: _txtAbbreviation = new JTextFieldOperator(this );
096: }
097: return _txtAbbreviation;
098: }
099:
100: /** Tries to find "Expansion:" JLabel in this dialog.
101: * @return JLabelOperator
102: */
103: public JLabelOperator lblExpansion() {
104: if (_lblExpansion == null) {
105: _lblExpansion = new JLabelOperator(
106: this ,
107: java.util.ResourceBundle
108: .getBundle(
109: "org.netbeans.modules.editor.options.Bundle")
110: .getString("AIP_Expand"));
111: }
112: return _lblExpansion;
113: }
114:
115: /** Tries to find null JTextArea in this dialog.
116: * @return JTextAreaOperator
117: */
118: public JTextAreaOperator txtExpansion() {
119: if (_txtExpansion == null) {
120: _txtExpansion = new JTextAreaOperator(this );
121: }
122: return _txtExpansion;
123: }
124:
125: /** Tries to find "OK" JButton in this dialog.
126: * @return JButtonOperator
127: */
128: public JButtonOperator btOK() {
129: if (_btOK == null) {
130: _btOK = new JButtonOperator(
131: this ,
132: java.util.ResourceBundle
133: .getBundle(
134: "org.netbeans.modules.editor.options.Bundle")
135: .getString("KBEP_OK_LABEL"));
136: }
137: return _btOK;
138: }
139:
140: /** Tries to find "Cancel" JButton in this dialog.
141: * @return JButtonOperator
142: */
143: public JButtonOperator btCancel() {
144: if (_btCancel == null) {
145: _btCancel = new JButtonOperator(
146: this ,
147: java.util.ResourceBundle
148: .getBundle(
149: "org.openide.explorer.propertysheet.Bundle")
150: .getString("CTL_Cancel"));
151: }
152: return _btCancel;
153: }
154:
155: /** Tries to find "Help" JButton in this dialog.
156: * @return JButtonOperator
157: */
158: public JButtonOperator btHelp() {
159: if (_btHelp == null) {
160: _btHelp = new JButtonOperator(
161: this ,
162: java.util.ResourceBundle
163: .getBundle(
164: "org.openide.explorer.propertysheet.Bundle")
165: .getString("CTL_Help"));
166: }
167: return _btHelp;
168: }
169:
170: //****************************************
171: // Low-level functionality definition part
172: //****************************************
173:
174: /** gets text for txtAbbreviation
175: * @return String text
176: */
177: public String getAbbreviation() {
178: return txtAbbreviation().getText();
179: }
180:
181: /** sets text for txtAbbreviation
182: * @param text String text
183: */
184: public void setAbbreviation(String text) {
185: txtAbbreviation().setText(text);
186: }
187:
188: /** types text for txtAbbreviation
189: * @param text String text
190: */
191: public void typeAbbreviation(String text) {
192: txtAbbreviation().typeText(text);
193: }
194:
195: /** gets text for txtExpansion
196: * @return String text
197: */
198: public String getExpansion() {
199: return txtExpansion().getText();
200: }
201:
202: /** sets text for txtExpansion
203: * @param text String text
204: */
205: public void setExpansion(String text) {
206: txtExpansion().setText(text);
207: }
208:
209: /** types text for txtExpansion
210: * @param text String text
211: */
212: public void typeExpansion(String text) {
213: txtExpansion().typeText(text);
214: }
215:
216: /** clicks on "OK" JButton
217: */
218: public void oK() {
219: btOK().push();
220:
221: try {
222: Thread.sleep(2000);
223: } catch (InterruptedException e) {
224: e.printStackTrace(System.err);
225: }
226: }
227:
228: /** clicks on "Cancel" JButton
229: */
230: public void cancel() {
231: btCancel().push();
232: }
233:
234: /** clicks on "Help" JButton
235: */
236: public void help() {
237: btHelp().push();
238: }
239:
240: //*****************************************
241: // High-level functionality definition part
242: //*****************************************
243:
244: /** Performs verification of EnterAbbreviation by accessing all its components.
245: */
246: public void verify() {
247: lblAbbreviation();
248: txtAbbreviation();
249: lblExpansion();
250: txtExpansion();
251: btOK();
252: btCancel();
253: btHelp();
254: }
255:
256: public void fillAbbreviation(String abbreviation, String expansion) {
257: if (!"".equals(txtAbbreviation().getText()))
258: txtAbbreviation().clearText();
259: typeAbbreviation(abbreviation);
260:
261: if (!"".equals(txtExpansion().getText()))
262: txtExpansion().clearText();
263: typeExpansion(expansion);
264: }
265:
266: /** Performs simple test of EnterAbbreviation
267: * @param args the command line arguments
268: */
269: public static void main(String args[]) {
270: new EnterAbbreviation().verify();
271: System.out.println("EnterAbbreviation verification finished.");
272: }
273: }
|