Source Code Cross Referenced for Find.java in  » IDE-Netbeans » editor » org » netbeans » jellytools » modules » editor » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » editor » org.netbeans.jellytools.modules.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        /*
043:         * Find.java
044:         *
045:         * Created on 1/17/05 5:08 PM
046:         */
047:        package org.netbeans.jellytools.modules.editor;
048:
049:        import java.awt.Robot;
050:        import java.awt.event.InputEvent;
051:        import java.awt.event.KeyEvent;
052:        import org.netbeans.jemmy.operators.*;
053:
054:        /** Class implementing all necessary methods for handling "Find" NbDialog.
055:         *
056:         * @author rs155161
057:         * @version 1.0
058:         */
059:        public class Find extends JDialogOperator {
060:
061:            /** Creates new Find that can handle it.
062:             */
063:            public Find() {
064:                super (java.util.ResourceBundle.getBundle(
065:                        "org.netbeans.editor.Bundle").getString("find-title"));
066:            }
067:
068:            private JLabelOperator _lblFindWhat;
069:            private JComboBoxOperator _cboFindWhat;
070:            private JCheckBoxOperator _cbHighlightSearch;
071:            private JCheckBoxOperator _cbIncrementalSearch;
072:            private JCheckBoxOperator _cbMatchCase;
073:            //private JCheckBoxOperator _cbSmartCase;
074:            private JCheckBoxOperator _cbMatchWholeWordsOnly;
075:            private JCheckBoxOperator _cbBackwardSearch;
076:            private JCheckBoxOperator _cbWrapSearch;
077:            private JCheckBoxOperator _cbRegularExpressions;
078:            private JCheckBoxOperator _cbBlockSearch;
079:            private JButtonOperator _btFind;
080:            private JButtonOperator _btClose;
081:            private JButtonOperator _btHelp;
082:
083:            //******************************
084:            // Subcomponents definition part
085:            //******************************
086:
087:            /** Tries to find "Find What:" JLabel in this dialog.
088:             * @return JLabelOperator
089:             */
090:            public JLabelOperator lblFindWhat() {
091:                if (_lblFindWhat == null) {
092:                    _lblFindWhat = new JLabelOperator(this ,
093:                            java.util.ResourceBundle.getBundle(
094:                                    "org.netbeans.editor.Bundle").getString(
095:                                    "find-what"));
096:                }
097:                return _lblFindWhat;
098:            }
099:
100:            /** Tries to find null JComboBox in this dialog.
101:             * @return JComboBoxOperator
102:             */
103:            public JComboBoxOperator cboFindWhat() {
104:                if (_cboFindWhat == null) {
105:                    _cboFindWhat = new JComboBoxOperator(this );
106:                }
107:                return _cboFindWhat;
108:            }
109:
110:            /** Tries to find " Highlight Search" JCheckBox in this dialog.
111:             * @return JCheckBoxOperator
112:             */
113:            public JCheckBoxOperator cbHighlightSearch() {
114:                if (_cbHighlightSearch == null) {
115:                    _cbHighlightSearch = new JCheckBoxOperator(this ,
116:                            java.util.ResourceBundle.getBundle(
117:                                    "org.netbeans.editor.Bundle").getString(
118:                                    "find-highlight-search"));
119:                }
120:                return _cbHighlightSearch;
121:            }
122:
123:            /** Tries to find " Incremental Search" JCheckBox in this dialog.
124:             * @return JCheckBoxOperator
125:             */
126:            public JCheckBoxOperator cbIncrementalSearch() {
127:                if (_cbIncrementalSearch == null) {
128:                    _cbIncrementalSearch = new JCheckBoxOperator(this ,
129:                            java.util.ResourceBundle.getBundle(
130:                                    "org.netbeans.editor.Bundle").getString(
131:                                    "find-inc-search"));
132:                }
133:                return _cbIncrementalSearch;
134:            }
135:
136:            /** Tries to find " Match Case" JCheckBox in this dialog.
137:             * @return JCheckBoxOperator
138:             */
139:            public JCheckBoxOperator cbMatchCase() {
140:                if (_cbMatchCase == null) {
141:                    _cbMatchCase = new JCheckBoxOperator(this ,
142:                            java.util.ResourceBundle.getBundle(
143:                                    "org.netbeans.editor.Bundle").getString(
144:                                    "find-match-case"));
145:                }
146:                return _cbMatchCase;
147:            }
148:
149:            /** Tries to find " Smart Case" JCheckBox in this dialog.
150:             * @return JCheckBoxOperator
151:             */
152:            /*public JCheckBoxOperator cbSmartCase() {
153:                if (_cbSmartCase==null) {
154:                    _cbSmartCase = new JCheckBoxOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("find-smart-case"));
155:                }
156:                return _cbSmartCase;
157:            }*/
158:
159:            /** Tries to find " Match Whole Words Only" JCheckBox in this dialog.
160:             * @return JCheckBoxOperator
161:             */
162:            public JCheckBoxOperator cbMatchWholeWordsOnly() {
163:                if (_cbMatchWholeWordsOnly == null) {
164:                    _cbMatchWholeWordsOnly = new JCheckBoxOperator(this ,
165:                            java.util.ResourceBundle.getBundle(
166:                                    "org.netbeans.editor.Bundle").getString(
167:                                    "find-whole-words"));
168:                }
169:                return _cbMatchWholeWordsOnly;
170:            }
171:
172:            /** Tries to find " Backward Search" JCheckBox in this dialog.
173:             * @return JCheckBoxOperator
174:             */
175:            public JCheckBoxOperator cbBackwardSearch() {
176:                if (_cbBackwardSearch == null) {
177:                    _cbBackwardSearch = new JCheckBoxOperator(this ,
178:                            java.util.ResourceBundle.getBundle(
179:                                    "org.netbeans.editor.Bundle").getString(
180:                                    "find-backward-search"));
181:                }
182:                return _cbBackwardSearch;
183:            }
184:
185:            /** Tries to find " Wrap Search" JCheckBox in this dialog.
186:             * @return JCheckBoxOperator
187:             */
188:            public JCheckBoxOperator cbWrapSearch() {
189:                if (_cbWrapSearch == null) {
190:                    _cbWrapSearch = new JCheckBoxOperator(this ,
191:                            java.util.ResourceBundle.getBundle(
192:                                    "org.netbeans.editor.Bundle").getString(
193:                                    "find-wrap-search"));
194:                }
195:                return _cbWrapSearch;
196:            }
197:
198:            /** Tries to find " Regular Expressions" JCheckBox in this dialog.
199:             * @return JCheckBoxOperator
200:             */
201:            public JCheckBoxOperator cbRegularExpressions() {
202:                if (_cbRegularExpressions == null) {
203:                    _cbRegularExpressions = new JCheckBoxOperator(this ,
204:                            java.util.ResourceBundle.getBundle(
205:                                    "org.netbeans.editor.Bundle").getString(
206:                                    "find-reg-exp"));
207:                }
208:                return _cbRegularExpressions;
209:            }
210:
211:            /** Tries to find " Block Search" JCheckBox in this dialog.
212:             * @return JCheckBoxOperator
213:             */
214:            public JCheckBoxOperator cbBlockSearch() {
215:                if (_cbBlockSearch == null) {
216:                    _cbBlockSearch = new JCheckBoxOperator(this ,
217:                            java.util.ResourceBundle.getBundle(
218:                                    "org.netbeans.editor.Bundle").getString(
219:                                    "find-block-search"));
220:                }
221:                return _cbBlockSearch;
222:            }
223:
224:            /** Tries to find "Find" JButton in this dialog.
225:             * @return JButtonOperator
226:             */
227:            public JButtonOperator btFind() {
228:                if (_btFind == null) {
229:                    _btFind = new JButtonOperator(this ,
230:                            java.util.ResourceBundle.getBundle(
231:                                    "org.netbeans.editor.Bundle").getString(
232:                                    "find-button-find"));
233:                }
234:                return _btFind;
235:            }
236:
237:            /** Tries to find "Close" JButton in this dialog.
238:             * @return JButtonOperator
239:             */
240:            public JButtonOperator btClose() {
241:                if (_btClose == null) {
242:                    _btClose = new JButtonOperator(this ,
243:                            java.util.ResourceBundle.getBundle(
244:                                    "org.netbeans.editor.Bundle").getString(
245:                                    "find-button-cancel"));
246:                }
247:                return _btClose;
248:            }
249:
250:            /** Tries to find "Help" JButton in this dialog.
251:             * @return JButtonOperator
252:             */
253:            public JButtonOperator btHelp() {
254:                if (_btHelp == null) {
255:                    _btHelp = new JButtonOperator(
256:                            this ,
257:                            java.util.ResourceBundle
258:                                    .getBundle(
259:                                            "org.openide.explorer.propertysheet.Bundle")
260:                                    .getString("CTL_Help"));
261:                }
262:                return _btHelp;
263:            }
264:
265:            //****************************************
266:            // Low-level functionality definition part
267:            //****************************************
268:
269:            /** returns selected item for cboFindWhat
270:             * @return String item
271:             */
272:            public String getSelectedFindWhat() {
273:                return cboFindWhat().getSelectedItem().toString();
274:            }
275:
276:            /** selects item for cboFindWhat
277:             * @param item String item
278:             */
279:            public void selectFindWhat(String item) {
280:                cboFindWhat().selectItem(item);
281:            }
282:
283:            /** types text for cboFindWhat
284:             * @param text String text
285:             */
286:            public void typeFindWhat(String text) {
287:                cboFindWhat().typeText(text);
288:            }
289:
290:            /** checks or unchecks given JCheckBox
291:             * @param state boolean requested state
292:             */
293:            public void checkHighlightSearch(boolean state) {
294:                if (cbHighlightSearch().isSelected() != state) {
295:                    cbHighlightSearch().push();
296:                }
297:            }
298:
299:            /** checks or unchecks given JCheckBox
300:             * @param state boolean requested state
301:             */
302:            public void checkIncrementalSearch(boolean state) {
303:                if (cbIncrementalSearch().isSelected() != state) {
304:                    cbIncrementalSearch().push();
305:                }
306:            }
307:
308:            /** checks or unchecks given JCheckBox
309:             * @param state boolean requested state
310:             */
311:            public void checkMatchCase(boolean state) {
312:                if (cbMatchCase().isSelected() != state) {
313:                    cbMatchCase().push();
314:                }
315:            }
316:
317:            /** checks or unchecks given JCheckBox
318:             * @param state boolean requested state
319:             */
320:            /*public void checkSmartCase(boolean state) {
321:                if (cbSmartCase().isSelected()!=state) {
322:                    cbSmartCase().push();
323:                }
324:            }*/
325:
326:            /** checks or unchecks given JCheckBox
327:             * @param state boolean requested state
328:             */
329:            public void checkMatchWholeWordsOnly(boolean state) {
330:                if (cbMatchWholeWordsOnly().isSelected() != state) {
331:                    cbMatchWholeWordsOnly().push();
332:                }
333:            }
334:
335:            /** checks or unchecks given JCheckBox
336:             * @param state boolean requested state
337:             */
338:            public void checkBackwardSearch(boolean state) {
339:                if (cbBackwardSearch().isSelected() != state) {
340:                    cbBackwardSearch().push();
341:                }
342:            }
343:
344:            /** checks or unchecks given JCheckBox
345:             * @param state boolean requested state
346:             */
347:            public void checkWrapSearch(boolean state) {
348:                if (cbWrapSearch().isSelected() != state) {
349:                    cbWrapSearch().push();
350:                }
351:            }
352:
353:            /** checks or unchecks given JCheckBox
354:             * @param state boolean requested state
355:             */
356:            public void checkRegularExpressions(boolean state) {
357:                if (cbRegularExpressions().isSelected() != state) {
358:                    cbRegularExpressions().push();
359:                }
360:            }
361:
362:            /** checks or unchecks given JCheckBox
363:             * @param state boolean requested state
364:             */
365:            public void checkBlockSearch(boolean state) {
366:                if (cbBlockSearch().isSelected() != state) {
367:                    cbBlockSearch().push();
368:                }
369:            }
370:
371:            /** clicks on "Find" JButton
372:             */
373:            public void find() {
374:                btFind().push();
375:            }
376:
377:            /** clicks on "Close" JButton
378:             */
379:            public void close() {
380:                btClose().push();
381:            }
382:
383:            /** clicks on "Help" JButton
384:             */
385:            public void help() {
386:                btHelp().push();
387:            }
388:
389:            //*****************************************
390:            // High-level functionality definition part
391:            //*****************************************
392:
393:            /** Performs verification of Find by accessing all its components.
394:             */
395:            public void verify() {
396:                lblFindWhat();
397:                cboFindWhat();
398:                cbHighlightSearch();
399:                cbIncrementalSearch();
400:                cbMatchCase();
401:                //cbSmartCase();
402:                cbMatchWholeWordsOnly();
403:                cbBackwardSearch();
404:                cbWrapSearch();
405:                cbRegularExpressions();
406:                cbBlockSearch();
407:                btFind();
408:                btClose();
409:                btHelp();
410:            }
411:
412:            public static void find(String text) {
413:                Find op = new Find();
414:                op.typeFindWhat(text);
415:                op.find();
416:            }
417:
418:            public static void find(String text, Robot robot) {
419:                Find op = new Find();
420:                robot.waitForIdle();
421:                java.awt.Point p = op.cboFindWhat().getLocationOnScreen();
422:                int x = p.x + op.cboFindWhat().getWidth() / 2;
423:                int y = p.y + op.cboFindWhat().getHeight() / 2;
424:                robot.mouseMove(x, y);
425:                robot.mousePress(InputEvent.BUTTON1_MASK);
426:                robot.delay(50);
427:                robot.mouseRelease(InputEvent.BUTTON1_MASK);
428:                char c;
429:                boolean upper;
430:                for (int i = 0; i < text.length(); i++) {
431:                    c = text.charAt(i);
432:                    if (Character.isUpperCase(c)) {
433:                        upper = true;
434:                    } else {
435:                        upper = false;
436:                        c = (char) (Character.toUpperCase((char) c));
437:                    }
438:                    if (upper) {
439:                        robot.keyPress(KeyEvent.VK_SHIFT);
440:                    }
441:                    robot.keyPress((int) c);
442:                    robot.delay(5);
443:                    robot.keyRelease((int) c);
444:                    robot.delay(5);
445:                    if (upper) {
446:                        robot.keyRelease(KeyEvent.VK_SHIFT);
447:                    }
448:                }
449:                p = op.btFind().getLocationOnScreen();
450:                x = p.x + op.btFind().getWidth() / 2;
451:                y = p.y + op.btFind().getHeight() / 2;
452:                robot.mouseMove(x, y);
453:                robot.mousePress(InputEvent.BUTTON1_MASK);
454:                robot.delay(50);
455:                robot.mouseRelease(InputEvent.BUTTON1_MASK);
456:                robot.delay(50);
457:                robot.waitForIdle();
458:            }
459:
460:            /** Performs simple test of Find
461:             * @param args the command line arguments
462:             */
463:            public static void main(String args[]) {
464:                new Find().verify();
465:                System.out.println("Find verification finished.");
466:                try {
467:                    Robot robot = new Robot();
468:                    System.out.println("Start delay.");
469:                    robot.delay(2000);
470:                    System.out.println("Delayed");
471:                    robot.waitForIdle();
472:                    robot.keyPress(KeyEvent.VK_CONTROL);
473:                    robot.delay(1);
474:                    robot.keyPress(KeyEvent.VK_F);
475:                    robot.delay(20);
476:                    robot.keyRelease(KeyEvent.VK_F);
477:                    robot.delay(1);
478:                    robot.keyRelease(KeyEvent.VK_CONTROL);
479:                    System.out.println("1");
480:                    robot.waitForIdle();
481:                    System.out.println("2");
482:                    Find.find("aaa", robot);
483:                    System.out.println("3");
484:
485:                } catch (Exception ex) {
486:                    ex.printStackTrace();
487:                }
488:            }
489:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.