Source Code Cross Referenced for SalmonProjectCreationWizard.java in  » J2EE » Sofia » com » salmonllc » ideTools » eclipse » 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 » Sofia » com.salmonllc.ideTools.eclipse 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.salmonllc.ideTools.eclipse;
002:
003:        import java.io.File;
004:        import java.io.FileOutputStream;
005:        import java.io.PrintWriter;
006:
007:        import org.eclipse.core.resources.IFolder;
008:        import org.eclipse.core.resources.IProject;
009:        import org.eclipse.core.resources.IResource;
010:        import org.eclipse.core.resources.IWorkspaceRoot;
011:        import org.eclipse.core.runtime.CoreException;
012:        import org.eclipse.core.runtime.IExecutableExtension;
013:        import org.eclipse.core.runtime.IProgressMonitor;
014:        import org.eclipse.jdt.core.IJavaProject;
015:        import org.eclipse.jdt.internal.ui.JavaPlugin;
016:        import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPage;
017:        import org.eclipse.jface.operation.IRunnableWithProgress;
018:        import org.eclipse.swt.SWT;
019:        import org.eclipse.swt.widgets.MessageBox;
020:        import org.eclipse.swt.widgets.Shell;
021:        import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
022:        import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
023:
024:        import com.salmonllc.ideTools.IDETool;
025:        import com.salmonllc.properties.Props;
026:
027:        /**
028:         * @author Administrator
029:         *
030:         * To change this generated comment edit the template variable "typecomment":
031:         * Window>Preferences>Java>Templates.
032:         * To enable and disable the creation of type comments go to
033:         * Window>Preferences>Java>Code Generation.
034:         */
035:        public class SalmonProjectCreationWizard extends
036:                SalmonProjectCreationWizardBase implements  IExecutableExtension {
037:
038:            private WizardNewProjectCreationPage _mainPage;
039:            private SalmonProjectCreationWizardPage _sofiaPage;
040:            private NewJavaProjectWizardPage _javaPage;
041:
042:            /**
043:             * Constructor for SalmonProjectCreationWizard.
044:             */
045:            public SalmonProjectCreationWizard() {
046:                super ();
047:            }
048:
049:            /**
050:             * @see org.eclipse.jface.wizard.IWizard#performFinish()
051:             */
052:            public boolean performFinish() {
053:                IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(
054:                        _javaPage.getRunnable());
055:                try {
056:                    getContainer().run(false, true, op);
057:                    IJavaProject javaProj = _javaPage.getNewJavaProject();
058:                    IProject proj = javaProj.getProject();
059:                    Props pr = SalmonPlugin.getSystemProps();
060:                    boolean propsInWebApp = pr.getBooleanProperty(
061:                            Props.IDE_USE_APP_PROPERTIES, false);
062:                    //First clear out the old source entries. There is a blank one that causes a lot of trouble			
063:                    clearSourceEntries(javaProj);
064:
065:                    //Create a JSP folder for the JSP
066:                    IFolder jspFolder = createFolder(proj, "Jsp");
067:
068:                    //Create a WEB-INF folder
069:                    IFolder webInf = createFolder(proj, "WEB-INF");
070:                    IFolder propsFolder = null;
071:                    createFolder(webInf, "XML");
072:                    if (propsInWebApp)
073:                        propsFolder = createFolder(webInf, "properties");
074:
075:                    //Create a bin folder for the output
076:                    IFolder binFolder = createFolder(proj, "bin");
077:                    javaProj.setOutputLocation(binFolder.getFullPath(), null);
078:
079:                    //Create a Java folder for the Java source
080:                    IFolder javaFolder = createFolder(proj, "Java");
081:                    addSourceEntry(javaProj, javaFolder);
082:
083:                    //Add the Salmon Project Nature to the project and add the Salmon project to the classpath
084:                    addNatureEntry(proj);
085:                    addReferencedProjectToClasspath(proj, javaProj);
086:
087:                    //Add the proper jars for the server type to the classpath
088:                    addServerJarsToClassPath(javaProj, pr);
089:
090:                    //Copy the WEB-INF files from the resources directory
091:                    copyWEBINFFiles(webInf, pr);
092:
093:                    //Copy Hello.jsp
094:                    copyHelloJSP(jspFolder, pr);
095:
096:                    //Add stuff to the salmon System.properties file for this project
097:                    updateSystemProps(proj, binFolder, javaFolder, jspFolder,
098:                            propsFolder, _sofiaPage.getJDBCJar(), pr,
099:                            "hello.jsp");
100:
101:                    //Create the property file for the project
102:                    String projectPropertyPath = SalmonPlugin
103:                            .getSalmonPropsPath();
104:                    String projectPropsName = proj.getDescription().getName();
105:                    boolean full = false;
106:                    if (propsInWebApp) {
107:                        projectPropertyPath = propsFolder.getLocation()
108:                                .toOSString();
109:                        projectPropsName = "System";
110:                        full = true;
111:                    }
112:                    createProjectPropertyFile(proj, webInf, _sofiaPage,
113:                            projectPropertyPath, projectPropsName, full, pr);
114:
115:                    //Create a dreamweaver project
116:                    if (_sofiaPage.getMakeDefault())
117:                        createDreamweaverProject(proj, pr);
118:
119:                    //Make this the default project
120:                    SalmonPlugin.getDefault().getPreferenceStore().setValue(
121:                            SalmonPlugin.PREF_DEFAULT_PROJECT,
122:                            proj.getDescription().getName());
123:
124:                    //Refresh the project to get all the copied files
125:                    proj.refreshLocal(IResource.DEPTH_INFINITE, null);
126:
127:                    //Set up the configuration file for Weblogic or tomcat
128:                    String type = SalmonPlugin.getServerType();
129:                    if (type != null) {
130:                        if (type == IDETool.SERVER_TOMCAT40
131:                                || type == IDETool.SERVER_TOMCAT41)
132:                            setupTomcatConfigFile(pr
133:                                    .getProperty(Props.IDE_SERVER_CONFIG_FILE),
134:                                    proj);
135:                        else if (type.equals(IDETool.SERVER_WEBLOGIC6))
136:                            setupWeblogicConfigFile(pr
137:                                    .getProperty(Props.IDE_SERVER_CONFIG_FILE),
138:                                    proj);
139:                    }
140:
141:                    //update the perspective
142:                    updatePerspective();
143:
144:                } catch (Exception e) {
145:                    MessageBox box = new MessageBox(new Shell(), SWT.ICON_ERROR
146:                            | SWT.OK | SWT.SYSTEM_MODAL);
147:                    box.setText("Error Creating Project.");
148:                    box.setMessage(e.getMessage());
149:                    box.open();
150:                    e.printStackTrace();
151:                }
152:
153:                return true;
154:            }
155:
156:            public void addPages() {
157:                if (isInError())
158:                    return;
159:
160:                super .addPages();
161:
162:                _mainPage = new WizardNewProjectCreationPage("Page 1");
163:                _mainPage.setTitle("New SOFIA Project");
164:                _mainPage
165:                        .setDescription("Create a new project using the Salmon Open Framework");
166:                addPage(_mainPage);
167:
168:                _sofiaPage = new SalmonProjectCreationWizardPage(this , "Page 2");
169:                _sofiaPage.setTitle("SOFIA project Options");
170:                _sofiaPage
171:                        .setDescription("SOFIA JDBC and Dreamweaver Settings");
172:                addPage(_sofiaPage);
173:
174:                IWorkspaceRoot root = JavaPlugin.getWorkspace().getRoot();
175:                _javaPage = new NewJavaProjectWizardPage(root, _mainPage);
176:            }
177:
178:            public void createProjectPropertyFile(IProject project,
179:                    IFolder webFolder, SalmonProjectCreationWizardPage page,
180:                    String propsPath, String propsName, boolean full, Props pr) {
181:                try {
182:                    String resourcePath = pr
183:                            .getProperty(Props.IDE_FRAMEWORK_RESOURCES_PATH);
184:                    File f = new File(resourcePath
185:                            + File.separator
186:                            + "salmonprops"
187:                            + File.separator
188:                            + (full ? "eclipseFull.properties"
189:                                    : "eclipse.properties"));
190:                    String text = IDETool.readFile(f);
191:
192:                    text = replace(text, "$PROJECTNAME$", project
193:                            .getDescription().getName());
194:                    text = replace(text, "$DRIVER$", page.getDriver());
195:                    text = replace(text, "$DBUSER$", page.getDBUser());
196:                    text = replace(text, "$DBPASSWORD$", page.getDBPassword());
197:                    text = replace(text, "$CONNECTURL$", page.getDBURL());
198:                    text = replace(text, "$WEBINF$", doubleSlash(webFolder
199:                            .getLocation().toOSString()));
200:
201:                    f = new File(propsPath + File.separatorChar + propsName
202:                            + ".properties");
203:                    PrintWriter pw = new PrintWriter(new FileOutputStream(f));
204:                    pw.print(text);
205:                    pw.close();
206:                } catch (Exception e) {
207:                    e.printStackTrace();
208:                }
209:
210:            }
211:
212:            /* (non-Javadoc)
213:             * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
214:             */
215:            protected void finishPage(IProgressMonitor monitor)
216:                    throws InterruptedException, CoreException {
217:
218:            }
219:
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.