Source Code Cross Referenced for FindEditorOperator.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » gravy » properties » editors » 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 » visualweb.api.designer » org.netbeans.modules.visualweb.gravy.properties.editors 
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-2007 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 2/11/03 1:29 PM
046:         */
047:        package org.netbeans.modules.visualweb.gravy.properties.editors;
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:        import javax.swing.JDialog;
055:        import org.netbeans.jellytools.Bundle;
056:        import org.netbeans.modules.visualweb.gravy.NbDialogOperator;
057:        import org.netbeans.jemmy.operators.*;
058:
059:        /** Class implementing all necessary methods for handling "Find" NbDialog.
060:         */
061:        public class FindEditorOperator extends NbDialogOperator {
062:
063:            /** Creates new Find that can handle it.
064:             */
065:            public FindEditorOperator() {
066:                super (java.util.ResourceBundle.getBundle(
067:                        "org.netbeans.editor.Bundle").getString("find-title"));
068:            }
069:
070:            /** Creates new StringArrayCustomEditorOperator
071:             * @param wrapper JDialogOperator wrapper for custom editor */
072:            public FindEditorOperator(JDialogOperator wrapper) {
073:                super ((JDialog) wrapper.getSource());
074:            }
075:
076:            private JLabelOperator _lblFindWhat;
077:            private JComboBoxOperator _cboFindWhat;
078:            public static final String ITEM_ = "";
079:            private JCheckBoxOperator _cbHighlightSearch;
080:            private JCheckBoxOperator _cbIncrementalSearch;
081:            private JCheckBoxOperator _cbMatchCase;
082:            private JCheckBoxOperator _cbSmartCase;
083:            private JCheckBoxOperator _cbMatchWholeWordsOnly;
084:            private JCheckBoxOperator _cbBackwardSearch;
085:            private JCheckBoxOperator _cbWrapSearch;
086:            private JButtonOperator _btFind;
087:            private JButtonOperator _btClose;
088:            private JButtonOperator _btHelp;
089:
090:            //******************************
091:            // Subcomponents definition part
092:            //******************************
093:
094:            /** Tries to find "Find What:" JLabel in this dialog.
095:             * @return JLabelOperator
096:             */
097:            public JLabelOperator lblFindWhat() {
098:                if (_lblFindWhat == null) {
099:                    _lblFindWhat = new JLabelOperator(this ,
100:                            java.util.ResourceBundle.getBundle(
101:                                    "org.netbeans.editor.Bundle").getString(
102:                                    "find-what"));
103:                }
104:                return _lblFindWhat;
105:            }
106:
107:            /** Tries to find null JComboBox in this dialog.
108:             * @return JComboBoxOperator
109:             */
110:            public JComboBoxOperator cboFindWhat() {
111:                if (_cboFindWhat == null) {
112:                    _cboFindWhat = new JComboBoxOperator(this );
113:                }
114:                return _cboFindWhat;
115:            }
116:
117:            /** Tries to find " Highlight Search" JCheckBox in this dialog.
118:             * @return JCheckBoxOperator
119:             */
120:            public JCheckBoxOperator cbHighlightSearch() {
121:                if (_cbHighlightSearch == null) {
122:                    _cbHighlightSearch = new JCheckBoxOperator(this ,
123:                            java.util.ResourceBundle.getBundle(
124:                                    "org.netbeans.editor.Bundle").getString(
125:                                    "find-highlight-search"));
126:                }
127:                return _cbHighlightSearch;
128:            }
129:
130:            /** Tries to find " Incremental Search" JCheckBox in this dialog.
131:             * @return JCheckBoxOperator
132:             */
133:            public JCheckBoxOperator cbIncrementalSearch() {
134:                if (_cbIncrementalSearch == null) {
135:                    _cbIncrementalSearch = new JCheckBoxOperator(this ,
136:                            java.util.ResourceBundle.getBundle(
137:                                    "org.netbeans.editor.Bundle").getString(
138:                                    "find-inc-search"));
139:                }
140:                return _cbIncrementalSearch;
141:            }
142:
143:            /** Tries to find " Match Case" JCheckBox in this dialog.
144:             * @return JCheckBoxOperator
145:             */
146:            public JCheckBoxOperator cbMatchCase() {
147:                if (_cbMatchCase == null) {
148:                    _cbMatchCase = new JCheckBoxOperator(this ,
149:                            java.util.ResourceBundle.getBundle(
150:                                    "org.netbeans.editor.Bundle").getString(
151:                                    "find-match-case"));
152:                }
153:                return _cbMatchCase;
154:            }
155:
156:            /** Tries to find " Smart Case" JCheckBox in this dialog.
157:             * @return JCheckBoxOperator
158:             */
159:            public JCheckBoxOperator cbSmartCase() {
160:                if (_cbSmartCase == null) {
161:                    _cbSmartCase = new JCheckBoxOperator(this ,
162:                            java.util.ResourceBundle.getBundle(
163:                                    "org.netbeans.editor.Bundle").getString(
164:                                    "find-smart-case"));
165:                }
166:                return _cbSmartCase;
167:            }
168:
169:            /** Tries to find " Match Whole Words Only" JCheckBox in this dialog.
170:             * @return JCheckBoxOperator
171:             */
172:            public JCheckBoxOperator cbMatchWholeWordsOnly() {
173:                if (_cbMatchWholeWordsOnly == null) {
174:                    _cbMatchWholeWordsOnly = new JCheckBoxOperator(this ,
175:                            java.util.ResourceBundle.getBundle(
176:                                    "org.netbeans.editor.Bundle").getString(
177:                                    "find-whole-words"));
178:                }
179:                return _cbMatchWholeWordsOnly;
180:            }
181:
182:            /** Tries to find " Backward Search" JCheckBox in this dialog.
183:             * @return JCheckBoxOperator
184:             */
185:            public JCheckBoxOperator cbBackwardSearch() {
186:                if (_cbBackwardSearch == null) {
187:                    _cbBackwardSearch = new JCheckBoxOperator(this ,
188:                            java.util.ResourceBundle.getBundle(
189:                                    "org.netbeans.editor.Bundle").getString(
190:                                    "find-backward-search"));
191:                }
192:                return _cbBackwardSearch;
193:            }
194:
195:            /** Tries to find " Wrap Search" JCheckBox in this dialog.
196:             * @return JCheckBoxOperator
197:             */
198:            public JCheckBoxOperator cbWrapSearch() {
199:                if (_cbWrapSearch == null) {
200:                    _cbWrapSearch = new JCheckBoxOperator(this ,
201:                            java.util.ResourceBundle.getBundle(
202:                                    "org.netbeans.editor.Bundle").getString(
203:                                    "find-wrap-search"));
204:                }
205:                return _cbWrapSearch;
206:            }
207:
208:            /** Tries to find "Find" JButton in this dialog.
209:             * @return JButtonOperator
210:             */
211:            public JButtonOperator btFind() {
212:                if (_btFind == null) {
213:                    _btFind = new JButtonOperator(this ,
214:                            java.util.ResourceBundle.getBundle(
215:                                    "org.netbeans.editor.Bundle").getString(
216:                                    "find-button-find"));
217:                }
218:                return _btFind;
219:            }
220:
221:            /** Tries to find "Close" JButton in this dialog.
222:             * @return JButtonOperator
223:             */
224:            public JButtonOperator btClose() {
225:                if (_btClose == null) {
226:                    _btClose = new JButtonOperator(this ,
227:                            java.util.ResourceBundle.getBundle(
228:                                    "org.netbeans.editor.Bundle").getString(
229:                                    "find-button-cancel"));
230:                }
231:                return _btClose;
232:            }
233:
234:            /** Tries to find "Help" JButton in this dialog.
235:             * @return JButtonOperator
236:             */
237:            public JButtonOperator btHelp() {
238:                if (_btHelp == null) {
239:                    _btHelp = new JButtonOperator(
240:                            this ,
241:                            java.util.ResourceBundle
242:                                    .getBundle(
243:                                            "org.openide.explorer.propertysheet.Bundle")
244:                                    .getString("CTL_Help"));
245:                }
246:                return _btHelp;
247:            }
248:
249:            //****************************************
250:            // Low-level functionality definition part
251:            //****************************************
252:
253:            /** returns selected item for cboFindWhat
254:             * @return String item
255:             */
256:            public String getSelectedFindWhat() {
257:                return cboFindWhat().getSelectedItem().toString();
258:            }
259:
260:            /** selects item for cboFindWhat
261:             * @param item String item
262:             */
263:            public void selectFindWhat(String item) {
264:                cboFindWhat().selectItem(item);
265:            }
266:
267:            /** types text for cboFindWhat
268:             * @param text String text
269:             */
270:            public void typeFindWhat(String text) {
271:                cboFindWhat().typeText(text);
272:            }
273:
274:            /** checks or unchecks given JCheckBox
275:             * @param state boolean requested state
276:             */
277:            public void checkHighlightSearch(boolean state) {
278:                if (cbHighlightSearch().isSelected() != state) {
279:                    cbHighlightSearch().push();
280:                }
281:            }
282:
283:            /** checks or unchecks given JCheckBox
284:             * @param state boolean requested state
285:             */
286:            public void checkIncrementalSearch(boolean state) {
287:                if (cbIncrementalSearch().isSelected() != state) {
288:                    cbIncrementalSearch().push();
289:                }
290:            }
291:
292:            /** checks or unchecks given JCheckBox
293:             * @param state boolean requested state
294:             */
295:            public void checkMatchCase(boolean state) {
296:                if (cbMatchCase().isSelected() != state) {
297:                    cbMatchCase().push();
298:                }
299:            }
300:
301:            /** checks or unchecks given JCheckBox
302:             * @param state boolean requested state
303:             */
304:            public void checkSmartCase(boolean state) {
305:                if (cbSmartCase().isSelected() != state) {
306:                    cbSmartCase().push();
307:                }
308:            }
309:
310:            /** checks or unchecks given JCheckBox
311:             * @param state boolean requested state
312:             */
313:            public void checkMatchWholeWordsOnly(boolean state) {
314:                if (cbMatchWholeWordsOnly().isSelected() != state) {
315:                    cbMatchWholeWordsOnly().push();
316:                }
317:            }
318:
319:            /** checks or unchecks given JCheckBox
320:             * @param state boolean requested state
321:             */
322:            public void checkBackwardSearch(boolean state) {
323:                if (cbBackwardSearch().isSelected() != state) {
324:                    cbBackwardSearch().push();
325:                }
326:            }
327:
328:            /** checks or unchecks given JCheckBox
329:             * @param state boolean requested state
330:             */
331:            public void checkWrapSearch(boolean state) {
332:                if (cbWrapSearch().isSelected() != state) {
333:                    cbWrapSearch().push();
334:                }
335:            }
336:
337:            /** checks or unchecks All JCheckBoxes
338:             * @param state boolean requested state
339:             */
340:            public void checkAll(boolean state) {
341:                checkMatchCase(state);
342:                checkSmartCase(state);
343:                checkMatchWholeWordsOnly(state);
344:
345:                checkHighlightSearch(state);
346:                checkIncrementalSearch(state);
347:                checkBackwardSearch(state);
348:                checkWrapSearch(state);
349:            }
350:
351:            /** clicks on "Find" JButton
352:             */
353:            public void find() {
354:                btFind().pushNoBlock();
355:            }
356:
357:            /** clicks on "Close" JButton
358:             */
359:            public void close() {
360:                btClose().push();
361:            }
362:
363:            /** clicks on "Help" JButton
364:             */
365:            public void help() {
366:                btHelp().push();
367:            }
368:
369:            //*****************************************
370:            // High-level functionality definition part
371:            //*****************************************
372:
373:            /** Performs verification of Find by accessing all its components.
374:             */
375:            public void verify() {
376:                lblFindWhat();
377:                cboFindWhat();
378:                cbHighlightSearch();
379:                cbIncrementalSearch();
380:                cbMatchCase();
381:                cbSmartCase();
382:                cbMatchWholeWordsOnly();
383:                cbBackwardSearch();
384:                cbWrapSearch();
385:                btFind();
386:                btClose();
387:                btHelp();
388:            }
389:
390:            public static void find(String text) {
391:                FindEditorOperator op = new FindEditorOperator();
392:                op.typeFindWhat(text);
393:                op.find();
394:            }
395:
396:            public static void find(String text, Robot robot) {
397:                FindEditorOperator op = new FindEditorOperator();
398:                robot.waitForIdle();
399:                java.awt.Point p = op.cboFindWhat().getLocationOnScreen();
400:                int x = p.x + op.cboFindWhat().getWidth() / 2;
401:                int y = p.y + op.cboFindWhat().getHeight() / 2;
402:                robot.mouseMove(x, y);
403:                robot.mousePress(InputEvent.BUTTON1_MASK);
404:                robot.delay(50);
405:                robot.mouseRelease(InputEvent.BUTTON1_MASK);
406:                char c;
407:                boolean upper;
408:                for (int i = 0; i < text.length(); i++) {
409:                    c = text.charAt(i);
410:                    if (Character.isUpperCase(c)) {
411:                        upper = true;
412:                    } else {
413:                        upper = false;
414:                        c = (char) (Character.toUpperCase((char) c));
415:                    }
416:                    if (upper) {
417:                        robot.keyPress(KeyEvent.VK_SHIFT);
418:                    }
419:                    robot.keyPress((int) c);
420:                    robot.delay(5);
421:                    robot.keyRelease((int) c);
422:                    robot.delay(5);
423:                    if (upper) {
424:                        robot.keyRelease(KeyEvent.VK_SHIFT);
425:                    }
426:                }
427:                p = op.btFind().getLocationOnScreen();
428:                x = p.x + op.btFind().getWidth() / 2;
429:                y = p.y + op.btFind().getHeight() / 2;
430:                robot.mouseMove(x, y);
431:                robot.mousePress(InputEvent.BUTTON1_MASK);
432:                robot.delay(50);
433:                robot.mouseRelease(InputEvent.BUTTON1_MASK);
434:                robot.delay(50);
435:                robot.waitForIdle();
436:            }
437:
438:            /** Performs simple test of Find
439:             * @param args the command line arguments
440:             */
441:            public static void main(String args[]) {
442:                //new Find().verify();
443:                System.out.println("Find verification finished.");
444:                try {
445:                    Robot robot = new Robot();
446:                    System.out.println("Start delay.");
447:                    robot.delay(2000);
448:                    System.out.println("Delayed");
449:                    robot.waitForIdle();
450:                    robot.keyPress(KeyEvent.VK_CONTROL);
451:                    robot.delay(1);
452:                    robot.keyPress(KeyEvent.VK_F);
453:                    robot.delay(20);
454:                    robot.keyRelease(KeyEvent.VK_F);
455:                    robot.delay(1);
456:                    robot.keyRelease(KeyEvent.VK_CONTROL);
457:                    System.out.println("1");
458:                    robot.waitForIdle();
459:                    System.out.println("2");
460:                    FindEditorOperator.find("aaa", robot);
461:                    System.out.println("3");
462:
463:                } catch (Exception ex) {
464:                    ex.printStackTrace();
465:                }
466:            }
467:        }
w__w__w__.j_a__v__a_2___s._c_o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.