Source Code Cross Referenced for WebFormDesignerOperator.java in  » IDE-Netbeans » performance » gui » window » 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 » performance » gui.window 
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-2007 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 gui.window;
043:
044:        import java.awt.Component;
045:
046:        import org.netbeans.jellytools.Bundle;
047:        import org.netbeans.jellytools.NbDialogOperator;
048:        import org.netbeans.jellytools.TopComponentOperator;
049:
050:        import org.netbeans.jemmy.ComponentChooser;
051:        import org.netbeans.jemmy.JemmyException;
052:        import org.netbeans.jemmy.JemmyProperties;
053:        import org.netbeans.jemmy.QueueTool;
054:        import org.netbeans.jemmy.TimeoutExpiredException;
055:        import org.netbeans.jemmy.operators.ComponentOperator;
056:        import org.netbeans.jemmy.operators.JButtonOperator;
057:        import org.netbeans.jemmy.operators.JPopupMenuOperator;
058:        import org.netbeans.jemmy.operators.JToggleButtonOperator;
059:        import org.netbeans.jemmy.operators.Operator;
060:        import org.netbeans.jemmy.operators.ContainerOperator;
061:
062:        /**
063:         *
064:         * @author mkhramov@netbeans.org, mmirilovic@netbeans.org
065:         */
066:        public class WebFormDesignerOperator extends TopComponentOperator {
067:
068:            private ComponentOperator surfacecomp = null;
069:
070:            /**
071:             * Creates a new instance of WebFormDesignerOperator
072:             * @param topComponentName creating component name
073:             */
074:            public WebFormDesignerOperator(String topComponentName) {
075:                this (topComponentName, 0);
076:            }
077:
078:            public WebFormDesignerOperator(String topComponentName, int Index) {
079:                //super(topComponentName,Index);
080:                super (TopComponentOperator.waitTopComponent(null,
081:                        topComponentName, Index,
082:                        new WebFormDesignerSubchooser()));
083:                try {
084:                    surfacecomp = new ComponentOperator(this ,
085:                            new DesignerPaneChooser());
086:                } catch (TimeoutExpiredException tex) {
087:                    JemmyProperties.getCurrentOutput().getOutput().println(
088:                            "TimeoutExpired exception");
089:                    throw new JemmyException(
090:                            "Cannot find designer surface because of expired timeout");
091:                }
092:            }
093:
094:            /**
095:             * Find web designer operator located certain top component
096:             * @param topComponentName name of the top component
097:             * @return WebFormDesignerOperator
098:             */
099:            public static WebFormDesignerOperator findWebFormDesignerOperator(
100:                    String topComponentName) {
101:                return findWebFormDesignerOperator(topComponentName, true);
102:            }
103:
104:            /**
105:             * Find web designer operator located certain top component
106:             * @param topComponentName name of the top component
107:             * @param exactlyMatch flag to match component name exactly
108:             * @return WebFormDesignerOperator
109:             */
110:            public static WebFormDesignerOperator findWebFormDesignerOperator(
111:                    String topComponentName, boolean exactlyMatch) {
112:                long oldTimeout = JemmyProperties.getCurrentTimeouts()
113:                        .getTimeout("ComponentOperator.WaitComponentTimeout");
114:                JemmyProperties.getCurrentTimeouts().setTimeout(
115:                        "ComponentOperator.WaitComponentTimeout", 120000);
116:
117:                StringComparator oldOperator = Operator
118:                        .getDefaultStringComparator();
119:                if (exactlyMatch) {
120:                    Operator
121:                            .setDefaultStringComparator(new DefaultStringComparator(
122:                                    false, false));
123:                }
124:                WebFormDesignerOperator webFormDesignerOperator = new WebFormDesignerOperator(
125:                        topComponentName);
126:                Operator.setDefaultStringComparator(oldOperator);
127:                JemmyProperties.getCurrentTimeouts().setTimeout(
128:                        "ComponentOperator.WaitComponentTimeout", oldTimeout);
129:                return webFormDesignerOperator;
130:            }
131:
132:            public void switchToDesignView() {
133:                ContainerOperator JSFContainer = new ContainerOperator(this 
134:                        .getParent().getParent());
135:                JToggleButtonOperator designViewButton = new JToggleButtonOperator(
136:                        JSFContainer, "Design"); // NOI18N
137:
138:                if (!designViewButton.isSelected())
139:                    designViewButton.pushNoBlock();
140:            }
141:
142:            public void switchToJSPView() {
143:                ContainerOperator JSFContainer = new ContainerOperator(this 
144:                        .getParent().getParent());
145:                JToggleButtonOperator jspViewButton = new JToggleButtonOperator(
146:                        JSFContainer, "JSP"); // NOI18N
147:
148:                if (!jspViewButton.isSelected())
149:                    jspViewButton.pushNoBlock();
150:            }
151:
152:            public void switchToCodeView() {
153:                ContainerOperator JSFContainer = new ContainerOperator(this 
154:                        .getParent().getParent());
155:                JToggleButtonOperator javaViewButton = new JToggleButtonOperator(
156:                        JSFContainer, "Java"); // NOI18N
157:
158:                if (!javaViewButton.isSelected())
159:                    javaViewButton.pushNoBlock();
160:            }
161:
162:            @Override
163:            public void closeDiscard() {
164:
165:                new Thread(new Runnable() {
166:                    public void run() {
167:                        pushMenuOnTab(Bundle.getStringTrimmed(
168:                                "org.netbeans.core.windows.actions.Bundle",
169:                                "LBL_CloseWindowAction"));
170:                    };
171:                }, "thread to close TopComponent").start();
172:
173:                try {
174:                    Thread.currentThread().sleep(1000);
175:                } catch (InterruptedException ex) {
176:                    // do nothing
177:                }
178:
179:                try {
180:                    NbDialogOperator dop = new NbDialogOperator("Question"); // NOI18N
181:                    JButtonOperator but = new JButtonOperator(dop, "Discard"); // NOI18N
182:                    but.push();
183:                } catch (TimeoutExpiredException exc) {
184:                    // do nothing
185:                }
186:            }
187:
188:            public void cancelSelection() {
189:                this .getDesignerPaneComponentOperator().pushKey(
190:                        java.awt.event.KeyEvent.VK_ESCAPE);
191:            }
192:
193:            public void deleteSelection() {
194:                this .getDesignerPaneComponentOperator().pushKey(
195:                        java.awt.event.KeyEvent.VK_DELETE);
196:            }
197:
198:            public void clickOnSurface() {
199:                getDesignerPaneComponentOperator().clickMouse();
200:                new QueueTool().waitEmpty();
201:            }
202:
203:            public void clickOnSurface(int x, int y) {
204:                getDesignerPaneComponentOperator().clickMouse(x, y, 1);
205:                new QueueTool().waitEmpty();
206:
207:            }
208:
209:            public JPopupMenuOperator clickPopup() {
210:                getDesignerPaneComponentOperator().clickForPopup();
211:                return new JPopupMenuOperator();
212:            }
213:
214:            public JPopupMenuOperator clickPopup(int x, int y) {
215:                getDesignerPaneComponentOperator().clickForPopup(x, y);
216:                return new JPopupMenuOperator();
217:            }
218:
219:            public void pushPopupMenu(String menuPath) {
220:                JPopupMenuOperator popup = clickPopup();
221:                popup.pushMenuNoBlock(menuPath);
222:            }
223:
224:            public void pushPopupMenu(String menuPath, int x, int y) {
225:                JPopupMenuOperator popup = clickPopup(x, y);
226:                popup.pushMenuNoBlock(menuPath);
227:            }
228:
229:            public ComponentOperator getDesignerPaneComponentOperator() {
230:                if (surfacecomp == null) {
231:                    throw new JemmyException(
232:                            "The design surface component is empty");
233:                }
234:                return surfacecomp;
235:            }
236:
237:            public void dump() {
238:                System.out.println("Dumping nested components");
239:                Component[] liss = null;
240:                try {
241:                    liss = this .getComponents();
242:                } catch (Exception ex) {
243:                    System.out.println("Exception during getComponents call");
244:                }
245:                System.out.println("Liss counted: " + liss.length);
246:                for (int i = 0; i < liss.length; i++) {
247:                    System.out.println(liss[i].toString());
248:                }
249:            }
250:
251:            public static final class DesignerPaneChooser implements 
252:                    ComponentChooser {
253:
254:                public boolean checkComponent(Component component) {
255:                    //dumpComponent(component);
256:                    // NB 5.5 class name
257:                    //return component.getClass().getName().equals("com.sun.rave.designer.DesignerPane");
258:                    // NB 6.0 class name
259:                    return component
260:                            .getClass()
261:                            .getName()
262:                            .equals(
263:                                    "org.netbeans.modules.visualweb.designer.DesignerPane");
264:                }
265:
266:                private void dumpComponent(Component component) {
267:                    System.out.println(component.getClass().toString());
268:                    System.out.println(component.getX());
269:                    System.out.println(component.getY());
270:                    System.out.println(component.getWidth());
271:                    System.out.println(component.getHeight());
272:
273:                }
274:
275:                public String getDescription() {
276:                    return "Designer Surface";
277:                }
278:            }
279:
280:            public static final class TopComponentSubchooser implements 
281:                    ComponentChooser {
282:
283:                public boolean checkComponent(Component component) {
284:                    JemmyProperties.getCurrentOutput().getOutput().println(
285:                            component.getClass().getName());
286:                    boolean result = component
287:                            .getClass()
288:                            .getName()
289:                            .equals(
290:                                    "org.netbeans.core.multiview.MultiViewCloneableTopComponent");
291:
292:                    return result;
293:                }
294:
295:                public String getDescription() {
296:                    return "Web Designer TopComponent";
297:                }
298:            }
299:
300:            public static final class WebFormDesignerSubchooser implements 
301:                    ComponentChooser {
302:                public boolean checkComponent(Component component) {
303:                    return component
304:                            .getClass()
305:                            .getName()
306:                            .equals(
307:                                    "org.netbeans.modules.visualweb.designer.jsf.ui.JsfTopComponent");
308:                }
309:
310:                public String getDescription() {
311:                    return "Web Designer Component";
312:                }
313:            }
314:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.