KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jellytools > modules > editor > Replace


1 /*
2  * Replace.java
3  *
4  * Created on 1/24/05 5:01 PM
5  */

6 package org.netbeans.jellytools.modules.editor;
7
8 import org.netbeans.jemmy.operators.*;
9 import org.netbeans.jemmy.util.NameComponentChooser;
10
11 /** Class implementing all necessary methods for handling "Replace" NbDialog.
12  *
13  * @author rs155161
14  * @version 1.0
15  */

16 public class Replace extends JDialogOperator {
17     
18     /** Creates new Replace that can handle it.
19      */

20     public Replace() {
21         super(java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("replace-title"));
22     }
23     
24     private JLabelOperator _lblFindWhat;
25     private JComboBoxOperator _cboFindWhat;
26     private JLabelOperator _lblReplaceWith;
27     private JComboBoxOperator _cboReplaceWith;
28     private JCheckBoxOperator _cbHighlightSearch;
29     private JCheckBoxOperator _cbIncrementalSearch;
30     private JCheckBoxOperator _cbMatchCase;
31     //private JCheckBoxOperator _cbSmartCase;
32
private JCheckBoxOperator _cbMatchWholeWordsOnly;
33     private JCheckBoxOperator _cbBackwardSearch;
34     private JCheckBoxOperator _cbWrapSearch;
35     private JCheckBoxOperator _cbRegularExpressions;
36     private JCheckBoxOperator _cbSearchSelection;
37     private JButtonOperator _btFind;
38     private JButtonOperator _btReplace;
39     private JButtonOperator _btReplaceAll;
40     private JButtonOperator _btClose;
41     private JButtonOperator _btHelp;
42     
43     
44     //******************************
45
// Subcomponents definition part
46
//******************************
47

48     /** Tries to find "Find What:" JLabel in this dialog.
49      * @return JLabelOperator
50      */

51     public JLabelOperator lblFindWhat() {
52         if (_lblFindWhat==null) {
53             _lblFindWhat = new JLabelOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-what"));
54         }
55         return _lblFindWhat;
56     }
57     
58     /** Tries to find null JComboBox in this dialog.
59      * @return JComboBoxOperator
60      */

61     public JComboBoxOperator cboFindWhat() {
62         if (_cboFindWhat==null) {
63             _cboFindWhat = new JComboBoxOperator(this);
64         }
65         return _cboFindWhat;
66     }
67     
68     /** Tries to find "Replace With:" JLabel in this dialog.
69      * @return JLabelOperator
70      */

71     public JLabelOperator lblReplaceWith() {
72         if (_lblReplaceWith==null) {
73             _lblReplaceWith = new JLabelOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-replace-with"));
74         }
75         return _lblReplaceWith;
76     }
77     
78     /** Tries to find null JComboBox in this dialog.
79      * @return JComboBoxOperator
80      */

81     public JComboBoxOperator cboReplaceWith() {
82         if (_cboReplaceWith==null) {
83             _cboReplaceWith = new JComboBoxOperator(this, 1);
84         }
85         return _cboReplaceWith;
86     }
87     
88     /** Tries to find " Highlight Search" JCheckBox in this dialog.
89      * @return JCheckBoxOperator
90      */

91     public JCheckBoxOperator cbHighlightSearch() {
92         if (_cbHighlightSearch==null) {
93             _cbHighlightSearch = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-highlight-search"));
94         }
95         return _cbHighlightSearch;
96     }
97     
98     /** Tries to find " Incremental Search" JCheckBox in this dialog.
99      * @return JCheckBoxOperator
100      */

101     public JCheckBoxOperator cbIncrementalSearch() {
102         if (_cbIncrementalSearch==null) {
103             _cbIncrementalSearch = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-inc-search"));
104         }
105         return _cbIncrementalSearch;
106     }
107     
108     /** Tries to find " Match Case" JCheckBox in this dialog.
109      * @return JCheckBoxOperator
110      */

111     public JCheckBoxOperator cbMatchCase() {
112         if (_cbMatchCase==null) {
113             _cbMatchCase = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-match-case"));
114         }
115         return _cbMatchCase;
116     }
117        
118     /** Tries to find " Match Whole Words Only" JCheckBox in this dialog.
119      * @return JCheckBoxOperator
120      */

121     public JCheckBoxOperator cbMatchWholeWordsOnly() {
122         if (_cbMatchWholeWordsOnly==null) {
123             _cbMatchWholeWordsOnly = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-whole-words"));
124         }
125         return _cbMatchWholeWordsOnly;
126     }
127     
128     /** Tries to find " Backward Search" JCheckBox in this dialog.
129      * @return JCheckBoxOperator
130      */

131     public JCheckBoxOperator cbBackwardSearch() {
132         if (_cbBackwardSearch==null) {
133             _cbBackwardSearch = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-backward-search"));
134         }
135         return _cbBackwardSearch;
136     }
137     
138     /** Tries to find " Wrap Search" JCheckBox in this dialog.
139      * @return JCheckBoxOperator
140      */

141     public JCheckBoxOperator cbWrapSearch() {
142         if (_cbWrapSearch==null) {
143             _cbWrapSearch = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-wrap-search"));
144         }
145         return _cbWrapSearch;
146     }
147     
148     /** Tries to find " Regular Expressions" JCheckBox in this dialog.
149      * @return JCheckBoxOperator
150      */

151     public JCheckBoxOperator cbRegularExpressions() {
152         if (_cbRegularExpressions==null) {
153             _cbRegularExpressions = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-reg-exp"));
154         }
155         return _cbRegularExpressions;
156     }
157     
158     /** Tries to find " Search Selection" JCheckBox in this dialog.
159      * @return JCheckBoxOperator
160      */

161     public JCheckBoxOperator cbSearchSelection() {
162         if (_cbSearchSelection==null) {
163             _cbSearchSelection = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-block-search"));
164         }
165         return _cbSearchSelection;
166     }
167     
168     /** Tries to find "Find" JButton in this dialog.
169      * @return JButtonOperator
170      */

171     public JButtonOperator btFind() {
172         if (_btFind==null) {
173             _btFind = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-button-find"));
174         }
175         return _btFind;
176     }
177     
178     /** Tries to find "Replace" JButton in this dialog.
179      * @return JButtonOperator
180      */

181     public JButtonOperator btReplace() {
182         if (_btReplace==null) {
183             _btReplace = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-button-replace"));
184         }
185         return _btReplace;
186     }
187     
188     /** Tries to find "Replace All" JButton in this dialog.
189      * @return JButtonOperator
190      */

191     public JButtonOperator btReplaceAll() {
192         if (_btReplaceAll==null) {
193             _btReplaceAll = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-button-replace-all"));
194         }
195         return _btReplaceAll;
196     }
197     
198     /** Tries to find "Close" JButton in this dialog.
199      * @return JButtonOperator
200      */

201     public JButtonOperator btClose() {
202         if (_btClose==null) {
203             _btClose = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-button-cancel"));
204         }
205         return _btClose;
206     }
207     
208     /** Tries to find "Help" JButton in this dialog.
209      * @return JButtonOperator
210      */

211     public JButtonOperator btHelp() {
212         if (_btHelp==null) {
213             _btHelp = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.openide.explorer.propertysheet.Bundle").getString("CTL_Help"));
214         }
215         return _btHelp;
216     }
217     
218     
219     //****************************************
220
// Low-level functionality definition part
221
//****************************************
222

223     /** returns selected item for cboFindWhat
224      * @return String item
225      */

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

233     public void selectFindWhat(String JavaDoc item) {
234         cboFindWhat().selectItem(item);
235     }
236     
237     /** types text for cboFindWhat
238      * @param text String text
239      */

240     public void typeFindWhat(String JavaDoc text) {
241         cboFindWhat().typeText(text);
242     }
243     
244     /** returns selected item for cboReplaceWith
245      * @return String item
246      */

247     public String JavaDoc getSelectedReplaceWith() {
248         return cboReplaceWith().getSelectedItem().toString();
249     }
250     
251     /** selects item for cboReplaceWith
252      * @param item String item
253      */

254     public void selectReplaceWith(String JavaDoc item) {
255         cboReplaceWith().selectItem(item);
256     }
257     
258     /** types text for cboReplaceWith
259      * @param text String text
260      */

261     public void typeReplaceWith(String JavaDoc text) {
262         cboReplaceWith().typeText(text);
263     }
264     
265     /** checks or unchecks given JCheckBox
266      * @param state boolean requested state
267      */

268     public void checkHighlightSearch(boolean state) {
269         if (cbHighlightSearch().isSelected()!=state) {
270             cbHighlightSearch().push();
271         }
272     }
273     
274     /** checks or unchecks given JCheckBox
275      * @param state boolean requested state
276      */

277     public void checkIncrementalSearch(boolean state) {
278         if (cbIncrementalSearch().isSelected()!=state) {
279             cbIncrementalSearch().push();
280         }
281     }
282     
283     /** checks or unchecks given JCheckBox
284      * @param state boolean requested state
285      */

286     public void checkMatchCase(boolean state) {
287         if (cbMatchCase().isSelected()!=state) {
288             cbMatchCase().push();
289         }
290     }
291     
292         
293     /** checks or unchecks given JCheckBox
294      * @param state boolean requested state
295      */

296     public void checkMatchWholeWordsOnly(boolean state) {
297         if (cbMatchWholeWordsOnly().isSelected()!=state) {
298             cbMatchWholeWordsOnly().push();
299         }
300     }
301     
302     /** checks or unchecks given JCheckBox
303      * @param state boolean requested state
304      */

305     public void checkBackwardSearch(boolean state) {
306         if (cbBackwardSearch().isSelected()!=state) {
307             cbBackwardSearch().push();
308         }
309     }
310     
311     /** checks or unchecks given JCheckBox
312      * @param state boolean requested state
313      */

314     public void checkWrapSearch(boolean state) {
315         if (cbWrapSearch().isSelected()!=state) {
316             cbWrapSearch().push();
317         }
318     }
319     
320     /** checks or unchecks given JCheckBox
321      * @param state boolean requested state
322      */

323     public void checkRegularExpressions(boolean state) {
324         if (cbRegularExpressions().isSelected()!=state) {
325             cbRegularExpressions().push();
326         }
327     }
328     
329     /** checks or unchecks given JCheckBox
330      * @param state boolean requested state
331      */

332     public void checkSearchSelection(boolean state) {
333         if (cbSearchSelection().isSelected()!=state) {
334             cbSearchSelection().push();
335         }
336     }
337     
338     /** clicks on "Find" JButton
339      */

340     public void find() {
341         btFind().push();
342     }
343     
344     /** clicks on "Replace" JButton
345      */

346     public void replace() {
347         btReplace().push();
348     }
349     
350     /** clicks on "Replace All" JButton
351      */

352     public void replaceAll() {
353         btReplaceAll().push();
354     }
355     
356     /** clicks on "Close" JButton
357      */

358     public void close() {
359         btClose().push();
360     }
361     
362     /** clicks on "Help" JButton
363      */

364     public void help() {
365         btHelp().push();
366     }
367     
368     
369     //*****************************************
370
// High-level functionality definition part
371
//*****************************************
372

373     /** Performs verification of Replace by accessing all its components.
374      */

375     public void verify() {
376         lblFindWhat();
377         cboFindWhat();
378         lblReplaceWith();
379         cboReplaceWith();
380         cbHighlightSearch();
381         cbIncrementalSearch();
382         cbMatchCase();
383         cbMatchWholeWordsOnly();
384         cbBackwardSearch();
385         cbWrapSearch();
386         cbRegularExpressions();
387         cbSearchSelection();
388         btFind();
389         btReplace();
390         btReplaceAll();
391         btClose();
392         btHelp();
393     }
394     
395     /** Performs simple test of Replace
396      * @param args the command line arguments
397      */

398     public static void main(String JavaDoc args[]) {
399         new Replace().verify();
400         System.out.println("Replace verification finished.");
401     }
402 }
403
404
Popular Tags