Source Code Cross Referenced for ProjectGenUtil.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » common » codegen » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.common.codegen 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         * Paul Mahar
021:         *
022:         */
023:        package org.enhydra.kelp.common.codegen;
024:
025:        // ToolBox
026:        import org.enhydra.tool.common.PathHandle;
027:        import org.enhydra.tool.codegen.ProjectGenerator;
028:        import org.enhydra.tool.codegen.ProjectOptionSet;
029:        import org.enhydra.tool.codegen.CodeGen;
030:        import org.enhydra.tool.codegen.OptionSet;
031:        import org.enhydra.tool.codegen.GeneratorException;
032:        import org.enhydra.tool.codegen.wizard.CodeGenPanel;
033:
034:        // AddinCore
035:        import org.enhydra.kelp.common.node.OtterProject;
036:        import org.enhydra.kelp.common.importer.ImportPaths;
037:        import org.enhydra.kelp.common.importer.ImportTool;
038:        import org.enhydra.kelp.common.ValidationException;
039:
040:        // JDK
041:        import java.awt.Component;
042:        import java.io.File;
043:        import java.util.ResourceBundle;
044:        import javax.swing.JOptionPane;
045:
046:        //
047:        abstract public class ProjectGenUtil {
048:
049:            // strings not to be resourced
050:            static ResourceBundle res = ResourceBundle
051:                    .getBundle("org.enhydra.kelp.common.Res"); // nores
052:            private final static String EXCEPTION_CREATE_GENERATOR = "ProjectGenUtil.createGenerator()"; // nores
053:
054:            //
055:            private OtterProject project = null;
056:            private CodeGen codeGen = null;
057:            private int option = JOptionPane.CANCEL_OPTION;
058:
059:            public static ProjectGenerator createGenerator()
060:                    throws CodeGenException {
061:                throw new CodeGenException(
062:                        ProjectGenUtil.EXCEPTION_CREATE_GENERATOR);
063:            }
064:
065:            /**
066:             * Constructor declaration
067:             *
068:             *
069:             */
070:            public ProjectGenUtil(ProjectGenerator gen) throws CodeGenException {
071:                try {
072:                    codeGen = new CodeGen(gen);
073:                } catch (GeneratorException e) {
074:                    throw new CodeGenException(e);
075:                }
076:            }
077:
078:            public ProjectGenUtil(OtterProject proj, ProjectGenerator gen)
079:                    throws CodeGenException {
080:                this (gen);
081:                init(proj);
082:            }
083:
084:            public CodeGen getCodeGen() {
085:                return codeGen;
086:            }
087:
088:            public void init(OtterProject proj) throws CodeGenException {
089:                project = proj;
090:                try {
091:                    initOptions();
092:                } catch (GeneratorException e) {
093:                    throw new CodeGenException(e);
094:                }
095:            }
096:
097:            /**
098:             * Method declaration
099:             *
100:             *
101:             * @return
102:             *
103:             * @exception GeneratorException
104:             */
105:            public CodeGenPanel[] getWizardPanels() throws CodeGenException {
106:                CodeGenPanel[] panels = null;
107:
108:                try {
109:                    panels = getGenerator().getWizardPanels();
110:                } catch (GeneratorException e) {
111:                    throw new CodeGenException(e);
112:                }
113:                return panels;
114:            }
115:
116:            /**
117:             * Method declaration
118:             *
119:             *
120:             * @return
121:             */
122:            public OtterProject getProject() {
123:                return project;
124:            }
125:
126:            /**
127:             * Method declaration
128:             *
129:             *
130:             * @return
131:             *
132:             * @exception GeneratorException
133:             */
134:            public File[] generate() throws CodeGenException {
135:                File[] files = new File[0];
136:
137:                try {
138:                    for (int i = 0; i < getGenerator().getWizardPanels().length; i++) {
139:                        getGenerator().getWizardPanels()[i].writeOptionSet();
140:                    }
141:                    getGenerator().setEcho(false);
142:                    files = getGenerator().generate();
143:                } catch (GeneratorException e) {
144:                    e.printStackTrace(System.err);
145:                    throw new CodeGenException(e);
146:                }
147:                importFiles(files);
148:                return files;
149:            }
150:
151:            public ProjectGenerator getGenerator() {
152:                ProjectGenerator generator = null;
153:
154:                generator = (ProjectGenerator) codeGen.getSelection();
155:                return generator;
156:            }
157:
158:            /**
159:             * Method declaration
160:             *
161:             *
162:             * @param owner
163:             *
164:             * @return
165:             */
166:            public File[] invokeWizard(Component owner) throws CodeGenException {
167:                File[] files = new File[0];
168:
169:                files = codeGen.invokeWizard(owner);
170:                option = codeGen.getOption();
171:                if (option == JOptionPane.CANCEL_OPTION) {
172:
173:                    // done
174:                } else if (files != null) {
175:                    importFiles(files);
176:                }
177:                return files;
178:            }
179:
180:            /**
181:             * Method declaration
182:             *
183:             * @return
184:             */
185:            public int getOption() {
186:                return option;
187:            }
188:
189:            //
190:            //
191:
192:            /**
193:             * Method declaration
194:             *
195:             * @return
196:             */
197:            private String getProjectSourcePath() throws CodeGenException {
198:                String path = new String();
199:
200:                try {
201:                    path = getGenerator().getProjectSourcePath();
202:                } catch (GeneratorException e) {
203:                    throw new CodeGenException(e);
204:                }
205:                return path;
206:            }
207:
208:            protected ImportPaths getImportPaths() throws CodeGenException {
209:                ImportPaths paths = null;
210:                String[][] map = new String[0][2];
211:                String pack = new String();
212:
213:                paths = new ImportPaths();
214:                try {
215:                    pack = getPackage();
216:                    paths.setRootPath(getGenerator().getDestination());
217:                    paths.setPackage(pack);
218:                    paths.setPackageMap(map);
219:                    paths.setSourcePath(getProjectSourcePath());
220:                    paths.setProject(project);
221:                } catch (ValidationException e) {
222:                    throw new CodeGenException(e);
223:                } catch (GeneratorException e) {
224:                    throw new CodeGenException(e);
225:                }
226:                return paths;
227:            }
228:
229:            /**
230:             * Method declaration
231:             *
232:             * @param files
233:             */
234:            public void importFiles(File[] files) throws CodeGenException {
235:                ImportTool tool = null;
236:                ImportPaths paths = null;
237:
238:                if (files.length > 0) {
239:                    tool = new ImportTool();
240:                    paths = getImportPaths();
241:                    tool.setPaths(getImportPaths());
242:                    tool.importFiles(files);
243:                    String[] path = new String[1];
244:
245:                    path[0] = paths.getSourcePath();
246:                    project.setSourcePathArray(path);
247:                }
248:            }
249:
250:            /**
251:             * Method declaration
252:             *
253:             *
254:             * @param p
255:             */
256:            protected void initOptions() throws GeneratorException {
257:                PathHandle phDest = null;
258:                String projectName = new String();
259:                String pack = new String();
260:
261:                phDest = PathHandle.createPathHandle(project
262:                        .getCodeGenDefaultDestination());
263:                projectName = project.getProjectRootName();
264:                pack = projectName.toLowerCase();
265:                getGenerator().getOptionSet().lookup(ProjectOptionSet.ROOT)
266:                        .setValue(phDest.getPath());
267:                getGenerator().getOptionSet().lookup(ProjectOptionSet.PROJECT)
268:                        .setValue(projectName);
269:                getGenerator().getOptionSet().lookup(ProjectOptionSet.PACKAGE)
270:                        .setValue(pack);
271:                getGenerator().getOptionSet().lookup(ProjectOptionSet.NOCLI)
272:                        .setValue(true);
273:            }
274:
275:            /**
276:             * Method declaration
277:             *
278:             *
279:             * @return
280:             *
281:             * @exception GeneratorException
282:             */
283:            private String getPackage() throws GeneratorException {
284:                OptionSet optionSet;
285:                String pack;
286:
287:                optionSet = getGenerator().getOptionSet();
288:                pack = optionSet.lookup(ProjectOptionSet.PACKAGE).getValue();
289:                return pack;
290:            }
291:
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.