KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > jsf > AddManagedBeanOperator


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 package org.netbeans.test.jsf;
20
21 import javax.swing.JTextField JavaDoc;
22 import org.netbeans.jellytools.NbDialogOperator;
23 import org.netbeans.jemmy.operators.JButtonOperator;
24 import org.netbeans.jemmy.operators.JComboBoxOperator;
25 import org.netbeans.jemmy.operators.JLabelOperator;
26 import org.netbeans.jemmy.operators.JTextAreaOperator;
27 import org.netbeans.jemmy.operators.JTextFieldOperator;
28
29 /** Class implementing all necessary methods for handling "Add Managed Bean" Dialog.
30  *
31  */

32 public class AddManagedBeanOperator extends NbDialogOperator {
33
34     /** Creates new AddManagedBeanOperator that can handle it.
35      */

36     public AddManagedBeanOperator() {
37         super("Add Managed Bean");
38     }
39
40     private JLabelOperator _lblBeanClass;
41     private JTextFieldOperator _txtBeanClass;
42     private JButtonOperator _btBrowse;
43     private JLabelOperator _lblScope;
44     private JComboBoxOperator _cboScope;
45     private JLabelOperator _lblBeanDescription;
46     private JTextAreaOperator _txtBeanDescription;
47     private JLabelOperator _lblBeanName;
48     private JTextFieldOperator _txtBeanName;
49     private JButtonOperator _btAdd;
50
51
52     //******************************
53
// Subcomponents definition part
54
//******************************
55

56     /** Tries to find "Bean Class:" JLabel in this dialog.
57      * @return JLabelOperator
58      */

59     public JLabelOperator lblBeanClass() {
60         if (_lblBeanClass==null) {
61             _lblBeanClass = new JLabelOperator(this, "Bean Class:");
62         }
63         return _lblBeanClass;
64     }
65
66     /** Tries to find null JTextField in this dialog.
67      * @return JTextFieldOperator
68      */

69     public JTextFieldOperator txtBeanClass() {
70         if (_txtBeanClass==null) {
71             _txtBeanClass = new JTextFieldOperator((JTextField JavaDoc)lblBeanClass().getLabelFor());
72         }
73         return _txtBeanClass;
74     }
75
76     /** Tries to find "Browse..." JButton in this dialog.
77      * @return JButtonOperator
78      */

79     public JButtonOperator btBrowse() {
80         if (_btBrowse==null) {
81             _btBrowse = new JButtonOperator(this, "Browse...");
82         }
83         return _btBrowse;
84     }
85
86     /** Tries to find "Scope:" JLabel in this dialog.
87      * @return JLabelOperator
88      */

89     public JLabelOperator lblScope() {
90         if (_lblScope==null) {
91             _lblScope = new JLabelOperator(this, "Scope:");
92         }
93         return _lblScope;
94     }
95
96     /** Tries to find null JComboBox in this dialog.
97      * @return JComboBoxOperator
98      */

99     public JComboBoxOperator cboScope() {
100         if (_cboScope==null) {
101             _cboScope = new JComboBoxOperator(this);
102         }
103         return _cboScope;
104     }
105
106     /** Tries to find "Bean Description:" JLabel in this dialog.
107      * @return JLabelOperator
108      */

109     public JLabelOperator lblBeanDescription() {
110         if (_lblBeanDescription==null) {
111             _lblBeanDescription = new JLabelOperator(this, "Bean Description:");
112         }
113         return _lblBeanDescription;
114     }
115
116     /** Tries to find null JTextArea in this dialog.
117      * @return JTextAreaOperator
118      */

119     public JTextAreaOperator txtBeanDescription() {
120         if (_txtBeanDescription==null) {
121             _txtBeanDescription = new JTextAreaOperator(this);
122         }
123         return _txtBeanDescription;
124     }
125
126     /** Tries to find "Bean Name:" JLabel in this dialog.
127      * @return JLabelOperator
128      */

129     public JLabelOperator lblBeanName() {
130         if (_lblBeanName==null) {
131             _lblBeanName = new JLabelOperator(this, "Bean Name:");
132         }
133         return _lblBeanName;
134     }
135
136     /** Tries to find null JTextField in this dialog.
137      * @return JTextFieldOperator
138      */

139     public JTextFieldOperator txtBeanName() {
140         if (_txtBeanName==null) {
141             _txtBeanName = new JTextFieldOperator((JTextField JavaDoc)lblBeanName().getLabelFor());
142         }
143         return _txtBeanName;
144     }
145
146     /** Tries to find "Add" JButton in this dialog.
147      * @return JButtonOperator
148      */

149     public JButtonOperator btAdd() {
150         if (_btAdd==null) {
151             _btAdd = new JButtonOperator(this, "Add");
152         }
153         return _btAdd;
154     }
155
156
157     //****************************************
158
// Low-level functionality definition part
159
//****************************************
160

161     /** gets text for txtBeanClass
162      * @return String text
163      */

164     public String JavaDoc getBeanClass() {
165         return txtBeanClass().getText();
166     }
167
168     /** sets text for txtBeanClass
169      * @param text String text
170      */

171     public void setBeanClass(String JavaDoc text) {
172         txtBeanClass().setText(text);
173     }
174
175     /** types text for txtBeanClass
176      * @param text String text
177      */

178     public void typeBeanClass(String JavaDoc text) {
179         txtBeanClass().typeText(text);
180     }
181
182     /** clicks on "Browse..." JButton
183      */

184     public void browse() {
185         btBrowse().push();
186     }
187
188     /** returns selected item for cboScope
189      * @return String item
190      */

191     public String JavaDoc getSelectedScope() {
192         return cboScope().getSelectedItem().toString();
193     }
194
195     /** selects item for cboScope
196      * @param item String item
197      */

198     public void selectScope(String JavaDoc item) {
199         cboScope().selectItem(item);
200     }
201
202     /** gets text for txtBeanDescription
203      * @return String text
204      */

205     public String JavaDoc getBeanDescription() {
206         return txtBeanDescription().getText();
207     }
208
209     /** sets text for txtBeanDescription
210      * @param text String text
211      */

212     public void setBeanDescription(String JavaDoc text) {
213         txtBeanDescription().setText(text);
214     }
215
216     /** types text for txtBeanDescription
217      * @param text String text
218      */

219     public void typeBeanDescription(String JavaDoc text) {
220         txtBeanDescription().typeText(text);
221     }
222
223     /** gets text for txtBeanName
224      * @return String text
225      */

226     public String JavaDoc getBeanName() {
227         return txtBeanName().getText();
228     }
229
230     /** sets text for txtBeanName
231      * @param text String text
232      */

233     public void setBeanName(String JavaDoc text) {
234         txtBeanName().setText(text);
235     }
236
237     /** types text for txtBeanName
238      * @param text String text
239      */

240     public void typeBeanName(String JavaDoc text) {
241         txtBeanName().typeText(text);
242     }
243
244     /** clicks on "Add" JButton
245      */

246     public void add() {
247         btAdd().push();
248     }
249
250
251     //*****************************************
252
// High-level functionality definition part
253
//*****************************************
254

255     /** Performs verification of AddManagedBeanOperator by accessing all its components.
256      */

257     public void verify() {
258         lblBeanClass();
259         txtBeanClass();
260         btBrowse();
261         lblScope();
262         cboScope();
263         lblBeanDescription();
264         txtBeanDescription();
265         lblBeanName();
266         txtBeanName();
267         btAdd();
268     }
269 }
270
271
Popular Tags