KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jellytools > modules > xml > XSLTransformationDialog


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 package org.netbeans.jellytools.modules.xml;
20
21 import org.netbeans.jemmy.operators.*;
22
23 /** Class implementing all necessary methods for handling "XSL Transformation" NbDialog.
24  *
25  * @author ms113234
26  * @version 1.0
27  */

28 public class XSLTransformationDialog extends JDialogOperator {
29
30     /** Creates new XSLTransformationDialog that can handle it.
31      * @throws TimeoutExpiredException when NbDialog not found
32      */

33     public XSLTransformationDialog() {
34         super( "XSL Transformation" );
35     }
36
37     private JCheckBoxOperator _cbOverwriteOutput;
38     private JLabelOperator _lblOutput;
39     private JButtonOperator _btBrowseSource;
40     private JComboBoxOperator _cboXMLSource;
41     private JLabelOperator _lblXSLTScript;
42     private JComboBoxOperator _cboJComboBox;
43     public static final String JavaDoc ITEM_DONOTHING = "Do Nothing";
44     public static final String JavaDoc ITEM_APPLYDEFAULTACTION = "Apply Default Action";
45     public static final String JavaDoc ITEM_OPENINBROWSER = "Open in Browser";
46     private JButtonOperator _btBrowseScript;
47     private JButtonOperator _btCancel;
48     private JComboBoxOperator _cboXSLTScript;
49     private JButtonOperator _btHelp;
50     private JButtonOperator _btOK;
51     private JComboBoxOperator _cboOutput;
52     public static final String JavaDoc ITEM_BOOKSHTML = "Books.html";
53     public static final String JavaDoc ITEM_PREVIEWOPENINBROWSER = "Preview (open in browser)";
54     private JLabelOperator _lblProcessOutput;
55     private JLabelOperator _lblXMLSource;
56     
57     
58     //******************************
59
// Subcomponents definition part
60
//******************************
61

62     /** Tries to find "Overwrite Output" JCheckBox in this dialog.
63      * @throws TimeoutExpiredException when component not found
64      * @return JCheckBoxOperator
65      */

66     public JCheckBoxOperator cbOverwriteOutput() {
67         if (_cbOverwriteOutput==null) {
68             _cbOverwriteOutput = new JCheckBoxOperator( this, "Overwrite Output", 0 );
69         }
70         return _cbOverwriteOutput;
71     }
72     
73     /** Tries to find "Output:" JLabel in this dialog.
74      * @throws TimeoutExpiredException when component not found
75      * @return JLabelOperator
76      */

77     public JLabelOperator lblOutput() {
78         if (_lblOutput==null) {
79             _lblOutput = new JLabelOperator( this, "Output:", 0 );
80         }
81         return _lblOutput;
82     }
83     
84     /** Tries to find "Browse..." JButton in this dialog.
85      * @throws TimeoutExpiredException when component not found
86      * @return JButtonOperator
87      */

88     public JButtonOperator btBrowseSource() {
89         if (_btBrowseSource==null) {
90             _btBrowseSource = new JButtonOperator( this, "Browse...", 0 );
91         }
92         return _btBrowseSource;
93     }
94     
95     /** Tries to find null JComboBox in this dialog.
96      * @throws TimeoutExpiredException when component not found
97      * @return JComboBoxOperator
98      */

99     public JComboBoxOperator cboXMLSource() {
100         if (_cboXMLSource==null) {
101             _cboXMLSource = new JComboBoxOperator(this, 0);
102         }
103         return _cboXMLSource;
104     }
105     
106     /** Tries to find "XSLT Script:" JLabel in this dialog.
107      * @throws TimeoutExpiredException when component not found
108      * @return JLabelOperator
109      */

110     public JLabelOperator lblXSLTScript() {
111         if (_lblXSLTScript==null) {
112             _lblXSLTScript = new JLabelOperator( this, "XSLT Script:", 0 );
113         }
114         return _lblXSLTScript;
115     }
116     
117     /** Tries to find null JComboBox in this dialog.
118      * @throws TimeoutExpiredException when component not found
119      * @return JComboBoxOperator
120      */

121     public JComboBoxOperator cboJComboBox() {
122         if (_cboJComboBox==null) {
123             _cboJComboBox = new JComboBoxOperator(this, 3);
124         }
125         return _cboJComboBox;
126     }
127     
128     /** Tries to find "Browse..." JButton in this dialog.
129      * @throws TimeoutExpiredException when component not found
130      * @return JButtonOperator
131      */

132     public JButtonOperator btBrowseScript() {
133         if (_btBrowseScript==null) {
134             _btBrowseScript = new JButtonOperator( this, "Browse...", 1 );
135         }
136         return _btBrowseScript;
137     }
138     
139     /** Tries to find "Cancel" JButton in this dialog.
140      * @throws TimeoutExpiredException when component not found
141      * @return JButtonOperator
142      */

143     public JButtonOperator btCancel() {
144         if (_btCancel==null) {
145             _btCancel = new JButtonOperator( this, "Cancel", 0 );
146         }
147         return _btCancel;
148     }
149     
150     /** Tries to find null JComboBox in this dialog.
151      * @throws TimeoutExpiredException when component not found
152      * @return JComboBoxOperator
153      */

154     public JComboBoxOperator cboXSLTScript() {
155         if (_cboXSLTScript==null) {
156             _cboXSLTScript = new JComboBoxOperator(this, 1);
157         }
158         return _cboXSLTScript;
159     }
160     
161     /** Tries to find "Help" JButton in this dialog.
162      * @throws TimeoutExpiredException when component not found
163      * @return JButtonOperator
164      */

165     public JButtonOperator btHelp() {
166         if (_btHelp==null) {
167             _btHelp = new JButtonOperator( this, "Help", 0 );
168         }
169         return _btHelp;
170     }
171     
172     /** Tries to find "OK" JButton in this dialog.
173      * @throws TimeoutExpiredException when component not found
174      * @return JButtonOperator
175      */

176     public JButtonOperator btOK() {
177         if (_btOK==null) {
178             _btOK = new JButtonOperator( this, "OK", 0 );
179         }
180         return _btOK;
181     }
182     
183     /** Tries to find null JComboBox in this dialog.
184      * @throws TimeoutExpiredException when component not found
185      * @return JComboBoxOperator
186      */

187     public JComboBoxOperator cboOutput() {
188         if (_cboOutput==null) {
189             _cboOutput = new JComboBoxOperator(this, 2);
190         }
191         return _cboOutput;
192     }
193     
194     /** Tries to find "Process Output:" JLabel in this dialog.
195      * @throws TimeoutExpiredException when component not found
196      * @return JLabelOperator
197      */

198     public JLabelOperator lblProcessOutput() {
199         if (_lblProcessOutput==null) {
200             _lblProcessOutput = new JLabelOperator( this, "Process Output:", 0 );
201         }
202         return _lblProcessOutput;
203     }
204     
205     /** Tries to find "XML Source:" JLabel in this dialog.
206      * @throws TimeoutExpiredException when component not found
207      * @return JLabelOperator
208      */

209     public JLabelOperator lblXMLSource() {
210         if (_lblXMLSource==null) {
211             _lblXMLSource = new JLabelOperator( this, "XML Source:", 0 );
212         }
213         return _lblXMLSource;
214     }
215     
216     
217     //****************************************
218
// Low-level functionality definition part
219
//****************************************
220

221     /** checks or unchecks given JCheckBox
222      * @param state boolean requested state
223      */

224     public void checkOverwriteOutput( boolean state ) {
225         if (cbOverwriteOutput().isSelected()!=state) {
226             cbOverwriteOutput().push();
227         }
228     }
229     
230     /** clicks on "Browse..." JButton
231      * @throws TimeoutExpiredException when JButton not found
232      */

233     public void browseSource() {
234         btBrowseSource().push();
235     }
236     
237     /** tries to find cboXMLSource and select item
238      * @param item String item
239      */

240     public void setXMLSource( String JavaDoc item ) {
241         cboXMLSource().selectItem(item, true, true);
242     }
243     
244     /** tries to find cboJComboBox and select item
245      * @param item String item
246      */

247     public void setJComboBox( String JavaDoc item ) {
248         cboJComboBox().selectItem(item, true, true);
249     }
250     
251     /** clicks on "Browse..." JButton
252      * @throws TimeoutExpiredException when JButton not found
253      */

254     public void browseScript() {
255         btBrowseScript().push();
256     }
257     
258     /** clicks on "Cancel" JButton
259      * @throws TimeoutExpiredException when JButton not found
260      */

261     public void cancel() {
262         btCancel().push();
263     }
264     
265     /** tries to find cboXSLTScript and select item
266      * @param item String item
267      */

268     public void setXSLTScript( String JavaDoc item ) {
269         cboXSLTScript().selectItem(item, true, true);
270     }
271     
272     /** clicks on "Help" JButton
273      * @throws TimeoutExpiredException when JButton not found
274      */

275     public void help() {
276         btHelp().push();
277     }
278     
279     /** clicks on "OK" JButton
280      * @throws TimeoutExpiredException when JButton not found
281      */

282     public void oK() {
283         btOK().push();
284     }
285     
286     /** tries to find cboOutput and select item
287      * @param item String item
288      */

289     public void setOutput( String JavaDoc item ) {
290         cboOutput().selectItem(item, true, true);
291     }
292     
293     
294     //*****************************************
295
// High-level functionality definition part
296
//*****************************************
297

298     /** Performs verification of XSLTransformationDialog by accessing all its components.
299      * @throws TimeoutExpiredException when any component not found
300      */

301     public void verify() {
302         cbOverwriteOutput();
303         lblOutput();
304         btBrowseSource();
305         cboXMLSource();
306         lblXSLTScript();
307         cboJComboBox();
308         btBrowseScript();
309         btCancel();
310         cboXSLTScript();
311         btHelp();
312         btOK();
313         cboOutput();
314         lblProcessOutput();
315         lblXMLSource();
316     }
317     
318     /** Performs simple test of XSLTransformationDialog
319      * @param args the command line arguments
320      */

321     public static void main(String JavaDoc args[]) {
322         new XSLTransformationDialog().verify();
323         System.out.println("XSLTransformationDialog verification finished.");
324     }
325 }
326
Popular Tags