KickJava   Java API By Example, From Geeks To Geeks.

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


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

24 package org.netbeans.jellytools.modules.xml.saxwizard;
25
26 import java.awt.Component JavaDoc;
27 import javax.swing.JComboBox JavaDoc;
28 import javax.swing.JTextField JavaDoc;
29 import javax.swing.table.TableCellEditor JavaDoc;
30 import org.netbeans.jellytools.WizardOperator;
31 import org.netbeans.jemmy.operators.*;
32 import org.netbeans.jemmy.util.Dumper;
33
34 /** Class implementing all necessary methods for handling "SAX Document Handler Wizard" NbDialog.
35  *
36  * @author ms113234
37  * @version 1.0
38  */

39 public class SAXDocumentHandlerWizardPage2 extends WizardOperator {
40     static final int ELEMENT_COLUMN = 0;
41     static final int TYPE_COLUMN = 1;
42     static final int METHOD_COLUMN = 2;
43     
44     public static final String JavaDoc IGNORE = "Ignore";
45     public static final String JavaDoc DATA = "Data";
46     public static final String JavaDoc CONTAINER = "Container";
47     public static final String JavaDoc MIXED = "Mixed";
48     public static final String JavaDoc MIXED_CONTAINER = "Mixed Container";
49     
50     /** Creates new SAXDocumentHandlerWizard2 that can handle it.
51      */

52     public SAXDocumentHandlerWizardPage2() {
53         super("SAX Document Handler Wizard");
54     }
55     
56     private JLabelOperator _lblSteps;
57     private JLabelOperator _lbl2Of4ElementMappings;
58     private JTextAreaOperator _txtJTextArea;
59     private JTableOperator _tabElementMappings;
60     private JButtonOperator _btCancel;
61     private JButtonOperator _btHelp;
62     
63     
64     //******************************
65
// Subcomponents definition part
66
//******************************
67

68     /** Tries to find "Steps" JLabel in this dialog.
69      * @return JLabelOperator
70      */

71     public JLabelOperator lblSteps() {
72         if (_lblSteps==null) {
73             _lblSteps = new JLabelOperator(this, "Steps");
74         }
75         return _lblSteps;
76     }
77     
78     /** Tries to find "2 of 4 - Element Mappings" JLabel in this dialog.
79      * @return JLabelOperator
80      */

81     public JLabelOperator lbl2Of4ElementMappings() {
82         if (_lbl2Of4ElementMappings==null) {
83             _lbl2Of4ElementMappings = new JLabelOperator(this, "2 of 4 - Element Mappings");
84         }
85         return _lbl2Of4ElementMappings;
86     }
87     
88     /** Tries to find null JTextArea in this dialog.
89      * @return JTextAreaOperator
90      */

91     public JTextAreaOperator txtJTextArea() {
92         if (_txtJTextArea==null) {
93             _txtJTextArea = new JTextAreaOperator(this);
94         }
95         return _txtJTextArea;
96     }
97     
98     /** Tries to find null SAXGeneratorMethodPanel$MethodsTable in this dialog.
99      * @return JTableOperator
100      */

101     public JTableOperator tabElementMappings() {
102         if (_tabElementMappings==null) {
103             _tabElementMappings = new JTableOperator(this);
104         }
105         return _tabElementMappings;
106     }
107     
108     /** Tries to find "Cancel" JButton in this dialog.
109      * @return JButtonOperator
110      */

111     public JButtonOperator btCancel() {
112         if (_btCancel==null) {
113             _btCancel = new JButtonOperator(this, "Cancel");
114         }
115         return _btCancel;
116     }
117     
118     /** Tries to find "Help" JButton in this dialog.
119      * @return JButtonOperator
120      */

121     public JButtonOperator btHelp() {
122         if (_btHelp==null) {
123             _btHelp = new JButtonOperator(this, "Help");
124         }
125         return _btHelp;
126     }
127     
128     //==========================================================================
129

130     /** Tries to find ValidatingTextField in Hnadler Method column in Element Mappings table.
131      * @return JTextFieldOperator
132      */

133     public JTextFieldOperator txtElement(int row) {
134         //return new JTextFieldOperator((JTextField) getTableCellEditorComponent(row, ELEMENT_COLUMN));
135
tabElementMappings().clickForEdit(row, ELEMENT_COLUMN);
136         return new JTextFieldOperator(tabElementMappings());
137     }
138
139     /** Tries to find JComboBox in Handler Type column in Element Mappings table.
140      * @return JComboBoxOperator
141      * @param row row nuber
142      */

143     public JComboBoxOperator cboHandlerType(int row) {
144         tabElementMappings().clickForEdit(row, TYPE_COLUMN);
145         return new JComboBoxOperator(tabElementMappings());
146     }
147     
148     /** Tries to find ValidatingTextField in Hnadler Method column in Element Mappings table.
149      * @return JTextFieldOperator
150      */

151     public JTextFieldOperator txtHandlerMethod(int row) {
152         tabElementMappings().clickForEdit(row, METHOD_COLUMN);
153         return new JTextFieldOperator(tabElementMappings());
154     }
155     
156     //****************************************
157
// Low-level functionality definition part
158
//****************************************
159

160     /** gets text for txtJTextArea
161      * @return String text
162      */

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

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

177     public void typeJTextArea(String JavaDoc text) {
178         txtJTextArea().typeText(text);
179     }
180     
181     /** clicks on "Cancel" JButton
182      */

183     public void cancel() {
184         btCancel().push();
185     }
186     
187     /** clicks on "Help" JButton
188      */

189     public void help() {
190         btHelp().push();
191     }
192     
193     //==========================================================================
194

195     /** returns selected item for cboHandlerType
196      * @return String item
197      */

198     public String JavaDoc getSelectedHandlerType(int row) {
199         return cboHandlerType(row).getSelectedItem().toString();
200     }
201     
202     /** selects item for cboHandlerType
203      * @param item String item
204      */

205     public void selectHandlerType(int row, String JavaDoc item) {
206         cboHandlerType(row).selectItem(item);
207     }
208     
209     /** gets text for txtHandlerMethod
210      * @return String text
211      */

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

219     public void setHandlerMethod(int row, String JavaDoc text) {
220         txtHandlerMethod(row).enterText(text);
221     }
222     
223     /** gets text for txtElement
224      * @return String text
225      */

226     public String JavaDoc getElement(int row) {
227         return txtElement(row).getText();
228     }
229     
230     //*****************************************
231
// High-level functionality definition part
232
//*****************************************
233

234     /** finds row in Element Mappings table by element, if element is not present
235      * returns -1
236      */

237     public int findTabRow(String JavaDoc element) {
238         int rows = tabElementMappings().getRowCount();
239         for (int i = 0; i < rows; i++) {
240             String JavaDoc cellVal = tabElementMappings().getCellEditor(i, ELEMENT_COLUMN).getCellEditorValue().toString();
241             if (element.equals(cellVal)) return i;
242         }
243         return -1;
244     }
245     
246     /** Performs verification of SAXDocumentHandlerWizard2 by accessing all its components.
247      */

248     public void verify() {
249         lblSteps();
250         lbl2Of4ElementMappings();
251         txtJTextArea();
252         tabElementMappings();
253         btCancel();
254         btHelp();
255     }
256     
257     /** Performs simple test of SAXDocumentHandlerWizard2
258      * @param args the command line arguments
259      */

260     public static void main(String JavaDoc args[]) {
261         new SAXDocumentHandlerWizardPage2().verify();
262         System.out.println("SAXDocumentHandlerWizardPage2 verification finished.");
263     }
264 }
265
266
Popular Tags