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-2006 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: package org.netbeans.test.jsf;
042:
043: import javax.swing.JTextField;
044: import org.netbeans.jellytools.NbDialogOperator;
045: import org.netbeans.jemmy.operators.JButtonOperator;
046: import org.netbeans.jemmy.operators.JComboBoxOperator;
047: import org.netbeans.jemmy.operators.JLabelOperator;
048: import org.netbeans.jemmy.operators.JTextAreaOperator;
049: import org.netbeans.jemmy.operators.JTextFieldOperator;
050:
051: /** Class implementing all necessary methods for handling "Add Managed Bean" Dialog.
052: *
053: */
054: public class AddManagedBeanOperator extends NbDialogOperator {
055:
056: /** Creates new AddManagedBeanOperator that can handle it.
057: */
058: public AddManagedBeanOperator() {
059: super ("Add Managed Bean");
060: }
061:
062: private JLabelOperator _lblBeanClass;
063: private JTextFieldOperator _txtBeanClass;
064: private JButtonOperator _btBrowse;
065: private JLabelOperator _lblScope;
066: private JComboBoxOperator _cboScope;
067: private JLabelOperator _lblBeanDescription;
068: private JTextAreaOperator _txtBeanDescription;
069: private JLabelOperator _lblBeanName;
070: private JTextFieldOperator _txtBeanName;
071: private JButtonOperator _btAdd;
072:
073: //******************************
074: // Subcomponents definition part
075: //******************************
076:
077: /** Tries to find "Bean Class:" JLabel in this dialog.
078: * @return JLabelOperator
079: */
080: public JLabelOperator lblBeanClass() {
081: if (_lblBeanClass == null) {
082: _lblBeanClass = new JLabelOperator(this , "Bean Class:");
083: }
084: return _lblBeanClass;
085: }
086:
087: /** Tries to find null JTextField in this dialog.
088: * @return JTextFieldOperator
089: */
090: public JTextFieldOperator txtBeanClass() {
091: if (_txtBeanClass == null) {
092: _txtBeanClass = new JTextFieldOperator(
093: (JTextField) lblBeanClass().getLabelFor());
094: }
095: return _txtBeanClass;
096: }
097:
098: /** Tries to find "Browse..." JButton in this dialog.
099: * @return JButtonOperator
100: */
101: public JButtonOperator btBrowse() {
102: if (_btBrowse == null) {
103: _btBrowse = new JButtonOperator(this , "Browse...");
104: }
105: return _btBrowse;
106: }
107:
108: /** Tries to find "Scope:" JLabel in this dialog.
109: * @return JLabelOperator
110: */
111: public JLabelOperator lblScope() {
112: if (_lblScope == null) {
113: _lblScope = new JLabelOperator(this , "Scope:");
114: }
115: return _lblScope;
116: }
117:
118: /** Tries to find null JComboBox in this dialog.
119: * @return JComboBoxOperator
120: */
121: public JComboBoxOperator cboScope() {
122: if (_cboScope == null) {
123: _cboScope = new JComboBoxOperator(this );
124: }
125: return _cboScope;
126: }
127:
128: /** Tries to find "Bean Description:" JLabel in this dialog.
129: * @return JLabelOperator
130: */
131: public JLabelOperator lblBeanDescription() {
132: if (_lblBeanDescription == null) {
133: _lblBeanDescription = new JLabelOperator(this ,
134: "Bean Description:");
135: }
136: return _lblBeanDescription;
137: }
138:
139: /** Tries to find null JTextArea in this dialog.
140: * @return JTextAreaOperator
141: */
142: public JTextAreaOperator txtBeanDescription() {
143: if (_txtBeanDescription == null) {
144: _txtBeanDescription = new JTextAreaOperator(this );
145: }
146: return _txtBeanDescription;
147: }
148:
149: /** Tries to find "Bean Name:" JLabel in this dialog.
150: * @return JLabelOperator
151: */
152: public JLabelOperator lblBeanName() {
153: if (_lblBeanName == null) {
154: _lblBeanName = new JLabelOperator(this , "Bean Name:");
155: }
156: return _lblBeanName;
157: }
158:
159: /** Tries to find null JTextField in this dialog.
160: * @return JTextFieldOperator
161: */
162: public JTextFieldOperator txtBeanName() {
163: if (_txtBeanName == null) {
164: _txtBeanName = new JTextFieldOperator(
165: (JTextField) lblBeanName().getLabelFor());
166: }
167: return _txtBeanName;
168: }
169:
170: /** Tries to find "Add" JButton in this dialog.
171: * @return JButtonOperator
172: */
173: public JButtonOperator btAdd() {
174: if (_btAdd == null) {
175: _btAdd = new JButtonOperator(this , "Add");
176: }
177: return _btAdd;
178: }
179:
180: //****************************************
181: // Low-level functionality definition part
182: //****************************************
183:
184: /** gets text for txtBeanClass
185: * @return String text
186: */
187: public String getBeanClass() {
188: return txtBeanClass().getText();
189: }
190:
191: /** sets text for txtBeanClass
192: * @param text String text
193: */
194: public void setBeanClass(String text) {
195: txtBeanClass().setText(text);
196: }
197:
198: /** types text for txtBeanClass
199: * @param text String text
200: */
201: public void typeBeanClass(String text) {
202: txtBeanClass().typeText(text);
203: }
204:
205: /** clicks on "Browse..." JButton
206: */
207: public void browse() {
208: btBrowse().push();
209: }
210:
211: /** returns selected item for cboScope
212: * @return String item
213: */
214: public String getSelectedScope() {
215: return cboScope().getSelectedItem().toString();
216: }
217:
218: /** selects item for cboScope
219: * @param item String item
220: */
221: public void selectScope(String item) {
222: cboScope().selectItem(item);
223: }
224:
225: /** gets text for txtBeanDescription
226: * @return String text
227: */
228: public String getBeanDescription() {
229: return txtBeanDescription().getText();
230: }
231:
232: /** sets text for txtBeanDescription
233: * @param text String text
234: */
235: public void setBeanDescription(String text) {
236: txtBeanDescription().setText(text);
237: }
238:
239: /** types text for txtBeanDescription
240: * @param text String text
241: */
242: public void typeBeanDescription(String text) {
243: txtBeanDescription().typeText(text);
244: }
245:
246: /** gets text for txtBeanName
247: * @return String text
248: */
249: public String getBeanName() {
250: return txtBeanName().getText();
251: }
252:
253: /** sets text for txtBeanName
254: * @param text String text
255: */
256: public void setBeanName(String text) {
257: txtBeanName().setText(text);
258: }
259:
260: /** types text for txtBeanName
261: * @param text String text
262: */
263: public void typeBeanName(String text) {
264: txtBeanName().typeText(text);
265: }
266:
267: /** clicks on "Add" JButton
268: */
269: public void add() {
270: btAdd().push();
271: }
272:
273: //*****************************************
274: // High-level functionality definition part
275: //*****************************************
276:
277: /** Performs verification of AddManagedBeanOperator by accessing all its components.
278: */
279: public void verify() {
280: lblBeanClass();
281: txtBeanClass();
282: btBrowse();
283: lblScope();
284: cboScope();
285: lblBeanDescription();
286: txtBeanDescription();
287: lblBeanName();
288: txtBeanName();
289: btAdd();
290: }
291: }
|