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.IOException;
027: import java.util.ArrayList;
028:
029: import org.eclipse.core.internal.resources.ProjectDescription;
030: import org.eclipse.core.resources.IFolder;
031: import org.eclipse.core.resources.IProject;
032: import org.eclipse.core.resources.IProjectDescription;
033: import org.eclipse.core.runtime.CoreException;
034: import org.eclipse.core.runtime.IProgressMonitor;
035: import org.eclipse.core.runtime.SubProgressMonitor;
036: import org.eclipse.jdt.core.IClasspathEntry;
037: import org.eclipse.jdt.core.JavaModelException;
038: import org.eclipse.jdt.launching.JavaRuntime;
039:
040: import com.bostechcorp.cbesb.common.i18n.I18N;
041: import com.bostechcorp.cbesb.common.i18n.Messages;
042: import com.bostechcorp.cbesb.ui.ide.classpath.CBESBCoreClasspathContainer;
043: import com.bostechcorp.cbesb.ui.ide.classpath.ClassPathContainerRepository;
044: import com.bostechcorp.cbesb.ui.ide.util.JavaProjectUtil;
045:
046: public class CBESBProjectCreationWizardPage extends ProjectWizardPage {
047: private IProgressMonitor monitor;
048:
049: public static final String WST_VALIDATION_BUILDER_ID = "org.eclipse.wst.validation.validationbuilder";
050:
051: public static final String ESB_NATURE = "com.bostechcorp.cbesb.ui.ide.esbproject";
052:
053: /**
054: * Constructor for the CBESBProjectCreationWizardPage object
055: *
056: * @param mainPage
057: * Description of the Parameter
058: */
059: public CBESBProjectCreationWizardPage(
060: WizardNewProjectCreationPage mainPage) {
061: super (mainPage);
062: // "ChainBuidler ESB Project"
063: this .setTitle(I18N.getString(Messages.IDE_ESB_PROJECT_NAME));//$NON-NLS-1$
064: // "Create a new ChainBuidler ESB Project"
065: this .setDescription(I18N
066: .getString(Messages.IDE_CREATE_ESB_PROJECT));//$NON-NLS-1$
067:
068: }
069:
070: /**
071: * Add necessary source and libraries
072: *
073: * @param entries
074: * @return
075: * @throws CoreException
076: */
077: protected IClasspathEntry[] checkEntries(IClasspathEntry[] entries)
078: throws CoreException {
079: // entries = JavaProjectUtil.mergeClasspathEntry(entries,
080: // JavaProjectUtil.createSourceClasspathEntry(fCurrProject, "src"));
081: entries = JavaProjectUtil.mergeClasspathEntry(entries,
082: JavaRuntime.getDefaultJREContainerEntry());
083: // entries = JavaProjectUtil.mergeClasspathEntry(entries,
084: // ClassPathContainerRepository.getInstance().getEntry(
085: // J2EE14ClasspathContainer.CLASSPATH_CONTAINER));
086: entries = JavaProjectUtil
087: .mergeClasspathEntry(
088: entries,
089: ClassPathContainerRepository
090: .getInstance()
091: .getEntry(
092: CBESBCoreClasspathContainer.CLASSPATH_CONTAINER));
093:
094: return entries;
095: }
096:
097: protected String[] getBuilders() {
098: return new String[] { WST_VALIDATION_BUILDER_ID };
099: }
100:
101: protected ArrayList customizePreDefinedResourceStructure(
102: IProject project, IProgressMonitor monitor)
103: throws CoreException, InterruptedException {
104: this .monitor = monitor;
105: ArrayList entries = new ArrayList();
106: createproject(project, entries);
107: return entries;
108: }
109:
110: private void createproject(IProject project, ArrayList entries)
111: throws CoreException, InterruptedException {
112: try {
113: IProjectDescription description = project.getDescription();
114: if (description == null)
115: description = new ProjectDescription();
116: description.setNatureIds(new String[] { ESB_NATURE });
117: project.setDescription(description, null);
118: addSourceFolders(project, entries);
119: createInitialContent(project);
120: project.refreshLocal(2, new SubProgressMonitor(monitor, 1));
121: } catch (JavaModelException e) {
122: e.printStackTrace();
123: throw e;
124: } catch (CoreException e) {
125: e.printStackTrace();
126: throw e;
127: } catch (IOException e) {
128: e.printStackTrace();
129: throw new InterruptedException(e.getMessage());
130: }
131: }
132:
133: protected void addSourceFolders(IProject project, ArrayList entries)
134: throws JavaModelException, CoreException, IOException {
135: addSourceFolder(project, entries, "src/java");
136: addSourceFolder(project, entries, "src/xlate");
137: addSourceFolder(project, entries, "src/formats");
138: addSourceFolder(project, entries, "src/test");
139: addSourceFolder(project, entries, "src/tables");
140: addSourceFolder(project, entries, "src/script");
141: addSourceFolder(project, entries, "src/wsdl");
142: addSourceFolder(project, entries, "src/auth/keys");
143: addSourceFolder(project, entries, "src/auth/certs");
144: addSourceFolder(project, entries, "src/database/drivers");
145: addSourceFolder(project, entries, "src/database/connections");
146: addSourceFolder(project, entries, "src/database/dataSourceMaps");
147: addSourceFolder(project, entries, "src/schedules");
148: addSourceFolder(project, entries, "src/etl/ExecConfig");
149: createESBProjectInfoFile(project, monitor);
150: IFolder folder = project.getProject().getFolder(
151: "src/formats/x12");
152: createFolder(folder);
153: folder = project.getProject().getFolder("src/formats/hl7");
154: createFolder(folder);
155: createTaggedMDLFile(project, monitor);
156:
157: }
158:
159: protected void createInitialContent(IProject project)
160: throws CoreException, JavaModelException, IOException {
161: // createJBIXMLfile(project);
162: super .createInitialContent(project, monitor);
163: super .createDerbyUserDBFile(project, monitor);
164: super .createX12zipFile(project, monitor);
165:
166: super .createHL7zipFile(project, monitor);
167: super .createCommonCustomCodeFile(project, monitor);
168: }
169:
170: /*
171: * private void createJBIXMLfile(IProject project) throws CoreException,
172: * JavaModelException, IOException { String jbixmlFilePath =
173: * project.getProject().getLocation().append(
174: * "/src/sa/").append(JBIXMLFILENAME).toOSString(); File jbixmlFile = new
175: * File(jbixmlFilePath); if (!jbixmlFile.exists())
176: * jbixmlFile.createNewFile(); project.refreshLocal(2, new
177: * SubProgressMonitor(monitor, 1)); }
178: */
179:
180: }
|