KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > j2ee > addmethod > AddCMPFieldDialog


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 package org.netbeans.test.j2ee.addmethod;
21
22 import org.netbeans.jemmy.operators.*;
23 import org.netbeans.jemmy.util.NameComponentChooser;
24
25 /** Class implementing all necessary methods for handling "Add CMP Field..." NbPresenter.
26  *
27  * @author lm97939
28  * @version 1.0
29  */

30 public class AddCMPFieldDialog extends JDialogOperator {
31
32     /**
33      * Creates new AddCMPFieldDialog that can handle it.
34      */

35     public AddCMPFieldDialog() {
36         super(org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddCmpFieldAction"));
37     }
38
39     private JTextFieldOperator _txtName;
40     private JTextFieldOperator _txtDescription;
41     private JComboBoxOperator _comboType;
42     private JCheckBoxOperator _cbGetter;
43     private JCheckBoxOperator _cbSetter;
44     private JCheckBoxOperator _cbGetter2;
45     private JCheckBoxOperator _cbSetter2;
46     private JButtonOperator _btOK;
47     private JButtonOperator _btCancel;
48
49
50     //******************************
51
// Subcomponents definition part
52
//******************************
53

54     /** Tries to find null JTextField in this dialog.
55      * @return JTextFieldOperator
56      */

57     public JTextFieldOperator txtName() {
58         if (_txtName==null) {
59             _txtName = new JTextFieldOperator(this);
60         }
61         return _txtName;
62     }
63
64     /** Tries to find null JTextField in this dialog.
65      * @return JTextFieldOperator
66      */

67     public JTextFieldOperator txtDescription() {
68         if (_txtDescription==null) {
69             _txtDescription = new JTextFieldOperator(this, 1);
70         }
71         return _txtDescription;
72     }
73
74     /** Tries to find null JComboBox in this dialog.
75      * @return JComboBoxOperator
76      */

77     public JComboBoxOperator comboType() {
78         if (_comboType==null) {
79             //_txtType = new JTextFieldOperator(this,2);
80
_comboType = new JComboBoxOperator(this);
81         }
82         return _comboType;
83     }
84
85     /** Tries to find "Getter" JCheckBox in this dialog.
86      * @return JCheckBoxOperator
87      */

88     public JCheckBoxOperator cbLocalGetter() {
89         if (_cbGetter==null) {
90             _cbGetter = new JCheckBoxOperator(this, "Getter");
91         }
92         return _cbGetter;
93     }
94
95     /** Tries to find "Setter" JCheckBox in this dialog.
96      * @return JCheckBoxOperator
97      */

98     public JCheckBoxOperator cbLocalSetter() {
99         if (_cbSetter==null) {
100             _cbSetter = new JCheckBoxOperator(this, "Setter");
101         }
102         return _cbSetter;
103     }
104
105     /** Tries to find "Getter" JCheckBox in this dialog.
106      * @return JCheckBoxOperator
107      */

108     public JCheckBoxOperator cbRemoteGetter() {
109         if (_cbGetter2==null) {
110             _cbGetter2 = new JCheckBoxOperator(this, "Getter", 1);
111         }
112         return _cbGetter2;
113     }
114
115     /** Tries to find "Setter" JCheckBox in this dialog.
116      * @return JCheckBoxOperator
117      */

118     public JCheckBoxOperator cbRemoteSetter() {
119         if (_cbSetter2==null) {
120             _cbSetter2 = new JCheckBoxOperator(this, "Setter", 1);
121         }
122         return _cbSetter2;
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(this, "OK");
131         }
132         return _btOK;
133     }
134
135     /** Tries to find "Cancel" JButton in this dialog.
136      * @return JButtonOperator
137      */

138     public JButtonOperator btCancel() {
139         if (_btCancel==null) {
140             _btCancel = new JButtonOperator(this, "Cancel");
141         }
142         return _btCancel;
143     }
144
145
146     //****************************************
147
// Low-level functionality definition part
148
//****************************************
149

150     /** gets text for txtName
151      * @return String text
152      */

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

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

167     public void typeName(String JavaDoc text) {
168         txtName().typeText(text);
169     }
170
171     /** gets text for txtDescription
172      * @return String text
173      */

174     public String JavaDoc getDescription() {
175         return txtDescription().getText();
176     }
177
178     /** sets text for txtDescription
179      * @param text String text
180      */

181     public void setDescription(String JavaDoc text) {
182         txtDescription().setText(text);
183     }
184
185     /** types text for txtDescription
186      * @param text String text
187      */

188     public void typeDescription(String JavaDoc text) {
189         txtDescription().typeText(text);
190     }
191
192     /** returns selected item for cboType
193      * @return String item
194      */

195     public String JavaDoc getSelectedType() {
196         return comboType().getTextField().getText();
197     }
198
199     /** selects item for cboType
200      * @param item String item
201      */

202     public void setType(String JavaDoc item) {
203         comboType().selectItem(item);
204     }
205
206     /** types text for cboType
207      * @param text String text
208      */

209     public void typeType(String JavaDoc text) {
210         comboType().getTextField().typeText(text);
211     }
212
213     /** checks or unchecks given JCheckBox
214      * @param state boolean requested state
215      */

216     public void checkLocalGetter(boolean state) {
217         if (cbLocalGetter().isSelected()!=state) {
218             cbLocalGetter().push();
219         }
220     }
221
222     /** checks or unchecks given JCheckBox
223      * @param state boolean requested state
224      */

225     public void checkLocalSetter(boolean state) {
226         if (cbLocalSetter().isSelected()!=state) {
227             cbLocalSetter().push();
228         }
229     }
230
231     /** checks or unchecks given JCheckBox
232      * @param state boolean requested state
233      */

234     public void checkRemoteGetter(boolean state) {
235         if (cbRemoteGetter().isSelected()!=state) {
236             cbRemoteGetter().push();
237         }
238     }
239
240     /** checks or unchecks given JCheckBox
241      * @param state boolean requested state
242      */

243     public void checkRemoteSetter(boolean state) {
244         if (cbRemoteSetter().isSelected()!=state) {
245             cbRemoteSetter().push();
246         }
247     }
248
249     /** clicks on "OK" JButton
250      */

251     public void ok() {
252         btOK().push();
253     }
254
255     /** clicks on "Cancel" JButton
256      */

257     public void cancel() {
258         btCancel().push();
259     }
260
261
262     //*****************************************
263
// High-level functionality definition part
264
//*****************************************
265

266     /**
267      * Performs verification of AddCMPFieldDialog by accessing all its components.
268      */

269     public void verify() {
270         txtName();
271         txtDescription();
272         comboType();
273         cbLocalGetter();
274         cbLocalSetter();
275         cbRemoteGetter();
276         cbRemoteSetter();
277         btOK();
278         btCancel();
279     }
280
281     /**
282      * Performs simple test of AddCMPFieldDialog
283      * @param args the command line arguments
284      */

285     public static void main(String JavaDoc args[]) {
286         new AddCMPFieldDialog().verify();
287         System.out.println("AddCMPField verification finished.");
288     }
289 }
290
291
Popular Tags