Source Code Cross Referenced for JColorChooserOperator.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: JColorChooserOperator.java,v 1.7 2007/10/05 11:35:16 jskrivanek Exp $ $Revision: 1.7 $ $Date: 2007/10/05 11:35:16 $
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.Outputable;
053:        import org.netbeans.jemmy.TestOut;
054:        import org.netbeans.jemmy.Timeoutable;
055:        import org.netbeans.jemmy.Timeouts;
056:
057:        import java.awt.Color;
058:        import java.awt.Component;
059:        import java.awt.Container;
060:
061:        import java.util.Hashtable;
062:
063:        import javax.swing.JComponent;
064:        import javax.swing.JColorChooser;
065:        import javax.swing.JTabbedPane;
066:
067:        import javax.swing.colorchooser.AbstractColorChooserPanel;
068:        import javax.swing.colorchooser.ColorSelectionModel;
069:
070:        import javax.swing.plaf.ColorChooserUI;
071:
072:        /**
073:         *
074:         * Class provides methods to cover main JColorChooser component functionality.
075:         * @author Alexandre Iline (alexandre.iline@sun.com)
076:         *	
077:         */
078:
079:        public class JColorChooserOperator extends JComponentOperator implements 
080:                Outputable {
081:
082:            /**
083:             * Identifier for a "color" property.
084:             * @see #getDump
085:             */
086:            public static final String COLOR_DPROP = "Color";
087:
088:            /**
089:             * Identifier for a "selected page" property.
090:             * @see #getDump
091:             */
092:            public static final String SELECTED_PAGE_DPROP = "Selected page";
093:
094:            private static final String RGB_TITLE = "RGB";
095:
096:            private final static long WAIT_LIST_PAINTED_TIMEOUT = 60000;
097:
098:            private TestOut output;
099:            private JTabbedPaneOperator tabbed;
100:            private JTextFieldOperator red;
101:            private JTextFieldOperator green;
102:            private JTextFieldOperator blue;
103:
104:            /**
105:             * Constructor.
106:             * @param comp a component
107:             */
108:            public JColorChooserOperator(JColorChooser comp) {
109:                super (comp);
110:                setTimeouts(JemmyProperties.getProperties().getTimeouts());
111:                setOutput(JemmyProperties.getProperties().getOutput());
112:                tabbed = new JTabbedPaneOperator(this );
113:            }
114:
115:            /**
116:             * Constructs a JColorChooserOperator object.
117:             * @param cont a container
118:             * @param chooser a component chooser specifying searching criteria.
119:             * @param index an index between appropriate ones.
120:             */
121:            public JColorChooserOperator(ContainerOperator cont,
122:                    ComponentChooser chooser, int index) {
123:                this ((JColorChooser) cont.waitSubComponent(
124:                        new JColorChooserFinder(chooser), index));
125:                copyEnvironment(cont);
126:            }
127:
128:            /**
129:             * Constructs a JColorChooserOperator object.
130:             * @param cont a container
131:             * @param chooser a component chooser specifying searching criteria.
132:             */
133:            public JColorChooserOperator(ContainerOperator cont,
134:                    ComponentChooser chooser) {
135:                this (cont, chooser, 0);
136:            }
137:
138:            /**
139:             * Constructor.
140:             * Waits component in container first.
141:             * Uses cont's timeout and output for waiting and to init operator.
142:             * @param cont Operator pointing a container to search component in.
143:             * @param index Ordinal component index.
144:             * 
145:             */
146:            public JColorChooserOperator(ContainerOperator cont, int index) {
147:                this ((JColorChooser) waitComponent(cont,
148:                        new JColorChooserFinder(), index));
149:                copyEnvironment(cont);
150:            }
151:
152:            /**
153:             * Constructor.
154:             * Waits component in container first.
155:             * Uses cont's timeout and output for waiting and to init operator.
156:             * @param cont Operator pointing a container to search component in.
157:             * 
158:             */
159:            public JColorChooserOperator(ContainerOperator cont) {
160:                this (cont, 0);
161:            }
162:
163:            /**
164:             * Searches JColorChooser in container.
165:             * @param cont Container to search component in.
166:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
167:             * @param index Ordinal component index.
168:             * @return JColorChooser instance or null if component was not found.
169:             */
170:            public static JColorChooser findJColorChooser(Container cont,
171:                    ComponentChooser chooser, int index) {
172:                return ((JColorChooser) findComponent(cont,
173:                        new JColorChooserFinder(chooser), index));
174:            }
175:
176:            /**
177:             * Searches 0'th JColorChooser in container.
178:             * @param cont Container to search component in.
179:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
180:             * @return JColorChooser instance or null if component was not found.
181:             */
182:            public static JColorChooser findJColorChooser(Container cont,
183:                    ComponentChooser chooser) {
184:                return (findJColorChooser(cont, chooser, 0));
185:            }
186:
187:            /**
188:             * Searches JColorChooser in container.
189:             * @param cont Container to search component in.
190:             * @param index Ordinal component index.
191:             * @return JColorChooser instance or null if component was not found.
192:             */
193:            public static JColorChooser findJColorChooser(Container cont,
194:                    int index) {
195:                return (findJColorChooser(cont, ComponentSearcher
196:                        .getTrueChooser(Integer.toString(index)
197:                                + "'th JColorChooser instance"), index));
198:            }
199:
200:            /**
201:             * Searches 0'th JColorChooser in container.
202:             * @param cont Container to search component in.
203:             * @return JColorChooser instance or null if component was not found.
204:             */
205:            public static JColorChooser findJColorChooser(Container cont) {
206:                return (findJColorChooser(cont, 0));
207:            }
208:
209:            /**
210:             * Waits JColorChooser in container.
211:             * @param cont Container to search component in.
212:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
213:             * @param index Ordinal component index.
214:             * @return JColorChooser instance or null if component was not displayed.
215:             * 
216:             */
217:            public static JColorChooser waitJColorChooser(Container cont,
218:                    ComponentChooser chooser, int index) {
219:                return ((JColorChooser) waitComponent(cont,
220:                        new JColorChooserFinder(chooser), index));
221:            }
222:
223:            /**
224:             * Waits 0'th JColorChooser in container.
225:             * @param cont Container to search component in.
226:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
227:             * @return JColorChooser instance or null if component was not displayed.
228:             * 
229:             */
230:            public static JColorChooser waitJColorChooser(Container cont,
231:                    ComponentChooser chooser) {
232:                return (waitJColorChooser(cont, chooser, 0));
233:            }
234:
235:            /**
236:             * Waits JColorChooser in container.
237:             * @param cont Container to search component in.
238:             * @param index Ordinal component index.
239:             * @return JColorChooser instance or null if component was not displayed.
240:             * 
241:             */
242:            public static JColorChooser waitJColorChooser(Container cont,
243:                    int index) {
244:                return (waitJColorChooser(cont, ComponentSearcher
245:                        .getTrueChooser(Integer.toString(index)
246:                                + "'th JColorChooser instance"), index));
247:            }
248:
249:            /**
250:             * Waits 0'th JColorChooser in container.
251:             * @param cont Container to search component in.
252:             * @return JColorChooser instance or null if component was not displayed.
253:             * 
254:             */
255:            public static JColorChooser waitJColorChooser(Container cont) {
256:                return (waitJColorChooser(cont, 0));
257:            }
258:
259:            public void setOutput(TestOut out) {
260:                output = out;
261:                super .setOutput(output.createErrorOutput());
262:            }
263:
264:            public TestOut getOutput() {
265:                return (output);
266:            }
267:
268:            /**
269:             * Switches tab to "RGB" page.
270:             */
271:            public void switchToRGB() {
272:                if (!tabbed.getTitleAt(tabbed.getSelectedIndex()).equals(
273:                        RGB_TITLE)) {
274:                    tabbed.selectPage(RGB_TITLE);
275:                }
276:                blue = new JTextFieldOperator(this , 2);
277:                green = new JTextFieldOperator(this , 1);
278:                red = new JTextFieldOperator(this , 0);
279:            }
280:
281:            /**
282:             * Enters red color component value.
283:             * Switches to "RGB" page first.
284:             * @param value red color component
285:             * @see #switchToRGB()
286:             * @see #enterColor(int, int, int)
287:             * @see #enterColor(java.awt.Color)
288:             * @see #enterColor(int)
289:             */
290:            public void enterRed(int value) {
291:                switchToRGB();
292:                red.setText(Integer.toString(value));
293:            }
294:
295:            /**
296:             * Enters green color component value.
297:             * Switches to "RGB" page first.
298:             * @param value green color component
299:             * @see #switchToRGB()
300:             * @see #enterColor(int, int, int)
301:             * @see #enterColor(java.awt.Color)
302:             * @see #enterColor(int)
303:             */
304:            public void enterGreen(int value) {
305:                switchToRGB();
306:                green.setText(Integer.toString(value));
307:            }
308:
309:            /**
310:             * Enters blue color component value.
311:             * Switches to "RGB" page first.
312:             * @param value blue color component
313:             * @see #switchToRGB()
314:             * @see #enterColor(int, int, int)
315:             * @see #enterColor(java.awt.Color)
316:             * @see #enterColor(int)
317:             */
318:            public void enterBlue(int value) {
319:                switchToRGB();
320:                blue.setText(Integer.toString(value));
321:            }
322:
323:            /**
324:             * Enters all color components values.
325:             * Switches to "RGB" page first.
326:             * @param red red color component
327:             * @param green green color component
328:             * @param blue blue color component
329:             * @see #switchToRGB()
330:             * @see #enterColor(java.awt.Color)
331:             * @see #enterColor(int)
332:             */
333:            public void enterColor(int red, int green, int blue) {
334:                switchToRGB();
335:                enterRed(red);
336:                enterGreen(green);
337:                enterBlue(blue);
338:            }
339:
340:            /**
341:             * Enters color.
342:             * Switches to "RGB" page first.
343:             * @param color a color
344:             * @see #switchToRGB()
345:             * @see #enterColor(int, int, int)
346:             * @see #enterColor(int)
347:             */
348:            public void enterColor(Color color) {
349:                enterColor(color.getRed(), color.getGreen(), color.getBlue());
350:            }
351:
352:            /**
353:             * Enters color.
354:             * Switches to "RGB" page first.
355:             * @param color a color
356:             * @see #switchToRGB()
357:             * @see #enterColor(int, int, int)
358:             * @see #enterColor(java.awt.Color)
359:             */
360:            public void enterColor(int color) {
361:                enterColor(new Color(color));
362:            }
363:
364:            /**
365:             * Returns information about component.
366:             */
367:            public Hashtable getDump() {
368:                Hashtable result = super .getDump();
369:                result.put(COLOR_DPROP, ((JColorChooser) getSource())
370:                        .getColor().toString());
371:                JTabbedPane tb = (JTabbedPane) tabbed.getSource();
372:                result.put(SELECTED_PAGE_DPROP, tb.getTitleAt(tb
373:                        .getSelectedIndex()));
374:                return (result);
375:            }
376:
377:            ////////////////////////////////////////////////////////
378:            //Mapping                                             //
379:
380:            /**Maps <code>JColorChooser.addChooserPanel(AbstractColorChooserPanel)</code> through queue*/
381:            public void addChooserPanel(
382:                    final AbstractColorChooserPanel abstractColorChooserPanel) {
383:                runMapping(new MapVoidAction("addChooserPanel") {
384:                    public void map() {
385:                        ((JColorChooser) getSource())
386:                                .addChooserPanel(abstractColorChooserPanel);
387:                    }
388:                });
389:            }
390:
391:            /**Maps <code>JColorChooser.getChooserPanels()</code> through queue*/
392:            public AbstractColorChooserPanel[] getChooserPanels() {
393:                return ((AbstractColorChooserPanel[]) runMapping(new MapAction(
394:                        "getChooserPanels") {
395:                    public Object map() {
396:                        return (((JColorChooser) getSource())
397:                                .getChooserPanels());
398:                    }
399:                }));
400:            }
401:
402:            /**Maps <code>JColorChooser.getColor()</code> through queue*/
403:            public Color getColor() {
404:                return ((Color) runMapping(new MapAction("getColor") {
405:                    public Object map() {
406:                        return (((JColorChooser) getSource()).getColor());
407:                    }
408:                }));
409:            }
410:
411:            /**Maps <code>JColorChooser.getPreviewPanel()</code> through queue*/
412:            public JComponent getPreviewPanel() {
413:                return ((JComponent) runMapping(new MapAction("getPreviewPanel") {
414:                    public Object map() {
415:                        return (((JColorChooser) getSource()).getPreviewPanel());
416:                    }
417:                }));
418:            }
419:
420:            /**Maps <code>JColorChooser.getSelectionModel()</code> through queue*/
421:            public ColorSelectionModel getSelectionModel() {
422:                return ((ColorSelectionModel) runMapping(new MapAction(
423:                        "getSelectionModel") {
424:                    public Object map() {
425:                        return (((JColorChooser) getSource())
426:                                .getSelectionModel());
427:                    }
428:                }));
429:            }
430:
431:            /**Maps <code>JColorChooser.getUI()</code> through queue*/
432:            public ColorChooserUI getUI() {
433:                return ((ColorChooserUI) runMapping(new MapAction("getUI") {
434:                    public Object map() {
435:                        return (((JColorChooser) getSource()).getUI());
436:                    }
437:                }));
438:            }
439:
440:            /**Maps <code>JColorChooser.removeChooserPanel(AbstractColorChooserPanel)</code> through queue*/
441:            public AbstractColorChooserPanel removeChooserPanel(
442:                    final AbstractColorChooserPanel abstractColorChooserPanel) {
443:                return ((AbstractColorChooserPanel) runMapping(new MapAction(
444:                        "removeChooserPanel") {
445:                    public Object map() {
446:                        return (((JColorChooser) getSource())
447:                                .removeChooserPanel(abstractColorChooserPanel));
448:                    }
449:                }));
450:            }
451:
452:            /**Maps <code>JColorChooser.setChooserPanels(AbstractColorChooserPanel[])</code> through queue*/
453:            public void setChooserPanels(
454:                    final AbstractColorChooserPanel[] abstractColorChooserPanel) {
455:                runMapping(new MapVoidAction("setChooserPanels") {
456:                    public void map() {
457:                        ((JColorChooser) getSource())
458:                                .setChooserPanels(abstractColorChooserPanel);
459:                    }
460:                });
461:            }
462:
463:            /**Maps <code>JColorChooser.setColor(int)</code> through queue*/
464:            public void setColor(final int i) {
465:                runMapping(new MapVoidAction("setColor") {
466:                    public void map() {
467:                        ((JColorChooser) getSource()).setColor(i);
468:                    }
469:                });
470:            }
471:
472:            /**Maps <code>JColorChooser.setColor(int, int, int)</code> through queue*/
473:            public void setColor(final int i, final int i1, final int i2) {
474:                runMapping(new MapVoidAction("setColor") {
475:                    public void map() {
476:                        ((JColorChooser) getSource()).setColor(i, i1, i2);
477:                    }
478:                });
479:            }
480:
481:            /**Maps <code>JColorChooser.setColor(Color)</code> through queue*/
482:            public void setColor(final Color color) {
483:                runMapping(new MapVoidAction("setColor") {
484:                    public void map() {
485:                        ((JColorChooser) getSource()).setColor(color);
486:                    }
487:                });
488:            }
489:
490:            /**Maps <code>JColorChooser.setPreviewPanel(JComponent)</code> through queue*/
491:            public void setPreviewPanel(final JComponent jComponent) {
492:                runMapping(new MapVoidAction("setPreviewPanel") {
493:                    public void map() {
494:                        ((JColorChooser) getSource())
495:                                .setPreviewPanel(jComponent);
496:                    }
497:                });
498:            }
499:
500:            /**Maps <code>JColorChooser.setSelectionModel(ColorSelectionModel)</code> through queue*/
501:            public void setSelectionModel(
502:                    final ColorSelectionModel colorSelectionModel) {
503:                runMapping(new MapVoidAction("setSelectionModel") {
504:                    public void map() {
505:                        ((JColorChooser) getSource())
506:                                .setSelectionModel(colorSelectionModel);
507:                    }
508:                });
509:            }
510:
511:            /**Maps <code>JColorChooser.setUI(ColorChooserUI)</code> through queue*/
512:            public void setUI(final ColorChooserUI colorChooserUI) {
513:                runMapping(new MapVoidAction("setUI") {
514:                    public void map() {
515:                        ((JColorChooser) getSource()).setUI(colorChooserUI);
516:                    }
517:                });
518:            }
519:
520:            //End of mapping                                      //
521:            ////////////////////////////////////////////////////////
522:
523:            /**
524:             * Checks component type.
525:             */
526:            public static class JColorChooserFinder extends Finder {
527:                /**
528:                 * Constructs JColorChooserFinder.
529:                 * @param sf other searching criteria.
530:                 */
531:                public JColorChooserFinder(ComponentChooser sf) {
532:                    super (JColorChooser.class, sf);
533:                }
534:
535:                /**
536:                 * Constructs JColorChooserFinder.
537:                 */
538:                public JColorChooserFinder() {
539:                    super (JColorChooser.class);
540:                }
541:            }
542:
543:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.