Source Code Cross Referenced for MUPUtils.java in  » IDE-Netbeans » uml » org » netbeans » test » uml » multipleprojects » utils » 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 » uml » org.netbeans.test.uml.multipleprojects.utils 
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 org.netbeans.test.uml.multipleprojects.utils;
043:
044:        import java.awt.AWTException;
045:        import java.awt.Point;
046:        import java.awt.Rectangle;
047:        import java.awt.Robot;
048:        import java.awt.event.KeyEvent;
049:        import java.io.FileNotFoundException;
050:        import javax.swing.SwingUtilities;
051:        import org.netbeans.jellytools.ProjectsTabOperator;
052:        import org.netbeans.jellytools.nodes.*;
053:        import org.netbeans.jemmy.EventTool;
054:        import org.netbeans.jemmy.JemmyProperties;
055:        import org.netbeans.test.umllib.DiagramOperator;
056:        import org.netbeans.test.umllib.MovingElementsOperator;
057:        import org.netbeans.test.umllib.NewDiagramWizardOperator;
058:        import org.netbeans.test.umllib.NewElementWizardOperator;
059:        import org.netbeans.test.umllib.NewPackageWizardOperator;
060:        import org.netbeans.test.umllib.Utils;
061:        import org.netbeans.test.umllib.util.PopupConstants;
062:
063:        /**
064:         * @author yaa
065:         */
066:        public class MUPUtils {
067:
068:            public MUPUtils() {
069:            }
070:
071:            public static DiagramOperator openDiagram(String pName,
072:                    String dName, String dType, String path) {
073:                long timeout = JemmyProperties
074:                        .getCurrentTimeout("DiagramOperator.WaitDiagramOperator");
075:                JemmyProperties.setCurrentTimeout(
076:                        "DiagramOperator.WaitDiagramOperator", 3000);
077:                try {
078:                    DiagramOperator diagram = new DiagramOperator(dName);
079:                    return diagram;
080:                } catch (Exception e) {
081:                } finally {
082:                    JemmyProperties.setCurrentTimeout(
083:                            "DiagramOperator.WaitDiagramOperator", timeout);
084:                }
085:
086:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
087:                ProjectRootNode root = null;
088:                timeout = JemmyProperties
089:                        .getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
090:                JemmyProperties.setCurrentTimeout(
091:                        "JTreeOperator.WaitNextNodeTimeout", 3000);
092:                try {
093:                    root = new ProjectRootNode(pto.tree(), pName);
094:                } catch (Exception e) {
095:                    try {
096:                        Utils.createJavaUMLProject(pName, path);
097:                    } catch (Exception e1) {
098:                        return null;
099:                    }
100:                    root = new ProjectRootNode(pto.tree(), pName);
101:                } finally {
102:                    JemmyProperties.setCurrentTimeout(
103:                            "JTreeOperator.WaitNextNodeTimeout", timeout);
104:                }
105:
106:                try {
107:                    Node nodeDiagrams = new Node(root, "Diagrams");
108:                    Node nodeDiagram = new Node(nodeDiagrams, dName);
109:                    pto.tree().clickOnPath(nodeDiagram.getTreePath(), 2);
110:                } catch (Exception e) {
111:                    Node nodeModel = new Node(root, "Model");
112:                    nodeModel
113:                            .performPopupActionNoBlock(PopupConstants.ADD_DIAGRAM);
114:                    timeout = JemmyProperties
115:                            .getCurrentTimeout("DialogWaiter.WaitDialogTimeout");
116:                    JemmyProperties.setCurrentTimeout(
117:                            "DialogWaiter.WaitDialogTimeout", 3000);
118:                    NewDiagramWizardOperator wiz = new NewDiagramWizardOperator();
119:                    JemmyProperties.setCurrentTimeout(
120:                            "DialogWaiter.WaitDialogTimeout", timeout);
121:                    wiz.setDiagramType(dType);
122:                    wiz.setDiagramName(dName);
123:                    wiz.clickOK();
124:                }
125:                JemmyProperties.setCurrentTimeout(
126:                        "JTreeOperator.WaitNextNodeTimeout", timeout);
127:                try {
128:                    Thread.sleep(500);
129:                } catch (Exception ex) {
130:                }
131:                return new DiagramOperator(dName);
132:            }
133:
134:            public static Node selectElementInModelTree(String prName,
135:                    String elName) {
136:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
137:                ProjectRootNode root = null;
138:                long timeout = JemmyProperties
139:                        .getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
140:                JemmyProperties.setCurrentTimeout(
141:                        "JTreeOperator.WaitNextNodeTimeout", 3000);
142:                try {
143:                    root = new ProjectRootNode(pto.tree(), prName);
144:                    Node nodeModel = new Node(root, "Model");
145:                    Node nodeElem = new Node(nodeModel, elName);
146:                    nodeElem.select();
147:                    return nodeElem;
148:                } catch (Exception e) {
149:                    return null;
150:                } finally {
151:                    JemmyProperties.setCurrentTimeout(
152:                            "JTreeOperator.WaitNextNodeTimeout", timeout);
153:                }
154:            }
155:
156:            public static Node selectElementInImportTree(String prName,
157:                    String elName) {
158:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
159:                ProjectRootNode root = null;
160:                long timeout = JemmyProperties
161:                        .getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
162:                JemmyProperties.setCurrentTimeout(
163:                        "JTreeOperator.WaitNextNodeTimeout", 3000);
164:                try {
165:                    root = new ProjectRootNode(pto.tree(), prName);
166:                    Node nodeImportedElements = new Node(root,
167:                            "Imported Elements");
168:                    Node nodeElem = new Node(nodeImportedElements, elName);
169:                    nodeElem.select();
170:                    return nodeElem;
171:                } catch (Exception e) {
172:                    return null;
173:                } finally {
174:                    JemmyProperties.setCurrentTimeout(
175:                            "JTreeOperator.WaitNextNodeTimeout", timeout);
176:                }
177:            }
178:
179:            public static void createElement(String prName, String elName,
180:                    String elType) {
181:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
182:                new EventTool().waitNoEvent(1000);
183:                ProjectRootNode root = new ProjectRootNode(pto.tree(), prName);
184:                Node nodeModel = new Node(root, "Model");
185:
186:                nodeModel.performPopupActionNoBlock(PopupConstants.ADD_ELEMENT);
187:                //JPopupMenuOperator popup = nodeModel.callPopup();
188:                //popup.pushMenuNoBlock(PopupConstants.ADD_ELEMENT);
189:
190:                new EventTool().waitNoEvent(1000);
191:
192:                NewElementWizardOperator ewo = new NewElementWizardOperator();
193:                ewo.setElementType(elType);
194:                ewo.setElementName(elName);
195:                ewo.clickFinish();
196:
197:                new EventTool().waitNoEvent(1000);
198:
199:                Node nodeElem = new Node(nodeModel, elName);
200:                nodeElem.select();
201:            }
202:
203:            public static void createPackage(String prName, String pkgName)
204:                    throws Exception {
205:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
206:                ProjectRootNode root = null;
207:                long timeout = JemmyProperties
208:                        .getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
209:                JemmyProperties.setCurrentTimeout(
210:                        "JTreeOperator.WaitNextNodeTimeout", 3000);
211:                try {
212:                    root = new ProjectRootNode(pto.tree(), prName);
213:                    Node nodeModel = new Node(root, "Model");
214:
215:                    nodeModel
216:                            .performPopupActionNoBlock(PopupConstants.ADD_PACKAGE);
217:                    //JPopupMenuOperator popup = nodeModel.callPopup();
218:                    //popup.pushMenuNoBlock(PopupConstants.ADD_PACKAGE);
219:
220:                    NewPackageWizardOperator pwo = new NewPackageWizardOperator();
221:                    pwo.setPackageName(pkgName);
222:                    pwo.clickFinish();
223:
224:                    new EventTool().waitNoEvent(1000);
225:
226:                    Node nodePkg = new Node(nodeModel, pkgName);
227:                    nodePkg.select();
228:                } catch (Exception e) {
229:                    throw e;
230:                } finally {
231:                    JemmyProperties.setCurrentTimeout(
232:                            "JTreeOperator.WaitNextNodeTimeout", timeout);
233:                }
234:            }
235:
236:            public static boolean moveElementInTree(String srcProject,
237:                    String tgtProject, String elName) {
238:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
239:                ProjectRootNode root = null;
240:                long timeout = JemmyProperties
241:                        .getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
242:                JemmyProperties.setCurrentTimeout(
243:                        "JTreeOperator.WaitNextNodeTimeout", 3000);
244:                try {
245:                    Node nodeSrc = new Node(new ProjectRootNode(pto.tree(),
246:                            srcProject), "Model|" + elName);
247:                    Node nodeTgt = new Node(new ProjectRootNode(pto.tree(),
248:                            tgtProject), "Model");
249:
250:                    nodeTgt.select();
251:                    nodeSrc.select();
252:
253:                    Rectangle rec1 = pto.tree().getPathBounds(
254:                            nodeSrc.getTreePath());
255:                    Point point1 = new Point(rec1.x + rec1.width / 2, rec1.y
256:                            + rec1.height / 2);
257:                    SwingUtilities.convertPointToScreen(point1, pto.tree()
258:                            .getSource());
259:
260:                    Rectangle rec2 = pto.tree().getPathBounds(
261:                            nodeTgt.getTreePath());
262:                    Point point2 = new Point(rec2.x + rec2.width / 2, rec2.y
263:                            + rec2.height / 2);
264:                    SwingUtilities.convertPointToScreen(point2, pto.tree()
265:                            .getSource());
266:
267:                    dragNDrop(point1, point2);
268:
269:                    new MovingElementsOperator().clickMoveElement();
270:
271:                    return true;
272:                } catch (Exception e) {
273:                    return false;
274:                } finally {
275:                    JemmyProperties.setCurrentTimeout(
276:                            "JTreeOperator.WaitNextNodeTimeout", timeout);
277:                }
278:            }
279:
280:            public static boolean importElementInTree(String srcProject,
281:                    String tgtProject, String elName)
282:                    throws FileNotFoundException {
283:                // moving element
284:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
285:                ProjectRootNode root = null;
286:                long timeout = JemmyProperties
287:                        .getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
288:                JemmyProperties.setCurrentTimeout(
289:                        "JTreeOperator.WaitNextNodeTimeout", 3000);
290:                try {
291:                    Node nodeSrc = new Node(new ProjectRootNode(pto.tree(),
292:                            srcProject), "Model|" + elName);
293:                    Node nodeTgt = new Node(new ProjectRootNode(pto.tree(),
294:                            tgtProject), "Model");
295:
296:                    nodeTgt.select();
297:                    nodeSrc.select();
298:
299:                    Rectangle rec1 = pto.tree().getPathBounds(
300:                            nodeSrc.getTreePath());
301:                    Point point1 = new Point(rec1.x + rec1.width / 2, rec1.y
302:                            + rec1.height / 2);
303:                    SwingUtilities.convertPointToScreen(point1, pto.tree()
304:                            .getSource());
305:
306:                    Rectangle rec2 = pto.tree().getPathBounds(
307:                            nodeTgt.getTreePath());
308:                    Point point2 = new Point(rec2.x + rec2.width / 2, rec2.y
309:                            + rec2.height / 2);
310:                    SwingUtilities.convertPointToScreen(point2, pto.tree()
311:                            .getSource());
312:
313:                    dragNDrop(point1, point2);
314:
315:                    new MovingElementsOperator().clickImportElement();
316:
317:                    return true;
318:                } catch (Exception e) {
319:                    return false;
320:                } finally {
321:                    JemmyProperties.setCurrentTimeout(
322:                            "JTreeOperator.WaitNextNodeTimeout", timeout);
323:                }
324:            }
325:
326:            /*
327:             public static boolean moveElementToDiagram(String srcProject, String tgtProject, String elName, String diagramName){
328:             ProjectsTabOperator pto = ProjectsTabOperator.invoke();
329:             long timeout = JemmyProperties.getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
330:             JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 3000);
331:             try{
332:             Node nodeDiagram = new Node(new ProjectRootNode(pto.tree(),tgtProject), "Model|" + diagramName);
333:             nodeDiagram.callPopup().pushMenuNoBlock("Open");
334:             DiagramOperator dia = new DiagramOperator(diagramName);
335:            
336:             Node nodeSrc = new Node(new ProjectRootNode(pto.tree(),srcProject), "Model|" + elName);
337:             nodeSrc.select();
338:            
339:             Rectangle rec1 = pto.tree().getPathBounds(nodeSrc.getTreePath());
340:             Point point1 = new Point(rec1.x + rec1.width/2, rec1.y + rec1.height/2);
341:             SwingUtilities.convertPointToScreen(point1, pto.tree().getSource());
342:            
343:             Point point2 = dia.getDrawingArea().getFreePoint();
344:             SwingUtilities.convertPointToScreen(point2, dia.getDrawingArea().getSource());
345:            
346:             dragNDrop(point1, point2);
347:            
348:             new MovingElementsOperator().clickMoveElement();
349:            
350:             return true;
351:             }catch(Exception e){
352:             return false;
353:             }finally{
354:             JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", timeout);
355:             }
356:             }
357:             */
358:            public static boolean importElementToDiagram(String srcProject,
359:                    String tgtProject, String elName, String diagramName) {
360:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
361:                long timeout = JemmyProperties
362:                        .getCurrentTimeout("JTreeOperator.WaitNextNodeTimeout");
363:                JemmyProperties.setCurrentTimeout(
364:                        "JTreeOperator.WaitNextNodeTimeout", 3000);
365:                try {
366:                    Node nodeDiagram = new Node(new ProjectRootNode(pto.tree(),
367:                            tgtProject), "Model|" + diagramName);
368:                    nodeDiagram.callPopup().pushMenuNoBlock("Open");
369:                    DiagramOperator dia = new DiagramOperator(diagramName);
370:
371:                    Node nodeSrc = new Node(new ProjectRootNode(pto.tree(),
372:                            srcProject), "Model|" + elName);
373:                    nodeSrc.select();
374:
375:                    Rectangle rec1 = pto.tree().getPathBounds(
376:                            nodeSrc.getTreePath());
377:                    Point point1 = new Point(rec1.x + rec1.width / 2, rec1.y
378:                            + rec1.height / 2);
379:                    SwingUtilities.convertPointToScreen(point1, pto.tree()
380:                            .getSource());
381:
382:                    Point point2 = dia.getDrawingArea().getFreePoint();
383:                    SwingUtilities.convertPointToScreen(point2, dia
384:                            .getDrawingArea().getSource());
385:
386:                    dragNDrop(point1, point2);
387:
388:                    return true;
389:                } catch (Exception e) {
390:                    return false;
391:                } finally {
392:                    JemmyProperties.setCurrentTimeout(
393:                            "JTreeOperator.WaitNextNodeTimeout", timeout);
394:                }
395:            }
396:
397:            private static void dragNDrop(Point p1, Point p2)
398:                    throws AWTException, InterruptedException {
399:                Robot r = new Robot();
400:                r.mouseMove(p1.x, p1.y);
401:                r.mousePress(KeyEvent.BUTTON1_MASK);
402:
403:                r.mouseMove(p2.x, p2.y);
404:                r.mouseRelease(KeyEvent.BUTTON1_MASK);
405:                Thread.sleep(1000);
406:                r.mouseMove(p2.x, p2.y + 5);
407:            }
408:
409:            public static void pushKey(int key) throws AWTException,
410:                    InterruptedException {
411:                Robot r = new Robot();
412:                r.keyPress(key);
413:                Thread.sleep(100);
414:                r.keyRelease(key);
415:            }
416:
417:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.