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:
042: package org.netbeans.test.jsf;
043:
044: import javax.swing.JComboBox;
045: import javax.swing.JTextField;
046: import org.netbeans.jellytools.NbDialogOperator;
047: import org.netbeans.jemmy.operators.JButtonOperator;
048: import org.netbeans.jemmy.operators.JCheckBoxOperator;
049: import org.netbeans.jemmy.operators.JComboBoxOperator;
050: import org.netbeans.jemmy.operators.JLabelOperator;
051: import org.netbeans.jemmy.operators.JTextAreaOperator;
052: import org.netbeans.jemmy.operators.JTextFieldOperator;
053:
054: /** Class implementing all necessary methods for handling "Add Navigation Case" NbDialog.
055: *
056: * @author luke
057: */
058: public class AddNavigationCaseDialogOperator extends NbDialogOperator {
059:
060: /** Creates new AddNavigationCase that can handle it.
061: */
062: public AddNavigationCaseDialogOperator() {
063: super ("Add Navigation Case");
064: }
065:
066: private JLabelOperator _lblFromView;
067: private JComboBoxOperator _cboFromView;
068: private JButtonOperator _btBrowse;
069: private JLabelOperator _lblFromAction;
070: private JTextFieldOperator _txtFromAction;
071: private JLabelOperator _lblFromOutcome;
072: private JTextFieldOperator _txtFromOutcome;
073: private JLabelOperator _lblToView;
074: private JButtonOperator _btBrowse2;
075: private JCheckBoxOperator _cbRedirect;
076: private JLabelOperator _lblRuleDescription;
077: private JTextAreaOperator _txtRuleDescription;
078: private JComboBoxOperator _cboToView;
079: private JButtonOperator _btAdd;
080:
081: //******************************
082: // Subcomponents definition part
083: //******************************
084:
085: /** Tries to find "From View:" JLabel in this dialog.
086: * @return JLabelOperator
087: */
088: public JLabelOperator lblFromView() {
089: if (_lblFromView == null) {
090: _lblFromView = new JLabelOperator(this , "From View:");
091: }
092: return _lblFromView;
093: }
094:
095: /** Tries to find null JComboBox in this dialog.
096: * @return JComboBoxOperator
097: */
098: public JComboBoxOperator cboFromView() {
099: if (_cboFromView == null) {
100: _cboFromView = new JComboBoxOperator(
101: (JComboBox) lblFromView().getLabelFor());
102: }
103: return _cboFromView;
104: }
105:
106: /** Tries to find "Browse..." JButton in this dialog.
107: * @return JButtonOperator
108: */
109: public JButtonOperator btBrowse() {
110: if (_btBrowse == null) {
111: _btBrowse = new JButtonOperator(this , "Browse...");
112: }
113: return _btBrowse;
114: }
115:
116: /** Tries to find "From Action:" JLabel in this dialog.
117: * @return JLabelOperator
118: */
119: public JLabelOperator lblFromAction() {
120: if (_lblFromAction == null) {
121: _lblFromAction = new JLabelOperator(this , "From Action:");
122: }
123: return _lblFromAction;
124: }
125:
126: /** Tries to find null JTextField in this dialog.
127: * @return JTextFieldOperator
128: */
129: public JTextFieldOperator txtFromAction() {
130: if (_txtFromAction == null) {
131: _txtFromAction = new JTextFieldOperator(
132: (JTextField) lblFromAction().getLabelFor());
133: }
134: return _txtFromAction;
135: }
136:
137: /** Tries to find "From Outcome:" JLabel in this dialog.
138: * @return JLabelOperator
139: */
140: public JLabelOperator lblFromOutcome() {
141: if (_lblFromOutcome == null) {
142: _lblFromOutcome = new JLabelOperator(this , "From Outcome:");
143: }
144: return _lblFromOutcome;
145: }
146:
147: /** Tries to find null JTextField in this dialog.
148: * @return JTextFieldOperator
149: */
150: public JTextFieldOperator txtFromOutcome() {
151: if (_txtFromOutcome == null) {
152: _txtFromOutcome = new JTextFieldOperator(
153: (JTextField) lblFromOutcome().getLabelFor());
154: }
155: return _txtFromOutcome;
156: }
157:
158: /** Tries to find "To View:" JLabel in this dialog.
159: * @return JLabelOperator
160: */
161: public JLabelOperator lblToView() {
162: if (_lblToView == null) {
163: _lblToView = new JLabelOperator(this , "To View:");
164: }
165: return _lblToView;
166: }
167:
168: /** Tries to find "Browse..." JButton in this dialog.
169: * @return JButtonOperator
170: */
171: public JButtonOperator btBrowse2() {
172: if (_btBrowse2 == null) {
173: _btBrowse2 = new JButtonOperator(this , "Browse...", 1);
174: }
175: return _btBrowse2;
176: }
177:
178: /** Tries to find "Redirect" JCheckBox in this dialog.
179: * @return JCheckBoxOperator
180: */
181: public JCheckBoxOperator cbRedirect() {
182: if (_cbRedirect == null) {
183: _cbRedirect = new JCheckBoxOperator(this , "Redirect");
184: }
185: return _cbRedirect;
186: }
187:
188: /** Tries to find "Rule Description:" JLabel in this dialog.
189: * @return JLabelOperator
190: */
191: public JLabelOperator lblRuleDescription() {
192: if (_lblRuleDescription == null) {
193: _lblRuleDescription = new JLabelOperator(this ,
194: "Rule Description:");
195: }
196: return _lblRuleDescription;
197: }
198:
199: /** Tries to find null JTextArea in this dialog.
200: * @return JTextAreaOperator
201: */
202: public JTextAreaOperator txtRuleDescription() {
203: if (_txtRuleDescription == null) {
204: _txtRuleDescription = new JTextAreaOperator(this );
205: }
206: return _txtRuleDescription;
207: }
208:
209: /** Tries to find null JComboBox in this dialog.
210: * @return JComboBoxOperator
211: */
212: public JComboBoxOperator cboToView() {
213: if (_cboToView == null) {
214: _cboToView = new JComboBoxOperator((JComboBox) lblToView()
215: .getLabelFor());
216: }
217: return _cboToView;
218: }
219:
220: /** Tries to find "Add" JButton in this dialog.
221: * @return JButtonOperator
222: */
223: public JButtonOperator btAdd() {
224: if (_btAdd == null) {
225: _btAdd = new JButtonOperator(this , "Add");
226: }
227: return _btAdd;
228: }
229:
230: public void add() {
231: btAdd().push();
232: }
233:
234: //****************************************
235: // Low-level functionality definition part
236: //****************************************
237:
238: /** returns selected item for cboFromView
239: * @return String item
240: */
241: public String getSelectedFromView() {
242: return cboFromView().getSelectedItem().toString();
243: }
244:
245: /** selects item for cboFromView
246: * @param item String item
247: */
248: public void selectFromView(String item) {
249: cboFromView().selectItem(item);
250: }
251:
252: /** types text for cboFromView
253: * @param text String text
254: */
255: public void typeFromView(String text) {
256: cboFromView().typeText(text);
257: }
258:
259: /** clicks on "Browse..." JButton
260: */
261: public void browse() {
262: btBrowse().push();
263: }
264:
265: /** gets text for txtFromAction
266: * @return String text
267: */
268: public String getFromAction() {
269: return txtFromAction().getText();
270: }
271:
272: /** sets text for txtFromAction
273: * @param text String text
274: */
275: public void setFromAction(String text) {
276: txtFromAction().setText(text);
277: }
278:
279: /** types text for txtFromAction
280: * @param text String text
281: */
282: public void typeFromAction(String text) {
283: txtFromAction().typeText(text);
284: }
285:
286: /** gets text for txtFromOutcome
287: * @return String text
288: */
289: public String getFromOutcome() {
290: return txtFromOutcome().getText();
291: }
292:
293: /** sets text for txtFromOutcome
294: * @param text String text
295: */
296: public void setFromOutcome(String text) {
297: txtFromOutcome().setText(text);
298: }
299:
300: /** types text for txtFromOutcome
301: * @param text String text
302: */
303: public void typeFromOutcome(String text) {
304: txtFromOutcome().typeText(text);
305: }
306:
307: /** clicks on "Browse..." JButton
308: */
309: public void browse2() {
310: btBrowse2().push();
311: }
312:
313: /** checks or unchecks given JCheckBox
314: * @param state boolean requested state
315: */
316: public void checkRedirect(boolean state) {
317: if (cbRedirect().isSelected() != state) {
318: cbRedirect().push();
319: }
320: }
321:
322: /** gets text for txtRuleDescription
323: * @return String text
324: */
325: public String getRuleDescription() {
326: return txtRuleDescription().getText();
327: }
328:
329: /** sets text for txtRuleDescription
330: * @param text String text
331: */
332: public void setRuleDescription(String text) {
333: txtRuleDescription().setText(text);
334: }
335:
336: /** types text for txtRuleDescription
337: * @param text String text
338: */
339: public void typeRuleDescription(String text) {
340: txtRuleDescription().typeText(text);
341: }
342:
343: /** returns selected item for cboToView
344: * @return String item
345: */
346: public String getSelectedToView() {
347: return cboToView().getSelectedItem().toString();
348: }
349:
350: /** selects item for cboToView
351: * @param item String item
352: */
353: public void selectToView(String item) {
354: cboToView().selectItem(item);
355: }
356:
357: /** types text for cboToView
358: * @param text String text
359: */
360: public void typeToView(String text) {
361: cboToView().typeText(text);
362: }
363:
364: //*****************************************
365: // High-level functionality definition part
366: //*****************************************
367:
368: /** Performs verification of AddNavigationCase by accessing all its components.
369: */
370: public void verify() {
371: lblFromView();
372: cboFromView();
373: btBrowse();
374: lblFromAction();
375: txtFromAction();
376: lblFromOutcome();
377: txtFromOutcome();
378: lblToView();
379: btBrowse2();
380: cbRedirect();
381: lblRuleDescription();
382: txtRuleDescription();
383: cboToView();
384: btAdd();
385: btCancel();
386: btHelp();
387: }
388: }
|