Source Code Cross Referenced for TextAreaOperator.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: TextAreaOperator.java,v 1.8 2007/10/05 11:35:51 jskrivanek Exp $ $Revision: 1.8 $ $Date: 2007/10/05 11:35:51 $
044:         *
045:         */
046:
047:        package org.netbeans.jemmy.operators;
048:
049:        import org.netbeans.jemmy.ActionProducer;
050:        import org.netbeans.jemmy.Action;
051:        import org.netbeans.jemmy.ComponentChooser;
052:        import org.netbeans.jemmy.ComponentSearcher;
053:        import org.netbeans.jemmy.JemmyProperties;
054:        import org.netbeans.jemmy.Outputable;
055:        import org.netbeans.jemmy.TestOut;
056:        import org.netbeans.jemmy.Timeoutable;
057:        import org.netbeans.jemmy.Timeouts;
058:
059:        import java.awt.Component;
060:        import java.awt.Container;
061:        import java.awt.Dimension;
062:        import java.awt.TextArea;
063:
064:        import java.awt.event.ActionListener;
065:        import java.awt.event.KeyEvent;
066:        import java.awt.event.TextListener;
067:
068:        import java.util.Hashtable;
069:
070:        /**
071:         * This operator type covers java.awt.textArea component.
072:         *
073:         * @see org.netbeans.jemmy.Timeouts
074:         *
075:         * @author Alexandre Iline (alexandre.iline@sun.com)
076:         *	
077:         */
078:
079:        public class TextAreaOperator extends TextComponentOperator implements 
080:                Timeoutable, Outputable {
081:
082:            /**
083:             * Identifier for a "text" property.
084:             * @see #getDump
085:             */
086:            public static final String TEXT_DPROP = "Text";
087:
088:            private final static long PUSH_KEY_TIMEOUT = 0;
089:            private final static long BETWEEN_KEYS_TIMEOUT = 0;
090:            private final static long CHANGE_CARET_POSITION_TIMEOUT = 60000;
091:            private final static long TYPE_TEXT_TIMEOUT = 60000;
092:
093:            private Timeouts timeouts;
094:            private TestOut output;
095:
096:            /**
097:             * Constructor.
098:             * @param b The <code>java.awt.TextArea</code> managed by
099:             * this instance.
100:             */
101:            public TextAreaOperator(TextArea b) {
102:                super (b);
103:            }
104:
105:            /**
106:             * Constructs a TextAreaOperator object.
107:             * @param cont a container
108:             * @param chooser a component chooser specifying searching criteria.
109:             * @param index an index between appropriate ones.
110:             */
111:            public TextAreaOperator(ContainerOperator cont,
112:                    ComponentChooser chooser, int index) {
113:                this ((TextArea) cont.waitSubComponent(new TextAreaFinder(
114:                        chooser), index));
115:                copyEnvironment(cont);
116:            }
117:
118:            /**
119:             * Constructs a TextAreaOperator object.
120:             * @param cont a container
121:             * @param chooser a component chooser specifying searching criteria.
122:             */
123:            public TextAreaOperator(ContainerOperator cont,
124:                    ComponentChooser chooser) {
125:                this (cont, chooser, 0);
126:            }
127:
128:            /**
129:             * Constructor.
130:             * Waits for a component in a container to show. The component is
131:             * identified as the <code>index+1</code>'th
132:             * <code>java.awt.TextArea</code> that shows, lies below
133:             * the container in the display containment hierarchy,
134:             * and that has the desired text. Uses cont's timeout and output
135:             * for waiting and to init this operator.
136:             * @param cont The operator for a container containing the sought for textArea.
137:             * @param text TextArea text. 
138:             * @param index Ordinal component index. The first component has <code>index</code> 0.
139:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
140:             */
141:            public TextAreaOperator(ContainerOperator cont, String text,
142:                    int index) {
143:                this ((TextArea) waitComponent(cont, new TextAreaByTextFinder(
144:                        text, cont.getComparator()), index));
145:                copyEnvironment(cont);
146:            }
147:
148:            /**
149:             * Constructor.
150:             * Waits for a component in a container to show. The component is
151:             * identified as the first
152:             * <code>java.awt.TextArea</code> that shows, lies below
153:             * the container in the display containment hierarchy,
154:             * and that has the desired text. Uses cont's timeout and output
155:             * for waiting and to init this operator.
156:             * @param cont The operator for a container containing the sought for textArea.
157:             * @param text TextArea text. 
158:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
159:             */
160:            public TextAreaOperator(ContainerOperator cont, String text) {
161:                this (cont, text, 0);
162:            }
163:
164:            /**
165:             * Constructor.
166:             * Waits component in container first.
167:             * Uses cont's timeout and output for waiting and to init operator.
168:             * @param cont The operator for a container containing the sought for textArea.
169:             * @param index Ordinal component index.
170:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
171:             */
172:            public TextAreaOperator(ContainerOperator cont, int index) {
173:                this (
174:                        (TextArea) waitComponent(cont, new TextAreaFinder(),
175:                                index));
176:                copyEnvironment(cont);
177:            }
178:
179:            /**
180:             * Constructor.
181:             * Waits component in container first.
182:             * Uses cont's timeout and output for waiting and to init operator.
183:             * @param cont The operator for a container containing the sought for textArea.
184:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
185:             */
186:            public TextAreaOperator(ContainerOperator cont) {
187:                this (cont, 0);
188:            }
189:
190:            /**
191:             * Searches TextArea in a container.
192:             * @param cont Container in which to search for the component.  The container
193:             * lies above the component in the display containment hierarchy.  The containment
194:             * need not be direct.
195:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation, defining and
196:             * applying search criteria.
197:             * @param index Ordinal component index.  The first <code>index</code> is 0.
198:             * @return TextArea instance or null if component was not found.
199:             */
200:            public static TextArea findTextArea(Container cont,
201:                    ComponentChooser chooser, int index) {
202:                return ((TextArea) findComponent(cont, new TextAreaFinder(
203:                        chooser), index));
204:            }
205:
206:            /**
207:             * Searches for the first TextArea in a container.
208:             * @param cont Container in which to search for the component.  The container
209:             * lies above the component in the display containment hierarchy.  The containment
210:             * need not be direct.
211:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation, defining and
212:             * applying search criteria.
213:             * @return TextArea instance or null if component was not found.
214:             */
215:            public static TextArea findTextArea(Container cont,
216:                    ComponentChooser chooser) {
217:                return (findTextArea(cont, chooser, 0));
218:            }
219:
220:            /**
221:             * Searches TextArea by text.
222:             * @param cont Container to search component in.
223:             * @param text TextArea text. If null, contents is not checked.
224:             * @param ce Compare text exactly.
225:             * @param ccs Compare text case sensitively.
226:             * @param index Ordinal component index.
227:             * @return TextArea instance or null if component was not found.
228:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
229:             */
230:            public static TextArea findTextArea(Container cont, String text,
231:                    boolean ce, boolean ccs, int index) {
232:                return (findTextArea(cont, new TextAreaByTextFinder(text,
233:                        new DefaultStringComparator(ce, ccs)), index));
234:            }
235:
236:            /**
237:             * Searches TextArea by text.
238:             * @param cont Container to search component in.
239:             * @param text TextArea text. If null, contents is not checked.
240:             * @param ce Compare text exactly.
241:             * @param ccs Compare text case sensitively.
242:             * @return TextArea instance or null if component was not found.
243:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
244:             */
245:            public static TextArea findTextArea(Container cont, String text,
246:                    boolean ce, boolean ccs) {
247:                return (findTextArea(cont, text, ce, ccs, 0));
248:            }
249:
250:            /**
251:             * Waits TextArea in container.
252:             * @param cont Container to search component in.
253:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
254:             * @param index Ordinal component index.
255:             * @return TextArea instance.
256:             */
257:            public static TextArea waitTextArea(Container cont,
258:                    ComponentChooser chooser, int index) {
259:                return ((TextArea) waitComponent(cont, new TextAreaFinder(
260:                        chooser), index));
261:            }
262:
263:            /**
264:             * Waits 0'th TextArea in container.
265:             * @param cont Container to search component in.
266:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
267:             * @return TextArea instance.
268:             */
269:            public static TextArea waitTextArea(Container cont,
270:                    ComponentChooser chooser) {
271:                return (waitTextArea(cont, chooser, 0));
272:            }
273:
274:            /**
275:             * Waits TextArea by text.
276:             * @param cont Container to search component in.
277:             * @param text TextArea text. If null, contents is not checked.
278:             * @param ce Compare text exactly.
279:             * @param ccs Compare text case sensitively.
280:             * @param index Ordinal component index.
281:             * @return TextArea instance.
282:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
283:             */
284:            public static TextArea waitTextArea(Container cont, String text,
285:                    boolean ce, boolean ccs, int index) {
286:                return (waitTextArea(cont, new TextAreaByTextFinder(text,
287:                        new DefaultStringComparator(ce, ccs)), index));
288:            }
289:
290:            /**
291:             * Waits TextArea by text.
292:             * @param cont Container to search component in.
293:             * @param text TextArea text. If null, contents is not checked.
294:             * @param ce Compare text exactly.
295:             * @param ccs Compare text case sensitively.
296:             * @return TextArea instance.
297:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
298:             */
299:            public static TextArea waitTextArea(Container cont, String text,
300:                    boolean ce, boolean ccs) {
301:                return (waitTextArea(cont, text, ce, ccs, 0));
302:            }
303:
304:            static {
305:                Timeouts.initDefault("TextAreaOperator.PushKeyTimeout",
306:                        PUSH_KEY_TIMEOUT);
307:                Timeouts.initDefault("TextAreaOperator.BetweenKeysTimeout",
308:                        BETWEEN_KEYS_TIMEOUT);
309:                Timeouts.initDefault(
310:                        "TextAreaOperator.ChangeCaretPositionTimeout",
311:                        CHANGE_CARET_POSITION_TIMEOUT);
312:                Timeouts.initDefault("TextAreaOperator.TypeTextTimeout",
313:                        TYPE_TEXT_TIMEOUT);
314:            }
315:
316:            public void setTimeouts(Timeouts timeouts) {
317:                super .setTimeouts(timeouts);
318:                this .timeouts = timeouts;
319:            }
320:
321:            public Timeouts getTimeouts() {
322:                return (timeouts);
323:            }
324:
325:            public void setOutput(TestOut out) {
326:                output = out;
327:                super .setOutput(output.createErrorOutput());
328:            }
329:
330:            public TestOut getOutput() {
331:                return (output);
332:            }
333:
334:            public Hashtable getDump() {
335:                Hashtable result = super .getDump();
336:                result.put(TEXT_DPROP, ((TextArea) getSource()).getText());
337:                return (result);
338:            }
339:
340:            ////////////////////////////////////////////////////////
341:            //Mapping                                             //
342:
343:            /**Maps <code>TextArea.getColumns()</code> through queue*/
344:            public int getColumns() {
345:                return (runMapping(new MapIntegerAction("getColumns") {
346:                    public int map() {
347:                        return (((TextArea) getSource()).getColumns());
348:                    }
349:                }));
350:            }
351:
352:            /**Maps <code>TextArea.getMinimumSize(int, int)</code> through queue*/
353:            public Dimension getMinimumSize(final int i, final int i1) {
354:                return ((Dimension) runMapping(new MapAction("getMinimumSize") {
355:                    public Object map() {
356:                        return (((TextArea) getSource()).getMinimumSize(i, i1));
357:                    }
358:                }));
359:            }
360:
361:            /**Maps <code>TextArea.getPreferredSize(int, int)</code> through queue*/
362:            public Dimension getPreferredSize(final int i, final int i1) {
363:                return ((Dimension) runMapping(new MapAction("getPreferredSize") {
364:                    public Object map() {
365:                        return (((TextArea) getSource())
366:                                .getPreferredSize(i, i1));
367:                    }
368:                }));
369:            }
370:
371:            /**Maps <code>TextArea.getRows()</code> through queue*/
372:            public int getRows() {
373:                return (runMapping(new MapIntegerAction("getRows") {
374:                    public int map() {
375:                        return (((TextArea) getSource()).getRows());
376:                    }
377:                }));
378:            }
379:
380:            /**Maps <code>TextArea.getScrollbarVisibility()</code> through queue*/
381:            public int getScrollbarVisibility() {
382:                return (runMapping(new MapIntegerAction(
383:                        "getScrollbarVisibility") {
384:                    public int map() {
385:                        return (((TextArea) getSource())
386:                                .getScrollbarVisibility());
387:                    }
388:                }));
389:            }
390:
391:            /**Maps <code>TextArea.replaceRange(String, int, int)</code> through queue*/
392:            public void replaceRange(final String string, final int i,
393:                    final int i1) {
394:                runMapping(new MapVoidAction("replaceRange") {
395:                    public void map() {
396:                        ((TextArea) getSource()).replaceRange(string, i, i1);
397:                    }
398:                });
399:            }
400:
401:            /**Maps <code>TextArea.setColumns(int)</code> through queue*/
402:            public void setColumns(final int i) {
403:                runMapping(new MapVoidAction("setColumns") {
404:                    public void map() {
405:                        ((TextArea) getSource()).setColumns(i);
406:                    }
407:                });
408:            }
409:
410:            /**Maps <code>TextArea.setRows(int)</code> through queue*/
411:            public void setRows(final int i) {
412:                runMapping(new MapVoidAction("setRows") {
413:                    public void map() {
414:                        ((TextArea) getSource()).setRows(i);
415:                    }
416:                });
417:            }
418:
419:            //End of mapping                                      //
420:            ////////////////////////////////////////////////////////
421:
422:            /**
423:             * Allows to find component by text.
424:             */
425:            public static class TextAreaByTextFinder implements 
426:                    ComponentChooser {
427:                String label;
428:                StringComparator comparator;
429:
430:                /**
431:                 * Constructs TextAreaByTextFinder.
432:                 * @param lb a text pattern
433:                 * @param comparator specifies string comparision algorithm.
434:                 */
435:                public TextAreaByTextFinder(String lb,
436:                        StringComparator comparator) {
437:                    label = lb;
438:                    this .comparator = comparator;
439:                }
440:
441:                /**
442:                 * Constructs TextAreaByTextFinder.
443:                 * @param lb a text pattern
444:                 */
445:                public TextAreaByTextFinder(String lb) {
446:                    this (lb, Operator.getDefaultStringComparator());
447:                }
448:
449:                public boolean checkComponent(Component comp) {
450:                    if (comp instanceof  TextArea) {
451:                        if (((TextArea) comp).getText() != null) {
452:                            return (comparator.equals(((TextArea) comp)
453:                                    .getText(), label));
454:                        }
455:                    }
456:                    return (false);
457:                }
458:
459:                public String getDescription() {
460:                    return ("TextArea with text \"" + label + "\"");
461:                }
462:            }
463:
464:            /**
465:             * Checks component type.
466:             */
467:            public static class TextAreaFinder extends Finder {
468:                /**
469:                 * Constructs TextAreaFinder.
470:                 * @param sf other searching criteria.
471:                 */
472:                public TextAreaFinder(ComponentChooser sf) {
473:                    super (TextArea.class, sf);
474:                }
475:
476:                /**
477:                 * Constructs TextAreaFinder.
478:                 */
479:                public TextAreaFinder() {
480:                    super (TextArea.class);
481:                }
482:            }
483:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.