001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */
024: package com.bostechcorp.cbesb.ui.ide.wizards;
025:
026: import java.io.File;
027: import java.io.IOException;
028: import java.util.ArrayList;
029: import java.util.List;
030:
031: import org.eclipse.core.internal.resources.ProjectDescription;
032: import org.eclipse.core.resources.IFolder;
033: import org.eclipse.core.resources.IProject;
034: import org.eclipse.core.resources.IProjectDescription;
035: import org.eclipse.core.runtime.CoreException;
036: import org.eclipse.core.runtime.IProgressMonitor;
037: import org.eclipse.core.runtime.SubProgressMonitor;
038: import org.eclipse.jdt.core.IClasspathEntry;
039: import org.eclipse.jdt.core.JavaModelException;
040: import org.eclipse.jdt.launching.JavaRuntime;
041:
042: import com.bostechcorp.cbesb.common.i18n.I18N;
043: import com.bostechcorp.cbesb.common.i18n.Messages;
044: import com.bostechcorp.cbesb.ui.ide.classpath.CBJBISAClasspathContainer;
045: import com.bostechcorp.cbesb.ui.ide.classpath.ClassPathContainerRepository;
046: import com.bostechcorp.cbesb.ui.ide.util.JavaProjectUtil;
047: import com.bostechcorp.cbesb.ui.util.ProjectUtil;
048:
049: public class JBISAProjectCreationWizardPage extends ProjectWizardPage {
050:
051: private IProgressMonitor monitor;
052:
053: final static String JBIXMLFILENAME = "jbi.xml";
054:
055: private List super Projects = null;
056:
057: public static final String WST_VALIDATION_BUILDER_ID = "org.eclipse.wst.validation.validationbuilder";
058:
059: public static final String JBI_NATURE = "com.bostechcorp.cbesb.ui.ide.jbiproject";
060:
061: /**
062: * Constructor for the CBESBProjectCreationWizardPage object
063: *
064: * @param mainPage
065: * Description of the Parameter
066: */
067: public JBISAProjectCreationWizardPage(
068: WizardNewProjectCreationPage mainPage) {
069: super (mainPage);
070: this .setTitle(I18N.getString(Messages.IDE_JBI_PROJECT_NAME));// "JBI
071: // Service
072: // Assembly
073: // Project");//$NON-NLS-1$
074: this .setDescription(I18N
075: .getString(Messages.IDE_CREATE_JBI_NAME));// "Create
076: // a
077: // new
078: // JBI
079: // Service
080: // Assembly
081: // Project");//$NON-NLS-1$
082: }
083:
084: /**
085: * Add necessary source and libraries
086: *
087: * @param entries
088: * @return
089: * @throws CoreException
090: */
091: protected IClasspathEntry[] checkEntries(IClasspathEntry[] entries)
092: throws CoreException {
093: // entries = JavaProjectUtil.mergeClasspathEntry(entries,
094: // JavaProjectUtil.createSourceClasspathEntry(fCurrProject, "src"));
095: entries = JavaProjectUtil.mergeClasspathEntry(entries,
096: JavaRuntime.getDefaultJREContainerEntry());
097: // entries = JavaProjectUtil.mergeClasspathEntry(entries,
098: // ClassPathContainerRepository.getInstance().getEntry(
099: // J2EE14ClasspathContainer.CLASSPATH_CONTAINER));
100: entries = JavaProjectUtil.mergeClasspathEntry(entries,
101: ClassPathContainerRepository.getInstance().getEntry(
102: CBJBISAClasspathContainer.CLASSPATH_CONTAINER));
103: return entries;
104: }
105:
106: protected String[] getBuilders() {
107: return new String[] { WST_VALIDATION_BUILDER_ID };
108: }
109:
110: protected ArrayList customizePreDefinedResourceStructure(
111: IProject project, IProgressMonitor monitor)
112: throws CoreException, InterruptedException {
113: this .monitor = monitor;
114: ArrayList entries = new ArrayList();
115: createproject(project, entries);
116: return entries;
117: }
118:
119: private void createproject(IProject project, ArrayList entries) {
120: try {
121: IProjectDescription description = project.getDescription();
122: if (description == null)
123: description = new ProjectDescription();
124: description.setNatureIds(new String[] { JBI_NATURE });
125: project.setDescription(description, null);
126: addSourceFolders(project, entries);
127: createInitialContent(project);
128: project.refreshLocal(2, new SubProgressMonitor(monitor, 1));
129: } catch (JavaModelException e) {
130: e.printStackTrace();
131: } catch (CoreException e) {
132: e.printStackTrace();
133: } catch (IOException e) {
134: e.printStackTrace();
135: }
136: }
137:
138: private void addSourceFolders(IProject project, ArrayList entries)
139: throws JavaModelException, CoreException {
140: addSourceFolder(project, entries, "src/java");
141: addSourceFolder(project, entries, "src/xlate");
142: addSourceFolder(project, entries, "src/formats");
143: addSourceFolder(project, entries, "src/test");
144: addSourceFolder(project, entries, "src/sa");
145: addSourceFolder(project, entries, "src/SUs");
146: addSourceFolder(project, entries, "src/tables");
147: addSourceFolder(project, entries, "src/script");
148: addSourceFolder(project, entries, "src/wsdl");
149: addSourceFolder(project, entries, "src/auth/keys");
150: addSourceFolder(project, entries, "src/auth/certs");
151: addSourceFolder(project, entries, "src/database/drivers");
152: addSourceFolder(project, entries, "src/database/connections");
153: addSourceFolder(project, entries, "src/database/dataSourceMaps");
154: addSourceFolder(project, entries, "src/customComp");
155: addSourceFolder(project, entries, "src/schedules");
156: addSourceFolder(project, entries, "src/etl/ExecConfig");
157: IFolder folder = project.getProject().getFolder(
158: "src/formats/x12");
159: createFolder(folder);
160: folder = project.getProject().getFolder("src/formats/hl7");
161: createFolder(folder);
162:
163: try {
164: createJBIProjectInfoFile(project, monitor, super Projects);
165: createTaggedMDLFile(project, monitor);
166: } catch (IOException e) {
167:
168: e.printStackTrace();
169: }
170:
171: }
172:
173: protected void createInitialContent(IProject project)
174: throws CoreException, JavaModelException, IOException {
175: super .createInitialContent(project, monitor);
176: createJBIXMLfile(project);
177: }
178:
179: private void createJBIXMLfile(IProject project)
180: throws CoreException, JavaModelException, IOException {
181: /*
182: * String jbixmlFilePath = project.getProject().getLocation().append(
183: * "/src/sa/").append(JBIXMLFILENAME).toOSString(); File jbixmlFile =
184: * new File(jbixmlFilePath); if (!jbixmlFile.exists())
185: * jbixmlFile.createNewFile();
186: */
187:
188: String JBISA1 = project.getProject().getLocation().append(
189: "/src/sa/")
190: .append(project.getName() + ".componentflow")
191: .toOSString();
192: File JBISA1File = new File(JBISA1);
193: if (!JBISA1File.exists())
194: JBISA1File.createNewFile();
195:
196: String JBISA12 = project.getProject().getLocation().append(
197: "/src/sa/").append(
198: project.getName() + ".componentflow_diagram")
199: .toOSString();
200: File JBISA2File = new File(JBISA12);
201: if (!JBISA2File.exists())
202: JBISA2File.createNewFile();
203:
204: try {
205: ProjectUtil.writeFileComponentflow(JBISA1, JBISA12, project
206: .getName());
207: } catch (IOException e1) {
208: e1.printStackTrace();
209: }
210: project.refreshLocal(2, new SubProgressMonitor(monitor, 1));
211: }
212:
213: public List getSuperProjects() {
214: return super Projects;
215: }
216:
217: public void setSuperProjects(List superProjects) {
218: this.superProjects = superProjects;
219: }
220:
221: }
|