Source Code Cross Referenced for UMLProject.java in  » IDE-Netbeans » uml » org » netbeans » test » umllib » project » 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.umllib.project 
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 Versio3n 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.umllib.project;
043:
044:        import javax.swing.ComboBoxModel;
045:        import javax.swing.JComboBox;
046:        import javax.swing.JTextField;
047:        import org.netbeans.api.project.ProjectInformation;
048:        import org.netbeans.api.project.ProjectUtils;
049:        import org.netbeans.jellytools.NewProjectWizardOperator;
050:        import org.netbeans.jellytools.OutputTabOperator;
051:        import org.netbeans.jellytools.ProjectsTabOperator;
052:        import org.netbeans.jellytools.TopComponentOperator;
053:        import org.netbeans.jellytools.nodes.Node;
054:        import org.netbeans.jemmy.operators.ContainerOperator;
055:        import org.netbeans.jemmy.operators.JButtonOperator;
056:        import org.netbeans.jemmy.operators.JComboBoxOperator;
057:        import org.netbeans.jemmy.operators.JDialogOperator;
058:        import org.netbeans.jemmy.operators.JEditorPaneOperator;
059:        import org.netbeans.jemmy.operators.JLabelOperator;
060:        import org.netbeans.jemmy.operators.JTextFieldOperator;
061:        import org.netbeans.jemmy.operators.Operator.StringComparator;
062:        import org.netbeans.test.umllib.DiagramTypes;
063:        import org.netbeans.test.umllib.NewDiagramWizardOperator;
064:        import org.netbeans.test.umllib.NewPackageWizardOperator;
065:        import org.netbeans.test.umllib.exceptions.NotFoundException;
066:        import org.netbeans.test.umllib.exceptions.UMLCommonException;
067:        import org.netbeans.test.umllib.util.LabelsAndTitles;
068:        import org.netbeans.test.umllib.util.PopupConstants;
069:        import org.netbeans.test.umllib.util.Utils;
070:
071:        public class UMLProject extends Project {
072:
073:            /** Creates a new instance of JavaProject */
074:            private static long TIME_WAIT = 1000;
075:
076:            private static String PROJECT_NAME_LABEL = "Project Name:";
077:            private static String PROJECT_LOCATION_LABEL = "Project Location:";
078:
079:            String javaProjectName;
080:            Node projectNode;
081:
082:            /**
083:             *
084:             * @param name
085:             * @param type
086:             */
087:            public UMLProject(String name, ProjectType type) {
088:                this (name, type, null);
089:            }
090:
091:            /**
092:             *
093:             * @param name
094:             * @param type
095:             * @param location
096:             */
097:            public UMLProject(String name, ProjectType type, String location) {
098:                this (name, type, location, null);
099:            }
100:
101:            /**
102:             *
103:             * @param name
104:             * @param type
105:             * @param location
106:             * @param javaProject
107:             */
108:            public UMLProject(String name, ProjectType type, String location,
109:                    String javaProject) {
110:                super (name, type, location);
111:                this .javaProjectName = javaProject;
112:                try {
113:                    Thread.sleep(TIME_WAIT);
114:                } catch (Exception e) {
115:                }
116:                projectNode = new Node(ProjectsTabOperator.invoke().tree(),
117:                        name);
118:
119:            }
120:
121:            /**
122:             *
123:             * @return
124:             */
125:            public String getJavaProjectName() {
126:                return javaProjectName;
127:            }
128:
129:            /**
130:             *
131:             * @return
132:             */
133:            public Node getProjectNode() {
134:                return projectNode;
135:            }
136:
137:            /**
138:             *
139:             * @param name
140:             * @param type
141:             * @return
142:             */
143:            public static UMLProject createProject(String name, ProjectType type) {
144:                return createProject(name, type, Utils.WORK_DIR, null);
145:            }
146:
147:            /**
148:             *
149:             * @param name
150:             * @param type
151:             * @param javaProject
152:             * @return
153:             */
154:            public static UMLProject createProject(String name,
155:                    ProjectType type, JavaProject javaProject) {
156:                return createProject(name, type, javaProject.getLocation(),
157:                        javaProject.getName());
158:            }
159:
160:            /**
161:             *
162:             * @param name
163:             * @param type
164:             * @param location
165:             * @return
166:             */
167:            public static UMLProject createProject(String name,
168:                    ProjectType type, String location) {
169:                return createProject(name, type, location, null);
170:            }
171:
172:            /**
173:             *
174:             * @param name
175:             * @param type
176:             * @param location
177:             * @param javaProjectName
178:             * @return
179:             */
180:            public static UMLProject createProject(String name,
181:                    ProjectType type, String location, String javaProjectName) {
182:
183:                location = (location == null) ? Utils.WORK_DIR : location;
184:
185:                NewProjectWizardOperator newProject = NewProjectWizardOperator
186:                        .invoke();
187:                try {
188:                    Thread.sleep(TIME_WAIT);
189:                } catch (Exception e) {
190:                }
191:                try {
192:                    Thread.sleep(TIME_WAIT * 4);
193:                } catch (Exception e) {
194:                }
195:
196:                newProject.selectCategory(LabelsAndTitles.PROJECT_CATEGORY_UML);
197:                newProject.selectProject(type.toString());
198:
199:                newProject.next();
200:
201:                try {
202:                    Thread.sleep(TIME_WAIT);
203:                } catch (Exception e) {
204:                }
205:
206:                //newProject.setName(name);
207:
208:                //new JTextFieldOperator(newProject, 0).setText(name);
209:                JLabelOperator prNmLabl = new JLabelOperator(newProject,
210:                        PROJECT_NAME_LABEL);
211:                new JTextFieldOperator((JTextField) (prNmLabl.getLabelFor()))
212:                        .setText(name);
213:
214:                try {
215:                    Thread.sleep(TIME_WAIT);
216:                } catch (Exception e) {
217:                }
218:
219:                //JTextFieldOperator projectLocation = new JTextFieldOperator(newProject, 1);
220:                JLabelOperator prLocLabl = new JLabelOperator(newProject,
221:                        PROJECT_LOCATION_LABEL);
222:                new JTextFieldOperator((JTextField) (prLocLabl.getLabelFor()))
223:                        .setText(location);
224:
225:                // projectLocation.setText(location);
226:
227:                if (javaProjectName != null) {
228:
229:                    switch (type) {
230:
231:                    case UML_JAVA_PLATFORM_MODEL:
232:
233:                        throw new UMLCommonException(
234:                                "Unsupported request: java platform uml project connected to java project");
235:
236:                    case UML_JAVA_REVERSE_ENGINEERING:
237:
238:                        JLabelOperator javaPrjLbl = new JLabelOperator(
239:                                newProject, "Java Project:");
240:                        JComboBoxOperator javaPrj = new JComboBoxOperator(
241:                                (JComboBox) (javaPrjLbl.getLabelFor()));
242:                        int ind = javaPrj.findItemIndex(javaProjectName,
243:                                javaPrj.getDefaultStringComparator());
244:                        if (ind < 0) {
245:                            //org.netbeans.modules.java.j2seproject.J2SEProject tmp2;
246:                            // tmp2.getLookup();
247:                            int count = javaPrj.getItemCount();
248:                            String tmp = "";
249:                            for (int i = 0; i < count; i++) {
250:                                org.netbeans.api.project.Project pr = ((org.netbeans.api.project.Project) (javaPrj
251:                                        .getItemAt(i)));
252:                                ProjectInformation pi = ProjectUtils
253:                                        .getInformation(pr);
254:                                tmp += javaPrj.getItemAt(i) + "////\\\\"
255:                                        + pi.getName() + "; ";
256:                                if (javaPrj.getDefaultStringComparator()
257:                                        .equals(javaProjectName, pi.getName())) {
258:                                    ind = i;
259:                                    break;
260:                                }
261:                            }
262:                            if (ind < 0)
263:                                throw new NotFoundException(
264:                                        "Can't find java project with name \""
265:                                                + javaProjectName
266:                                                + "\" in project's combobox, current: "
267:                                                + javaPrj + ", all items: "
268:                                                + tmp);
269:                        }
270:                        javaPrj.selectItem(ind);
271:                        javaPrj.waitItemSelected(ind);
272:
273:                        break;
274:
275:                    }
276:
277:                }
278:
279:                new JButtonOperator(newProject, "Finish").push();
280:                //
281:
282:                if (type.equals(ProjectType.UML_JAVA_PLATFORM_MODEL)
283:                        || type
284:                                .equals(ProjectType.UML_PLATFORM_INDEPENDET_MODEL)) {
285:                    try {
286:                        Thread.sleep(TIME_WAIT);
287:                    } catch (Exception e) {
288:                    }
289:                    try {
290:                        NewDiagramWizardOperator wizardDialog = new NewDiagramWizardOperator();
291:                        wizardDialog.clickCancel();
292:                    } catch (Exception ex) {
293:
294:                    }
295:                }
296:                //
297:                newProject.waitClosed();
298:                //may be very fast
299:                try {
300:                    JDialogOperator opPr = new JDialogOperator(
301:                            "Opening Project");
302:                    opPr.waitClosed();
303:                } catch (Exception ex) {
304:                }
305:                //
306:
307:                //check for output window fo re
308:                if (type.equals(ProjectType.UML_JAVA_REVERSE_ENGINEERING)) {
309:                    ContainerOperator reOut = null;
310:                    try {
311:                        reOut = new OutputTabOperator("Reverse Engineering Log");
312:                    } catch (Exception ex) {
313:                        try {
314:                            reOut = new TopComponentOperator(
315:                                    "Output - Reverse Engineering Log");
316:                        } catch (Exception ex2) {
317:                            throw new UMLCommonException(
318:                                    "Can't initialize/find output window/tab: "
319:                                            + ex + ";" + ex2);
320:                        }
321:                    }
322:                    new JEditorPaneOperator(reOut).waitText("Task Successful");
323:                }
324:                //
325:                //
326:
327:                return new UMLProject(name, type, location, javaProjectName);
328:
329:            }
330:
331:            public void reverseEngineerOperation(String node,
332:                    String diagramName, DiagramTypes diagramType) {
333:                reverseEngineerOperation(new Node(getProjectNode(), node),
334:                        diagramName, diagramType);
335:            }
336:
337:            public void reverseEngineerOperation(Node node, String diagramName,
338:                    DiagramTypes diagramType) {
339:
340:                node
341:                        .performPopupActionNoBlock(PopupConstants.REVERSE_ENGINEER_OPERATION);
342:
343:                NewDiagramWizardOperator dw = new NewDiagramWizardOperator();
344:                dw.setDiagramType(diagramType.toString());
345:                dw.setDiagramName(diagramName);
346:                dw.clickFinish();
347:
348:            }
349:
350:            public void addPackage(Node node, String packageName) {
351:                addPackage(node, packageName, null, null);
352:            }
353:
354:            public void addPackage(Node node, String packageName,
355:                    String diagramName, DiagramTypes diagramType) {
356:
357:                node.performPopupActionNoBlock(PopupConstants.ADD_PACKAGE);
358:                NewPackageWizardOperator pw = new NewPackageWizardOperator();
359:                pw.setPackageName(packageName);
360:
361:                if (diagramName != null) {
362:
363:                    pw.setCreateDiagram(true);
364:                    pw.setDiagramType(diagramType.toString());
365:                    pw.setDiagramName(diagramName);
366:                }
367:
368:                pw.clickFinish();
369:
370:            }
371:
372:            public void generateCode(JavaProject javaProject) {
373:                generateCode(getProjectNode(), javaProject);
374:            }
375:
376:            /* public void generateCode(Node node, JavaProject javaProject){
377:                 generateCode(node, javaProject.getLocation() + "/" + javaProject.getName() + "/src");
378:             }*/
379:
380:            public void generateCode(Node node, JavaProject javaProject) {
381:                generateCode(node, javaProject.getName());
382:            }
383:
384:            public void generateCode(Node node, String javaProjectName) {
385:
386:                node.performPopupActionNoBlock("Generate Code...");
387:                JDialogOperator codeGenDialog = new JDialogOperator(
388:                        "Generate Code");
389:
390:                JLabelOperator targetPrjLbl = new JLabelOperator(codeGenDialog,
391:                        "Target Project:");
392:                JComboBoxOperator targetPrj = new JComboBoxOperator(
393:                        (JComboBox) (targetPrjLbl.getLabelFor()));
394:                int ind = findItemIndex(targetPrj, javaProjectName, targetPrj
395:                        .getDefaultStringComparator());
396:                if (ind < 0) {
397:                    int count = targetPrj.getItemCount();
398:                    String tmp = "";
399:                    for (int i = 0; i < count; i++) {
400:                        org.netbeans.api.project.Project pr = (org.netbeans.api.project.Project) (targetPrj
401:                                .getItemAt(i));
402:                        ProjectInformation pi = ProjectUtils.getInformation(pr);
403:                        tmp += targetPrj.getItemAt(i) + "////\\\\"
404:                                + pi.getName() + "; ";
405:                        if (targetPrj.getDefaultStringComparator().equals(
406:                                javaProjectName, pi.getName())) {
407:                            ind = i;
408:                            break;
409:                        }
410:                    }
411:                    if (ind < 0) {
412:                        throw new NotFoundException(
413:                                "Can't find target project with name \""
414:                                        + javaProjectName
415:                                        + "\" in project's combobox, current: "
416:                                        + targetPrj + ", all items: " + tmp);
417:                    }
418:                }
419:                targetPrj.selectItem(ind);
420:                targetPrj.waitItemSelected(ind);
421:                try {
422:                    Thread.sleep(2000);
423:                } catch (Exception e) {
424:                }
425:                JButtonOperator button = new JButtonOperator(codeGenDialog,
426:                        "OK");
427:                button.pushNoBlock();
428:            }
429:
430:            // same as JComboBoxOperator.findItemIndex, plus handles blank option
431:            public int findItemIndex(JComboBoxOperator comboBoxOperator,
432:                    String item, StringComparator comparator) {
433:                ComboBoxModel model = comboBoxOperator.getModel();
434:                for (int i = 0; i < model.getSize(); i++) {
435:                    if (model.getElementAt(i) != null) {
436:                        if (comparator.equals(model.getElementAt(i).toString(),
437:                                item)) {
438:                            return (i);
439:                        }
440:                    }
441:                }
442:                return (-1);
443:            }
444:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.