KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jellytools > modules > xml > saxwizard > SAXDocumentHandlerWizardPage3


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  * SAXDocumentHandlerWizardPage3.java
21  *
22  * Created on 8/5/02 4:17 PM
23  */

24 package org.netbeans.jellytools.modules.xml.saxwizard;
25
26 import org.netbeans.jellytools.WizardOperator;
27 import org.netbeans.jemmy.operators.*;
28
29 /** Class implementing all necessary methods for handling "SAX Document Handler Wizard" NbDialog.
30  *
31  * @author ms113234
32  * @version 1.0
33  */

34 public class SAXDocumentHandlerWizardPage3 extends WizardOperator {
35     static final int ELEMENT_COLUMN = 0;
36     static final int METHOD_COLUMN = 1;
37     static final int RET_TYPE_COLUMN = 2;
38     
39     public static final String JavaDoc NO_METHOD = "[none]";
40     
41     /** Creates new SAXDocumentHandlerWizardPage3 that can handle it.
42      */

43     public SAXDocumentHandlerWizardPage3() {
44         super("SAX Document Handler Wizard");
45     }
46     
47     private JLabelOperator _lblSteps;
48     private JLabelOperator _lbl3Of4DataConvertorsOptional;
49     private JTextAreaOperator _txtJTextArea;
50     private JTableOperator _tabDataConvertors;
51     private JButtonOperator _btCancel;
52     private JButtonOperator _btHelp;
53     
54     
55     //******************************
56
// Subcomponents definition part
57
//******************************
58

59     /** Tries to find "Steps" JLabel in this dialog.
60      * @return JLabelOperator
61      */

62     public JLabelOperator lblSteps() {
63         if (_lblSteps==null) {
64             _lblSteps = new JLabelOperator(this, "Steps");
65         }
66         return _lblSteps;
67     }
68     
69     /** Tries to find "3 of 4 - Data Convertors (Optional)" JLabel in this dialog.
70      * @return JLabelOperator
71      */

72     public JLabelOperator lbl3Of4DataConvertorsOptional() {
73         if (_lbl3Of4DataConvertorsOptional==null) {
74             _lbl3Of4DataConvertorsOptional = new JLabelOperator(this, "3 of 4 - Data Convertors (Optional)");
75         }
76         return _lbl3Of4DataConvertorsOptional;
77     }
78     
79     /** Tries to find null JTextArea in this dialog.
80      * @return JTextAreaOperator
81      */

82     public JTextAreaOperator txtJTextArea() {
83         if (_txtJTextArea==null) {
84             _txtJTextArea = new JTextAreaOperator(this);
85         }
86         return _txtJTextArea;
87     }
88     
89     /** Tries to find null SAXGeneratorParsletPanel$ParsletsTable in this dialog.
90      * @return JTableOperator
91      */

92     public JTableOperator tabDataConvertors() {
93         if (_tabDataConvertors==null) {
94             _tabDataConvertors = new JTableOperator(this);
95         }
96         return _tabDataConvertors;
97     }
98     
99     /** Tries to find "Cancel" JButton in this dialog.
100      * @return JButtonOperator
101      */

102     public JButtonOperator btCancel() {
103         if (_btCancel==null) {
104             _btCancel = new JButtonOperator(this, "Cancel");
105         }
106         return _btCancel;
107     }
108     
109     /** Tries to find "Help" JButton in this dialog.
110      * @return JButtonOperator
111      */

112     public JButtonOperator btHelp() {
113         if (_btHelp==null) {
114             _btHelp = new JButtonOperator(this, "Help");
115         }
116         return _btHelp;
117     }
118     
119     //==========================================================================
120

121     /** Tries to find JTextField in Element column in Data Convertors table.
122      * @return JTextFieldOperator
123      */

124     public JTextFieldOperator txtElement(int row) {
125         tabDataConvertors().clickForEdit(row, ELEMENT_COLUMN);
126         return new JTextFieldOperator(tabDataConvertors());
127     }
128     
129     /** Tries to find JTextField in Convertor Method column in Data Convertors table.
130      * @return JTextFieldOperator
131      */

132     public JTextFieldOperator txtConvertorMethod(int row) {
133         tabDataConvertors().clickForEdit(row, METHOD_COLUMN);
134         return new JTextFieldOperator(tabDataConvertors());
135     }
136     
137     /** Tries to find JComboBox in Convertor Method column in Data Convertors table.
138      * @return JComboBoxOperator
139      */

140     public JComboBoxOperator cboConvertorMethod(int row) {
141         tabDataConvertors().clickForEdit(row, METHOD_COLUMN);
142         return new JComboBoxOperator(tabDataConvertors());
143     }
144     
145     /** Tries to find JTextField in Return Type column in Data Convertors table.
146      * @return JTextFieldOperator
147      * @param row row nuber
148      */

149     public JTextFieldOperator txtReturnType(int row) {
150         tabDataConvertors().clickForEdit(row, RET_TYPE_COLUMN);
151         return new JTextFieldOperator(tabDataConvertors());
152     }
153     
154     /** Tries to find JComboBox in Return Type column in Data Convertors table.
155      * @return JComboBoxOperator
156      * @param row row nuber
157      */

158     public JComboBoxOperator cboReturnType(int row) {
159         tabDataConvertors().clickForEdit(row, RET_TYPE_COLUMN);
160         return new JComboBoxOperator(tabDataConvertors());
161     }
162     
163     //****************************************
164
// Low-level functionality definition part
165
//****************************************
166

167     /** gets text for txtJTextArea
168      * @return String text
169      */

170     public String JavaDoc getJTextArea() {
171         return txtJTextArea().getText();
172     }
173     
174     /** sets text for txtJTextArea
175      * @param text String text
176      */

177     public void setJTextArea(String JavaDoc text) {
178         txtJTextArea().setText(text);
179     }
180     
181     /** types text for txtJTextArea
182      * @param text String text
183      */

184     public void typeJTextArea(String JavaDoc text) {
185         txtJTextArea().typeText(text);
186     }
187     
188     /** clicks on "Cancel" JButton
189      */

190     public void cancel() {
191         btCancel().push();
192     }
193     
194     /** clicks on "Help" JButton
195      */

196     public void help() {
197         btHelp().push();
198     }
199     
200     //==========================================================================
201

202     /** gets text for txtElement
203      * @return String text
204      */

205     public String JavaDoc getElement(int row) {
206         return txtElement(row).getText();
207     }
208     
209     /** gets text for txtConvertorMethod
210      * @return String text
211      */

212     public String JavaDoc getConvertorMethod(int row) {
213         return txtConvertorMethod(row).getText();
214     }
215     
216     /** sets text for txtConvertorMethod
217      * @param text String text
218      */

219     public void setConvertorMethod(int row, String JavaDoc text) {
220         txtConvertorMethod(row).enterText(text);
221     }
222     
223     /** returns selected item for cboConvertorMethod
224      * @return String item
225      */

226     public String JavaDoc getSelectedConvertorMethod(int row) {
227         return cboConvertorMethod(row).getSelectedItem().toString();
228     }
229     
230     /** selects item for cboConvertorMethod
231      * @param item String item
232      */

233     public void selectConvertorMethod(int row, String JavaDoc item) {
234         cboConvertorMethod(row).selectItem(item);
235     }
236     
237     /** gets text for txtReturnType
238      * @return String text
239      */

240     public String JavaDoc getReturnType(int row) {
241         return txtReturnType(row).getText();
242     }
243     
244     /** sets text for txtReturnType
245      * @param text String text
246      */

247     public void setReturnType(int row, String JavaDoc text) {
248         txtReturnType(row).enterText(text);
249     }
250     
251     /** returns selected item for cboReturnType
252      * @return String item
253      */

254     public String JavaDoc getSelectedReturnType(int row) {
255         return cboReturnType(row).getSelectedItem().toString();
256     }
257     
258     /** selects item for cboReturnType
259      * @param item String item
260      */

261     public void selectReturnType(int row, String JavaDoc item) {
262         cboReturnType(row).selectItem(item);
263     }
264
265     //*****************************************
266
// High-level functionality definition part
267
//*****************************************
268

269    /** finds row in Element Mappings table by element, if element is not present
270      * returns -1
271      */

272     public int findTabRow(String JavaDoc element) {
273         int rows = tabDataConvertors().getRowCount();
274         for (int i = 0; i < rows; i++) {
275             String JavaDoc cellVal = tabDataConvertors().getCellEditor(i, ELEMENT_COLUMN).getCellEditorValue().toString();
276             if (element.equals(cellVal)) return i;
277         }
278         return -1;
279     }
280     
281     /** Performs verification of SAXDocumentHandlerWizardPage3 by accessing all its components.
282      */

283     public void verify() {
284         lblSteps();
285         lbl3Of4DataConvertorsOptional();
286         txtJTextArea();
287         tabDataConvertors();
288         btCancel();
289         btHelp();
290     }
291     
292     /** Performs simple test of SAXDocumentHandlerWizardPage3
293      * @param args the command line arguments
294      */

295     public static void main(String JavaDoc args[]) {
296         new SAXDocumentHandlerWizardPage3().verify();
297         System.out.println("SAXDocumentHandlerWizardPage3 verification finished.");
298     }
299 }
300
301
Popular Tags