Source Code Cross Referenced for HelpOperator.java in  » IDE-Netbeans » jellytools » org » netbeans » jellytools » 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 » jellytools » org.netbeans.jellytools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.jellytools;
043:
044:        import java.awt.Component;
045:        import java.awt.Dialog;
046:        import java.awt.Frame;
047:        import java.awt.Window;
048:        import org.netbeans.jellytools.actions.HelpAction;
049:        import org.netbeans.jemmy.ComponentChooser;
050:        import org.netbeans.jemmy.TestOut;
051:        import org.netbeans.jemmy.operators.JButtonOperator;
052:        import org.netbeans.jemmy.operators.JEditorPaneOperator;
053:        import org.netbeans.jemmy.operators.JSplitPaneOperator;
054:        import org.netbeans.jemmy.operators.JTabbedPaneOperator;
055:        import org.netbeans.jemmy.operators.JTextFieldOperator;
056:        import org.netbeans.jemmy.operators.JTreeOperator;
057:        import org.netbeans.jemmy.operators.WindowOperator;
058:
059:        /** Class implementing all necessary methods for handling "IDE Help" Frame.
060:         * Normally the Help window is a JFrame.
061:         * But the Help window can be transformed to a JDialog 
062:         * when another modal dialog is shown. This operator can handle both states.
063:         *
064:         * @see HelpAction
065:         * @author Adam.Sotona@sun.com
066:         * @author Jiri.Skrivanek@sun.com
067:         */
068:        public class HelpOperator extends WindowOperator {
069:
070:            /** Creates new HelpOperator that can handle it. It tries to find a window
071:             * which contains some javax.help.JHelp* sub component.
072:             * It throws TimeoutExpiredException when window is not found
073:             */
074:            public HelpOperator() {
075:                super (WindowOperator.waitWindow(new HelpWindowChooser()));
076:            }
077:
078:            /** Creates new HelpOperator that can handle it. It tries to find a window
079:             * which contains some javax.help.JHelp* sub component and the window
080:             * has given title.
081:             * It throws TimeoutExpiredException when JFrame not found
082:             * @param title String help frame title 
083:             */
084:            public HelpOperator(String title) {
085:                super (WindowOperator.waitWindow(new HelpWindowChooser(title)));
086:            }
087:
088:            private static final HelpAction helpAction = new HelpAction();
089:
090:            private JButtonOperator _btBack;
091:            private JButtonOperator _btNext;
092:            private JButtonOperator _btPrint;
093:            private JButtonOperator _btPageSetup;
094:            private JSplitPaneOperator _splpHelpSplitPane;
095:            private JTabbedPaneOperator _tbpHelpTabPane;
096:            private JTreeOperator _treeContents;
097:            private JTreeOperator _treeSearch;
098:            private JTextFieldOperator _txtSearchFind;
099:            private JEditorPaneOperator _txtContentViewer;
100:
101:            /** Returns title of help window. The help window can be either JFrame
102:             * or JDialog.
103:             * @return title of help window
104:             */
105:            public String getTitle() {
106:                if (getSource() instanceof  Frame) {
107:                    return ((Frame) getSource()).getTitle();
108:                } else {
109:                    return ((Dialog) getSource()).getTitle();
110:                }
111:            }
112:
113:            /** invokes default help
114:             * @return HelpOperator for invoked help */
115:            public static HelpOperator invoke() {
116:                helpAction.perform();
117:                return new HelpOperator();
118:            }
119:
120:            /** invokes help with defined help set
121:             * @param helpSet String help set name
122:             * @return HelpOperator for invoked help */
123:            /* Help set submenu not used for NetBeans 3.6.
124:            public static HelpOperator invoke(String helpSet) {
125:                new HelpAction(helpSet).perform();
126:                return new HelpOperator(helpSet);
127:            }
128:             */
129:
130:            /** Tries to find "" JButton in this dialog.
131:             * It throws TimeoutExpiredException when component not found
132:             * @return JButtonOperator
133:             */
134:            public JButtonOperator btBack() {
135:                if (_btBack == null) {
136:                    _btBack = new JButtonOperator(this , helpButtonChooser, 0);
137:                }
138:                return _btBack;
139:            }
140:
141:            /** Tries to find "" JButton in this dialog.
142:             * It throws TimeoutExpiredException when component not found
143:             * @return JButtonOperator
144:             */
145:            public JButtonOperator btNext() {
146:                if (_btNext == null) {
147:                    _btNext = new JButtonOperator(this , helpButtonChooser, 1);
148:                }
149:                return _btNext;
150:            }
151:
152:            /** Tries to find "" JButton in this dialog.
153:             * It throws TimeoutExpiredException when component not found
154:             * @return JButtonOperator
155:             */
156:            public JButtonOperator btPrint() {
157:                if (_btPrint == null) {
158:                    _btPrint = new JButtonOperator(this , helpButtonChooser, 2);
159:                }
160:                return _btPrint;
161:            }
162:
163:            /** Tries to find "" JSplitPaneOperator in this dialog.
164:             * It throws TimeoutExpiredException when component not found
165:             * @return JButtonOperator
166:             */
167:            public JSplitPaneOperator splpHelpSplitPane() {
168:                if (_splpHelpSplitPane == null) {
169:                    _splpHelpSplitPane = new JSplitPaneOperator(this );
170:                }
171:                return _splpHelpSplitPane;
172:            }
173:
174:            /** Tries to find "" JTabbedPane in this dialog.
175:             * It throws TimeoutExpiredException when component not found
176:             * @return JButtonOperator
177:             */
178:            public JTabbedPaneOperator tbpHelpTabPane() {
179:                if (_tbpHelpTabPane == null) {
180:                    _tbpHelpTabPane = new JTabbedPaneOperator(
181:                            splpHelpSplitPane());
182:                }
183:                return _tbpHelpTabPane;
184:            }
185:
186:            /** Tries to find "" JButton in this dialog.
187:             * It throws TimeoutExpiredException when component not found
188:             * @return JButtonOperator
189:             */
190:            public JButtonOperator btPageSetup() {
191:                if (_btPageSetup == null) {
192:                    _btPageSetup = new JButtonOperator(this , helpButtonChooser,
193:                            3);
194:                }
195:                return _btPageSetup;
196:            }
197:
198:            /** Tries to find JTree in Contents tab of this dialog.
199:             * It throws TimeoutExpiredException when component not found
200:             * @return JTreeOperator
201:             */
202:            public JTreeOperator treeContents() {
203:                selectPageContents();
204:                if (_treeContents == null) {
205:                    _treeContents = new JTreeOperator(tbpHelpTabPane(), 0);
206:                }
207:                return _treeContents;
208:            }
209:
210:            /** Tries to find JTree in Search tab of this dialog.
211:             * It throws TimeoutExpiredException when component not found
212:             * @return JTreeOperator
213:             */
214:            public JTreeOperator treeSearch() {
215:                selectPageSearch();
216:                if (_treeSearch == null) {
217:                    _treeSearch = new JTreeOperator(tbpHelpTabPane(), 0);
218:                }
219:                return _treeSearch;
220:            }
221:
222:            /** Tries to find JTextField Find in Search tab of this dialog.
223:             * It throws TimeoutExpiredException when component not found
224:             * @return JTextFieldOperator
225:             */
226:            public JTextFieldOperator txtSearchFind() {
227:                selectPageSearch();
228:                if (_txtSearchFind == null) {
229:                    _txtSearchFind = new JTextFieldOperator(tbpHelpTabPane(), 0);
230:                }
231:                return _txtSearchFind;
232:            }
233:
234:            /** Tries to find null BasicContentViewerUI$JHEditorPane in this dialog.
235:             * It throws TimeoutExpiredException when component not found
236:             * @return JEditorPaneOperator
237:             */
238:            public JEditorPaneOperator txtContentViewer() {
239:                if (_txtContentViewer == null) {
240:                    _txtContentViewer = new JEditorPaneOperator(
241:                            splpHelpSplitPane(), 0);
242:                }
243:                return _txtContentViewer;
244:            }
245:
246:            /** clicks on "Back" JButton
247:             * It throws TimeoutExpiredException when MetalSplitPaneDivider$1 not found
248:             */
249:            public void back() {
250:                btBack().push();
251:            }
252:
253:            /** clicks on "Next" JButton
254:             * It throws TimeoutExpiredException when JButton not found
255:             */
256:            public void next() {
257:                btNext().push();
258:            }
259:
260:            /** clicks on "Print" JButton
261:             * It throws TimeoutExpiredException when JButton not found
262:             */
263:            public void print() {
264:                btPrint().push();
265:            }
266:
267:            /** clicks on "Page Setup" JButton
268:             * It throws TimeoutExpiredException when JButton not found
269:             */
270:            public void pageSetup() {
271:                btPageSetup().pushNoBlock();
272:            }
273:
274:            /** selects page Contents */
275:            public void selectPageContents() {
276:                tbpHelpTabPane().selectPage(0);
277:            }
278:
279:            /** selects page Search */
280:            public void selectPageSearch() {
281:                tbpHelpTabPane().selectPage(1);
282:            }
283:
284:            /** tries to find and set text of txtSearchFind
285:             * @param text String text
286:             */
287:            public void searchFind(String text) {
288:                txtSearchFind().enterText(text);
289:            }
290:
291:            /** returns help content in plain text form
292:             * @return String text of help
293:             */
294:            public String getContentText() {
295:                return txtContentViewer().getText();
296:            }
297:
298:            /** Performs verification by accessing all sub-components */
299:            public void verify() {
300:                btBack();
301:                btNext();
302:                btPageSetup();
303:                btPrint();
304:                treeContents();
305:                txtContentViewer();
306:                treeSearch();
307:                txtSearchFind();
308:            }
309:
310:            /** Implementation of ComponentChooser to choose component which 
311:             * is instance of javax.help.JHelp*. */
312:            private static final ComponentChooser jHelpChooser = new ComponentChooser() {
313:                public boolean checkComponent(Component comp) {
314:                    return comp.getClass().getName().startsWith(
315:                            "javax.help.JHelp");
316:                }
317:
318:                public String getDescription() {
319:                    return ("any javax.help");
320:                }
321:            };
322:
323:            /** Compare title of window with given pattern. */
324:            private static boolean compareTitle(WindowOperator oper,
325:                    String expectedTitle) {
326:                String title;
327:                if (oper.getSource() instanceof  Frame) {
328:                    title = ((Frame) oper.getSource()).getTitle();
329:                } else {
330:                    title = ((Dialog) oper.getSource()).getTitle();
331:                }
332:                return oper.getComparator().equals(title, expectedTitle);
333:            }
334:
335:            /** SubChooser to determine Window which contains some 
336:             *  javax.help.JHelp* sub component.
337:             */
338:            private static final class HelpWindowChooser implements 
339:                    ComponentChooser {
340:
341:                private String title;
342:
343:                public HelpWindowChooser() {
344:                }
345:
346:                public HelpWindowChooser(String title) {
347:                    this .title = title;
348:                }
349:
350:                public boolean checkComponent(Component comp) {
351:                    WindowOperator winOper = new WindowOperator((Window) comp);
352:                    winOper.setOutput(TestOut.getNullOutput());
353:                    if (winOper.findSubComponent(jHelpChooser) != null) {
354:                        if (title != null) {
355:                            return compareTitle(winOper, title);
356:                        } else {
357:                            return true;
358:                        }
359:                    }
360:                    return false;
361:                }
362:
363:                public String getDescription() {
364:                    return "containing any javax.help.JHelp component"
365:                            + (title == null ? "" : " and with title '" + title
366:                                    + "'");
367:                }
368:            }
369:
370:            /** SubChooser to find HelpButton in help window. */
371:            private static final ComponentChooser helpButtonChooser = new ComponentChooser() {
372:
373:                public boolean checkComponent(Component comp) {
374:                    return comp.getClass().getName().endsWith("HelpButton");
375:                }
376:
377:                public String getDescription() {
378:                    return "HelpButton";
379:                }
380:            };
381:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.