KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jellytools > modules > editor > EnterAbbreviation


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 /*
21  * EnterAbbreviation.java
22  *
23  * Created on 8/28/02 11:08 AM
24  */

25 package org.netbeans.jellytools.modules.editor;
26
27 import org.netbeans.jemmy.operators.*;
28
29 /** Class implementing all necessary methods for handling "Enter Abbreviation" NbDialog.
30  *
31  * @author jl105142
32  * @version 1.0
33  */

34 public class EnterAbbreviation extends JDialogOperator {
35
36     /** Creates new EnterAbbreviation that can handle it.
37      */

38     public EnterAbbreviation() {
39         super(java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("AEP_EnterAbbrev"));
40     }
41     
42     private JLabelOperator _lblAbbreviation;
43     private JTextFieldOperator _txtAbbreviation;
44     private JLabelOperator _lblExpansion;
45     private JTextAreaOperator _txtExpansion;
46     private JButtonOperator _btOK;
47     private JButtonOperator _btCancel;
48     private JButtonOperator _btHelp;
49     
50     
51     //******************************
52
// Subcomponents definition part
53
//******************************
54

55     /** Tries to find "Abbreviation:" JLabel in this dialog.
56      * @return JLabelOperator
57      */

58     public JLabelOperator lblAbbreviation() {
59         if (_lblAbbreviation==null) {
60             _lblAbbreviation = new JLabelOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("AIP_Abbrev"));
61         }
62         return _lblAbbreviation;
63     }
64     
65     /** Tries to find null JTextField in this dialog.
66      * @return JTextFieldOperator
67      */

68     public JTextFieldOperator txtAbbreviation() {
69         if (_txtAbbreviation==null) {
70             _txtAbbreviation = new JTextFieldOperator(this);
71         }
72         return _txtAbbreviation;
73     }
74     
75     /** Tries to find "Expansion:" JLabel in this dialog.
76      * @return JLabelOperator
77      */

78     public JLabelOperator lblExpansion() {
79         if (_lblExpansion==null) {
80             _lblExpansion = new JLabelOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("AIP_Expand"));
81         }
82         return _lblExpansion;
83     }
84     
85     /** Tries to find null JTextArea in this dialog.
86      * @return JTextAreaOperator
87      */

88     public JTextAreaOperator txtExpansion() {
89         if (_txtExpansion==null) {
90             _txtExpansion = new JTextAreaOperator(this);
91         }
92         return _txtExpansion;
93     }
94     
95     /** Tries to find "OK" JButton in this dialog.
96      * @return JButtonOperator
97      */

98     public JButtonOperator btOK() {
99         if (_btOK==null) {
100             _btOK = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("KBEP_OK_LABEL"));
101         }
102         return _btOK;
103     }
104     
105     /** Tries to find "Cancel" JButton in this dialog.
106      * @return JButtonOperator
107      */

108     public JButtonOperator btCancel() {
109         if (_btCancel==null) {
110             _btCancel = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.openide.explorer.propertysheet.Bundle").getString("CTL_Cancel"));
111         }
112         return _btCancel;
113     }
114     
115     /** Tries to find "Help" JButton in this dialog.
116      * @return JButtonOperator
117      */

118     public JButtonOperator btHelp() {
119         if (_btHelp==null) {
120             _btHelp = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.openide.explorer.propertysheet.Bundle").getString("CTL_Help"));
121         }
122         return _btHelp;
123     }
124     
125     
126     //****************************************
127
// Low-level functionality definition part
128
//****************************************
129

130     /** gets text for txtAbbreviation
131      * @return String text
132      */

133     public String JavaDoc getAbbreviation() {
134         return txtAbbreviation().getText();
135     }
136     
137     /** sets text for txtAbbreviation
138      * @param text String text
139      */

140     public void setAbbreviation(String JavaDoc text) {
141         txtAbbreviation().setText(text);
142     }
143     
144     /** types text for txtAbbreviation
145      * @param text String text
146      */

147     public void typeAbbreviation(String JavaDoc text) {
148         txtAbbreviation().typeText(text);
149     }
150     
151     /** gets text for txtExpansion
152      * @return String text
153      */

154     public String JavaDoc getExpansion() {
155         return txtExpansion().getText();
156     }
157     
158     /** sets text for txtExpansion
159      * @param text String text
160      */

161     public void setExpansion(String JavaDoc text) {
162         txtExpansion().setText(text);
163     }
164     
165     /** types text for txtExpansion
166      * @param text String text
167      */

168     public void typeExpansion(String JavaDoc text) {
169         txtExpansion().typeText(text);
170     }
171     
172     /** clicks on "OK" JButton
173      */

174     public void oK() {
175         btOK().push();
176         
177         try {
178             Thread.sleep(2000);
179         } catch (InterruptedException JavaDoc e) {
180             e.printStackTrace(System.err);
181         }
182     }
183     
184     /** clicks on "Cancel" JButton
185      */

186     public void cancel() {
187         btCancel().push();
188     }
189     
190     /** clicks on "Help" JButton
191      */

192     public void help() {
193         btHelp().push();
194     }
195     
196     
197     //*****************************************
198
// High-level functionality definition part
199
//*****************************************
200

201     /** Performs verification of EnterAbbreviation by accessing all its components.
202      */

203     public void verify() {
204         lblAbbreviation();
205         txtAbbreviation();
206         lblExpansion();
207         txtExpansion();
208         btOK();
209         btCancel();
210         btHelp();
211     }
212     
213     public void fillAbbreviation(String JavaDoc abbreviation, String JavaDoc expansion) {
214         if (!"".equals(txtAbbreviation().getText()))
215             txtAbbreviation().clearText();
216         typeAbbreviation(abbreviation);
217         
218         if (!"".equals(txtExpansion().getText()))
219             txtExpansion().clearText();
220         typeExpansion(expansion);
221     }
222     
223     /** Performs simple test of EnterAbbreviation
224      * @param args the command line arguments
225      */

226     public static void main(String JavaDoc args[]) {
227         new EnterAbbreviation().verify();
228         System.out.println("EnterAbbreviation verification finished.");
229     }
230 }
231
232
Popular Tags