commited for NA
diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/FlexibileWebModuleCreationDataModel.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/FlexibileWebModuleCreationDataModel.java
new file mode 100644
index 0000000..4f5d4d9
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/FlexibileWebModuleCreationDataModel.java
@@ -0,0 +1,315 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.jst.j2ee.internal.web.archive.operations;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModel;
+import org.eclipse.jst.j2ee.application.operations.AddModuleToEARDataModel;
+import org.eclipse.jst.j2ee.application.operations.AddWebModuleToEARDataModel;
+import org.eclipse.jst.j2ee.application.operations.FlexibleJ2EEModuleCreationDataModel;
+import org.eclipse.jst.j2ee.application.operations.IAnnotationsDataModel;
+import org.eclipse.jst.j2ee.application.operations.J2EEModuleCreationDataModel;
+import org.eclipse.jst.j2ee.common.XMLResource;
+import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl;
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
+import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
+import org.eclipse.jst.j2ee.internal.project.IWebNatureConstants;
+import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
+import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
+import org.eclipse.wst.common.frameworks.operations.WTPOperation;
+import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
+import org.eclipse.wst.common.frameworks.operations.WTPPropertyDescriptor;
+import org.eclipse.wst.common.modulecore.internal.util.IModuleConstants;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+
+import com.ibm.wtp.common.logger.proxy.Logger;
+
+/**
+ * This dataModel is used for to create Web Modules.
+ * 
+ * This class (and all its fields and methods) is likely to change during the WTP 1.0 milestones as
+ * the new project structures are adopted. Use at your own risk.
+ * 
+ * @since WTP 1.0
+ */
+public class FlexibileWebModuleCreationDataModel extends FlexibleJ2EEModuleCreationDataModel {
+
+	/**
+	 * Type Integer
+	 */
+	public static final String SERVLET_VERSION = "WebModuleCreationDataModel.SERVLET_VERSION"; //$NON-NLS-1$
+	/**
+	 * Type Integer
+	 */
+	public static final String JSP_VERSION = "WebModuleCreationDataModel.JSP_VERSION"; //$NON-NLS-1$
+	/**
+	 * Type String
+	 */
+	public static final String CONTEXT_ROOT = AddWebModuleToEARDataModel.CONTEXT_ROOT;
+
+
+
+
+	public WTPOperation getDefaultOperation() {
+		return new FlexibileWebModuleCreationOperation(this);
+	}
+
+	/**
+	 * @return Returns the default J2EE spec level based on the Global J2EE Preference
+	 */
+	protected Integer getDefaultJ2EEModuleVersion() {
+		int highestJ2EEPref = J2EEPlugin.getDefault().getJ2EEPreferences().getHighestJ2EEVersionID();
+		switch (highestJ2EEPref) {
+			case (J2EEVersionConstants.J2EE_1_4_ID) :
+				return new Integer(J2EEVersionConstants.WEB_2_4_ID);
+			case (J2EEVersionConstants.J2EE_1_3_ID) :
+				return new Integer(J2EEVersionConstants.WEB_2_3_ID);
+			case (J2EEVersionConstants.J2EE_1_2_ID) :
+				return new Integer(J2EEVersionConstants.WEB_2_2_ID);
+			default :
+				return new Integer(J2EEVersionConstants.WEB_2_4_ID);
+		}
+	}
+
+
+	protected void init() {
+		//setJ2EENatureID(IWebNatureConstants.J2EE_NATURE_ID);
+		//setProperty(EDIT_MODEL_ID, IWebNatureConstants.EDIT_MODEL_ID);
+//		getProjectDataModel().setProperty(ProjectCreationDataModel.PROJECT_NATURES, new String[]{IModuleConstants.MODULE_NATURE_ID});
+//		getJavaProjectCreationDataModel().setProperty(JavaProjectCreationDataModel.SOURCE_FOLDERS, new String[]{getDefaultJavaSourceFolderName()});
+		updateOutputLocation();
+		super.init();
+	}
+
+
+
+	protected boolean doSetProperty(String propertyName, Object propertyValue) {
+		boolean retVal = super.doSetProperty(propertyName, propertyValue);
+		if (propertyName.equals(USE_ANNOTATIONS)) {
+			notifyEnablementChange(J2EE_MODULE_VERSION);
+		} else if (propertyName.equals(J2EE_MODULE_VERSION)) {
+			if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3)
+				setProperty(USE_ANNOTATIONS, Boolean.FALSE);
+			notifyEnablementChange(USE_ANNOTATIONS);
+		} else if (propertyName.equals(CONTEXT_ROOT)) {
+			getAddModuleToApplicationDataModel().setProperty(AddWebModuleToEARDataModel.CONTEXT_ROOT, propertyValue);
+		}
+		return retVal;
+	}
+
+	private void updateOutputLocation() {
+//		getJavaProjectCreationDataModel().setProperty(JavaProjectCreationDataModel.OUTPUT_LOCATION, getOutputLocation());
+	}
+
+//	private Object getOutputLocation() {
+//		StringBuffer buf = new StringBuffer(getStringProperty(WEB_CONTENT));
+//		buf.append(IPath.SEPARATOR);
+//		buf.append(IWebNatureConstants.INFO_DIRECTORY);
+//		buf.append(IPath.SEPARATOR);
+//		buf.append(IWebNatureConstants.CLASSES_DIRECTORY);
+//		return buf.toString();
+//	}
+
+	protected void initValidBaseProperties() {
+		super.initValidBaseProperties();
+		addValidBaseProperty(SERVLET_VERSION);
+		addValidBaseProperty(JSP_VERSION);
+		addValidBaseProperty(USE_ANNOTATIONS);
+		addValidBaseProperty(CONTEXT_ROOT);
+	}
+
+	protected AddModuleToEARDataModel createModuleNestedModel() {
+		return new AddWebModuleToEARDataModel();
+	}
+
+	private Object updateAddToEar() {
+		//IRuntime type = getServerTargetDataModel().getRuntimeTarget();
+//		Boolean ret = Boolean.FALSE;
+//		IRuntime type = getProjectDataModel().getServerTargetDataModel().getRuntimeTarget();
+//		if (type == null)
+//			return Boolean.TRUE;
+//		IRuntimeType rType = type.getRuntimeType();
+//		if (rType == null)
+//			return Boolean.TRUE;
+//		return ret;
+		//return new Boolean(!rType.getVendor().equals(APACHE_VENDER_NAME));
+		return null;
+	}
+
+	protected Object getDefaultProperty(String propertyName) {
+
+
+		if (propertyName.equals(ADD_TO_EAR)) {
+			return updateAddToEar();
+
+		}
+
+//		if (propertyName.equals(WEB_CONTENT)) {
+//			String webContentFolderPref = J2EEPlugin.getDefault().getJ2EEPreferences().getJ2EEWebContentFolderName();
+//			if (webContentFolderPref == null || webContentFolderPref.length() == 0)
+//				webContentFolderPref = IWebNatureConstants.WEB_MODULE_DIRECTORY_;
+//			return webContentFolderPref;
+//		}
+		if (propertyName.equals(CONTEXT_ROOT)) {
+			return getAddModuleToApplicationDataModel().getProperty(CONTEXT_ROOT);
+		}
+
+		if (propertyName.equals(SERVLET_VERSION)) {
+			int moduleVersion = getIntProperty(J2EE_MODULE_VERSION);
+			int servletVersion = J2EEVersionConstants.SERVLET_2_2;
+			switch (moduleVersion) {
+				case J2EEVersionConstants.WEB_2_2_ID :
+					servletVersion = J2EEVersionConstants.SERVLET_2_2;
+					break;
+				case J2EEVersionConstants.WEB_2_3_ID :
+				case J2EEVersionConstants.WEB_2_4_ID :
+					servletVersion = J2EEVersionConstants.SERVLET_2_3;
+					break;
+			}
+			return new Integer(servletVersion);
+		}
+		if (propertyName.equals(JSP_VERSION)) {
+			int moduleVersion = getIntProperty(J2EE_MODULE_VERSION);
+			int jspVersion = J2EEVersionConstants.JSP_1_2_ID;
+			switch (moduleVersion) {
+				case J2EEVersionConstants.WEB_2_2_ID :
+					jspVersion = J2EEVersionConstants.JSP_1_2_ID;
+					break;
+				case J2EEVersionConstants.WEB_2_3_ID :
+				case J2EEVersionConstants.WEB_2_4_ID :
+					jspVersion = J2EEVersionConstants.JSP_2_0_ID;
+					break;
+			}
+			return new Integer(jspVersion);
+		}
+		return super.getDefaultProperty(propertyName);
+	}
+
+	protected WTPPropertyDescriptor doGetPropertyDescriptor(String propertyName) {
+		if (propertyName.equals(J2EE_MODULE_VERSION)) {
+			Integer propertyValue = (Integer) getProperty(propertyName);
+			String description = null;
+			switch (propertyValue.intValue()) {
+				case J2EEVersionConstants.WEB_2_2_ID :
+					description = J2EEVersionConstants.VERSION_2_2_TEXT;
+					break;
+				case J2EEVersionConstants.WEB_2_3_ID :
+					description = J2EEVersionConstants.VERSION_2_3_TEXT;
+					break;
+				case J2EEVersionConstants.WEB_2_4_ID :
+				default :
+					description = J2EEVersionConstants.VERSION_2_4_TEXT;
+					break;
+			}
+			return new WTPPropertyDescriptor(propertyValue, description);
+		}
+		return super.doGetPropertyDescriptor(propertyName);
+	}
+
+	protected WTPPropertyDescriptor[] getValidJ2EEModuleVersionDescriptors() {
+		int highestJ2EEPref = J2EEPlugin.getDefault().getJ2EEPreferences().getHighestJ2EEVersionID();
+		WTPPropertyDescriptor[] descriptors = null;
+		switch (highestJ2EEPref) {
+			case J2EEVersionConstants.J2EE_1_2_ID :
+				descriptors = new WTPPropertyDescriptor[1];
+				descriptors[0] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.WEB_2_2_ID), J2EEVersionConstants.VERSION_2_2_TEXT);
+				break;
+			case J2EEVersionConstants.J2EE_1_3_ID :
+				descriptors = new WTPPropertyDescriptor[2];
+				descriptors[0] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.WEB_2_2_ID), J2EEVersionConstants.VERSION_2_2_TEXT);
+				descriptors[1] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.WEB_2_3_ID), J2EEVersionConstants.VERSION_2_3_TEXT);
+				break;
+			case J2EEVersionConstants.J2EE_1_4_ID :
+			default :
+				descriptors = new WTPPropertyDescriptor[3];
+				descriptors[0] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.WEB_2_2_ID), J2EEVersionConstants.VERSION_2_2_TEXT);
+				descriptors[1] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.WEB_2_3_ID), J2EEVersionConstants.VERSION_2_3_TEXT);
+				descriptors[2] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.WEB_2_4_ID), J2EEVersionConstants.VERSION_2_4_TEXT);
+				break;
+		}
+		return descriptors;
+	}
+
+	protected int convertModuleVersionToJ2EEVersion(int moduleVersion) {
+		switch (moduleVersion) {
+			case J2EEVersionConstants.WEB_2_2_ID :
+				return J2EEVersionConstants.J2EE_1_2_ID;
+			case J2EEVersionConstants.WEB_2_3_ID :
+				return J2EEVersionConstants.J2EE_1_3_ID;
+			case J2EEVersionConstants.WEB_2_4_ID :
+				return J2EEVersionConstants.J2EE_1_4_ID;
+		}
+		return -1;
+	}
+
+	protected Integer convertJ2EEVersionToModuleVersion(Integer j2eeVersion) {
+		switch (j2eeVersion.intValue()) {
+			case J2EEVersionConstants.J2EE_1_2_ID :
+				return new Integer(J2EEVersionConstants.WEB_2_2_ID);
+			case J2EEVersionConstants.J2EE_1_3_ID :
+				return new Integer(J2EEVersionConstants.WEB_2_3_ID);
+			case J2EEVersionConstants.J2EE_1_4_ID :
+				return new Integer(J2EEVersionConstants.WEB_2_4_ID);
+		}
+		return super.convertJ2EEVersionToModuleVersion(j2eeVersion);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEModuleCreationDataModel#getModuleType()
+	 */
+	protected EClass getModuleType() {
+		return CommonarchiveFactoryImpl.getPackage().getWARFile();
+	}
+
+	protected String getModuleExtension() {
+		return ".war"; //$NON-NLS-1$
+	}
+
+	protected Boolean basicIsEnabled(String propertyName) {
+		if (USE_ANNOTATIONS.equals(propertyName)) {
+			if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3)
+				return Boolean.FALSE;
+			return Boolean.TRUE;
+		}
+		return super.basicIsEnabled(propertyName);
+	}
+
+	protected IStatus doValidateProperty(String propertyName) {
+		if (propertyName.equals(CONTEXT_ROOT)) {
+			if (getBooleanProperty(ADD_TO_EAR)) {
+				return getAddModuleToApplicationDataModel().validateProperty(AddWebModuleToEARDataModel.CONTEXT_ROOT);
+			}
+			return OK_STATUS;
+
+		}
+		return super.doValidateProperty(propertyName);
+	}
+
+	public void propertyChanged(WTPOperationDataModelEvent event) {
+		super.propertyChanged(event);
+		if (event.getDataModel() == getAddModuleToApplicationDataModel() && event.getPropertyName().equals(AddWebModuleToEARDataModel.CONTEXT_ROOT) && event.getDataModel().isSet(AddWebModuleToEARDataModel.CONTEXT_ROOT)) {
+			setProperty(CONTEXT_ROOT, event.getProperty());
+		} //else if (event.getDataModel() == getServerTargetDataModel() && event.getPropertyName().equals(ServerTargetDataModel.RUNTIME_TARGET_ID) && event.getDataModel().isSet(ServerTargetDataModel.RUNTIME_TARGET_ID))
+			//setProperty(ADD_TO_EAR, updateAddToEar());
+	}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/FlexibileWebModuleCreationOperation.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/FlexibileWebModuleCreationOperation.java
new file mode 100644
index 0000000..966e4c2
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/FlexibileWebModuleCreationOperation.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Nov 6, 2003
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package org.eclipse.jst.j2ee.internal.web.archive.operations;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jst.j2ee.application.operations.FlexibileJ2EEModuleCreationOperation;
+import org.eclipse.jst.j2ee.application.operations.FlexibleJ2EEModuleCreationDataModel;
+import org.eclipse.jst.j2ee.application.operations.IAnnotationsDataModel;
+import org.eclipse.jst.j2ee.application.operations.J2EEModuleCreationDataModel;
+import org.eclipse.wst.common.modulecore.ModuleCore;
+import org.eclipse.wst.common.modulecore.ModuleCoreFactory;
+import org.eclipse.wst.common.modulecore.ModuleType;
+import org.eclipse.wst.common.modulecore.ProjectModules;
+import org.eclipse.wst.common.modulecore.WorkbenchModule;
+import org.eclipse.wst.common.modulecore.WorkbenchModuleResource;
+import org.eclipse.wst.common.modulecore.internal.operation.ArtifactEditOperation;
+import org.eclipse.wst.common.modulecore.internal.util.IModuleConstants;
+
+public class FlexibileWebModuleCreationOperation extends FlexibileJ2EEModuleCreationOperation {
+	public FlexibileWebModuleCreationOperation(FlexibileWebModuleCreationDataModel dataModel) {
+		super(dataModel);
+	}
+
+	public FlexibileWebModuleCreationOperation() {
+		super();
+	}
+
+	protected void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+		super.createModule(monitor);
+		//TODO add contextRoot and contentName to workbechModule
+		//J2EEWebNatureRuntime nature = J2EEWebNatureRuntime.getRuntime(((WebModuleCreationDataModel)operationDataModel).getTargetProject());
+		//WebArtifactEdit webArtifactEdit = (WebArtifactEdit)ModuleCore.getFirstArtifactEditForRead(((WebModuleCreationDataModel)operationDataModel).getTargetProject());
+		//nature.getWebSettings().setWebContentName(operationDataModel.getStringProperty(WebModuleCreationDataModel.WEB_CONTENT));
+		//nature.getWebSettings().setContextRoot(operationDataModel.getStringProperty(webArtifactEdit.getContextRoot()));
+		//URIConverter uriConverter = ((ProjectResourceSet) nature.getResourceSet()).getURIConverter();
+		//dont need this, keeps nature in synch with websetting file
+		//if (uriConverter instanceof J2EEModuleWorkbenchURIConverterImpl)
+		//	((J2EEModuleWorkbenchURIConverterImpl) uriConverter).recomputeContainersIfNecessary();
+	}
+
+	protected void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+		
+		ArtifactEditOperation op = new ArtifactEditOperation( (FlexibleJ2EEModuleCreationDataModel) operationDataModel){
+			
+		};
+		
+//		EditModelOperation op = new EditModelOperation((J2EEModuleCreationDataModel) operationDataModel) {
+//			protected void execute(IProgressMonitor amonitor) throws CoreException, InvocationTargetException, InterruptedException {
+//				WebEditModel model = (WebEditModel) editModel;
+//				IFolder moduleRoot = WebPropertiesUtil.getModuleServerRoot(model.getProject());
+//				IFolder metainf = moduleRoot.getFolder(J2EEConstants.META_INF);
+//				if (!metainf.exists()) {
+//					IFolder parent = metainf.getParent().getFolder(null);
+//					if (!parent.exists()) {
+//						parent.create(true, true, null);
+//					}
+//					metainf.create(true, true, null);
+//				}
+//				IFolder webinf = moduleRoot.getFolder(J2EEConstants.WEB_INF);
+//				if (!webinf.exists()) {
+//					webinf.create(true, true, null);
+//				}
+//				IFolder lib = webinf.getFolder("lib"); //$NON-NLS-1$
+//				if (!lib.exists()) {
+//					lib.create(true, true, null);
+//				}
+//				model.makeDeploymentDescriptorWithRoot();
+//			}
+//		};
+		op.doRun(monitor);
+	}
+
+	protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+		super.execute(monitor);
+		FlexibleJ2EEModuleCreationDataModel dataModel = (FlexibleJ2EEModuleCreationDataModel) operationDataModel;
+
+		//.wtpmodule should be created when creating a project
+		//createInitialWTPModulesFile(); 
+
+		if (((FlexibileWebModuleCreationDataModel) operationDataModel).getBooleanProperty(IAnnotationsDataModel.USE_ANNOTATIONS))
+			addAnnotationsBuilder();
+	}
+
+    /**
+     * 
+     */
+//    private void createInitialWTPModulesFile() {
+//    	ModuleCore moduleCore = null;
+//		try {
+//			IProject containingProject = getProject();
+//			moduleCore = ModuleCore.getModuleCoreForWrite(containingProject);
+//			moduleCore.prepareProjectModulesIfNecessary(); 
+//			ProjectModules projectModules = moduleCore.getModuleModelRoot();
+//			addContent(projectModules);
+//			moduleCore.saveIfNecessary(null); 
+//		} finally {
+//			if(moduleCore != null)
+//				moduleCore.dispose();
+//		}     
+//    }
+	/**
+	 * @param projectModules
+	 */
+	private void addContent(ProjectModules projectModules) {
+	    WorkbenchModule webModule = addWorkbenchModule(projectModules, getModuleName()+".war", createModuleURI()); //$NON-NLS-1$
+		addResource(webModule, getModuleRelativeFile(getWebContentSourcePath(), getProject()), getWebContentDeployPath());
+		addResource(webModule, getModuleRelativeFile(getJavaSourceSourcePath(), getProject()), getJavaSourceDeployPath());
+	}
+	
+	/**
+	 * @return
+	 */
+	private URI createModuleURI() {
+		return URI.createURI("module:/resource/"+getProject().getName()+IPath.SEPARATOR+getModuleName()+".war"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	public void addResource(WorkbenchModule aModule, IResource aSourceFile, String aDeployPath) {
+		WorkbenchModuleResource resource = ModuleCoreFactory.eINSTANCE.createWorkbenchModuleResource();		
+		resource.setSourcePath(URI.createURI(aSourceFile.getFullPath().toString()));
+		resource.setDeployedPath(URI.createURI(aDeployPath));
+		aModule.getResources().add(resource);
+	}
+	public WorkbenchModule addWorkbenchModule(ProjectModules theModules, String aDeployedName, URI aHandle) {
+		WorkbenchModule module = ModuleCoreFactory.eINSTANCE.createWorkbenchModule();
+		module.setHandle(aHandle);  
+		module.setDeployedName(aDeployedName);  
+		ModuleType type = ModuleCoreFactory.eINSTANCE.createModuleType();
+		type.setModuleTypeId(IModuleConstants.JST_WEB_MODULE);
+		module.setModuleType(type);
+		theModules.getWorkbenchModules().add(module);
+		return module;
+	}
+	public IFile getModuleRelativeFile(String aModuleRelativePath, IProject project) {
+		return getProject().getFile(new Path(IPath.SEPARATOR + aModuleRelativePath));
+	}
+	
+	public IProject getProject() {
+	    J2EEModuleCreationDataModel dataModel = (J2EEModuleCreationDataModel) operationDataModel;
+	    return dataModel.getProjectDataModel().getProject();
+	}
+
+	/**
+	 * @return
+	 */
+	public String getJavaSourceSourcePath() {
+		return "/JavaSource"; //$NON-NLS-1$
+	}
+	
+	/**
+	 * @return
+	 */
+	public String getJavaSourceDeployPath() {
+		return "/WEB-INF/classes"; //$NON-NLS-1$
+	}
+	
+	/**
+	 * @return
+	 */
+	public String getWebContentSourcePath() {
+		return "/WebContent"; //$NON-NLS-1$
+	}
+	
+	/**
+	 * @return
+	 */
+	public String getWebContentDeployPath() {
+		return "/"; //$NON-NLS-1$
+	}
+	
+	public String getModuleName() {
+		return getProject().getName();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jst.j2ee.application.operations.FlexibileJ2EECreationOperation#createModule(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	protected void createModule(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+		// TODO Auto-generated method stub
+		
+	}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibileJ2EECreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibileJ2EECreationOperation.java
new file mode 100644
index 0000000..76f9247
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibileJ2EECreationOperation.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Oct 31, 2003
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package org.eclipse.jst.j2ee.application.operations;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
+import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetOperation;
+import org.eclipse.wst.common.frameworks.operations.WTPOperation;
+
+public abstract class FlexibileJ2EECreationOperation extends WTPOperation {
+
+	public FlexibileJ2EECreationOperation(FlexibleJ2EECreationDataModel dataModel) {
+		super(dataModel);
+	}
+
+	public FlexibileJ2EECreationOperation() {
+		super();
+	}
+
+	protected abstract void createModule(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException;
+
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibileJ2EEModuleCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibileJ2EEModuleCreationOperation.java
new file mode 100644
index 0000000..a32d116
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibileJ2EEModuleCreationOperation.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Nov 5, 2003
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package org.eclipse.jst.j2ee.application.operations;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jst.j2ee.internal.J2EEConstants;
+import org.eclipse.jst.j2ee.internal.project.ManifestFileCreationAction;
+
+public abstract class FlexibileJ2EEModuleCreationOperation extends FlexibileJ2EECreationOperation {
+	/**
+	 * name of the template emitter to be used to generate the deployment descriptor from the tags
+	 */
+	protected static final String TEMPLATE_EMITTER = "org.eclipse.jst.j2ee.ejb.annotations.emitter.template"; //$NON-NLS-1$
+	/**
+	 * id of the builder used to kick off generation of web metadata based on parsing of annotations
+	 */
+	protected static final String BUILDER_ID = "builderId"; //$NON-NLS-1$
+	
+	public FlexibileJ2EEModuleCreationOperation(FlexibleJ2EEModuleCreationDataModel dataModel) {
+		super(dataModel);
+	}
+
+	public FlexibileJ2EEModuleCreationOperation() {
+		super();
+	}
+
+	protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+		FlexibleJ2EEModuleCreationDataModel dataModel = (FlexibleJ2EEModuleCreationDataModel) operationDataModel;
+		createModule(monitor);
+		if (dataModel.getBooleanProperty(J2EEArtifactCreationDataModel.CREATE_DEFAULT_FILES)) {
+			createDeploymentDescriptor(monitor);
+			//J2EENature nature = (J2EENature) dataModel.getProjectDataModel().getProject().getNature(dataModel.getJ2EENatureID());
+			//createManifest(nature, monitor);
+		}
+		linkToEARIfNecessary(dataModel, monitor);
+	}
+
+	protected abstract void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException;
+
+	public static void linkToEARIfNecessary(FlexibleJ2EEModuleCreationDataModel moduleModel, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+//		if (moduleModel.getBooleanProperty(J2EEModuleCreationDataModel.ADD_TO_EAR)) {
+//			EnterpriseApplicationCreationDataModel earModel = moduleModel.getApplicationCreationDataModel();
+//			if (!earModel.getTargetProject().exists()) {
+//				EnterpriseApplicationCreationOperation earOp = new EnterpriseApplicationCreationOperation(earModel);
+//				earOp.doRun(monitor);
+//			}
+//			AddArchiveProjectToEARDataModel addModuleModel = moduleModel.getAddModuleToApplicationDataModel();
+//			AddArchiveProjectToEAROperation addModuleOp = new AddArchiveProjectToEAROperation(addModuleModel);
+//			addModuleOp.doRun(monitor);
+//		}
+	}
+
+	protected void createModule(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+//		JavaProjectCreationDataModel projectModel = ((J2EEModuleCreationDataModel) operationDataModel).getJavaProjectCreationDataModel();
+//		JavaProjectCreationOperation javaProjectOperation = new JavaProjectCreationOperation(projectModel);
+//		javaProjectOperation.doRun(monitor);
+//		updateClasspath(projectModel);
+		//J2EEModuleCreationDataModel dataModel = (J2EEModuleCreationDataModel) operationDataModel;
+		//J2EENature nature = (J2EENature) dataModel.getProjectDataModel().getProject().getNature(dataModel.getJ2EENatureID());
+		//setVersion(nature, monitor);
+		//addServerTarget(monitor);
+	}
+
+	/**
+	 * @param projectModel
+	 * @throws JavaModelException
+	 */
+//	private void updateClasspath(JavaProjectCreationDataModel projectModel) throws JavaModelException {
+//		ClassPathSelection classpath = ((J2EEModuleCreationDataModel) getOperationDataModel()).getClassPathSelection();
+//		if (classpath == null || classpath.getClasspathElements().size() == 0)
+//			return;
+//		IClasspathEntry[] newEntries = classpath.getClasspathEntriesForSelected();
+//		IProject project = projectModel.getProject();
+//		if (project == null)
+//			return;
+//		IJavaProject javaProject = JavaCore.create(project);
+//		IClasspathEntry[] existingEntries = javaProject.getRawClasspath();
+//
+//		List allEntries = new ArrayList();
+//		if (existingEntries != null && existingEntries.length > 0)
+//			allEntries.addAll(Arrays.asList(existingEntries));
+//		if (newEntries != null && newEntries.length > 0)
+//			allEntries.addAll(Arrays.asList(newEntries));
+//		IClasspathEntry[] finalEntriesArray = new IClasspathEntry[allEntries.size()];
+//		allEntries.toArray(finalEntriesArray);
+//		javaProject.setRawClasspath(finalEntriesArray, new NullProgressMonitor());
+//	}
+
+	/**
+	 * @param monitor
+	 */
+//	protected void createManifest(J2EENature nature, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+//		if (nature.getEMFRoot() != null) {
+//			try {
+//				IFile file = nature.getEMFRoot().getFile(new Path(J2EEConstants.MANIFEST_URI));
+//				ManifestFileCreationAction.createManifestFile(file, nature.getProject());
+//			} catch (IOException ioe) {
+//				com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError(ioe);
+//				return;
+//			}
+//			UpdateManifestOperation op = new UpdateManifestOperation(((J2EEModuleCreationDataModel) operationDataModel).getUpdateManifestDataModel());
+//			op.doRun(monitor);
+//		}
+//	}
+
+
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#dispose(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	protected void dispose(IProgressMonitor pm) {
+		try {
+			getOperationDataModel().dispose();
+			super.dispose(pm);
+		} catch (RuntimeException re) {
+			//Ignore
+		}
+	}
+	
+	/**
+	 * This method is intended for internal use only.  This method will add the annotations builder
+	 * for Xdoclet to the targetted project.  This needs to be removed from the operation and set
+	 * up to be more extensible throughout the workbench.
+	 * @see EJBModuleCreationOperation#execute(IProgressMonitor)
+	 * 
+	 * @deprecated
+	 */
+	protected final void addAnnotationsBuilder() {
+		try {
+			// Find the xdoclet builder from the extension registry
+			IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATE_EMITTER);
+			String builderID = configurationElements[0].getNamespace() + "."+ configurationElements[0].getAttribute(BUILDER_ID); //$NON-NLS-1$
+			IProject project = operationDataModel.getTargetProject(); 
+			IProjectDescription description = project.getDescription();
+			ICommand[] commands = description.getBuildSpec();
+			boolean found = false;
+			// Check if the builder is already set on the project
+			for (int i = 0; i < commands.length; ++i) {
+				if (commands[i].getBuilderName().equals(builderID)) {
+					found = true;
+					break;
+				}
+			}
+			// If the builder is not on the project, add it
+			if (!found) {
+				ICommand command = description.newCommand();
+				command.setBuilderName(builderID);
+				ICommand[] newCommands = new ICommand[commands.length + 1];
+				System.arraycopy(commands, 0, newCommands, 0, commands.length);
+				newCommands[commands.length] = command;
+				IProjectDescription desc = project.getDescription();
+				desc.setBuildSpec(newCommands);
+				project.setDescription(desc, null);
+			}
+		} catch (Exception e) {
+			//Ignore
+		}
+	}
+
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJ2EECreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJ2EECreationDataModel.java
index 809c3c9..b91ece9 100644
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJ2EECreationDataModel.java
+++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJ2EECreationDataModel.java
@@ -39,7 +39,7 @@
 	 * <code>Boolean.TRUE</code>. If this property is set to <code>Boolean.TRUE</code> then a
 	 * default deployment descriptor and supporting bindings files will be generated.
 	 */
-	public static final String SHOULD_CREATE_PROJECT = "FlexibleJ2EECreationDataModel.CREATE_DEFAULT_FILES"; //$NON-NLS-1$
+	public static final String SHOULD_CREATE_PROJECT = "FlexibleJ2EECreationDataModel.SHOULD_CREATE_PROJECT"; //$NON-NLS-1$
 
 	/**
 	 * Optional, type String
@@ -60,7 +60,7 @@
 
 	private static final String NESTED_MODEL_J2EE_PROJECT_CREATION = "FlexibleJ2EECreationDataModel.NESTED_MODEL_J2EE_PROJECT_CREATION"; //$NON-NLS-1$
 	
-	private J2EEProjectCreationDataModel j2eeProjectDataModel;
+//	private J2EEProjectCreationDataModel j2eeProjectDataModel;
 	
 	protected void initValidBaseProperties() {
 		addValidBaseProperty(CREATE_DEFAULT_FILES);
@@ -70,23 +70,24 @@
 	}
 	protected void initNestedModels() {
 		super.initNestedModels();
-		initProjectModel();
-		addNestedModel(NESTED_MODEL_J2EE_PROJECT_CREATION, j2eeProjectDataModel);
+//		initProjectModel();
+//		addNestedModel(NESTED_MODEL_J2EE_PROJECT_CREATION, j2eeProjectDataModel);
 	}
-	protected void initProjectModel() {
-	    j2eeProjectDataModel = new J2EEProjectCreationDataModel();
-	}
-	/**
-	 * @param projectDataModel
-	 *            The projectDataModel to set.
-	 */
-	protected final void setProjectDataModel(J2EEProjectCreationDataModel projectDataModel) {
-		j2eeProjectDataModel = projectDataModel;
-	}
-
-	public final J2EEProjectCreationDataModel getProjectDataModel() {
-		return j2eeProjectDataModel;
-	}
+	
+//	protected void initProjectModel() {
+//	    j2eeProjectDataModel = new J2EEProjectCreationDataModel();
+//	}
+//	/**
+//	 * @param projectDataModel
+//	 *            The projectDataModel to set.
+//	 */
+//	protected final void setProjectDataModel(J2EEProjectCreationDataModel projectDataModel) {
+//		j2eeProjectDataModel = projectDataModel;
+//	}
+//
+//	public final J2EEProjectCreationDataModel getProjectDataModel() {
+//		return j2eeProjectDataModel;
+//	}
 	protected Boolean basicIsEnabled(String propertyName) {
 		return (Boolean) getProperty(IS_ENABLED);
 	}
@@ -94,14 +95,14 @@
 	public void propertyChanged(WTPOperationDataModelEvent event) {
 		if (event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG) {
 			WTPOperationDataModel dm = event.getDataModel();
-			if (dm == j2eeProjectDataModel) {
-				String prop = event.getPropertyName();
-				if (prop.equals(ProjectCreationDataModel.PROJECT_NAME) || prop.equals(ServerTargetDataModel.PROJECT_NAME)) {
-					setProperty(PROJECT_NAME, event.getProperty()); //setting on outer will synch
-					// all others
-					return;
-				}
-			}
+//			if (dm == j2eeProjectDataModel) {
+//				String prop = event.getPropertyName();
+//				if (prop.equals(ProjectCreationDataModel.PROJECT_NAME) || prop.equals(ServerTargetDataModel.PROJECT_NAME)) {
+//					setProperty(PROJECT_NAME, event.getProperty()); //setting on outer will synch
+//					// all others
+//					return;
+//				}
+//			}
 		}
 		super.propertyChanged(event);
 	}
@@ -109,24 +110,35 @@
 	protected boolean doSetProperty(String propertyName, Object propertyValue) {
 		super.doSetProperty(propertyName, propertyValue);
 		if (EditModelOperationDataModel.PROJECT_NAME.equals(propertyName)) {
-			j2eeProjectDataModel.getProjectDataModel().setProperty(ProjectCreationDataModel.PROJECT_NAME, propertyValue);
-			j2eeProjectDataModel.getServerTargetDataModel().setProperty(ServerTargetDataModel.PROJECT_NAME, propertyValue);
+//			j2eeProjectDataModel.getProjectDataModel().setProperty(ProjectCreationDataModel.PROJECT_NAME, propertyValue);
+//			j2eeProjectDataModel.getServerTargetDataModel().setProperty(ServerTargetDataModel.PROJECT_NAME, propertyValue);
 		} else if (IS_ENABLED.equals(propertyName)) {
 			notifyEnablementChange(PROJECT_NAME);
 		}
 		return true;
 	}
 	protected IStatus doValidateProperty(String propertyName) {
-		if (propertyName.equals(PROJECT_NAME)) {
-			IStatus status = j2eeProjectDataModel.getProjectDataModel().validateProperty(ProjectCreationDataModel.PROJECT_NAME);
-			String projectName = getStringProperty(PROJECT_NAME);
-			if (status.isOK()) {
-				if (projectName.indexOf("#") != -1) { //$NON-NLS-1$
-					String errorMessage = J2EECreationResourceHandler.getString("InvalidCharsError"); //$NON-NLS-1$
-					return WTPCommonPlugin.createErrorStatus(errorMessage);
-				}
-			} else
-				return status;
+//		if (propertyName.equals(PROJECT_NAME)) {
+//			//IStatus status = j2eeProjectDataModel.getProjectDataModel().validateProperty(ProjectCreationDataModel.PROJECT_NAME);
+//			String projectName = getStringProperty(PROJECT_NAME);
+//			if (status.isOK()) {
+//				if (projectName.indexOf("#") != -1) { //$NON-NLS-1$
+//					String errorMessage = J2EECreationResourceHandler.getString("InvalidCharsError"); //$NON-NLS-1$
+//					return WTPCommonPlugin.createErrorStatus(errorMessage);
+//				}
+//			} else
+//				return status;
+			
+			if (propertyName.equals(MODULE_NAME)) {
+				IStatus status = OK_STATUS; 
+				String projectName = getStringProperty(PROJECT_NAME);
+				if (status.isOK()) {
+					if (projectName.indexOf("#") != -1) { //$NON-NLS-1$
+						String errorMessage = J2EECreationResourceHandler.getString("InvalidCharsError"); //$NON-NLS-1$
+						return WTPCommonPlugin.createErrorStatus(errorMessage);
+					}
+				} else
+					return status;			
 
 		} else if (propertyName.equals(NESTED_MODEL_VALIDATION_HOOK)) {
 			return OK_STATUS;