KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jellytools > modules > java > MethodParameterOperator


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  * MethodParameterOperator.java
22  *
23  * Created on 10/3/02 5:15 PM
24  */

25 package org.netbeans.jellytools.modules.java;
26
27 import org.netbeans.jellytools.Bundle;
28 import org.netbeans.jemmy.operators.*;
29
30 /** Class implementing all necessary methods for handling "Enter Method Parameter" NbPresenter.
31  *
32  * @author jb105785
33  * @version 1.0
34  */

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

39     public MethodParameterOperator() {
40         super(Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "LAB_EnterParameter"));
41     }
42
43     private JLabelOperator _lblType;
44     private JComboBoxOperator _cboType;
45     private JLabelOperator _lblName;
46     private JTextFieldOperator _txtName;
47     private JCheckBoxOperator _cbFinal;
48     private JButtonOperator _btOK;
49     private JButtonOperator _btCancel;
50
51
52     //******************************
53
// Subcomponents definition part
54
//******************************
55

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

59     public JLabelOperator lblType() {
60         if (_lblType==null) {
61             _lblType = new JLabelOperator(this, Bundle.getString("org.openide.src.nodes.Bundle", "CTL_Type"));
62         }
63         return _lblType;
64     }
65
66     /** Tries to find null JComboBox in this dialog.
67      * @return JComboBoxOperator
68      */

69     public JComboBoxOperator cboType() {
70         if (_cboType==null) {
71             _cboType = new JComboBoxOperator(this);
72         }
73         return _cboType;
74     }
75
76     /** Tries to find "Name:" JLabel in this dialog.
77      * @return JLabelOperator
78      */

79     public JLabelOperator lblName() {
80         if (_lblName==null) {
81             _lblName = new JLabelOperator(this, Bundle.getString("org.openide.src.nodes.Bundle", "CTL_Name"));
82         }
83         return _lblName;
84     }
85
86     /** Tries to find null JTextField in this dialog.
87      * @return JTextFieldOperator
88      */

89     public JTextFieldOperator txtName() {
90         if (_txtName==null) {
91             _txtName = new JTextFieldOperator(this, 1);
92         }
93         return _txtName;
94     }
95
96     /** Tries to find "Final" JCheckBox in this dialog.
97      * @return JCheckBoxOperator
98      */

99     public JCheckBoxOperator cbFinal() {
100         if (_cbFinal==null) {
101             _cbFinal = new JCheckBoxOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "CTL_Final"));
102         }
103         return _cbFinal;
104     }
105
106     /** Tries to find "OK" JButton in this dialog.
107      * @return JButtonOperator
108      */

109     public JButtonOperator btOK() {
110         if (_btOK==null) {
111             _btOK = new JButtonOperator(this, Bundle.getString("org.openide.Bundle", "CTL_OK"));
112         }
113         return _btOK;
114     }
115
116     /** Tries to find "Cancel" JButton in this dialog.
117      * @return JButtonOperator
118      */

119     public JButtonOperator btCancel() {
120         if (_btCancel==null) {
121             _btCancel = new JButtonOperator(this, Bundle.getString("org.openide.Bundle", "CTL_CANCEL"));
122         }
123         return _btCancel;
124     }
125
126
127     //****************************************
128
// Low-level functionality definition part
129
//****************************************
130

131     /** returns selected item for cboType
132      * @return String item
133      */

134     public String JavaDoc getSelectedType() {
135         return cboType().getSelectedItem().toString();
136     }
137
138     /** selects item for cboType
139      * @param item String item
140      */

141     public void selectType(String JavaDoc item) {
142         cboType().selectItem(item);
143     }
144
145     /** types text for cboType
146      * @param text String text
147      */

148     public void typeType(String JavaDoc text) {
149         cboType().typeText(text);
150     }
151
152     /** gets text for txtName
153      * @return String text
154      */

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

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

169     public void typeName(String JavaDoc text) {
170         txtName().typeText(text);
171     }
172
173     /** checks or unchecks given JCheckBox
174      * @param state boolean requested state
175      */

176     public void checkFinal(boolean state) {
177         if (cbFinal().isSelected()!=state) {
178             cbFinal().push();
179         }
180     }
181
182     /** clicks on "OK" JButton
183      */

184     public void oK() {
185         btOK().push();
186     }
187
188     /** clicks on "Cancel" JButton
189      */

190     public void cancel() {
191         btCancel().push();
192     }
193
194
195     //*****************************************
196
// High-level functionality definition part
197
//*****************************************
198

199     /** Performs verification of MethodParameterOperator by accessing all its components.
200      */

201     public void verify() {
202         lblType();
203         cboType();
204         lblName();
205         txtName();
206         cbFinal();
207         btOK();
208         btCancel();
209     }
210
211     /** Performs simple test of MethodParameterOperator
212     * @param args the command line arguments
213     */

214     public static void main(String JavaDoc args[]) {
215         new MethodParameterOperator().verify();
216         System.out.println("MethodParameterOperator verification finished.");
217     }
218 }
219
220
Popular Tags