Source Code Cross Referenced for JEditorPaneOperator.java in  » IDE-Netbeans » 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 » IDE Netbeans » 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$ $Revision$ $Date$
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.Outputable;
052:        import org.netbeans.jemmy.TestOut;
053:        import org.netbeans.jemmy.TimeoutExpiredException;
054:
055:        import java.awt.Component;
056:        import java.awt.Container;
057:
058:        import java.awt.event.KeyEvent;
059:        import java.awt.event.InputEvent;
060:
061:        import java.io.InputStream;
062:        import java.io.IOException;
063:
064:        import java.net.URL;
065:
066:        import java.util.Hashtable;
067:
068:        import javax.swing.JEditorPane;
069:
070:        import javax.swing.event.HyperlinkEvent;
071:        import javax.swing.event.HyperlinkListener;
072:
073:        import javax.swing.text.EditorKit;
074:
075:        /**
076:         * Class provides basic functions to operate with JEditorPane
077:         * (selection, typing, deleting)
078:         *
079:         * <BR><BR>Timeouts used: <BR>
080:         * JTextComponentOperator.PushKeyTimeout - time between key pressing and releasing during text typing <BR>
081:         * JTextComponentOperator.BetweenKeysTimeout - time to sleep between two chars typing <BR>
082:         * JTextComponentOperator.ChangeCaretPositionTimeout - maximum time to change caret position <BR>
083:         * JTextComponentOperator.TypeTextTimeout - maximum time to type text <BR>
084:         * ComponentOperator.WaitComponentTimeout - time to wait component displayed <BR>
085:         * ComponentOperator.WaitFocusTimeout - time to wait component focus <BR>
086:         * JScrollBarOperator.OneScrollClickTimeout - time for one scroll click <BR>
087:         * JScrollBarOperator.WholeScrollTimeout - time for the whole scrolling <BR>.
088:         *
089:         * @see org.netbeans.jemmy.Timeouts
090:         *
091:         * @author Alexandre Iline (alexandre.iline@sun.com)
092:         */
093:
094:        public class JEditorPaneOperator extends JTextComponentOperator {
095:
096:            /**
097:             * Identifier for a "content type" property.
098:             * @see #getDump
099:             */
100:            public static final String CONTENT_TYPE_DPROP = "Content type";
101:
102:            private boolean pageNavigation = false;
103:
104:            /**
105:             * Constructor.
106:             * @param b a component
107:             */
108:            public JEditorPaneOperator(JEditorPane b) {
109:                super (b);
110:            }
111:
112:            /**
113:             * Constructs a JEditorPaneOperator object.
114:             * @param cont a container
115:             * @param chooser a component chooser specifying searching criteria.
116:             * @param index an index between appropriate ones.
117:             */
118:            public JEditorPaneOperator(ContainerOperator cont,
119:                    ComponentChooser chooser, int index) {
120:                this ((JEditorPane) cont.waitSubComponent(new JEditorPaneFinder(
121:                        chooser), index));
122:                copyEnvironment(cont);
123:            }
124:
125:            /**
126:             * Constructs a JEditorPaneOperator object.
127:             * @param cont a container
128:             * @param chooser a component chooser specifying searching criteria.
129:             */
130:            public JEditorPaneOperator(ContainerOperator cont,
131:                    ComponentChooser chooser) {
132:                this (cont, chooser, 0);
133:            }
134:
135:            /**
136:             * Constructor.
137:             * Waits component in container first.
138:             * Uses cont's timeout and output for waiting and to init operator.
139:             * @param cont a container
140:             * @param text Button text. 
141:             * @param index Ordinal component index.
142:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
143:             * @throws TimeoutExpiredException
144:             */
145:            public JEditorPaneOperator(ContainerOperator cont, String text,
146:                    int index) {
147:                this ((JEditorPane) waitComponent(cont, new JEditorPaneFinder(
148:                        new JTextComponentOperator.JTextComponentByTextFinder(
149:                                text, cont.getComparator())), index));
150:                copyEnvironment(cont);
151:            }
152:
153:            /**
154:             * Constructor.
155:             * Waits component in container first.
156:             * Uses cont's timeout and output for waiting and to init operator.
157:             * @param cont a container
158:             * @param text Button text. 
159:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
160:             * @throws TimeoutExpiredException
161:             */
162:            public JEditorPaneOperator(ContainerOperator cont, String text) {
163:                this (cont, text, 0);
164:            }
165:
166:            /**
167:             * Constructor.
168:             * Waits component in container first.
169:             * Uses cont's timeout and output for waiting and to init operator.
170:             * @param cont a container
171:             * @param index Ordinal component index.
172:             * @throws TimeoutExpiredException
173:             */
174:            public JEditorPaneOperator(ContainerOperator cont, int index) {
175:                this ((JEditorPane) waitComponent(cont, new JEditorPaneFinder(),
176:                        index));
177:                copyEnvironment(cont);
178:            }
179:
180:            /**
181:             * Constructor.
182:             * Waits component in container first.
183:             * Uses cont's timeout and output for waiting and to init operator.
184:             * @param cont a container
185:             * @throws TimeoutExpiredException
186:             */
187:            public JEditorPaneOperator(ContainerOperator cont) {
188:                this (cont, 0);
189:            }
190:
191:            /**
192:             * Searches JEditorPane in container.
193:             * @param cont Container to search component in.
194:             * @param chooser a component chooser specifying searching criteria.
195:             * @param index Ordinal component index.
196:             * @return JEditorPane instance or null if component was not found.
197:             */
198:            public static JEditorPane findJEditorPane(Container cont,
199:                    ComponentChooser chooser, int index) {
200:                return ((JEditorPane) findJTextComponent(cont,
201:                        new JEditorPaneFinder(chooser), index));
202:            }
203:
204:            /**
205:             * Searches JEditorPane in container.
206:             * @param cont Container to search component in.
207:             * @param chooser a component chooser specifying searching criteria.
208:             * @return JEditorPane instance or null if component was not found.
209:             */
210:            public static JEditorPane findJEditorPane(Container cont,
211:                    ComponentChooser chooser) {
212:                return (findJEditorPane(cont, chooser, 0));
213:            }
214:
215:            /**
216:             * Searches JEditorPane by text.
217:             * @param cont Container to search component in.
218:             * @param text Component text.
219:             * @param ce Compare text exactly.
220:             * @param ccs Compare text case sensitively.
221:             * @param index Ordinal component index.
222:             * @return JEditorPane instance or null if component was not found.
223:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
224:             */
225:            public static JEditorPane findJEditorPane(Container cont,
226:                    String text, boolean ce, boolean ccs, int index) {
227:                return (findJEditorPane(cont, new JEditorPaneFinder(
228:                        new JTextComponentOperator.JTextComponentByTextFinder(
229:                                text, new DefaultStringComparator(ce, ccs))),
230:                        index));
231:            }
232:
233:            /**
234:             * Searches JEditorPane by text.
235:             * @param cont Container to search component in.
236:             * @param text Component text.
237:             * @param ce Compare text exactly.
238:             * @param ccs Compare text case sensitively.
239:             * @return JEditorPane instance or null if component was not found.
240:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
241:             */
242:            public static JEditorPane findJEditorPane(Container cont,
243:                    String text, boolean ce, boolean ccs) {
244:                return (findJEditorPane(cont, text, ce, ccs, 0));
245:            }
246:
247:            /**
248:             * Waits JEditorPane in container.
249:             * @param cont Container to search component in.
250:             * @param chooser a component chooser specifying searching criteria.
251:             * @param index Ordinal component index.
252:             * @return JEditorPane instance.
253:             * @throws TimeoutExpiredException
254:             */
255:            public static JEditorPane waitJEditorPane(Container cont,
256:                    ComponentChooser chooser, int index) {
257:                return ((JEditorPane) waitJTextComponent(cont,
258:                        new JEditorPaneFinder(chooser), index));
259:            }
260:
261:            /**
262:             * Waits JEditorPane in container.
263:             * @param cont Container to search component in.
264:             * @param chooser a component chooser specifying searching criteria.
265:             * @return JEditorPane instance.
266:             * @throws TimeoutExpiredException
267:             */
268:            public static JEditorPane waitJEditorPane(Container cont,
269:                    ComponentChooser chooser) {
270:                return (waitJEditorPane(cont, chooser, 0));
271:            }
272:
273:            /**
274:             * Waits JEditorPane by text.
275:             * @param cont Container to search component in.
276:             * @param text Component text.
277:             * @param ce Compare text exactly.
278:             * @param ccs Compare text case sensitively.
279:             * @param index Ordinal component index.
280:             * @return JEditorPane instance.
281:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
282:             * @throws TimeoutExpiredException
283:             */
284:            public static JEditorPane waitJEditorPane(Container cont,
285:                    String text, boolean ce, boolean ccs, int index) {
286:                return (waitJEditorPane(cont, new JEditorPaneFinder(
287:                        new JTextComponentOperator.JTextComponentByTextFinder(
288:                                text, new DefaultStringComparator(ce, ccs))),
289:                        index));
290:            }
291:
292:            /**
293:             * Waits JEditorPane by text.
294:             * @param cont Container to search component in.
295:             * @param text Component text.
296:             * @param ce Compare text exactly.
297:             * @param ccs Compare text case sensitively.
298:             * @return JEditorPane instance.
299:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
300:             * @throws TimeoutExpiredException
301:             */
302:            public static JEditorPane waitJEditorPane(Container cont,
303:                    String text, boolean ce, boolean ccs) {
304:                return (waitJEditorPane(cont, text, ce, ccs, 0));
305:            }
306:
307:            /**
308:             * Notifies whether "PageUp" and "PageDown" should be used
309:             * to change caret position. If can be useful if text takes 
310:             * some pages.
311:             * @param yesOrNo whether to use "PageUp" and "PageDown"
312:             * @deprecated vlue set by this method is not used anymore:
313:             * all navigating is performed by TextDriver.
314:             */
315:            public void usePageNavigationKeys(boolean yesOrNo) {
316:                pageNavigation = yesOrNo;
317:            }
318:
319:            /**
320:             * Returns information about component.
321:             */
322:            public Hashtable getDump() {
323:                Hashtable result = super .getDump();
324:                result.put(CONTENT_TYPE_DPROP, ((JEditorPane) getSource())
325:                        .getContentType());
326:                return (result);
327:            }
328:
329:            ////////////////////////////////////////////////////////
330:            //Mapping                                             //
331:
332:            /**Maps <code>JEditorPane.addHyperlinkListener(HyperlinkListener)</code> through queue*/
333:            public void addHyperlinkListener(
334:                    final HyperlinkListener hyperlinkListener) {
335:                runMapping(new MapVoidAction("addHyperlinkListener") {
336:                    public void map() {
337:                        ((JEditorPane) getSource())
338:                                .addHyperlinkListener(hyperlinkListener);
339:                    }
340:                });
341:            }
342:
343:            /**Maps <code>JEditorPane.fireHyperlinkUpdate(HyperlinkEvent)</code> through queue*/
344:            public void fireHyperlinkUpdate(final HyperlinkEvent hyperlinkEvent) {
345:                runMapping(new MapVoidAction("fireHyperlinkUpdate") {
346:                    public void map() {
347:                        ((JEditorPane) getSource())
348:                                .fireHyperlinkUpdate(hyperlinkEvent);
349:                    }
350:                });
351:            }
352:
353:            /**Maps <code>JEditorPane.getContentType()</code> through queue*/
354:            public String getContentType() {
355:                return ((String) runMapping(new MapAction("getContentType") {
356:                    public Object map() {
357:                        return (((JEditorPane) getSource()).getContentType());
358:                    }
359:                }));
360:            }
361:
362:            /**Maps <code>JEditorPane.getEditorKit()</code> through queue*/
363:            public EditorKit getEditorKit() {
364:                return ((EditorKit) runMapping(new MapAction("getEditorKit") {
365:                    public Object map() {
366:                        return (((JEditorPane) getSource()).getEditorKit());
367:                    }
368:                }));
369:            }
370:
371:            /**Maps <code>JEditorPane.getEditorKitForContentType(String)</code> through queue*/
372:            public EditorKit getEditorKitForContentType(final String string) {
373:                return ((EditorKit) runMapping(new MapAction(
374:                        "getEditorKitForContentType") {
375:                    public Object map() {
376:                        return (((JEditorPane) getSource())
377:                                .getEditorKitForContentType(string));
378:                    }
379:                }));
380:            }
381:
382:            /**Maps <code>JEditorPane.getPage()</code> through queue*/
383:            public URL getPage() {
384:                return ((URL) runMapping(new MapAction("getPage") {
385:                    public Object map() {
386:                        return (((JEditorPane) getSource()).getPage());
387:                    }
388:                }));
389:            }
390:
391:            /**Maps <code>JEditorPane.read(InputStream, Object)</code> through queue*/
392:            public void read(final InputStream inputStream, final Object object) {
393:                runMapping(new MapVoidAction("read") {
394:                    public void map() throws IOException {
395:                        ((JEditorPane) getSource()).read(inputStream, object);
396:                    }
397:                });
398:            }
399:
400:            /**Maps <code>JEditorPane.removeHyperlinkListener(HyperlinkListener)</code> through queue*/
401:            public void removeHyperlinkListener(
402:                    final HyperlinkListener hyperlinkListener) {
403:                runMapping(new MapVoidAction("removeHyperlinkListener") {
404:                    public void map() {
405:                        ((JEditorPane) getSource())
406:                                .removeHyperlinkListener(hyperlinkListener);
407:                    }
408:                });
409:            }
410:
411:            /**Maps <code>JEditorPane.setContentType(String)</code> through queue*/
412:            public void setContentType(final String string) {
413:                runMapping(new MapVoidAction("setContentType") {
414:                    public void map() {
415:                        ((JEditorPane) getSource()).setContentType(string);
416:                    }
417:                });
418:            }
419:
420:            /**Maps <code>JEditorPane.setEditorKit(EditorKit)</code> through queue*/
421:            public void setEditorKit(final EditorKit editorKit) {
422:                runMapping(new MapVoidAction("setEditorKit") {
423:                    public void map() {
424:                        ((JEditorPane) getSource()).setEditorKit(editorKit);
425:                    }
426:                });
427:            }
428:
429:            /**Maps <code>JEditorPane.setEditorKitForContentType(String, EditorKit)</code> through queue*/
430:            public void setEditorKitForContentType(final String string,
431:                    final EditorKit editorKit) {
432:                runMapping(new MapVoidAction("setEditorKitForContentType") {
433:                    public void map() {
434:                        ((JEditorPane) getSource()).setEditorKitForContentType(
435:                                string, editorKit);
436:                    }
437:                });
438:            }
439:
440:            /**Maps <code>JEditorPane.setPage(String)</code> through queue*/
441:            public void setPage(final String string) {
442:                runMapping(new MapVoidAction("setPage") {
443:                    public void map() throws IOException {
444:                        ((JEditorPane) getSource()).setPage(string);
445:                    }
446:                });
447:            }
448:
449:            /**Maps <code>JEditorPane.setPage(URL)</code> through queue*/
450:            public void setPage(final URL uRL) {
451:                runMapping(new MapVoidAction("setPage") {
452:                    public void map() throws IOException {
453:                        ((JEditorPane) getSource()).setPage(uRL);
454:                    }
455:                });
456:            }
457:
458:            //End of mapping                                      //
459:            ////////////////////////////////////////////////////////
460:
461:            /**
462:             * Checks component type.
463:             */
464:            public static class JEditorPaneFinder extends Finder {
465:                /**
466:                 * Constructs JEditorPaneFinder.
467:                 * @param sf other searching criteria.
468:                 */
469:                public JEditorPaneFinder(ComponentChooser sf) {
470:                    super (JEditorPane.class, sf);
471:                }
472:
473:                /**
474:                 * Constructs JEditorPaneFinder.
475:                 */
476:                public JEditorPaneFinder() {
477:                    super (JEditorPane.class);
478:                }
479:            }
480:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.