Source Code Cross Referenced for JTreeMouseDriver.java in  » IDE-Netbeans » jemmy » org » netbeans » jemmy » drivers » trees » 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.drivers.trees 
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.drivers.trees;
048:
049:        import java.awt.Point;
050:
051:        import java.awt.event.InputEvent;
052:        import java.awt.event.KeyEvent;
053:
054:        import javax.swing.text.JTextComponent;
055:
056:        import javax.swing.tree.TreeModel;
057:        import javax.swing.tree.TreePath;
058:
059:        import org.netbeans.jemmy.JemmyException;
060:        import org.netbeans.jemmy.QueueTool;
061:        import org.netbeans.jemmy.Timeout;
062:        import org.netbeans.jemmy.Waitable;
063:        import org.netbeans.jemmy.Waiter;
064:
065:        import org.netbeans.jemmy.drivers.DriverManager;
066:        import org.netbeans.jemmy.drivers.LightSupportiveDriver;
067:        import org.netbeans.jemmy.drivers.MouseDriver;
068:        import org.netbeans.jemmy.drivers.PathChooser;
069:        import org.netbeans.jemmy.drivers.TextDriver;
070:        import org.netbeans.jemmy.drivers.TreeDriver;
071:
072:        import org.netbeans.jemmy.operators.ComponentOperator;
073:        import org.netbeans.jemmy.operators.JTextComponentOperator;
074:        import org.netbeans.jemmy.operators.JTreeOperator;
075:        import org.netbeans.jemmy.operators.Operator;
076:
077:        /**
078:         * TreeDriver for javax.swing.JTree component type.
079:         * Uses mouse operations.
080:         *
081:         * @author Alexandre Iline(alexandre.iline@sun.com)
082:         */
083:        public class JTreeMouseDriver extends LightSupportiveDriver implements 
084:                TreeDriver {
085:            QueueTool queueTool;
086:
087:            /**
088:             * Constructs a JTreeMouseDriver.
089:             */
090:            public JTreeMouseDriver() {
091:                super (
092:                        new String[] { "org.netbeans.jemmy.operators.JTreeOperator" });
093:                queueTool = new QueueTool();
094:            }
095:
096:            public void selectItem(ComponentOperator oper, int index) {
097:                selectItems(oper, new int[] { index });
098:            }
099:
100:            public void selectItems(final ComponentOperator oper, int[] indices) {
101:                ((JTreeOperator) oper).clearSelection();
102:                checkSupported(oper);
103:                final MouseDriver mdriver = DriverManager.getMouseDriver(oper);
104:                final JTreeOperator toper = (JTreeOperator) oper;
105:                final Timeout clickTime = oper.getTimeouts().create(
106:                        "ComponentOperator.MouseClickTimeout");
107:                QueueTool qt = new QueueTool();
108:                for (int i = 0; i < indices.length; i++) {
109:                    final int index = i;
110:                    if (!queueTool.isDispatchThread()) {
111:                        toper.scrollToRow(indices[i]);
112:                    }
113:                    final Point p = toper.getPointToClick(indices[index]);
114:                    queueTool.invokeSmoothly(new QueueTool.QueueAction(
115:                            "Path selecting") {
116:                        public Object launch() {
117:                            mdriver.clickMouse(oper, p.x, p.y, 1, Operator
118:                                    .getDefaultMouseButton(), (index == 0) ? 0
119:                                    : InputEvent.CTRL_MASK, clickTime);
120:                            return (null);
121:                        }
122:                    });
123:                }
124:                //1.5 workaround
125:                if (System.getProperty("java.specification.version").compareTo(
126:                        "1.4") > 0) {
127:                    if (!QueueTool.isDispatchThread()) {
128:                        queueTool.setOutput(oper.getOutput()
129:                                .createErrorOutput());
130:                        queueTool.waitEmpty(10);
131:                        queueTool.waitEmpty(10);
132:                        queueTool.waitEmpty(10);
133:                    }
134:                }
135:                //end of 1.5 workaround
136:            }
137:
138:            public void expandItem(ComponentOperator oper, final int index) {
139:                checkSupported(oper);
140:                final JTreeOperator toper = (JTreeOperator) oper;
141:                final MouseDriver mdriver = DriverManager.getMouseDriver(oper);
142:                if (!toper.isExpanded(index)) {
143:                    queueTool.invokeSmoothly(new QueueTool.QueueAction(
144:                            "Path selecting") {
145:                        public Object launch() {
146:                            Point p = toper.getPointToClick(index);
147:                            mdriver
148:                                    .clickMouse(
149:                                            toper,
150:                                            p.x,
151:                                            p.y,
152:                                            2,
153:                                            Operator.getDefaultMouseButton(),
154:                                            0,
155:                                            toper
156:                                                    .getTimeouts()
157:                                                    .create(
158:                                                            "ComponentOperator.MouseClickTimeout"));
159:                            return (null);
160:                        }
161:                    });
162:                }
163:            }
164:
165:            public void collapseItem(ComponentOperator oper, final int index) {
166:                checkSupported(oper);
167:                final JTreeOperator toper = (JTreeOperator) oper;
168:                final MouseDriver mdriver = DriverManager.getMouseDriver(oper);
169:                if (toper.isExpanded(index)) {
170:                    queueTool.invokeSmoothly(new QueueTool.QueueAction(
171:                            "Path selecting") {
172:                        public Object launch() {
173:                            Point p = toper.getPointToClick(index);
174:                            mdriver
175:                                    .clickMouse(
176:                                            toper,
177:                                            p.x,
178:                                            p.y,
179:                                            2,
180:                                            Operator.getDefaultMouseButton(),
181:                                            0,
182:                                            toper
183:                                                    .getTimeouts()
184:                                                    .create(
185:                                                            "ComponentOperator.MouseClickTimeout"));
186:                            return (null);
187:                        }
188:                    });
189:                }
190:            }
191:
192:            public void editItem(ComponentOperator oper, int index,
193:                    Object newValue, Timeout waitEditorTime) {
194:                JTextComponentOperator textoper = startEditingAndReturnEditor(
195:                        oper, index, waitEditorTime);
196:                final TextDriver text = DriverManager
197:                        .getTextDriver(JTextComponentOperator.class);
198:                text.clearText(textoper);
199:                text.typeText(textoper, newValue.toString(), 0);
200:                DriverManager.getKeyDriver(oper).pushKey(
201:                        textoper,
202:                        KeyEvent.VK_ENTER,
203:                        0,
204:                        oper.getTimeouts().create(
205:                                "ComponentOperator.PushKeyTimeout"));
206:            }
207:
208:            public void startEditing(ComponentOperator oper, int index,
209:                    Timeout waitEditorTime) {
210:                startEditingAndReturnEditor(oper, index, waitEditorTime);
211:            }
212:
213:            private JTextComponentOperator startEditingAndReturnEditor(
214:                    ComponentOperator oper, final int index,
215:                    Timeout waitEditorTime) {
216:                checkSupported(oper);
217:                final JTreeOperator toper = (JTreeOperator) oper;
218:                final MouseDriver mdriver = DriverManager.getMouseDriver(oper);
219:                queueTool.invokeSmoothly(new QueueTool.QueueAction(
220:                        "Path selecting") {
221:                    public Object launch() {
222:                        Point p = toper.getPointToClick(index);
223:                        mdriver.clickMouse(toper, p.x, p.y, 1, Operator
224:                                .getDefaultMouseButton(), 0, toper
225:                                .getTimeouts().create(
226:                                        "ComponentOperator.MouseClickTimeout"));
227:                        return (null);
228:                    }
229:                });
230:                oper.getTimeouts().sleep("JTreeOperator.BeforeEditTimeout");
231:                queueTool.invokeSmoothly(new QueueTool.QueueAction(
232:                        "Path selecting") {
233:                    public Object launch() {
234:                        Point p = toper.getPointToClick(index);
235:                        mdriver.clickMouse(toper, p.x, p.y, 1, Operator
236:                                .getDefaultMouseButton(), 0, toper
237:                                .getTimeouts().create(
238:                                        "ComponentOperator.MouseClickTimeout"));
239:                        return (null);
240:                    }
241:                });
242:                toper.getTimeouts().setTimeout(
243:                        "ComponentOperator.WaitComponentTimeout",
244:                        waitEditorTime.getValue());
245:                return (new JTextComponentOperator(
246:                        (JTextComponent) toper
247:                                .waitSubComponent(new JTextComponentOperator.JTextComponentFinder())));
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.