Source Code Cross Referenced for JDialogOperator.java in  » Testing » jemmy » org » netbeans » jemmy » operators » 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 » Testing » jemmy » org.netbeans.jemmy.operators 
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): Alexandre Iline.
025:         *
026:         * The Original Software is the Jemmy library.
027:         * The Initial Developer of the Original Software is Alexandre Iline.
028:         * 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:         * $Id: JDialogOperator.java,v 1.5 2007/10/05 11:35:22 jskrivanek Exp $ $Revision: 1.5 $ $Date: 2007/10/05 11:35:22 $
044:         *
045:         */
046:
047:        package org.netbeans.jemmy.operators;
048:
049:        import org.netbeans.jemmy.ComponentChooser;
050:        import org.netbeans.jemmy.ComponentSearcher;
051:        import org.netbeans.jemmy.JemmyProperties;
052:        import org.netbeans.jemmy.TestOut;
053:        import org.netbeans.jemmy.Timeouts;
054:        import org.netbeans.jemmy.TimeoutExpiredException;
055:        import org.netbeans.jemmy.DialogWaiter;
056:
057:        import java.awt.Component;
058:        import java.awt.Container;
059:        import java.awt.Dialog;
060:        import java.awt.Window;
061:
062:        import javax.accessibility.AccessibleContext;
063:
064:        import javax.swing.JDialog;
065:        import javax.swing.JLayeredPane;
066:        import javax.swing.JMenuBar;
067:        import javax.swing.JRootPane;
068:
069:        /**
070:         * <BR><BR>Timeouts used: <BR>
071:         * DialogWaiter.WaitDialogTimeout - time to wait dialog displayed <BR>
072:         * DialogWaiter.AfterDialogTimeout - time to sleep after dialog has been dispayed <BR>.
073:         *
074:         * @see org.netbeans.jemmy.Timeouts
075:         * 
076:         * @author Alexandre Iline (alexandre.iline@sun.com)
077:         *	
078:         */
079:
080:        public class JDialogOperator extends DialogOperator {
081:
082:            /**
083:             * Constructor.
084:             * @param w a component
085:             */
086:            public JDialogOperator(JDialog w) {
087:                super (w);
088:            }
089:
090:            /**
091:             * Constructs a JDialogOperator object.
092:             * @param chooser a component chooser specifying searching criteria.
093:             * @param index an index between appropriate ones.
094:             * @param env an operator to copy environment from.
095:             */
096:            public JDialogOperator(ComponentChooser chooser, int index,
097:                    Operator env) {
098:                this (waitJDialog(new JDialogFinder(chooser), index, env
099:                        .getTimeouts(), env.getOutput()));
100:                copyEnvironment(env);
101:            }
102:
103:            /**
104:             * Constructs a JDialogOperator object.
105:             * @param chooser a component chooser specifying searching criteria.
106:             * @param index an index between appropriate ones.
107:             */
108:            public JDialogOperator(ComponentChooser chooser, int index) {
109:                this (chooser, index, Operator.getEnvironmentOperator());
110:            }
111:
112:            /**
113:             * Constructs a JDialogOperator object.
114:             * @param chooser a component chooser specifying searching criteria.
115:             */
116:            public JDialogOperator(ComponentChooser chooser) {
117:                this (chooser, 0);
118:            }
119:
120:            /**
121:             * Constructs a JDialogOperator object.
122:             * @param owner window - owner
123:             * @param chooser a component chooser specifying searching criteria.
124:             * @param index an index between appropriate ones.
125:             */
126:            public JDialogOperator(WindowOperator owner,
127:                    ComponentChooser chooser, int index) {
128:                this ((JDialog) owner.waitSubWindow(new JDialogFinder(chooser),
129:                        index));
130:                copyEnvironment(owner);
131:            }
132:
133:            /**
134:             * Constructs a JDialogOperator object.
135:             * @param owner window - owner
136:             * @param chooser a component chooser specifying searching criteria.
137:             */
138:            public JDialogOperator(WindowOperator owner,
139:                    ComponentChooser chooser) {
140:                this (owner, chooser, 0);
141:            }
142:
143:            /**
144:             * Constructor.
145:             * Waits for the dialog with "title" subtitle.
146:             * Uses owner's timeout and output for waiting and to init operator.
147:             * @param owner Operator pointing to a window owner.
148:             * @param title The desired title.
149:             * @param index Ordinal index.  The first dialog has <code>index</code> 0.
150:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
151:             * 
152:             */
153:            public JDialogOperator(WindowOperator owner, String title, int index) {
154:                this (waitJDialog(owner, new JDialogFinder(
155:                        new DialogByTitleFinder(title, owner.getComparator())),
156:                        index));
157:                copyEnvironment(owner);
158:            }
159:
160:            /**
161:             * Constructor.
162:             * Waits for the dialog with "title" subtitle.
163:             * Uses owner's timeout and output for waiting and to init operator.
164:             * @param owner Operator pointing to a window owner.
165:             * @param title The desired title.
166:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
167:             * 
168:             */
169:            public JDialogOperator(WindowOperator owner, String title) {
170:                this (owner, title, 0);
171:            }
172:
173:            /**
174:             * Constructor.
175:             * Waits for the index'th dialog between owner's children.
176:             * Uses owner'th timeout and output for waiting and to init operator.
177:             * @param owner Operator pointing to a window owner.
178:             * @param index Ordinal component index.
179:             * 
180:             */
181:            public JDialogOperator(WindowOperator owner, int index) {
182:                this ((JDialog) waitJDialog(owner, new JDialogFinder(), index));
183:                copyEnvironment(owner);
184:            }
185:
186:            /**
187:             * Constructor.
188:             * Waits for the first dialog between owner's children.
189:             * Uses owner'th timeout and output for waiting and to init operator.
190:             * @param owner Operator pointing to a window owner.
191:             * 
192:             */
193:            public JDialogOperator(WindowOperator owner) {
194:                this (owner, 0);
195:            }
196:
197:            /**
198:             * Constructor.
199:             * Waits for the dialog with "title" subtitle.
200:             * Constructor can be used in complicated cases when
201:             * output or timeouts should differ from default.
202:             * @param title a window title
203:             * @param index Ordinal component index.
204:             * @param env an operator to copy environment from.
205:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
206:             * 
207:             */
208:            public JDialogOperator(String title, int index, Operator env) {
209:                this (new JDialogFinder(new DialogByTitleFinder(title, env
210:                        .getComparator())), index, env);
211:            }
212:
213:            /**
214:             * Constructor.
215:             * Waits for the dialog with "title" subtitle.
216:             * Uses current timeouts and output values.
217:             * @param title a window title
218:             * @param index Ordinal component index.
219:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
220:             * @see JemmyProperties#getCurrentTimeouts()
221:             * @see JemmyProperties#getCurrentOutput()
222:             * 
223:             */
224:            public JDialogOperator(String title, int index) {
225:                this (title, index, ComponentOperator.getEnvironmentOperator());
226:            }
227:
228:            /**
229:             * Constructor.
230:             * Waits for the dialog with "title" subtitle.
231:             * Uses current timeouts and output values.
232:             * @param title a window title
233:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
234:             * @see JemmyProperties#getCurrentTimeouts()
235:             * @see JemmyProperties#getCurrentOutput()
236:             * 
237:             */
238:            public JDialogOperator(String title) {
239:                this (title, 0);
240:            }
241:
242:            /**
243:             * Constructor.
244:             * Waits for the index'th dialog.
245:             * Uses current timeout and output for waiting and to init operator.
246:             * @param index Ordinal component index.
247:             * 
248:             */
249:            public JDialogOperator(int index) {
250:                this ((JDialog) waitJDialog(new JDialogFinder(), index,
251:                        ComponentOperator.getEnvironmentOperator()
252:                                .getTimeouts(), ComponentOperator
253:                                .getEnvironmentOperator().getOutput()));
254:                copyEnvironment(ComponentOperator.getEnvironmentOperator());
255:            }
256:
257:            /**
258:             * Constructor.
259:             * Waits for the first dialog.
260:             * Uses current timeout and output for waiting and to init operator.
261:             * 
262:             */
263:            public JDialogOperator() {
264:                this (0);
265:            }
266:
267:            /**
268:             * Searches an index'th dialog.
269:             * @param chooser a component chooser specifying searching criteria.
270:             * @param index an index between appropriate ones.
271:             * @return JDialog instance or null if component was not found.
272:             */
273:            public static JDialog findJDialog(ComponentChooser chooser,
274:                    int index) {
275:                return ((JDialog) DialogWaiter.getDialog(new JDialogFinder(
276:                        chooser), index));
277:            }
278:
279:            /**
280:             * Searches a dialog.
281:             * @param chooser a component chooser specifying searching criteria.
282:             * @return JDialog instance or null if component was not found.
283:             */
284:            public static JDialog findJDialog(ComponentChooser chooser) {
285:                return (findJDialog(chooser, 0));
286:            }
287:
288:            /**
289:             * Searches an index'th dialog by title.
290:             * @param title Dialog title
291:             * @param ce Compare exactly. If true, text can be a substring of caption.
292:             * @param cc Compare case sensitively. If true, both text and caption are 
293:             * @param index an index between appropriate ones.
294:             * @return JDialog instance or null if component was not found.
295:             */
296:            public static JDialog findJDialog(String title, boolean ce,
297:                    boolean cc, int index) {
298:                return ((JDialog) DialogWaiter.getDialog(new JDialogFinder(
299:                        new DialogByTitleFinder(title,
300:                                new DefaultStringComparator(ce, cc))), index));
301:            }
302:
303:            /**
304:             * Searches a dialog by title.
305:             * @param title Dialog title
306:             * @param ce Compare exactly. If true, text can be a substring of caption.
307:             * @param cc Compare case sensitively. If true, both text and caption are 
308:             * @return JDialog instance or null if component was not found.
309:             */
310:            public static JDialog findJDialog(String title, boolean ce,
311:                    boolean cc) {
312:                return (findJDialog(title, ce, cc, 0));
313:            }
314:
315:            /**
316:             * Searches an index'th dialog between owner's owned windows.
317:             * @param owner Window - dialog owner.
318:             * @param chooser a component chooser specifying searching criteria.
319:             * @param index an index between appropriate ones.
320:             * @return JDialog instance or null if component was not found.
321:             */
322:            public static JDialog findJDialog(Window owner,
323:                    ComponentChooser chooser, int index) {
324:                return ((JDialog) DialogWaiter.getDialog(owner,
325:                        new JDialogFinder(chooser), index));
326:            }
327:
328:            /**
329:             * Searches a dialog between owner's owned windows.
330:             * @param owner Window - dialog owner.
331:             * @param chooser a component chooser specifying searching criteria.
332:             * @return JDialog instance or null if component was not found.
333:             */
334:            public static JDialog findJDialog(Window owner,
335:                    ComponentChooser chooser) {
336:                return (findJDialog(owner, chooser, 0));
337:            }
338:
339:            /**
340:             * Searches an index'th dialog by title between owner's owned windows.
341:             * @param owner Window - dialog owner.
342:             * @param title Dialog title
343:             * @param ce Compare exactly. If true, text can be a substring of caption.
344:             * @param cc Compare case sensitively. If true, both text and caption are 
345:             * @param index an index between appropriate ones.
346:             * @return JDialog instance or null if component was not found.
347:             */
348:            public static JDialog findJDialog(Window owner, String title,
349:                    boolean ce, boolean cc, int index) {
350:                return ((JDialog) DialogWaiter.getDialog(owner,
351:                        new JDialogFinder(new DialogByTitleFinder(title,
352:                                new DefaultStringComparator(ce, cc))), index));
353:            }
354:
355:            /**
356:             * Searches a dialog by title between owner's owned windows.
357:             * @param owner Window - dialog owner.
358:             * @param title Dialog title
359:             * @param ce Compare exactly. If true, text can be a substring of caption.
360:             * @param cc Compare case sensitively. If true, both text and caption are 
361:             * @return JDialog instance or null if component was not found.
362:             */
363:            public static JDialog findJDialog(Window owner, String title,
364:                    boolean ce, boolean cc) {
365:                return (findJDialog(owner, title, ce, cc, 0));
366:            }
367:
368:            /**
369:             * Waits an index'th dialog.
370:             * @param chooser a component chooser specifying searching criteria.
371:             * @param index an index between appropriate ones.
372:             * @return JDialog instance or null if component was not found.
373:             * 
374:             */
375:            public static JDialog waitJDialog(ComponentChooser chooser,
376:                    int index) {
377:                return (waitJDialog(chooser, index, JemmyProperties
378:                        .getCurrentTimeouts(), JemmyProperties
379:                        .getCurrentOutput()));
380:            }
381:
382:            /**
383:             * Waits a dialog.
384:             * @param chooser a component chooser specifying searching criteria.
385:             * @return JDialog instance or null if component was not found.
386:             * 
387:             */
388:            public static JDialog waitJDialog(ComponentChooser chooser) {
389:                return (waitJDialog(chooser, 0));
390:            }
391:
392:            /**
393:             * Waits an index'th dialog by title.
394:             * @param title Dialog title
395:             * @param ce Compare exactly. If true, text can be a substring of caption.
396:             * @param cc Compare case sensitively. If true, both text and caption are 
397:             * @param index an index between appropriate ones.
398:             * @return JDialog instance or null if component was not found.
399:             * 
400:             */
401:            public static JDialog waitJDialog(String title, boolean ce,
402:                    boolean cc, int index) {
403:                return (waitJDialog(new JDialogFinder(new DialogByTitleFinder(
404:                        title, new DefaultStringComparator(ce, cc))), index));
405:            }
406:
407:            /**
408:             * Waits a dialog by title.
409:             * @param title Dialog title
410:             * @param ce Compare exactly. If true, text can be a substring of caption.
411:             * @param cc Compare case sensitively. If true, both text and caption are 
412:             * @return JDialog instance or null if component was not found.
413:             * 
414:             */
415:            public static JDialog waitJDialog(String title, boolean ce,
416:                    boolean cc) {
417:                return (waitJDialog(title, ce, cc, 0));
418:            }
419:
420:            /**
421:             * Waits an index'th dialog between owner's owned windows.
422:             * @param owner Window - dialog owner.
423:             * @param chooser a component chooser specifying searching criteria.
424:             * @param index an index between appropriate ones.
425:             * @return JDialog instance or null if component was not found.
426:             * 
427:             */
428:            public static JDialog waitJDialog(Window owner,
429:                    ComponentChooser chooser, int index) {
430:                return (waitJDialog(owner, chooser, index, JemmyProperties
431:                        .getCurrentTimeouts(), JemmyProperties
432:                        .getCurrentOutput()));
433:            }
434:
435:            /**
436:             * Waits a dialog between owner's owned windows.
437:             * @param owner Window - dialog owner.
438:             * @param chooser a component chooser specifying searching criteria.
439:             * @return JDialog instance or null if component was not found.
440:             * 
441:             */
442:            public static JDialog waitJDialog(Window owner,
443:                    ComponentChooser chooser) {
444:                return (waitJDialog(owner, chooser, 0));
445:            }
446:
447:            /**
448:             * Waits an index'th dialog by title between owner's owned windows.
449:             * @param owner Window - dialog owner.
450:             * @param title Dialog title
451:             * @param ce Compare exactly. If true, text can be a substring of caption.
452:             * @param cc Compare case sensitively. If true, both text and caption are 
453:             * @param index an index between appropriate ones.
454:             * @return JDialog instance or null if component was not found.
455:             * 
456:             */
457:            public static JDialog waitJDialog(Window owner, String title,
458:                    boolean ce, boolean cc, int index) {
459:                return (waitJDialog(owner, new JDialogFinder(
460:                        new DialogByTitleFinder(title,
461:                                new DefaultStringComparator(ce, cc))), index));
462:            }
463:
464:            /**
465:             * Waits a dialog by title between owner's owned windows.
466:             * @param owner Window - dialog owner.
467:             * @param title Dialog title
468:             * @param ce Compare exactly. If true, text can be a substring of caption.
469:             * @param cc Compare case sensitively. If true, both text and caption are 
470:             * @return JDialog instance or null if component was not found.
471:             * 
472:             */
473:            public static JDialog waitJDialog(Window owner, String title,
474:                    boolean ce, boolean cc) {
475:                return (waitJDialog(owner, title, ce, cc, 0));
476:            }
477:
478:            /**
479:             * Searhs for modal dialog currently staying on top.
480:             * @return dialog or null if no modal dialog is currently
481:             * displayed.
482:             */
483:            public static Dialog getTopModalDialog() {
484:                return (DialogWaiter.getDialog(new ComponentChooser() {
485:                    public boolean checkComponent(Component comp) {
486:                        if (comp instanceof  Dialog) {
487:                            Dialog dialog = (Dialog) comp;
488:                            if (dialog.isModal()) {
489:                                Window[] ow = dialog.getOwnedWindows();
490:                                for (int i = 0; i < ow.length; i++) {
491:                                    if (ow[i].isVisible()) {
492:                                        return (false);
493:                                    }
494:                                }
495:                                return (true);
496:                            }
497:                        }
498:                        return (false);
499:                    }
500:
501:                    public String getDescription() {
502:                        return ("Upper modal dialog");
503:                    }
504:                }));
505:            }
506:
507:            ////////////////////////////////////////////////////////
508:            //Mapping                                             //
509:
510:            /**Maps <code>JDialog.getAccessibleContext()</code> through queue*/
511:            public AccessibleContext getAccessibleContext() {
512:                return ((AccessibleContext) runMapping(new MapAction(
513:                        "getAccessibleContext") {
514:                    public Object map() {
515:                        return (((JDialog) getSource()).getAccessibleContext());
516:                    }
517:                }));
518:            }
519:
520:            /**Maps <code>JDialog.getContentPane()</code> through queue*/
521:            public Container getContentPane() {
522:                return ((Container) runMapping(new MapAction("getContentPane") {
523:                    public Object map() {
524:                        return (((JDialog) getSource()).getContentPane());
525:                    }
526:                }));
527:            }
528:
529:            /**Maps <code>JDialog.getDefaultCloseOperation()</code> through queue*/
530:            public int getDefaultCloseOperation() {
531:                return (runMapping(new MapIntegerAction(
532:                        "getDefaultCloseOperation") {
533:                    public int map() {
534:                        return (((JDialog) getSource())
535:                                .getDefaultCloseOperation());
536:                    }
537:                }));
538:            }
539:
540:            /**Maps <code>JDialog.getGlassPane()</code> through queue*/
541:            public Component getGlassPane() {
542:                return ((Component) runMapping(new MapAction("getGlassPane") {
543:                    public Object map() {
544:                        return (((JDialog) getSource()).getGlassPane());
545:                    }
546:                }));
547:            }
548:
549:            /**Maps <code>JDialog.getJMenuBar()</code> through queue*/
550:            public JMenuBar getJMenuBar() {
551:                return ((JMenuBar) runMapping(new MapAction("getJMenuBar") {
552:                    public Object map() {
553:                        return (((JDialog) getSource()).getJMenuBar());
554:                    }
555:                }));
556:            }
557:
558:            /**Maps <code>JDialog.getLayeredPane()</code> through queue*/
559:            public JLayeredPane getLayeredPane() {
560:                return ((JLayeredPane) runMapping(new MapAction(
561:                        "getLayeredPane") {
562:                    public Object map() {
563:                        return (((JDialog) getSource()).getLayeredPane());
564:                    }
565:                }));
566:            }
567:
568:            /**Maps <code>JDialog.getRootPane()</code> through queue*/
569:            public JRootPane getRootPane() {
570:                return ((JRootPane) runMapping(new MapAction("getRootPane") {
571:                    public Object map() {
572:                        return (((JDialog) getSource()).getRootPane());
573:                    }
574:                }));
575:            }
576:
577:            /**Maps <code>JDialog.setContentPane(Container)</code> through queue*/
578:            public void setContentPane(final Container container) {
579:                runMapping(new MapVoidAction("setContentPane") {
580:                    public void map() {
581:                        ((JDialog) getSource()).setContentPane(container);
582:                    }
583:                });
584:            }
585:
586:            /**Maps <code>JDialog.setDefaultCloseOperation(int)</code> through queue*/
587:            public void setDefaultCloseOperation(final int i) {
588:                runMapping(new MapVoidAction("setDefaultCloseOperation") {
589:                    public void map() {
590:                        ((JDialog) getSource()).setDefaultCloseOperation(i);
591:                    }
592:                });
593:            }
594:
595:            /**Maps <code>JDialog.setGlassPane(Component)</code> through queue*/
596:            public void setGlassPane(final Component component) {
597:                runMapping(new MapVoidAction("setGlassPane") {
598:                    public void map() {
599:                        ((JDialog) getSource()).setGlassPane(component);
600:                    }
601:                });
602:            }
603:
604:            /**Maps <code>JDialog.setJMenuBar(JMenuBar)</code> through queue*/
605:            public void setJMenuBar(final JMenuBar jMenuBar) {
606:                runMapping(new MapVoidAction("setJMenuBar") {
607:                    public void map() {
608:                        ((JDialog) getSource()).setJMenuBar(jMenuBar);
609:                    }
610:                });
611:            }
612:
613:            /**Maps <code>JDialog.setLayeredPane(JLayeredPane)</code> through queue*/
614:            public void setLayeredPane(final JLayeredPane jLayeredPane) {
615:                runMapping(new MapVoidAction("setLayeredPane") {
616:                    public void map() {
617:                        ((JDialog) getSource()).setLayeredPane(jLayeredPane);
618:                    }
619:                });
620:            }
621:
622:            /**Maps <code>JDialog.setLocationRelativeTo(Component)</code> through queue*/
623:            public void setLocationRelativeTo(final Component component) {
624:                runMapping(new MapVoidAction("setLocationRelativeTo") {
625:                    public void map() {
626:                        ((JDialog) getSource())
627:                                .setLocationRelativeTo(component);
628:                    }
629:                });
630:            }
631:
632:            //End of mapping                                      //
633:            ////////////////////////////////////////////////////////
634:
635:            /**
636:             * A method to be used from subclasses.
637:             * Uses timeouts and output passed as parameters during the waiting.
638:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
639:             * @param index Ordinal component index.
640:             * @param timeouts timeouts to be used during the waiting.
641:             * @param output an output to be used during the waiting.
642:             * @return Component instance or null if component was not found.
643:             */
644:            protected static JDialog waitJDialog(ComponentChooser chooser,
645:                    int index, Timeouts timeouts, TestOut output) {
646:                try {
647:                    DialogWaiter waiter = new DialogWaiter();
648:                    waiter.setTimeouts(timeouts);
649:                    waiter.setOutput(output);
650:                    return ((JDialog) waiter.waitDialog(new JDialogFinder(
651:                            chooser), index));
652:                } catch (InterruptedException e) {
653:                    output.printStackTrace(e);
654:                    return (null);
655:                }
656:            }
657:
658:            /**
659:             * A method to be used from subclasses.
660:             * Uses <code>owner</code>'s timeouts and output during the waiting.
661:             * @param owner a window - dialog owner.
662:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
663:             * @param index Ordinal component index.
664:             * @return Component instance or null if component was not found.
665:             * @throws TimeoutExpiredException
666:             */
667:            protected static JDialog waitJDialog(WindowOperator owner,
668:                    ComponentChooser chooser, int index) {
669:                return (waitJDialog((Window) owner.getSource(), chooser, index,
670:                        owner.getTimeouts(), owner.getOutput()));
671:            }
672:
673:            /**
674:             * A method to be used from subclasses.
675:             * Uses timeouts and output passed as parameters during the waiting.
676:             * @param owner a window - dialog owner.
677:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
678:             * @param index Ordinal component index.
679:             * @param timeouts timeouts to be used during the waiting.
680:             * @param output an output to be used during the waiting.
681:             * @return Component instance or null if component was not found.
682:             */
683:            protected static JDialog waitJDialog(Window owner,
684:                    ComponentChooser chooser, int index, Timeouts timeouts,
685:                    TestOut output) {
686:                try {
687:                    DialogWaiter waiter = new DialogWaiter();
688:                    waiter.setTimeouts(timeouts);
689:                    waiter.setOutput(output);
690:                    return ((JDialog) waiter.waitDialog(owner,
691:                            new JDialogFinder(chooser), index));
692:                } catch (InterruptedException e) {
693:                    JemmyProperties.getCurrentOutput().printStackTrace(e);
694:                    return (null);
695:                }
696:            }
697:
698:            /**
699:             * Checks component type.
700:             */
701:            public static class JDialogFinder extends Finder {
702:                /**
703:                 * Constructs JDialogFinder.
704:                 * @param sf other searching criteria.
705:                 */
706:                public JDialogFinder(ComponentChooser sf) {
707:                    super (JDialog.class, sf);
708:                }
709:
710:                /**
711:                 * Constructs JDialogFinder.
712:                 */
713:                public JDialogFinder() {
714:                    super (JDialog.class);
715:                }
716:            }
717:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.