Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations')
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectToEAROperation.java327
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEARDataModel.java151
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEAROperation.java63
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveToEARDataModel.java191
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationDataModel.java38
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationOperation.java58
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddModuleToEARDataModel.java114
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddUtilityProjectToEARDataModel.java224
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddWebModuleToEARDataModel.java145
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AppClientModuleExportDataModel.java81
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClassPathSelection.java601
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathElement.java396
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathSelectionHelper.java119
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationDataModel.java543
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationOperation.java129
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EARComponentCreationOperation.java115
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModel.java258
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModelOld.java258
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperation.java78
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperationOld.java74
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationExportDataModel.java97
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationImportDataModel.java819
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportFactory.java1
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportRegistry.java3
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJavaProjectCreationDataModel.java19
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationDataModel.java139
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationOperation.java74
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/IAnnotationsDataModel.java35
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationDataModelOld.java184
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationOperationOld.java51
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactExportDataModel.java238
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactImportDataModel.java462
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationDataModel.java378
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationOperation.java359
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationDataModelOld.java502
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationOperationOld.java203
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleExportDataModel.java23
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleImportDataModel.java98
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportDataModel.java64
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportOperation.java85
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportDataModel.java418
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportOperation.java305
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JARDependencyTraverser.java141
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JavaUtilityJARProjectCreationOperationOld.java52
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestDataModel.java136
-rw-r--r--plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestOperation.java81
46 files changed, 2 insertions, 8928 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectToEAROperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectToEAROperation.java
deleted file mode 100644
index fac53e101..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectToEAROperation.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/***************************************************************************************************
- * 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 27, 2003
- *
- * To change the template for this generated file go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-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.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.jst.j2ee.application.Application;
-import org.eclipse.jst.j2ee.application.ApplicationResource;
-import org.eclipse.jst.j2ee.application.Module;
-import org.eclipse.jst.j2ee.internal.application.impl.ApplicationResourceImpl;
-import org.eclipse.jst.j2ee.internal.archive.operations.EJBArchiveOpsResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.AddModuleToEARProjectCommand;
-import org.eclipse.jst.j2ee.internal.earcreation.AddUtilityJARMapCommand;
-import org.eclipse.jst.j2ee.internal.earcreation.EAREditModel;
-import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime;
-import org.eclipse.jst.j2ee.internal.earcreation.RemoveModuleFromEARProjectCommand;
-import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEditOperation;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
-import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetOperation;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperation;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.ServerCore;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-public class AddArchiveProjectToEAROperation extends EARArtifactEditOperation {
-
- private IProgressMonitor monitor;
-
- private static class CopyJARFileCommand extends AbstractCommand implements Command {
-
- IProject earProject = null;
- IProgressMonitor monitor = null;
- IFile file = null;
- String uri = null;
- IFile target = null;
-
- /**
- * Constructor
- */
- public CopyJARFileCommand(IProject earProject, IProgressMonitor monitor, IFile file, String uri) {
- super();
- this.earProject = earProject;
- this.monitor = monitor;
- this.file = file;
- this.uri = uri;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.common.command.Command#execute()
- */
- public void execute() {
- IPath path = null;
- try {
- path = new Path(uri);
- target = earProject.getFile(path);
- mkdirs(path);
- file.copy(target.getFullPath(), true, new SubProgressMonitor(new NullProgressMonitor(), 1));
- } catch (Exception ex) {
- Logger.getLogger().logError(ex);
- }
-
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.common.command.Command#undo()
- */
- public void undo() {
- try {
- if (target != null)
- target.delete(true, new NullProgressMonitor());
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.common.command.Command#redo()
- */
- public void redo() {
- execute();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.common.command.AbstractCommand#prepare()
- */
- protected boolean prepare() {
- return true;
- }
-
- /**
- * @param path
- * @throws CoreException
- */
- private void mkdirs(IPath path) throws CoreException {
- int segments = path.segmentCount();
- for (int i = segments - 1; i > 0; i--) {
- IFolder folder = earProject.getFolder(path.removeLastSegments(i));
- if (!folder.exists())
- folder.create(true, true, null);
- }
- }
- }
-
- public AddArchiveProjectToEAROperation(AddArchiveToEARDataModel dataModel) {
- super(dataModel);
- }
-
- protected void execute(IProgressMonitor aMonitor) throws CoreException, InvocationTargetException, InterruptedException {
- this.monitor = aMonitor;
- AddArchiveToEARDataModel dataModel = (AddArchiveToEARDataModel) operationDataModel;
- String originalID = null;
- ApplicationResource resource = null;
- String uri = dataModel.getStringProperty(AddArchiveToEARDataModel.ARCHIVE_URI);
- EARNatureRuntime nature = EARNatureRuntime.getRuntime(dataModel.getTargetProject());
- Application app = nature.getApplication();
- Module module = app.getFirstModule(uri);
- if (module != null) {
- resource = (ApplicationResource) module.eResource();
- originalID = resource.getID(module);
- }
-
- Command command = createCommand(dataModel);
- if (null != command) {
- getCommandStack().execute(command);
- }
-
- if (originalID != null) {
- module = app.getFirstModule(uri);
- resource = (ApplicationResourceImpl) module.eResource();
- resource.setID(module, originalID);
- }
-
- addServerTarget(aMonitor);
- if (!dataModel.isModuleArchive())
- updateUtilProject((AddUtilityProjectToEARDataModel) dataModel, aMonitor);
- addAllDependentJARs();
-
- }
-
- private void addAllDependentJARs() throws CoreException {
- Map dependents = computeAllDependents();
- if (dependents.isEmpty())
- return;
- Iterator iter = dependents.entrySet().iterator();
- Map.Entry entry = null;
- IResource resource = null;
- String uri = null;
- CompoundCommand compoundCommand = new CompoundCommand();
- compoundCommand.setLabel(EJBArchiveOpsResourceHandler.getString("Copy_Dep_JARS_UI")); //$NON-NLS-1$
- while (iter.hasNext()) {
- entry = (Map.Entry) iter.next();
- resource = (IResource) entry.getKey();
- uri = (String) entry.getValue();
- switch (resource.getType()) {
- case IResource.FILE :
- addDependentJARFile((IFile) resource, uri, compoundCommand);
- break;
- case IResource.PROJECT :
- addDependentJARProject((IProject) resource, uri, compoundCommand);
- break;
- }
- }
- getCommandStack().execute(compoundCommand);
- }
-
- /**
- * @param project
- * @param uri
- * @param compoundCommand
- */
- private void addDependentJARProject(IProject project, String uri, CompoundCommand compoundCommand) {
- AddUtilityJARMapCommand cmd = new AddUtilityJARMapCommand(getEARProject(), uri, project);
- compoundCommand.append(cmd);
- }
-
- /**
- * @param file
- * @param uri
- * @param compoundCommand
- * @throws CoreException
- */
- private void addDependentJARFile(IFile file, String uri, CompoundCommand compoundCommand) throws CoreException {
- CopyJARFileCommand cmd = new CopyJARFileCommand(getEARProject(), monitor, file, uri);
- compoundCommand.append(cmd);
- }
-
- protected void addServerTarget(IProgressMonitor aMonitor) throws CoreException, InvocationTargetException, InterruptedException {
- if (operationDataModel.getBooleanProperty(AddArchiveToEARDataModel.SYNC_TARGET_RUNTIME)) {
- ServerTargetDataModel model = ((AddArchiveToEARDataModel) operationDataModel).getServerTargetDataModel();
- ServerTargetOperation serverTargetOperation = new ServerTargetOperation(model);
- serverTargetOperation.doRun(aMonitor);
- }
- }
-
- /**
- * @param model
- */
- private void updateUtilProject(AddUtilityProjectToEARDataModel model, IProgressMonitor aMonitor) {
- WorkbenchComponent wbComp = (WorkbenchComponent) model.getProperty(AddUtilityProjectToEARDataModel.ARCHIVE_MODULE);
- IProject proj = ((AddArchiveToEARDataModel)operationDataModel).getProjectForGivenComponent(wbComp);
- if (proj != null && J2EEProjectUtilities.getFirstReferencingEARProject(proj) == null) {
- createManifest(model, aMonitor);
- IRuntime runtime = ServerCore.getProjectProperties(proj).getRuntimeTarget();
- if (runtime == null)
- addRuntimeTarget(model, aMonitor);
- }
- }
-
- /**
- * @param model
- */
- private void addRuntimeTarget(AddUtilityProjectToEARDataModel model, IProgressMonitor aMonitor) {
- ServerTargetOperation op = new ServerTargetOperation(model.getServerTargetModel());
- runNestedOperation(op, aMonitor);
- }
-
- /**
- * @param model
- */
- private void createManifest(AddUtilityProjectToEARDataModel model, IProgressMonitor aMonitor) {
- UpdateManifestOperation op = new UpdateManifestOperation(model.getManifestModel());
- runNestedOperation(op, aMonitor);
- }
-
- private void runNestedOperation(WTPOperation op, IProgressMonitor aMonitor) {
- try {
- op.doRun(aMonitor);
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- }
- }
-
- /**
- * @param dataModel
- * @return
- */
- private Command createCommand(AddArchiveToEARDataModel dataModel) {
- IProject project = getArchiveProject();
- String uri = dataModel.getStringProperty(AddArchiveToEARDataModel.ARCHIVE_URI);
- EARNatureRuntime nature = EARNatureRuntime.getRuntime(dataModel.getTargetProject());
- if (project == nature.getMappedProject(uri)) {
- return null;
- }
-
- Module m = null;
- //TODO fix up ((EAREditModel) editModel).getApplication().getFirstModule(uri);
- RemoveModuleFromEARProjectCommand removeCommand = null;
- if (null != m) {
- removeCommand = new RemoveModuleFromEARProjectCommand(m, dataModel.getTargetProject());
- }
- Command addCommand = null;
- if (dataModel.isModuleArchive()) {
- String contextRoot = null;
- if (((AddModuleToEARDataModel) dataModel).isWebModuleArchive())
- contextRoot = dataModel.getStringProperty(AddWebModuleToEARDataModel.CONTEXT_ROOT);
- addCommand = new AddModuleToEARProjectCommand(project, dataModel.getTargetProject(), uri, contextRoot, null);
- } else
- addCommand = new AddUtilityJARMapCommand(dataModel.getTargetProject(), uri, project);
-
- if (null != removeCommand) {
- return removeCommand.chain(addCommand);
- }
- return addCommand;
- }
-
- private IProject getArchiveProject() {
- WorkbenchComponent wbComp = (WorkbenchComponent) operationDataModel.getProperty(AddUtilityProjectToEARDataModel.ARCHIVE_MODULE);
- return ((AddArchiveToEARDataModel)operationDataModel).getProjectForGivenComponent(wbComp);
- }
-
- private IProject getEARProject() {
- return ((AddArchiveToEARDataModel)operationDataModel).getTargetProject();
- }
-
- private Map computeAllDependents() {
- IProject archiveProject = getArchiveProject();
- IProject earProject = getEARProject();
- if (archiveProject == null || earProject == null)
- return Collections.EMPTY_MAP;
- return new JARDependencyTraverser(archiveProject, earProject).run();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEARDataModel.java
deleted file mode 100644
index 93fae5d49..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEARDataModel.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * 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 27, 2003
- *
- * To change the template for this generated file go to Window>Preferences>Java>Code Generation>Code and
- * Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperationDataModel;
-
-
-/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class AddArchiveProjectsToEARDataModel extends EditModelOperationDataModel {
- /**
- * Requred. This must be a list of IProjects. This list must contain all projects being added
- * even if there is a corresponding model in the MODULE_MODELS list.
- */
- public static final String MODULE_LIST = "AddArchiveProjectsToEARDataModel.MODULE_LIST"; //$NON-NLS-1$
-
- /**
- * Optional - This is a list of AddArchiveProjectsToEARDataModel objects. This allows for non
- * default URIs or other overrides based on the module type.
- */
- public static final String MODULE_MODELS = "AddArchiveProjectsToEARDataModel.MODULE_MODELS"; //$NON-NLS-1$
-
- /**
- * This is a convenience property to return models for all projects in the MODULE_LIST. So you
- * could have some module models defined with overrides and this property will ensure that a
- * model gets created for projects in the MODULE_LIST that do not have a model.
- */
- public static final String ALL_MODULE_MODELS = "AddModulesToEARDataModel.ALL_MODULE_MODELS"; //$NON-NLS-1$
-
- public WTPOperation getDefaultOperation() {
- return new AddArchiveProjectsToEAROperation(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#init()
- */
- protected void init() {
- super.init();
- setProperty(EDIT_MODEL_ID, IEARNatureConstants.EDIT_MODEL_ID);
- }
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(MODULE_LIST);
- addValidBaseProperty(MODULE_MODELS);
- addValidBaseProperty(ALL_MODULE_MODELS);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#getDefaultProperty(java.lang.String)
- */
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(MODULE_LIST) || propertyName.equals(MODULE_MODELS)) {
- return Collections.EMPTY_LIST;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doGetProperty(java.lang.String)
- */
- protected Object doGetProperty(String propertyName) {
- if (propertyName.equals(ALL_MODULE_MODELS)) {
- return computeAllModuleModels();
- }
- return super.doGetProperty(propertyName);
- }
-
- /**
- * @return
- */
- private List computeAllModuleModels() {
- List projects = (List) getProperty(MODULE_LIST);
- List models = (List) getProperty(MODULE_MODELS);
- if (!projects.isEmpty())
- return computeAllArchiveModels(projects, models);
- return models;
- }
-
- /**
- * @param projects
- * @param models
- * @return
- */
- private List computeAllArchiveModels(List projects, List models) {
- List allModels = new ArrayList(projects.size());
- String earProjName = getStringProperty(PROJECT_NAME);
- IProject project = null;
- AddArchiveToEARDataModel model = null;
- for (int i = 0; i < projects.size(); i++) {
- project = (IProject) projects.get(i);
- model = findOrCreateModel(project, models);
- if (model != null) {
- model.setProperty(AddArchiveToEARDataModel.PROJECT_NAME, earProjName);
- allModels.add(model);
- }
- }
- return allModels;
- }
-
- /**
- * @param project
- * @param models
- * @return
- */
- private AddArchiveToEARDataModel findOrCreateModel(IProject project, List models) {
- //TODO: implement for modules not projects
-// if (!models.isEmpty()) {
-// AddArchiveToEARDataModel model = null;
-// for (int i = 0; i < models.size(); i++) {
-// model = (AddArchiveToEARDataModel) models.get(i);
-// if (project.equals(model.getProperty(AddArchiveToEARDataModel.ARCHIVE_PROJECT)))
-// return model;
-// }
-// }
- //Not found so we need to create one.
- return null; //TODO fix up createArchiveModel(project);
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEAROperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEAROperation.java
deleted file mode 100644
index 565ebca6b..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveProjectsToEAROperation.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * 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 26, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.common.internal.emfworkbench.integration.CompoundingCommandStack;
-import org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperation;
-
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class AddArchiveProjectsToEAROperation extends EditModelOperation {
- /**
- * @param operationDataModel
- */
- public AddArchiveProjectsToEAROperation(AddArchiveProjectsToEARDataModel operationDataModel) {
- super(operationDataModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- AddArchiveProjectsToEARDataModel dataModel = (AddArchiveProjectsToEARDataModel) operationDataModel;
- List models = (List) dataModel.getProperty(AddArchiveProjectsToEARDataModel.ALL_MODULE_MODELS);
- if (!models.isEmpty()) {
- CompoundingCommandStack cmdStack = new CompoundingCommandStack(getCommandStack());
- AddArchiveToEARDataModel model;
- AddArchiveProjectToEAROperation op = null;
- for (int i = 0; i < models.size(); i++) {
- model = (AddArchiveToEARDataModel) models.get(i);
- op = new AddArchiveProjectToEAROperation(model);
- op.setCommandStack(cmdStack);
- op.doRun(monitor);
- }
- cmdStack.performExecution();
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveToEARDataModel.java
deleted file mode 100644
index 337e6e512..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddArchiveToEARDataModel.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * 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 25, 2003
- *
- * To change the template for this generated file go to Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEdit;
-import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEditOperationDataModel;
-import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
-import org.eclipse.wst.common.modulecore.ModuleCore;
-import org.eclipse.wst.common.modulecore.UnresolveableURIException;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public abstract class AddArchiveToEARDataModel extends EARArtifactEditOperationDataModel {
- /**
- * Required - This is the module that is being added to the EAR (designated by the
- * PROJECT_NAME). type = WorkbenchComponent
- */
- public static final String ARCHIVE_MODULE = "AddModuleToEARDataModel.ARCHIVE_PROJECT"; //$NON-NLS-1$
- /**
- * Optional - The URI used for the archive in the EAR project. type = String
- */
- public static final String ARCHIVE_URI = "AddModuleToEARDataModel.URI"; //$NON-NLS-1$
- /**
- * Required - This is the boolean value to sync the module target runtime to that of the EAR
- * project default - false;
- */
- public static final String SYNC_TARGET_RUNTIME = "AddModuleToEARDataModel.SYNC_TARGET_RUNTIME"; //$NON-NLS-1$
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperationDataModel#initValidBaseProperties()
- */
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(ARCHIVE_MODULE);
- addValidBaseProperty(ARCHIVE_URI);
- addValidBaseProperty(SYNC_TARGET_RUNTIME);
- }
-
- protected IStatus doValidateProperty(String propertyName) {
- if (PROJECT_NAME.equals(propertyName)) {
- IProject project = getTargetProject();
- try {
- if (project == null || !project.exists() || !project.isOpen() || !project.hasNature(IEARNatureConstants.NATURE_ID)) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_PROJECT_NOT_EAR));
- }
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- }
- if (ARCHIVE_MODULE.equals(propertyName)) {
- WorkbenchComponent module = (WorkbenchComponent) getProperty(propertyName);
- if (null == module) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_MODULE_MODULE_NULL));
- }
- IProject containingProj = getProjectForGivenComponent(module);
- if (!containingProj.isOpen()) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_MODULE_MODULE_CLOSED));
- }
- } else if (ARCHIVE_URI.equals(propertyName)) {
- String uri = getStringProperty(ARCHIVE_URI);
- if (uri == null || uri.trim().length() == 0) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_PROJECT_URI_EMPTY));
- }
-
- EARArtifactEdit earEdit = null;
- try {
- earEdit = getEARArtifactEditForRead();
- if (earEdit.uriExists(uri)) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_PROJECT_URI_EXISTS));
- }
- } finally {
- if (earEdit != null) {
- earEdit.dispose();
- }
- }
- }
- return super.doValidateProperty(propertyName);
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- boolean returnValue = super.doSetProperty(propertyName, propertyValue);
- if (propertyName.equals(ARCHIVE_MODULE)) {
- notifyDefaultChange(ARCHIVE_URI);
- }
- return returnValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#getDefaultProperty(java.lang.String)
- */
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(ARCHIVE_URI))
- return getDefaultArchiveURI();
- return super.getDefaultProperty(propertyName);
- }
-
- /**
- * @return
- */
- protected String getDefaultArchiveURI() {
- WorkbenchComponent module = (WorkbenchComponent) getProperty(ARCHIVE_MODULE);
- if (module != null) {
- StringBuffer b = new StringBuffer();
- b.append(module.getName().replace(' ', '_'));
- b.append('.');
- b.append(getDefaultURIExtension());
- return b.toString();
- }
- return ""; //$NON-NLS-1$
- }
-
- protected String getDefaultURIExtension() {
- return "jar"; //$NON-NLS-1$
- }
-
- public boolean isModuleArchive() {
- return false;
- }
-
- /**
- * @return
- */
- public ServerTargetDataModel getServerTargetDataModel() {
- ServerTargetDataModel model = new ServerTargetDataModel();
- IRuntime earRuntime = ServerCore.getProjectProperties(getTargetProject()).getRuntimeTarget();
- if (earRuntime != null)
- model.setProperty(ServerTargetDataModel.RUNTIME_TARGET_ID, earRuntime.getId());
- else
- model.setProperty(ServerTargetDataModel.RUNTIME_TARGET_ID, null);
- WorkbenchComponent module = (WorkbenchComponent) getProperty(ARCHIVE_MODULE);
- IProject modProject = getProjectForGivenComponent(module);
- if (modProject != null)
- model.setProperty(ServerTargetDataModel.PROJECT_NAME, modProject.getName());
- return model;
- }
-
- public IProject getProjectForGivenComponent(WorkbenchComponent wbComp) {
- IProject modProject = null;
- try {
- modProject = ModuleCore.getContainingProject(wbComp.getHandle());
- } catch (UnresolveableURIException ex) {
- Logger.getLogger().logError(ex);
- }
- return modProject;
- }
-
- public AddArchiveToEARDataModel createArchiveModel() {
- AddArchiveToEARDataModel model = null;
-// switch (ModuleType) {
-// case XMLResource.WEB_APP_TYPE :
-// model = new AddWebModuleToEARDataModel();
-// break;
-// default :
-// model = new AddModuleToEARDataModel();
-// break;
-// }
-// model = new AddUtilityProjectToEARDataModel();
- return model;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationDataModel.java
deleted file mode 100644
index 05416fb7f..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationDataModel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.util.ArrayList;
-import java.util.Collections;
-
-import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEditOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-
-public class AddComponentToEnterpriseApplicationDataModel extends EARArtifactEditOperationDataModel {
- //Used for adding module components to an Enterprise Application during EAR component creation
- public static final String MODULE_LIST = "AddComponentToEnterpriseApplicationDataModel.MODULE_LIST"; //$NON-NLS-1$
-
- public static final String EAR_MODULE_NAME = "AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME";
- //Used for adding module componenet to Enterprise Application during module creation
- public static final String ARCHIVE_MODULE = "AddComponentToEnterpriseApplicationDataModel.ARCHIVE_PROJECT"; //$NON-NLS-1$
-
- public AddComponentToEnterpriseApplicationDataModel() {
- super();
-
- }
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(MODULE_LIST);
- addValidBaseProperty(EAR_MODULE_NAME);
- addValidBaseProperty(ARCHIVE_MODULE);
- }
-
- public WTPOperation getDefaultOperation() {
- return new AddComponentToEnterpriseApplicationOperation(this);
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(MODULE_LIST) )
- return new ArrayList();
- return super.getDefaultProperty(propertyName);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationOperation.java
deleted file mode 100644
index 57d92ce15..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddComponentToEnterpriseApplicationOperation.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEditOperation;
-import org.eclipse.wst.common.modulecore.ModuleCore;
-import org.eclipse.wst.common.modulecore.ReferencedComponent;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.impl.ModuleCoreFactoryImpl;
-
-public class AddComponentToEnterpriseApplicationOperation extends EARArtifactEditOperation {
- public static final String metaInfFolderDeployPath = "/"; //$NON-NLS-1$
-
- public AddComponentToEnterpriseApplicationOperation(AddComponentToEnterpriseApplicationDataModel operationDataModel) {
- super(operationDataModel);
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- addComponentToEnterpriseApplication(monitor);
- }
-
- private void addComponentToEnterpriseApplication(IProgressMonitor monitor) {
- ModuleCore moduleCore = null;
- try{
- moduleCore = ModuleCore.getModuleCoreForWrite(getProject());
- WorkbenchComponent earComp = moduleCore.findWorkbenchModuleByDeployName(operationDataModel.getStringProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME));
- AddComponentToEnterpriseApplicationDataModel dm = (AddComponentToEnterpriseApplicationDataModel)getOperationDataModel();
- URI runtimeURI = URI.createURI(metaInfFolderDeployPath);
- List list = (List)dm.getProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST);
- if (list != null && list.size() > 0) {
- for (int i = 0; i < list.size(); i++) {
- ReferencedComponent rc = ModuleCoreFactoryImpl.eINSTANCE.createReferencedComponent();
- WorkbenchComponent wc = (WorkbenchComponent)list.get(i);
- rc.setHandle(wc.getHandle());
- rc.setRuntimePath(runtimeURI);
- earComp.getReferencedComponents().add(rc);
- }
- }
- moduleCore.saveIfNecessary(null);
- } finally {
- if (null != moduleCore) {
- moduleCore.dispose();
- }
- }
- }
-
- public IProject getProject() {
- String projName = operationDataModel.getStringProperty(AddComponentToEnterpriseApplicationDataModel.PROJECT_NAME );
- return ProjectUtilities.getProject( projName );
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddModuleToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddModuleToEARDataModel.java
deleted file mode 100644
index 13a393153..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddModuleToEARDataModel.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.application.operations;
-
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.operation.ArtifactEditOperationDataModel;
-import org.eclipse.wst.common.modulecore.internal.util.IModuleConstants;
-
-/**
- *
- */
-public class AddModuleToEARDataModel extends AddArchiveToEARDataModel {
-
- /**
- *
- */
- public static final String MODULE_PROJECT_LIST = "AddModuleToEARDataModel.MODULE_PROJECT_LIST"; //$NON-NLS-1$
-
- /**
- *
- */
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(MODULE_PROJECT_LIST);
- }
-
- /**
- *
- * @param earModuleName
- * @param module
- * @return
- */
- public static AddModuleToEARDataModel createAddToEARDataModel(String earModuleName, WorkbenchComponent module) {
- AddModuleToEARDataModel model = new AddModuleToEARDataModel();
- model.setProperty(ArtifactEditOperationDataModel.MODULE_NAME, earModuleName);
- model.setProperty(AddArchiveToEARDataModel.ARCHIVE_MODULE, module);
- return model;
- }
-
- /**
- *
- * @return
- */
- public AddModuleToEARDataModel getAppropriateDataModel() {
- AddModuleToEARDataModel model = this;
- WorkbenchComponent wbComp = (WorkbenchComponent) getProperty(AddArchiveToEARDataModel.ARCHIVE_MODULE);
- if (wbComp != null && wbComp.getComponentType().getModuleTypeId() == IModuleConstants.JST_WEB_MODULE) {
- //model = AddWebModuleToEARDataModel.createAddWebModuleToEARDataModel(getStringProperty(MODULE_NAME), wbComp);
- model.setProperty(AddArchiveToEARDataModel.ARCHIVE_URI, getProperty(ARCHIVE_URI));
- }
- return model;
- }
-
- /**
- *
- */
- public WTPOperation getDefaultOperation() {
- return new AddArchiveProjectToEAROperation(this);
- }
-
- /**
- *
- */
- protected String getDefaultArchiveURI() {
- return getStringProperty(ARCHIVE_URI);
- //TODO: reimplement
-// IProject archiveProj = (IProject) getProperty(ARCHIVE_PROJECT);
-// J2EENature j2eeNature = J2EENature.getRegisteredRuntime(archiveProj);
-// if (j2eeNature != null) {
-// J2EEModuleNature modNature = (J2EEModuleNature) j2eeNature;
-// String existingURI = modNature.getModuleUriInFirstEAR();
-// if (existingURI != null)
-// return existingURI;
-// }
-// return super.getDefaultArchiveURI();
- }
-
- /**
- *
- */
- protected String getDefaultURIExtension() {
- WorkbenchComponent wbComp = (WorkbenchComponent) getProperty(AddArchiveToEARDataModel.ARCHIVE_MODULE);
- if (wbComp != null && wbComp.getComponentType().getModuleTypeId() == IModuleConstants.JST_WEB_MODULE)
- return "war"; //$NON-NLS-1$
- if (wbComp != null && wbComp.getComponentType().getModuleTypeId() == IModuleConstants.JST_CONNECTOR_MODULE)
- return "rar"; //$NON-NLS-1$
- return super.getDefaultURIExtension();
- }
-
- /**
- *
- */
- public boolean isModuleArchive() {
- return true;
- }
-
- /**
- *
- * @return
- */
- public boolean isWebModuleArchive() {
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddUtilityProjectToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddUtilityProjectToEARDataModel.java
deleted file mode 100644
index 9562cb2c1..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddUtilityProjectToEARDataModel.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * 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 25, 2003
- *
- * To change the template for this generated file go to Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.j2ee.common.XMLResource;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.EAREditModel;
-import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime;
-import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.util.IModuleConstants;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class AddUtilityProjectToEARDataModel extends AddArchiveToEARDataModel {
- /**
- * (non-Javadoc)
- * * @deprecated - This method is deprecated module must be passed
- * @see org.eclipse.jst.j2ee.internal.internal.application.operations.AddArchiveProjectToEARDataModel#getDefaultArchiveURI()
- */
- public static AddUtilityProjectToEARDataModel createAddToEARDataModel(String earProjectName, IProject moduleProject) {
- AddUtilityProjectToEARDataModel model = new AddUtilityProjectToEARDataModel();
- model.setProperty(AddModuleToEARDataModel.PROJECT_NAME, earProjectName);
- //model.setProperty(AddModuleToEARDataModel.ARCHIVE_PROJECT, moduleProject);
- return model;
- }
- public static AddUtilityProjectToEARDataModel createAddToEARDataModel(String earModuleName, WorkbenchComponent module) {
- AddUtilityProjectToEARDataModel model = new AddUtilityProjectToEARDataModel();
- model.setProperty(AddModuleToEARDataModel.MODULE_NAME, earModuleName);
- model.setProperty(AddModuleToEARDataModel.ARCHIVE_MODULE, module);
- return model;
- }
- private static final String NESTED_MODEL_MANIFEST = "AddUtilityProjectToEARDataModel.NESTED_MODEL_MANIFEST"; //$NON-NLS-1$
- private static final String NESTED_MODEL_SERVER_TARGET = "AddUtilityProjectToEARDataModel.NESTED_MODEL_SERVER_TARGET"; //$NON-NLS-1$
-
- private UpdateManifestDataModel manifestModel;
- private ServerTargetDataModel serverTargetModel;
-
- public WTPOperation getDefaultOperation() {
- return new AddArchiveProjectToEAROperation(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#initNestedModels()
- */
- protected void initNestedModels() {
- super.initNestedModels();
- manifestModel = new UpdateManifestDataModel();
- addNestedModel(NESTED_MODEL_MANIFEST, manifestModel);
- serverTargetModel = new ServerTargetDataModel();
- addNestedModel(NESTED_MODEL_SERVER_TARGET, serverTargetModel);
- }
-
- /**
- *
- */
- private void updateServerTargetIDs() {
- EARNatureRuntime nature = EARNatureRuntime.getRuntime(getTargetProject());
- if (nature != null) {
- serverTargetModel.setIntProperty(ServerTargetDataModel.J2EE_VERSION_ID, nature.getJ2EEVersion());
- IRuntime targetType = ServerCore.getProjectProperties(getTargetProject()).getRuntimeTarget();
- if (targetType != null)
- serverTargetModel.setProperty(ServerTargetDataModel.RUNTIME_TARGET_ID, targetType.getId());
- //We need to use the EAR type for now.
- serverTargetModel.setIntProperty(ServerTargetDataModel.DEPLOYMENT_TYPE_ID, XMLResource.APPLICATION_TYPE);
- }
- }
-
- public String getUtilityJARUriInFirstEAR(IProject utilProject) {
- Object key = new Object();
- EARNatureRuntime earNature = J2EEProjectUtilities.getFirstReferencingEARProject(utilProject);
- if (earNature != null) {
- EAREditModel model;
- UtilityJARMapping mapping;
- model = earNature.getEarEditModelForRead(key);
- try {
- mapping = model.getUtilityJARMapping(utilProject);
- if (mapping != null && mapping.getUri() != null && mapping.getUri().length() > 0)
- return mapping.getUri();
- } finally {
- model.releaseAccess(key);
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doSetProperty(java.lang.String,
- * java.lang.Object)
- */
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- boolean result = super.doSetProperty(propertyName, propertyValue);
- if (propertyName.equals(ARCHIVE_MODULE)) {
- WorkbenchComponent wbComp = (WorkbenchComponent) propertyValue;
- IProject proj = getProjectForGivenComponent(wbComp);
- updateManifestModel(proj);
- updateServerTargetModel(proj);
- } else if (propertyName.equals(PROJECT_NAME))
- updateServerTargetIDs();
- return result;
- }
-
- /**
- * @param proj
- */
- private void updateServerTargetModel(IProject proj) {
- if (proj != null) {
- serverTargetModel.setProperty(ServerTargetDataModel.PROJECT_NAME, proj.getName());
- }
- }
-
- private void updateManifestModel(IProject proj) {
- if (proj != null)
- manifestModel.setProperty(UpdateManifestDataModel.PROJECT_NAME, proj.getName());
- else
- manifestModel.setProperty(UpdateManifestDataModel.PROJECT_NAME, null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jst.j2ee.internal.internal.application.operations.AddArchiveProjectToEARDataModel#getDefaultArchiveURI()
- */
- protected String getDefaultArchiveURI() {
- WorkbenchComponent wbComp = (WorkbenchComponent) getProperty(ARCHIVE_MODULE);
- return wbComp.getHandle().toString();
- //TODO: port
-// IProject project = (IProject) getProperty(ARCHIVE_PROJECT);
-// if (project != null) {
-// String defaultURI = getUtilityJARUriInFirstEAR(project);
-// if (defaultURI != null)
-// return defaultURI;
-// }
-// return super.getDefaultArchiveURI();
- }
-
- protected IStatus doValidateProperty(String propertyName) {
- if (ARCHIVE_MODULE.equals(propertyName)) {
- IStatus status = super.doValidateProperty(propertyName);
- if (!status.isOK()) {
- return status;
- }
- //TODO redo without editmodel
-// Object key = new Object();
-// EAREditModel editModel = null;
-// try {
-// editModel = (EAREditModel) getEditModelForRead(key);
-// if (null != editModel.getUtilityJARMapping((IProject) getProperty(ARCHIVE_PROJECT))) {
-// return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_PROJECT_UTIL_MAPPED));
-// }
-// } finally {
-// if (null != editModel) {
-// editModel.releaseAccess(key);
-// }
-// }
- WorkbenchComponent wbComp = (WorkbenchComponent) getProperty(ARCHIVE_MODULE);
- if (isWebOrClientModule(wbComp) || !isJavaModule(wbComp)) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_PROJECT_NOT_JAVA));
- }
- } else if (ARCHIVE_URI.equals(propertyName)) {
- IStatus status = super.doValidateProperty(propertyName);
- if (!status.isOK()) {
- return status;
- }
- if (!getStringProperty(ARCHIVE_URI).endsWith(".jar")) { //$NON-NLS-1$
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.ADD_PROJECT_UTIL_URI));
- }
- }
- return super.doValidateProperty(propertyName);
- }
-
- private boolean isJavaModule(WorkbenchComponent wbComp) {
- return wbComp.getComponentType().getModuleTypeId().equals(IModuleConstants.JST_UTILITY_MODULE);
- }
-
- private boolean isWebOrClientModule(WorkbenchComponent wbComp) {
- String typeID = wbComp.getComponentType().getModuleTypeId();
- return typeID.equals(IModuleConstants.JST_WEB_MODULE) || typeID.equals(IModuleConstants.JST_APPCLIENT_MODULE);
- }
-
- /**
- * @return Returns the manifestModel.
- */
- public UpdateManifestDataModel getManifestModel() {
- return manifestModel;
- }
-
- /**
- * @return Returns the serverTargetModel.
- */
- public ServerTargetDataModel getServerTargetModel() {
- return serverTargetModel;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddWebModuleToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddWebModuleToEARDataModel.java
deleted file mode 100644
index fb1b4fc98..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AddWebModuleToEARDataModel.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.operation.ArtifactEditOperationDataModel;
-
-
-/**
- *
- */
-public class AddWebModuleToEARDataModel extends AddComponentToEnterpriseApplicationDataModel {
-
- /**
- * Optional - This is the context root stored with the module in the application.xml.
- */
- public static final String CONTEXT_ROOT = "AddWebModuleToEARDataModel.CONTEXT_ROOT"; //$NON-NLS-1$
-
- /**
- *
- */
- public String defaultContextRoot = ""; //$NON-NLS-1$
-
- /**
- *
- * @param earModuleName
- * @param module
- * @return
- */
- public static AddWebModuleToEARDataModel createAddWebModuleToEARDataModel(String earModuleName, WorkbenchComponent module) {
- AddWebModuleToEARDataModel model = new AddWebModuleToEARDataModel();
- model.setProperty(ArtifactEditOperationDataModel.MODULE_NAME, earModuleName);
- model.setProperty(AddArchiveToEARDataModel.ARCHIVE_MODULE, module);
- return model;
- }
-
- /**
- *
- */
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(CONTEXT_ROOT);
- }
-
- /**
- *
- */
- protected String getDefaultURIExtension() {
- return "war"; //$NON-NLS-1$
- }
-
- /**
- *
- */
- public boolean isWebModuleArchive() {
- return true;
- }
-
- /**
- *
- */
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- boolean notify = super.doSetProperty(propertyName, propertyValue);
- if (notify && propertyName.equals(ARCHIVE_MODULE))
- notifyDefaultChange(CONTEXT_ROOT);
- return notify;
- }
-
- /**
- *
- */
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(CONTEXT_ROOT))
- return getDefaultContextRoot();
- return super.getDefaultProperty(propertyName);
- }
-
- /**
- *
- * @return
- */
- private String getDefaultContextRoot() {
- if (defaultContextRoot.equals("")) //$NON-NLS-1$
- return computeDefaultContextRoot();
- return defaultContextRoot;
- }
-
- private String computeDefaultContextRoot() {
- String wbCompName = (String)getProperty(ARCHIVE_MODULE);
- if (wbCompName != null && wbCompName.length() > 0)
- return wbCompName.replace(' ', '_');
- return null;
- }
-
- /**
- *
- */
- protected IStatus doValidateProperty(String propertyName) {
- if (CONTEXT_ROOT.equals(propertyName)) {
- return validateContextRoot(getStringProperty(CONTEXT_ROOT));
- }
- return super.doValidateProperty(propertyName);
- }
-
- /**
- *
- * @param contextRoot
- * @return
- */
- public IStatus validateContextRoot(String contextRoot) {
- if (contextRoot.equals("") || contextRoot == null) { //$NON-NLS-1$
- return J2EEPlugin.newErrorStatus(ProjectSupportResourceHandler.getString("Context_Root_cannot_be_empty_2", new Object[]{contextRoot}), null); //$NON-NLS-1$
- }
- else if (contextRoot.trim().equals(contextRoot)) {
- StringTokenizer stok = new StringTokenizer(contextRoot, "."); //$NON-NLS-1$
- while (stok.hasMoreTokens()) {
- String token = stok.nextToken();
- for (int i = 0; i < token.length(); i++) {
- if (!(token.charAt(i) == '_') && !(token.charAt(i) == '-') && !(token.charAt(i) == '/') && Character.isLetterOrDigit(token.charAt(i)) == false) {
- Object[] invalidChar = new Object[]{(new Character(token.charAt(i))).toString()};
- String errorStatus = ProjectSupportResourceHandler.getString("The_character_is_invalid_in_a_context_root",invalidChar); //$NON-NLS-1$
- return J2EEPlugin.newErrorStatus(errorStatus, null);
- }
- }
- }
- }
- else
- return J2EEPlugin.newErrorStatus(ProjectSupportResourceHandler.getString("Names_cannot_begin_or_end_with_whitespace_5", new Object[]{contextRoot}), null); //$NON-NLS-1$
- return OK_STATUS;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AppClientModuleExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AppClientModuleExportDataModel.java
deleted file mode 100644
index c2cd7a63a..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/AppClientModuleExportDataModel.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.jst.j2ee.applicationclient.creation.IApplicationClientNatureConstants;
-import org.eclipse.jst.j2ee.internal.archive.operations.AppClientModuleExportOperation;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * This dataModel is used to export Application Client Modules to Application Client Jar files.
- *
- * 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 final class AppClientModuleExportDataModel extends J2EEModuleExportDataModel {
-
- /**
- * Exports the specified Application Client Module project to the specified Application Client
- * Jar file.
- *
- * @param appClientProjectName
- * The name of the Application Client Module project to export.
- * @param appClientJarFileName
- * The fully qualified Application Client Jar file location to export the specified
- * Application Client Module project.
- * @param overwriteExisting
- * If this is <code>true</code> then an existing file at the location specified by
- * <code>earFileName</code> will be overwritten.
- * @param exportSource
- * If this is <code>true</code> then all source files in the specified Application
- * Client Module will be included in the resulting Application Client Jar file.
- * @since WTP 1.0
- */
- public static void exportProject(String appClientProjectName, String appClientJarFileName, boolean overwriteExisting, boolean exportSource) {
- AppClientModuleExportDataModel dataModel = new AppClientModuleExportDataModel();
- dataModel.setProperty(PROJECT_NAME, appClientProjectName);
- dataModel.setBooleanProperty(OVERWRITE_EXISTING, overwriteExisting);
- dataModel.setProperty(ARCHIVE_DESTINATION, appClientJarFileName);
- dataModel.setBooleanProperty(EXPORT_SOURCE_FILES, exportSource);
- try {
- dataModel.getDefaultOperation().run(null);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- }
- }
-
- public WTPOperation getDefaultOperation() {
- return new AppClientModuleExportOperation(this);
- }
-
- public AppClientModuleExportDataModel() {
- super();
- }
-
- protected String getModuleExtension() {
- return ".jar"; //$NON-NLS-1$
- }
-
- protected String getNatureID() {
- return IApplicationClientNatureConstants.NATURE_ID;
- }
-
- protected String getWrongProjectTypeString(String projectName) {
- return EARCreationResourceHandler.getString(EARCreationResourceHandler.NOT_AN_APP_CLIENT, new Object[]{projectName});
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClassPathSelection.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClassPathSelection.java
deleted file mode 100644
index 39221e688..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClassPathSelection.java
+++ /dev/null
@@ -1,601 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Container;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ManifestException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategy;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.internal.archive.operations.EARProjectLoadStrategyImpl;
-import org.eclipse.jst.j2ee.internal.archive.operations.J2EELoadStrategyImpl;
-import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime;
-import org.eclipse.jst.j2ee.internal.earcreation.ModuleMapHelper;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-public class ClassPathSelection {
- protected Archive archive;
- protected IProject earProject;
- protected List classpathElements;
- protected Map urisToElements;
- protected boolean modified;
- private String targetProjectName;
- protected Map ejbToClientJARs = null;
- protected Map clientToEJBJARs = null;
- public static final int FILTER_EJB_SERVER_JARS = 0;
- public static final int FILTER_EJB_CLIENT_JARS = 1;
- public static final int FILTER_NONE = 2;
-
- protected int filterLevel = 2;
-
- protected static Comparator comparator = new Comparator() {
- /**
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, Object o2) {
- Archive a1 = (Archive) o1;
- Archive a2 = (Archive) o2;
- return a1.getURI().compareTo(a2.getURI());
- }
- };
-
- public ClassPathSelection(Archive anArchive, String targetProjectName, EARFile earFile) {
- super();
- archive = anArchive;
- this.targetProjectName = targetProjectName;
- initializeEARProject(earFile);
- initializeElements();
- }
-
- /**
- * ClassPathSelection constructor comment.
- */
- public ClassPathSelection(Archive anArchive, EARFile earFile) {
- super();
- archive = anArchive;
- initializeEARProject(earFile);
- initializeElements();
- }
-
- protected ClasspathElement createElement(Archive referencingArchive, Archive referencedArchive, String cpEntry) {
- ClasspathElement element = new ClasspathElement(referencingArchive);
- element.setValid(true);
- element.setText(referencedArchive.getURI());
- element.setTargetArchive(referencedArchive);
- element.setEarProject(earProject);
- setProjectValues(element, referencedArchive);
- if (cpEntry != null)
- element.setValuesSelected(cpEntry);
- setType(element, referencedArchive);
- return element;
- }
-
- protected ClasspathElement createInvalidElement(String cpEntry) {
- ClasspathElement element = new ClasspathElement(archive);
- element.setValid(false);
- element.setSelected(true);
- element.setRelativeText(cpEntry);
- element.setText(cpEntry);
- element.setEarProject(earProject);
- setInvalidProject(element);
- return element;
- }
-
- /**
- * @param element
- */
- private void setInvalidProject(ClasspathElement element) {
- IProject earProj = element.getEarProject();
- EARNatureRuntime nature = EARNatureRuntime.getRuntime(earProj);
- if (nature != null) {
- IProject mappedProject = nature.getMappedProject(element.getRelativeText());
- element.setProject(mappedProject);
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 1:17:21 PM)
- *
- * @return java.util.List
- */
- public java.util.List getClasspathElements() {
- return classpathElements;
- }
-
- /**
- * Adapter method to convert the manifest class path entries which map to a project to a list of
- * classpath entries for a java build path
- */
- protected IClasspathEntry[] getClasspathEntries(boolean filterSelected) {
- List result = new ArrayList();
- IClasspathEntry[] array = null;
- ;
- ClasspathElement element = null;
- for (int i = 0; i < classpathElements.size(); i++) {
- element = (ClasspathElement) classpathElements.get(i);
- if (filterSelected && !element.isSelected())
- continue;
- array = ((ClasspathElement) classpathElements.get(i)).newClasspathEntries();
- if (array == null)
- continue;
- for (int j = 0; j < array.length; j++) {
- if (!result.contains(array[j]))
- result.add(array[j]);
- }
- }
- return (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
- }
-
- /**
- * Adapter method to convert the manifest class path entries which map to a project to a list of
- * classpath entries for a java build path
- */
- public IClasspathEntry[] getClasspathEntriesForAll() {
- return getClasspathEntries(false);
- }
-
- /**
- * Adapter method to convert the manifest class path entries which map to a project to a list of
- * classpath entries for a java build path
- */
- public IClasspathEntry[] getClasspathEntriesForSelected() {
- return getClasspathEntries(true);
- }
-
- protected EARFile getEARFile() {
- if (archive == null)
- return null;
-
- Container parent = archive.getContainer();
- if (parent != null && parent.isEARFile())
- return (EARFile) parent;
- return null;
- }
-
- protected static IProject getEARProject(Archive anArchive) {
- Container c = anArchive.getContainer();
- if (!c.isEARFile())
- return null;
- EARFile ear = (EARFile) c;
- LoadStrategy loader = ear.getLoadStrategy();
- if (!(loader instanceof EARProjectLoadStrategyImpl))
- return null;
-
- return ((EARProjectLoadStrategyImpl) loader).getProject();
- }
-
- public Archive getArchive() {
- return archive;
- }
-
- protected IProject getProject(Archive anArchive) {
- LoadStrategy loader = anArchive.getLoadStrategy();
- if (!(loader instanceof J2EELoadStrategyImpl))
- return ModuleMapHelper.getProject(anArchive.getURI(), getEARFile());
-
- return ((J2EELoadStrategyImpl) loader).getProject();
- }
-
- public String getText() {
- return archive.getURI();
- }
-
- protected Archive getArchive(String uri, List archives) {
- for (int i = 0; i < archives.size(); i++) {
- Archive anArchive = (Archive) archives.get(i);
- if (anArchive.getURI().equals(uri))
- return anArchive;
- }
- return null;
- }
-
- protected void initializeElements() {
- ejbToClientJARs = J2EEProjectUtilities.collectEJBClientJARs(getEARFile());
- clientToEJBJARs = reverse(ejbToClientJARs);
- classpathElements = new ArrayList();
- urisToElements = new HashMap();
- String[] cp = new String[0];
- try {
- cp = archive.getManifest().getClassPathTokenized();
- } catch (ManifestException ex) {
- Logger.getLogger().logError(ex);
- }
- List archives = getEARFile().getArchiveFiles();
- Archive other = null;
- ClasspathElement element = null;
- for (int i = 0; i < cp.length; i++) {
- String cpEntry = cp[i];
- String uri = ArchiveUtil.deriveEARRelativeURI(cpEntry, archive);
- other = getArchive(uri, archives);
- if (other != null && ArchiveUtil.isValidDependency(other, archive)) {
- element = createElement(archive, other, cpEntry);
- archives.remove(other);
- } else {
- element = createInvalidElement(cpEntry);
- if (element.representsImportedJar()) {
- element.setValid(true);
- element.setProject(getProject(archive));
- }
- if (other != null)
- element.setProject(getProject(other));
- }
- addClasspathElement(element, uri);
- }
- Collections.sort(archives, comparator);
- //Anything that remains in the list of available archives that is valid should be
- //available for selection
- for (int i = 0; i < archives.size(); i++) {
- other = (Archive) archives.get(i);
- if (other != archive && ArchiveUtil.isValidDependency(other, archive)) {
- IProject project = getProject(other);
- if (null == targetProjectName || null == project || !project.getName().equals(targetProjectName)) {
- element = createElement(archive, other, null);
- element.setProject(getProject(other));
- addClasspathElement(element, other.getURI());
- }
- }
- }
- }
-
- private void initializeEARProject(EARFile earFile) {
- LoadStrategy loadStrat = earFile.getLoadStrategy();
- if (loadStrat instanceof EARProjectLoadStrategyImpl)
- earProject = ((EARProjectLoadStrategyImpl) loadStrat).getProject();
- }
-
- private void setType(ClasspathElement element, Archive other) {
- if (other == null)
- return;
- else if (clientToEJBJARs.containsKey(other))
- element.setJarType(ClasspathElement.EJB_CLIENT_JAR);
- else if (other.isEJBJarFile())
- element.setJarType(ClasspathElement.EJB_JAR);
- }
-
- /**
- * @param localejbToClientJARs
- * @return
- */
- private Map reverse(Map localejbToClientJARs) {
- if (localejbToClientJARs == null || localejbToClientJARs.isEmpty())
- return Collections.EMPTY_MAP;
- Map result = new HashMap();
- Iterator iter = localejbToClientJARs.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- result.put(entry.getValue(), entry.getKey());
- }
- return result;
- }
-
- protected void addClasspathElement(ClasspathElement element, String uri) {
- classpathElements.add(element);
- urisToElements.put(uri, element);
- element.setParentSelection(this);
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 6:05:11 PM)
- *
- * @return boolean
- */
- public boolean isModified() {
- return modified;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 6:05:11 PM)
- *
- * @param newModified
- * boolean
- */
- public void setModified(boolean newModified) {
- modified = newModified;
- }
-
- protected void setProjectValues(ClasspathElement element, Archive referencedArchive) {
- IProject p = getProject(referencedArchive);
- if (p == null)
- return;
-
- element.setProject(p);
- //Handle the imported jars in the project
- String[] cp = null;
- try {
- cp = referencedArchive.getManifest().getClassPathTokenized();
- } catch (ManifestException mfEx) {
- Logger.getLogger().logError(mfEx);
- cp = new String[]{};
- }
- List paths = new ArrayList(cp.length);
- for (int i = 0; i < cp.length; i++) {
-
- IFile file = null;
- try {
- file = p.getFile(cp[i]);
- } catch (IllegalArgumentException invalidPath) {
- continue;
- }
- if (file.exists())
- paths.add(file.getFullPath());
- }
- if (!paths.isEmpty())
- element.setImportedJarPaths(paths);
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < classpathElements.size(); i++) {
- ClasspathElement element = (ClasspathElement) classpathElements.get(i);
- if (element.isSelected()) {
- sb.append(element.getRelativeText());
- sb.append(" "); //$NON-NLS-1$
- }
- }
- //Remove the trailing space
- if (sb.length() > 0)
- sb.deleteCharAt(sb.length() - 1);
- return sb.toString();
- }
-
- public void setAllSelected(boolean selected) {
- setAllSelected(classpathElements, selected);
- }
-
- public void setAllSelected(List elements, boolean selected) {
- for (int i = 0; i < elements.size(); i++) {
- ClasspathElement elmt = (ClasspathElement) elements.get(i);
- elmt.setSelected(selected);
- }
- }
-
- /* borrowed code from jdt */
- protected List moveUp(List elements, List move) {
- int nElements = elements.size();
- List res = new ArrayList(nElements);
- Object floating = null;
- for (int i = 0; i < nElements; i++) {
- Object curr = elements.get(i);
- if (move.contains(curr)) {
- res.add(curr);
- } else {
- if (floating != null) {
- res.add(floating);
- }
- floating = curr;
- }
- }
- if (floating != null) {
- res.add(floating);
- }
- return res;
- }
-
- /* borrowed code from jdt */
- public void moveUp(List toMoveUp) {
- setModifiedIfAnySelected(toMoveUp);
- if (toMoveUp.size() > 0)
- classpathElements = moveUp(classpathElements, toMoveUp);
- }
-
- /* borrowed code from jdt */
- public void moveDown(List toMoveDown) {
- setModifiedIfAnySelected(toMoveDown);
- if (toMoveDown.size() > 0)
- classpathElements = reverse(moveUp(reverse(classpathElements), toMoveDown));
-
- }
-
- /* borrowed code from jdt */
- protected List reverse(List p) {
- List reverse = new ArrayList(p.size());
- for (int i = p.size() - 1; i >= 0; i--) {
- reverse.add(p.get(i));
- }
- return reverse;
- }
-
- public ClasspathElement getClasspathElement(String uri) {
- if (urisToElements == null)
- return null;
- return (ClasspathElement) urisToElements.get(uri);
- }
-
- public ClasspathElement getClasspathElement(IProject archiveProject) {
- if (archiveProject != null) {
- for (int i = 0; i < classpathElements.size(); i++) {
- ClasspathElement elmnt = (ClasspathElement) classpathElements.get(i);
- if (archiveProject.equals(elmnt.getProject()))
- return elmnt;
- }
- }
- return null;
- }
-
- public boolean hasDirectOrIndirectDependencyTo(IProject archiveProject) {
- ClasspathElement element = getClasspathElement(archiveProject);
- if (element == null)
- return false;
- Archive anArchive = null;
- if (element.isValid()) {
- try {
- anArchive = (Archive) getEARFile().getFile(element.getText());
- } catch (FileNotFoundException e) {
- }
- }
- return anArchive != null && archive.hasClasspathVisibilityTo(anArchive);
- }
-
- public boolean hasDirectOrIndirectDependencyTo(String jarName) {
- ClasspathElement element = getClasspathElement(jarName);
- if (element == null)
- return false;
- Archive anArchive = null;
- if (element.isValid()) {
- try {
- anArchive = (Archive) getEARFile().getFile(element.getText());
- } catch (FileNotFoundException e) {
- }
- }
- return anArchive != null && archive.hasClasspathVisibilityTo(anArchive);
- }
-
-
- public boolean isAnyJarSelected(int type) {
- if (classpathElements != null) {
- for (int i = 0; i < classpathElements.size(); i++) {
- ClasspathElement element = (ClasspathElement) classpathElements.get(i);
- if (element.getJarType() == type && element.isSelected())
- return true;
- }
- }
- return false;
- }
-
-
- public boolean isAnyEJBJarSelected() {
- return isAnyJarSelected(ClasspathElement.EJB_JAR);
- }
-
-
-
- public boolean isAnyEJBClientJARSelected() {
- return isAnyJarSelected(ClasspathElement.EJB_CLIENT_JAR);
-
- }
-
- /**
- * @return
- */
- public int getFilterLevel() {
- return filterLevel;
- }
-
- /**
- * @param i
- */
- public void setFilterLevel(int i) {
- filterLevel = i;
- }
-
- /**
- * This method selects or deselects indivual elements based on the filter level, and
- * additionally sets the filter level.
- *
- * @param i
- */
- public void selectFilterLevel(int level) {
- setFilterLevel(level);
- switch (level) {
- case FILTER_EJB_CLIENT_JARS :
- invertClientJARSelections(ClasspathElement.EJB_CLIENT_JAR);
- break;
- case FILTER_EJB_SERVER_JARS :
- invertClientJARSelections(ClasspathElement.EJB_JAR);
- break;
- default :
- break;
- }
- }
-
- public void invertClientJARSelection(IProject aProject, IProject opposite) {
- ClasspathElement element = getClasspathElement(aProject);
- ClasspathElement oppositeElement = (opposite == null ? null : getClasspathElement(opposite));
- if (element.isSelected())
- invertSelectionIfPossible(element, oppositeElement);
- }
-
- private void invertClientJARSelections(int elementType) {
- if (classpathElements == null)
- return;
-
- for (int i = 0; i < classpathElements.size(); i++) {
- ClasspathElement element = (ClasspathElement) classpathElements.get(i);
- if (element.getJarType() == elementType && element.isSelected()) {
- invertSelectionIfPossible(element, null);
- }
- }
- }
-
- /**
- * @param element
- * @param elementType
- */
- private void invertSelectionIfPossible(ClasspathElement element, ClasspathElement opposite) {
- if (element == null)
- return;
- if (opposite == null)
- opposite = getOppositeElement(element);
- if (opposite != null) {
- opposite.setSelected(true);
- element.setSelected(false);
- }
- }
-
- /**
- * If the element represents an EJB client JAR, returns the corresponding server JAR. If the
- * element represents an EJB server JAR, returns the corresponding client JAR.
- */
- public ClasspathElement getOppositeElement(ClasspathElement element) {
- String uri = element.getText();
- Archive target = element.getTargetArchive();
- if (uri == null || target == null)
- return null;
- Archive oppositeJAR = null;
- switch (element.getJarType()) {
- case (ClasspathElement.EJB_CLIENT_JAR) :
- oppositeJAR = (Archive) clientToEJBJARs.get(target);
- break;
- case (ClasspathElement.EJB_JAR) :
- oppositeJAR = (Archive) ejbToClientJARs.get(target);
- break;
- default :
- break;
- }
- if (oppositeJAR != null)
- return getClasspathElement(oppositeJAR.getURI());
-
- return null;
- }
-
- private void setModifiedIfAnySelected(List elements) {
- for (int i = 0; i < elements.size(); i++) {
- ClasspathElement element = (ClasspathElement) elements.get(i);
- if (element.isSelected())
- setModified(true);
- }
- }
-
- public boolean isMyClientJAR(ClasspathElement element) {
- if (element == null)
- return false;
-
- Archive myClientJar = (Archive) ejbToClientJARs.get(archive);
- return myClientJar != null && myClientJar == element.getTargetArchive();
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathElement.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathElement.java
deleted file mode 100644
index 56450502f..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathElement.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.internal.archive.operations.J2EEImportConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-
-
-public class ClasspathElement {
- public final static int UTIL_JAR = 0;
- public final static int EJB_JAR = 1;
- public final static int EJB_CLIENT_JAR = 2;
- protected int jarType = UTIL_JAR;
- /** The owner archive of this entry */
- protected Archive archive;
-
- /** The archive this entry references, if it exists */
- protected Archive targetArchive;
-
- /** The display text for this item */
- protected String text;
- /** Indicates if this is selected in the view */
- protected boolean selected;
- protected boolean valid;
- /**
- * The text that is an actual Class-Path entry in the Manifest; in the case of multi-segment
- * uris, might look like ../xxx
- */
- protected String relativeText;
- /** The project that corresponds to the dependent module, when it exists */
- protected IProject project;
- /**
- * If the project is not null, there may be imported jars in the project List of IPath
- */
- protected List importedJarPaths;
- protected IProject earProject;
- protected ClassPathSelection parentSelection;
-
- public ClasspathElement(Archive anArchive) {
- super();
- archive = anArchive;
- }
-
- protected void computeRelativeText() {
-
- relativeText = J2EEProjectUtilities.computeRelativeText(archive.getURI(), getText());
- if (relativeText == null)
- relativeText = getText();
- }
-
- /**
- * Insert the method's description here. Creation date: (8/28/2001 5:07:26 PM)
- *
- * @return org.eclipse.core.resources.IProject
- */
- public org.eclipse.core.resources.IProject getEarProject() {
- return earProject;
- }
-
- protected IFile getImportedJarAsIFile() {
- if (getProject() != null) {
- if (getText() != null && getText().endsWith(J2EEImportConstants.IMPORTED_JAR_SUFFIX)) {
- IFile file = getProject().getFile(getText());
- if (file != null && file.exists())
- return file;
- }
- }
- return null;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/28/2001 4:33:35 PM)
- *
- * @return java.util.List
- */
- public java.util.List getImportedJarPaths() {
- return importedJarPaths;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/27/2001 1:14:04 PM)
- *
- * @return int
- */
- public int getJarType() {
- return jarType;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/25/2001 6:21:01 PM)
- *
- * @return org.eclipse.core.resources.IProject
- */
- public org.eclipse.core.resources.IProject getProject() {
- return project;
- }
-
- public String getProjectName() {
- return project == null ? null : project.getName();
- }
-
- public java.lang.String getRelativeText() {
- if (relativeText == null)
- computeRelativeText();
- return relativeText;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 11:00:36 AM)
- *
- * @return java.lang.String
- */
- public java.lang.String getText() {
- return text;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 11:01:46 AM)
- *
- * @return boolean
- */
- public boolean isSelected() {
- return selected;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/27/2001 1:04:35 PM)
- *
- * @return boolean
- */
- public boolean isValid() {
- return valid;
- }
-
- public IResource getResource() {
- if (project != null)
- return project;
- return earProject.getFile(getText());
- }
-
- /**
- * Adapter method to convert this manifest class path element to zero or more classpath entries
- * for a java build path
- */
- public IClasspathEntry[] newClasspathEntries(Set visited) {
- if (visited.contains(this))
- return new IClasspathEntry[0];
- visited.add(this);
- if (representsImportedJar())
- return new IClasspathEntry[]{JavaCore.newLibraryEntry(getImportedJarAsIFile().getFullPath(), null, null)};
-
- if (!valid && isSelected())
- return new IClasspathEntry[0];
-
- if (project == null)
- return newClasspathEntriesFromEARProject(visited);
-
- IClasspathEntry projectEntry = JavaCore.newProjectEntry(getProject().getFullPath(), true);
- if (importedJarPaths == null || importedJarPaths.isEmpty())
- return new IClasspathEntry[]{projectEntry};
-
- List result = new ArrayList(2);
- result.add(projectEntry);
- for (int i = 0; i < importedJarPaths.size(); i++) {
- IPath path = (IPath) importedJarPaths.get(i);
- result.add(JavaCore.newLibraryEntry(path, null, null));
- }
- return (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
- }
-
- public IClasspathEntry[] newClasspathEntries() {
- return newClasspathEntries(new HashSet());
- }
-
- protected IClasspathEntry newClasspathEntryFromEARProj() {
- IPath path = earProject.getFile(getText()).getFullPath();
- return JavaCore.newLibraryEntry(path, path, null, true);
- }
-
- /**
- * The archive is in the EAR and not in a project.
- */
- protected IClasspathEntry[] newClasspathEntriesFromEARProject(Set visited) {
- List cpEntries = new ArrayList();
- cpEntries.add(newClasspathEntryFromEARProj());
- traverseClasspaths(cpEntries, visited);
- return (IClasspathEntry[]) cpEntries.toArray(new IClasspathEntry[cpEntries.size()]);
- }
-
- /*
- * If you have a dependency to a JAR in the EAR project, and the JAR depends on another JAR in
- * the EAR; you want to compile cleanly after import, so you need both those JARs on your build
- * path
- */
- protected void traverseClasspaths(List projectCpEntries, Set visited) {
-
- File aFile = null;
- try {
- aFile = getEARFile().getFile(getText());
- } catch (FileNotFoundException notThere) {
- }
- if (aFile == null || !aFile.isArchive())
- return;
-
- Archive depArchive = (Archive) aFile;
- String[] manifestCpEntries = depArchive.getManifest().getClassPathTokenized();
- for (int i = 0; i < manifestCpEntries.length; i++) {
- String uri = ArchiveUtil.deriveEARRelativeURI(manifestCpEntries[i], depArchive);
- if (uri == null)
- continue;
- ClasspathElement other = parentSelection.getClasspathElement(uri);
- //If the other element is already selected, then
- // we don't need to add it again
- if (other == null || other.isSelected())
- continue;
- IClasspathEntry[] cpEntries = other.newClasspathEntries(visited);
- for (int j = 0; j < cpEntries.length; j++) {
- if (!projectCpEntries.contains(cpEntries[j]))
- projectCpEntries.add(cpEntries[j]);
- }
- }
- }
-
-
- public boolean representsImportedJar() {
- return getImportedJarAsIFile() != null;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/28/2001 5:07:26 PM)
- *
- * @param newEarProject
- * org.eclipse.core.resources.IProject
- */
- public void setEarProject(org.eclipse.core.resources.IProject newEarProject) {
- earProject = newEarProject;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/28/2001 4:33:35 PM)
- *
- * @param newImportedJarPaths
- * java.util.List
- */
- public void setImportedJarPaths(java.util.List newImportedJarPaths) {
- importedJarPaths = newImportedJarPaths;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/27/2001 1:14:04 PM)
- *
- * @param newJarType
- * int
- */
- public void setJarType(int newJarType) {
- jarType = newJarType;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/25/2001 6:21:01 PM)
- *
- * @param newProject
- * org.eclipse.core.resources.IProject
- */
- public void setProject(org.eclipse.core.resources.IProject newProject) {
- project = newProject;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 4:20:55 PM)
- *
- * @param newRelativeText
- * java.lang.String
- */
- public void setRelativeText(java.lang.String newRelativeText) {
- relativeText = newRelativeText;
- }
-
- public void setSelected(Archive referencingJar, Archive referencedJar, List classPath) {
- for (int i = 0; i < classPath.size(); i++) {
- String cpEntry = (String) classPath.get(i);
- String uri = ArchiveUtil.deriveEARRelativeURI(cpEntry, referencingJar);
- if (uri != null && uri.equals(referencedJar.getURI())) {
- setSelected(true);
- return;
- }
- }
- setSelected(false);
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 11:01:46 AM)
- *
- * @param newSelected
- * boolean
- */
- public void setSelected(boolean newSelected) {
- boolean oldSelected = selected;
- selected = newSelected;
- if (oldSelected != newSelected && parentSelection != null)
- parentSelection.setModified(true);
- }
-
- /**
- * Insert the method's description here. Creation date: (8/22/2001 11:00:36 AM)
- *
- * @param newText
- * java.lang.String
- */
- public void setText(java.lang.String newText) {
- text = newText;
- }
-
- /**
- * Insert the method's description here. Creation date: (8/27/2001 1:04:35 PM)
- *
- * @param newValid
- * boolean
- */
- public void setValid(boolean newValid) {
- valid = newValid;
- }
-
- public void setValuesSelected(String cpEntry) {
- setSelected(true);
- setRelativeText(cpEntry);
- }
-
- public String toString() {
- return "ClasspatheElement(" + getText() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected EARFile getEARFile() {
- return (EARFile) archive.getContainer();
- }
-
- void setParentSelection(ClassPathSelection selection) {
- parentSelection = selection;
- }
-
- /**
- * Returns the archive.
- *
- * @return Archive
- */
- public Archive getArchive() {
- return archive;
- }
-
- public boolean isEJBJar() {
- return jarType == EJB_JAR;
- }
-
- public boolean isEJBClientJar() {
- return jarType == EJB_CLIENT_JAR;
- }
-
- /**
- * @return
- */
- public Archive getTargetArchive() {
- return targetArchive;
- }
-
- /**
- * @param archive
- */
- public void setTargetArchive(Archive archive) {
- targetArchive = archive;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathSelectionHelper.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathSelectionHelper.java
deleted file mode 100644
index 44fc112c9..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ClasspathSelectionHelper.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * 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 14, 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 org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.jst.j2ee.application.Application;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.NullLoadStrategyImpl;
-import org.eclipse.jst.j2ee.internal.earcreation.EAREditModel;
-import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class ClasspathSelectionHelper {
-
- public static ClassPathSelection createClasspathSelection(IProject moduleProject, String moduleExtension, IProject earProject, EClass moduleType) {
- // if(true){
- // return null;
- // }
-
- if (earProject == null || !earProject.exists()) {
- return null;
- }
- EARFile earFile = null;
- try {
- EARNatureRuntime earNature = (EARNatureRuntime) earProject.getNature(IEARNatureConstants.NATURE_ID);
- earFile = earNature.asEARFile(true, false);
-
- CommonarchiveFactory factory = getCommonArchiveFactory();
- CommonarchivePackage pkg = getCommonArchiveFactory().getCommonarchivePackage();
- ModuleFile bogusModuleFile = null;
- if (moduleType == pkg.getEJBJarFile())
- bogusModuleFile = factory.createEJBJarFile();
- else if (moduleType == pkg.getApplicationClientFile())
- bogusModuleFile = factory.createApplicationClientFile();
- else if (moduleType == pkg.getWARFile())
- bogusModuleFile = factory.createWARFile();
- else if (moduleType == pkg.getRARFile())
- bogusModuleFile = factory.createRARFile();
-
- bogusModuleFile.setURI(getUniqueUriInEAR(moduleProject, moduleExtension, earNature));
- bogusModuleFile.setManifest((ArchiveManifest) new ArchiveManifestImpl());
- bogusModuleFile.setLoadStrategy(new NullLoadStrategyImpl());
- earFile.getFiles().add(bogusModuleFile);
-
- return new ClassPathSelection(bogusModuleFile, moduleProject.getName(), earFile);
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- } catch (OpenFailureException e) {
- Logger.getLogger().logError(e);
- } finally {
- // The client of the ClasspathSelection has the responsibility of closing
- // the EARFile
- // if(earFile != null)
- // earFile.close();
- }
- return null;
-
- }
-
- protected static CommonarchiveFactory getCommonArchiveFactory() {
- return ((CommonarchivePackage) EPackage.Registry.INSTANCE.getEPackage(CommonarchivePackage.eNS_URI)).getCommonarchiveFactory();
- }
-
- protected static String getUniqueUriInEAR(IProject moduleProject, String moduleExtension, EARNatureRuntime earNature) {
- String base = moduleProject.getName().replace(' ', '_');
- String result = base + moduleExtension;
- EAREditModel earEditModel = null;
- Object key = new Object();
- try {
- if (earNature == null)
- return result;
- earEditModel = earNature.getEarEditModelForRead(key);
- Application app = earEditModel.getApplication();
- if (app == null)
- return result;
- int counter = 1;
- while (app.getFirstModule(result) != null)
- result = base + (counter++) + moduleExtension;
- } finally {
- if (null != earEditModel) {
- earEditModel.releaseAccess(key);
- }
- earEditModel = null;
- }
- return result;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationDataModel.java
deleted file mode 100644
index a61663afa..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationDataModel.java
+++ /dev/null
@@ -1,543 +0,0 @@
-/*******************************************************************************
- * 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 12, 2003
- *
- * To change the template for this generated file go to Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.internal.localstore.CoreFileSystemLibrary;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.j2ee.applicationclient.creation.AppClientModuleCreationDataModel;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleManager;
-import org.eclipse.jst.j2ee.internal.moduleextension.EjbModuleExtension;
-import org.eclipse.jst.j2ee.internal.moduleextension.JcaModuleExtension;
-import org.eclipse.jst.j2ee.internal.moduleextension.WebModuleExtension;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
-
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class DefaultModuleProjectCreationDataModel extends WTPOperationDataModel {
- private static final String CONNECTOR_SUFFIX = "Connector"; //$NON-NLS-1$
- private static final String CLIENT_SUFFIX = "Client"; //$NON-NLS-1$
- private static final String WEB_SUFFIX = "Web"; //$NON-NLS-1$
- private static final String EJB_SUFFIX = "EJB"; //$NON-NLS-1$
- /**
- * Required - This is the name used to caculate the module project names. type String
- */
- public static final String BASE_NAME = "DefaultModuleProjectCreationDataModel.BASE_NAME"; //$NON-NLS-1$
- /**
- * Required - Set the J2EE version which each default module will be set to. type Integer
- */
- public static final String J2EE_VERSION = "DefaultModuleProjectCreationDataModel.J2EE_VERSION"; //$NON-NLS-1$
- private static final int EJB = 0;
- private static final int WEB = 1;
- private static final int RAR = 2;
- private static final int CLIENT = 3;
- private static String CREATE_BASE = "DefaultModuleProjectCreationDataModel.CREATE_"; //$NON-NLS-1$
- private static String PROJECT_BASE = "DefaultModuleProjectCreationDataModel.PROJECT_NAME_"; //$NON-NLS-1$
- /**
- * Default is true. type Boolean
- */
- public static final String CREATE_EJB = CREATE_BASE + EJB;
- /**
- * The EJB Project name to use. type String
- */
- public static final String EJB_PROJECT_NAME = PROJECT_BASE + EJB;
- /**
- * Default is true. type Boolean
- */
- public static final String CREATE_WEB = CREATE_BASE + WEB;
- /**
- * The WEB Project name to use. type String
- */
- public static final String WEB_PROJECT_NAME = PROJECT_BASE + WEB;
- /**
- * Default is true. type Boolean
- */
- public static final String CREATE_APPCLIENT = CREATE_BASE + CLIENT;
- /**
- * The EJB Project name to use. type String
- */
- public static final String APPCLIENT_PROJECT_NAME = PROJECT_BASE + CLIENT;
- /**
- * Default is true. type Boolean
- */
- public static final String CREATE_CONNECTOR = CREATE_BASE + RAR;
- /**
- * The EJB Project name to use. type String
- */
- public static final String CONNECTOR_PROJECT_NAME = PROJECT_BASE + RAR;
-
- /**
- * Used for validation only; validates no collsions between various module names. Do not set
- * this value.
- */
- public static final String MODULE_NAME_COLLISIONS_VALIDATION = "DefaultModuleProjectCreationDataModel.MODULE_NAME_COLLISIONS_VALIDATION"; //$NON-NLS-1$
-
- /**
- * Default is true. type Boolean
- */
- public static final String ENABLED = "DefaultModuleProjectCreationDataModel.ENABLED"; //$NON-NLS-1$
-
- private static final String NESTED_MODEL_EJB = "DefaultModuleProjectCreationDataModel.NESTED_MODEL_EJB"; //$NON-NLS-1$
- private static final String NESTED_MODEL_WEB = "DefaultModuleProjectCreationDataModel.NESTED_MODEL_WEB"; //$NON-NLS-1$
- private static final String NESTED_MODEL_JCA = "DefaultModuleProjectCreationDataModel.NESTED_MODEL_JCA"; //$NON-NLS-1$
- private static final String NESTED_MODEL_CLIENT = "DefaultModuleProjectCreationDataModel.NESTED_MODEL_CLIENT"; //$NON-NLS-1$
-
- private J2EEModuleCreationDataModelOld ejbModel;
- private J2EEModuleCreationDataModelOld webModel;
- private J2EEModuleCreationDataModelOld jcaModel;
- private AppClientModuleCreationDataModel clientModel;
-
- /**
- *
- */
- public DefaultModuleProjectCreationDataModel() {
- super();
- }
-
- public WTPOperation getDefaultOperation() {
- return new DefaultModuleProjectCreationOperation(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#initValidBaseProperties()
- */
- protected void initValidBaseProperties() {
- addValidBaseProperty(BASE_NAME);
- addValidBaseProperty(APPCLIENT_PROJECT_NAME);
- addValidBaseProperty(CONNECTOR_PROJECT_NAME);
- addValidBaseProperty(EJB_PROJECT_NAME);
- addValidBaseProperty(WEB_PROJECT_NAME);
- addValidBaseProperty(CREATE_CONNECTOR);
- addValidBaseProperty(CREATE_APPCLIENT);
- addValidBaseProperty(CREATE_EJB);
- addValidBaseProperty(CREATE_WEB);
- addValidBaseProperty(J2EE_VERSION);
- addValidBaseProperty(ENABLED);
- addValidBaseProperty(MODULE_NAME_COLLISIONS_VALIDATION);
- super.initValidBaseProperties();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#initNestedModels()
- */
- protected void initNestedModels() {
- clientModel = new AppClientModuleCreationDataModel();
- addNestedModel(NESTED_MODEL_CLIENT, clientModel);
- EjbModuleExtension ejbExt = EarModuleManager.getEJBModuleExtension();
- if (ejbExt != null) {
- ejbModel = ejbExt.createProjectDataModel();
- if (ejbModel != null)
- addNestedModel(NESTED_MODEL_EJB, ejbModel);
- }
- WebModuleExtension webExt = EarModuleManager.getWebModuleExtension();
- if (webExt != null) {
- webModel = webExt.createProjectDataModel();
- if (webModel != null)
- addNestedModel(NESTED_MODEL_WEB, webModel);
- }
- JcaModuleExtension rarExt = EarModuleManager.getJCAModuleExtension();
- if (rarExt != null) {
- jcaModel = rarExt.createProjectDataModel();
- if (jcaModel != null)
- addNestedModel(NESTED_MODEL_JCA, jcaModel);
- }
- }
-
- private void addNestedModel(String modelName, J2EEModuleCreationDataModelOld moduleModel) {
- moduleModel.setProperty(J2EEModuleCreationDataModelOld.UI_SHOW_EAR_SECTION, Boolean.FALSE);
- super.addNestedModel(modelName, moduleModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#getDefaultProperty(java.lang.String)
- */
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.startsWith(CREATE_BASE))
- return getDefaultCreateValue(propertyName);
- if (propertyName.equals(ENABLED))
- return Boolean.TRUE;
- return super.getDefaultProperty(propertyName);
- }
-
- /**
- * @return
- */
- private Object getDefaultCreateValue(String propertyName) {
- if (propertyName.equals(CREATE_CONNECTOR)) {
- int version = getIntProperty(J2EE_VERSION);
- if (version < J2EEVersionConstants.J2EE_1_3_ID)
- return Boolean.FALSE;
- }
- return Boolean.TRUE;
- }
-
- private int convertPropertyNameToInt(String propertyName) {
- int length = propertyName.length();
- String numString = propertyName.substring(length - 1, length);
- return Integer.parseInt(numString);
- }
-
- /**
- * @param projectName
- * @return
- */
- private String ensureUniqueProjectName(String projectName) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- String newName = projectName;
- int index = 0;
- IProject proj = root.getProject(newName);
- while (proj.exists()) {
- index++;
- newName = projectName + index;
- proj = root.getProject(newName);
- }
- return newName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doSetProperty(java.lang.String,
- * java.lang.Object)
- */
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- boolean notify = super.doSetProperty(propertyName, propertyValue);
- if (propertyName.startsWith(PROJECT_BASE)) {
- setNestedProjectName(convertPropertyNameToInt(propertyName), (String) propertyValue);
- return true;
- }
- if (propertyName.equals(J2EE_VERSION)) {
- updatedJ2EEVersion((Integer) propertyValue);
- return true;
- }
- if (propertyName.equals(BASE_NAME)) {
- setDefaultProjectNames((String) propertyValue);
- return true;
- }
- if (propertyName.startsWith(CREATE_BASE))
- notifyEnablement(convertPropertyNameToInt(propertyName));
- return notify;
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- if (event.getPropertyName().equals(J2EEModuleCreationDataModelOld.PROJECT_NAME)) {
- Object source = event.getDataModel();
- String propertyName = null;
- if (ejbModel == source) {
- propertyName = EJB_PROJECT_NAME;
- } else if (webModel == source) {
- propertyName = WEB_PROJECT_NAME;
- } else if (jcaModel == source) {
- propertyName = CONNECTOR_PROJECT_NAME;
- } else if (clientModel == source) {
- propertyName = APPCLIENT_PROJECT_NAME;
- }
- if (null != propertyName) {
- setProperty(propertyName, event.getProperty());
- return;
- }
- }
- super.propertyChanged(event);
- }
-
- /**
- * @param flag
- */
- private void notifyEnablement(int flag) {
- String propertyName = null;
- switch (flag) {
- case EJB :
- propertyName = EJB_PROJECT_NAME;
- break;
- case WEB :
- propertyName = WEB_PROJECT_NAME;
- break;
- case CLIENT :
- propertyName = APPCLIENT_PROJECT_NAME;
- break;
- case RAR :
- propertyName = CONNECTOR_PROJECT_NAME;
- }
- if (propertyName != null)
- notifyEnablementChange(propertyName);
- }
-
- private void updatedJ2EEVersion(Integer version) {
- setNestedJ2EEVersion(version);
- if (version.intValue() < J2EEVersionConstants.J2EE_1_3_ID && isSet(CREATE_CONNECTOR)) {
- setProperty(CREATE_CONNECTOR, Boolean.FALSE);
- }
- }
-
- public IStatus validateModuleNameCollisions() {
- if (getBooleanProperty(ENABLED)) {
- ArrayList list = new ArrayList();
- String projectName = null;
- String actualProjectName = null;
- boolean errorCollision = false;
- boolean errorNoSelection = true;
- if (getBooleanProperty(CREATE_APPCLIENT)) {
- actualProjectName = clientModel.getTargetProject().getName();
- projectName = CoreFileSystemLibrary.isCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase();
- list.add(projectName);
- errorNoSelection = false;
- }
- if (getBooleanProperty(CREATE_EJB)) {
- actualProjectName = ejbModel.getTargetProject().getName();
- projectName = CoreFileSystemLibrary.isCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase();
- if (!list.contains(projectName)) {
- list.add(projectName);
- } else {
- errorCollision = true;
- }
- errorNoSelection = false;
- }
- if (!errorCollision && getBooleanProperty(CREATE_WEB)) {
- actualProjectName = webModel.getTargetProject().getName();
- projectName = CoreFileSystemLibrary.isCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase();
- if (!list.contains(projectName)) {
- list.add(projectName);
- } else {
- errorCollision = true;
- }
- errorNoSelection = false;
- }
- if (!errorCollision && getBooleanProperty(CREATE_CONNECTOR)) {
- actualProjectName = jcaModel.getTargetProject().getName();
- projectName = CoreFileSystemLibrary.isCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase();
- if (!list.contains(projectName)) {
- list.add(projectName);
- } else {
- errorCollision = true;
- }
- errorNoSelection = false;
- }
- if (errorCollision) {
- return J2EEPlugin.newErrorStatus(EARCreationResourceHandler.getString("DuplicateModuleNames", new Object[]{actualProjectName}), null); //$NON-NLS-1$
- } else if (errorNoSelection) {
- return J2EEPlugin.newErrorStatus(EARCreationResourceHandler.getString("NoModulesSelected"), null); //$NON-NLS-1$
- }
- }
-
- return OK_STATUS;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doValidateProperty(java.lang.String)
- */
- protected IStatus doValidateProperty(String propertyName) {
- if (propertyName.startsWith(PROJECT_BASE)) {
- return validateNestedProjectName(convertPropertyNameToInt(propertyName));
- } else if (propertyName.equals(MODULE_NAME_COLLISIONS_VALIDATION)) {
- return validateModuleNameCollisions();
- } else if (propertyName.equals(NESTED_MODEL_VALIDATION_HOOK)) {
- return OK_STATUS;
- }
- return super.doValidateProperty(propertyName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doGetProperty(java.lang.String)
- */
- protected Object doGetProperty(String propertyName) {
- if (propertyName.startsWith(PROJECT_BASE))
- return getNestedProjectName(convertPropertyNameToInt(propertyName));
- return super.doGetProperty(propertyName);
- }
-
- private void setDefaultNestedProjectName(String name, int flag) {
- J2EEModuleCreationDataModelOld modModule = getNestedModel(flag);
- if (modModule != null) {
- String projName = ensureUniqueProjectName(name);
- modModule.setProperty(J2EEModuleCreationDataModelOld.PROJECT_NAME, projName);
- }
- }
-
- /**
- * @param string
- */
- private void setDefaultProjectNames(String base) {
- String projectName;
- if (base.endsWith(EJB_SUFFIX))
- projectName = base;
- else
- projectName = base + EJB_SUFFIX;
- setDefaultNestedProjectName(projectName, EJB);
- if (base.endsWith(WEB_SUFFIX))
- projectName = base;
- else
- projectName = base + WEB_SUFFIX;
- setDefaultNestedProjectName(projectName, WEB);
- if (base.endsWith(CLIENT_SUFFIX))
- projectName = base;
- else
- projectName = base + CLIENT_SUFFIX;
- setDefaultNestedProjectName(projectName, CLIENT);
- if (base.endsWith(CONNECTOR_SUFFIX))
- projectName = base;
- else
- projectName = base + CONNECTOR_SUFFIX;
- setDefaultNestedProjectName(projectName, RAR);
- }
-
- /**
- * @param j2eeVersion
- */
- private void setNestedJ2EEVersion(Object j2eeVersion) {
- if (ejbModel != null)
- ejbModel.setProperty(J2EEModuleCreationDataModelOld.J2EE_VERSION, j2eeVersion);
- if (webModel != null)
- webModel.setProperty(J2EEModuleCreationDataModelOld.J2EE_VERSION, j2eeVersion);
- if (jcaModel != null)
- jcaModel.setProperty(J2EEModuleCreationDataModelOld.J2EE_VERSION, j2eeVersion);
- clientModel.setProperty(J2EEModuleCreationDataModelOld.J2EE_VERSION, j2eeVersion);
- }
-
- /**
- * @param flag
- * @param projectName
- */
- private void setNestedProjectName(int flag, String projectName) {
- J2EEModuleCreationDataModelOld model = getNestedModel(flag);
- if (model != null) {
- model.setProperty(J2EEModuleCreationDataModelOld.PROJECT_NAME, projectName);
- }
- }
-
- /**
- * @param flag
- */
- private IStatus validateNestedProjectName(int flag) {
- J2EEModuleCreationDataModelOld model = getNestedModel(flag);
- if (model != null) {
- String createProperty = null;
- switch (flag) {
- case EJB :
- createProperty = CREATE_EJB;
- break;
- case WEB :
- createProperty = CREATE_WEB;
- break;
- case CLIENT :
- createProperty = CREATE_APPCLIENT;
- break;
- case RAR :
- createProperty = CREATE_CONNECTOR;
- break;
- }
- if (null != createProperty && getBooleanProperty(createProperty)) {
- return model.validateProperty(J2EEModuleCreationDataModelOld.PROJECT_NAME);
- }
- }
- return J2EEPlugin.OK_STATUS;
- }
-
- private Object getNestedProjectName(int flag) {
- J2EEModuleCreationDataModelOld model = getNestedModel(flag);
- if (model != null)
- return model.getProperty(J2EEModuleCreationDataModelOld.PROJECT_NAME);
- return null;
- }
-
- private J2EEModuleCreationDataModelOld getNestedModel(int flag) {
- switch (flag) {
- case EJB :
- return ejbModel;
- case WEB :
- return webModel;
- case CLIENT :
- return clientModel;
- case RAR :
- return jcaModel;
- }
- return null;
- }
-
- /**
- * @return Returns the clientModel.
- */
- public AppClientModuleCreationDataModel getClientModel() {
- return clientModel;
- }
-
- /**
- * @return Returns the ejbModel.
- */
- public J2EEModuleCreationDataModelOld getEjbModel() {
- return ejbModel;
- }
-
- /**
- * @return Returns the rarModel.
- */
- public J2EEModuleCreationDataModelOld getJCAModel() {
- return jcaModel;
- }
-
- /**
- * @return Returns the webModel.
- */
- public J2EEModuleCreationDataModelOld getWebModel() {
- return webModel;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#basicIsEnabled(java.lang.String)
- */
- protected Boolean basicIsEnabled(String propertyName) {
- if (propertyName.equals(CREATE_CONNECTOR) || propertyName.equals(CONNECTOR_PROJECT_NAME)) {
- int version = getIntProperty(J2EE_VERSION);
- boolean result = version > J2EEVersionConstants.J2EE_1_2_ID;
- if (result)
- return (Boolean) getProperty(CREATE_CONNECTOR);
- return new Boolean(result);
- }
- if (propertyName.equals(APPCLIENT_PROJECT_NAME))
- return (Boolean) getProperty(CREATE_APPCLIENT);
- if (propertyName.equals(EJB_PROJECT_NAME))
- return (Boolean) getProperty(CREATE_EJB);
- if (propertyName.equals(WEB_PROJECT_NAME))
- return (Boolean) getProperty(CREATE_WEB);
- return super.basicIsEnabled(propertyName);
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationOperation.java
deleted file mode 100644
index d7012de35..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/DefaultModuleProjectCreationOperation.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * 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 13, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>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.applicationclient.creation.AppClientModuleCreationDataModel;
-import org.eclipse.jst.j2ee.applicationclient.creation.AppClientModuleCreationOperation;
-import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleExtension;
-import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleManager;
-import org.eclipse.jst.j2ee.internal.moduleextension.JcaModuleExtension;
-import org.eclipse.wst.common.frameworks.internal.activities.WTPActivityBridge;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class DefaultModuleProjectCreationOperation extends WTPOperation {
-
- /**
- * This activity no longer exists use ENTERPRISE_JAVA instead
- *
- * @deprecated
- */
- public static final String APP_CLIENT_DEV_ACTIVITY_ID = "org.eclipse.jst.j2ee.application.client.development"; //$NON-NLS-1$
- /**
- * This activity no longer exists use ENTERPRISE_JAVA instead
- *
- * @deprecated
- */
- public static final String EJB_DEV_ACTIVITY_ID = "com.ibm.wtp.ejb.development"; //$NON-NLS-1$
- /**
- * This activity no longer exists use ENTERPRISE_JAVA instead
- *
- * @deprecated
- */
- public static final String JCA_DEV_ACTIVITY_ID = "com.ibm.wtp.jca.development"; //$NON-NLS-1$
- public static final String WEB_DEV_ACTIVITY_ID = "com.ibm.wtp.web.development"; //$NON-NLS-1$
- public static final String ENTERPRISE_JAVA = "com.ibm.wtp.ejb.development"; //$NON-NLS-1$
-
- /**
- * @param operationDataModel
- */
- public DefaultModuleProjectCreationOperation(DefaultModuleProjectCreationDataModel operationDataModel) {
- super(operationDataModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- DefaultModuleProjectCreationDataModel model = (DefaultModuleProjectCreationDataModel) operationDataModel;
- if (model.getEjbModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_EJB))
- createEJBModuleProject(model.getEjbModel(), monitor);
- if (model.getWebModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_WEB))
- createWebModuleProject(model.getWebModel(), monitor);
- if (model.getJCAModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_CONNECTOR))
- createRarModuleProject(model.getJCAModel(), monitor);
- if (model.getClientModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_APPCLIENT))
- createAppClientModuleProject(model.getClientModel(), monitor);
- }
-
- /**
- * @param model
- */
- private void createEJBModuleProject(J2EEModuleCreationDataModelOld model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EarModuleExtension ext = EarModuleManager.getEJBModuleExtension();
- runModuleExtensionOperation(ext, model, monitor);
- WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true);
- }
-
- /**
- * @param model
- */
- private void createWebModuleProject(J2EEModuleCreationDataModelOld model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EarModuleExtension ext = EarModuleManager.getWebModuleExtension();
- runModuleExtensionOperation(ext, model, monitor);
- WTPActivityBridge.getInstance().enableActivity(WEB_DEV_ACTIVITY_ID, true);
- }
-
- /**
- * @param model
- */
- private void createRarModuleProject(J2EEModuleCreationDataModelOld model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- JcaModuleExtension jcaExt = EarModuleManager.getJCAModuleExtension();
- runModuleExtensionOperation(jcaExt, model, monitor);
- WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true);
- }
-
- private void runModuleExtensionOperation(EarModuleExtension extension, J2EEModuleCreationDataModelOld model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- if (extension != null) {
- J2EEModuleCreationOperationOld op = extension.createProjectCreationOperation(model);
- if (op != null)
- op.doRun(monitor);
- }
- }
-
- /**
- * @param model
- */
- private void createAppClientModuleProject(J2EEModuleCreationDataModelOld model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- AppClientModuleCreationOperation op = new AppClientModuleCreationOperation((AppClientModuleCreationDataModel) model);
- op.doRun(monitor);
- WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true);
-
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EARComponentCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EARComponentCreationOperation.java
deleted file mode 100644
index 854426e7e..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EARComponentCreationOperation.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Created on Mar 17, 2005
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.J2EEVersionUtil;
-import org.eclipse.jst.j2ee.internal.earcreation.EARComponentCreationDataModel;
-import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEdit;
-import org.eclipse.wst.common.modulecore.ModuleCore;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.operation.ComponentCreationDataModel;
-import org.eclipse.wst.common.modulecore.internal.util.IModuleConstants;
-import org.eclipse.wst.common.modulecore.resources.IVirtualContainer;
-import org.eclipse.wst.common.modulecore.resources.IVirtualFolder;
-
-public class EARComponentCreationOperation extends J2EEComponentCreationOperation {
- public EARComponentCreationOperation(EARComponentCreationDataModel dataModel) {
- super(dataModel);
- }
-
- public EARComponentCreationOperation() {
- super();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.application.operations.J2EEComponentCreationOperation#createAndLinkJ2EEComponents()
- */
- protected void createAndLinkJ2EEComponents() throws CoreException {
- IVirtualContainer component = ModuleCore.create(getProject(), getModuleDeployName());
- component.commit();
- //create and link META-INF folder
- IVirtualFolder metaInfFolder = component.getFolder(new Path("/" + J2EEConstants.META_INF)); //$NON-NLS-1$
- metaInfFolder.createLink(new Path("/" + getModuleName() + "/" + J2EEConstants.META_INF), 0, null);
- }
-
- public IProject getProject() {
- String projName = operationDataModel.getStringProperty(EARComponentCreationDataModel.PROJECT_NAME );
- return ProjectUtilities.getProject( projName );
- }
-
- protected void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- //should cache wbmodule when created instead of searching ?
- ModuleCore moduleCore = null;
- EARArtifactEdit edit = null;
- try {
- EARComponentCreationDataModel dm = (EARComponentCreationDataModel)getOperationDataModel();
- moduleCore = ModuleCore.getModuleCoreForWrite(getProject());
- WorkbenchComponent earComp = moduleCore.findWorkbenchModuleByDeployName(
- operationDataModel.getStringProperty(EARComponentCreationDataModel.COMPONENT_DEPLOY_NAME));
- edit = EARArtifactEdit.getEARArtifactEditForWrite(earComp);
- int versionId = ((ComponentCreationDataModel)getOperationDataModel()).getIntProperty(ComponentCreationDataModel.COMPONENT_VERSION);
- edit.createModelRoot(getModuleName(), versionId);
- // set version to WorkbenchComponent
- String versionText = J2EEVersionUtil.getJ2EETextVersion(versionId);
- earComp.getComponentType().setVersion(versionText);
- // save
- moduleCore.saveIfNecessary(null);
- } finally {
- if (null != moduleCore) {
- moduleCore.dispose();
- }
- if (edit != null)
- edit.dispose();
- }
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- J2EEComponentCreationDataModel dataModel = (J2EEComponentCreationDataModel) operationDataModel;
- createAndLinkJ2EEComponents();
- setupComponentType(IModuleConstants.JST_EAR_MODULE);
- if (dataModel.getBooleanProperty(J2EEComponentCreationDataModel.CREATE_DEFAULT_FILES)) {
- createDeploymentDescriptor(monitor);
- }
- addModulesToEAR(monitor);
- }
-
- private void addModulesToEAR(IProgressMonitor monitor) {
- try{
- AddComponentToEnterpriseApplicationDataModel dm = new AddComponentToEnterpriseApplicationDataModel();
- dm.setProperty(AddComponentToEnterpriseApplicationDataModel.PROJECT_NAME, getProject().getName());
- dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME, getOperationDataModel().getProperty(EARComponentCreationDataModel.COMPONENT_DEPLOY_NAME));
- List modulesList = (List)getOperationDataModel().getProperty(EARComponentCreationDataModel.J2EE_COMPONENT_LIST);
- if(modulesList != null && !modulesList.isEmpty()) {
- dm.setProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST,modulesList);
- AddComponentToEnterpriseApplicationOperation addModuleOp = (AddComponentToEnterpriseApplicationOperation)dm.getDefaultOperation();
- addModuleOp.execute(monitor);
- }
- } catch(Exception e) {
- Logger.getLogger().log(e);
- }
- }
-
- protected void addResources(WorkbenchComponent component ){
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.application.operations.J2EEComponentCreationOperation#getVersion()
- */
- protected String getVersion() {
- int version = operationDataModel.getIntProperty(J2EEComponentCreationDataModel.COMPONENT_VERSION);
- return J2EEVersionUtil.getJ2EETextVersion(version);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModel.java
deleted file mode 100644
index a52e52d6d..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModel.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/***************************************************************************************************
- * 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 27, 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.IPath;
-import org.eclipse.jst.j2ee.common.XMLResource;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-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.internal.emfworkbench.operation.EditModelOperationDataModel;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * This dataModel is used for to create Enterprise Applications.
- *
- * 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 final class EnterpriseApplicationCreationDataModel extends J2EEArtifactCreationDataModelOld {
- /**
- * An optional dataModel propertyName for an Integer type. It is used to specify the J2EE
- * Version for the new Enterprise Application. The default value is computed based on the
- * highest J2EE version specified in the J2EE Properties.
- *
- * @since WTP 1.0
- */
- public static final String APPLICATION_VERSION = "J2EEApplicationCreationDataModel.APPLICATION_VERSION"; //$NON-NLS-1$
-
- /*
- * A List containing IProjects
- */
- public static final String MODULE_LIST = AddArchiveProjectsToEARDataModel.MODULE_LIST;
- /*
- * UI only, type Boolean, default false.
- */
- public static final String UI_SHOW_FIRST_PAGE_ONLY = "J2EEApplicationCreationDataModel.UI_SHOW_FIRST_PAGE_ONLY"; //$NON-NLS-1$
-
- private static final String NESTED_MODEL_ADD_ARCHIVE_TO_EAR = "J2EEApplicationCreationDataModel.NESTED_MODEL_ADD_ARCHIVE_TO_EAR"; //$NON-NLS-1$
- private AddArchiveProjectsToEARDataModel addModulesToEARDataModel;
-
- /**
- * Creates an Enterprise Application project with the specified name and version in the
- * specified location.
- *
- * @param projectName
- * The name of the Enterprise Application project to create.
- * @param projectLocation
- * Sets the local file system location for the described project. The path must be
- * either an absolute file system path, or a relative path whose first segment is the
- * name of a defined workspace path variable. If <code>null</code> is specified,
- * the default location is used.
- * @param applicationVersion
- * Sets the J2EE Version for the descibed project. The version must be one of
- * <code>J2EEVersionConstants.J2EE_1_2_ID</code>,
- * <code>J2EEVersionConstants.J2EE_1_3_ID</code>, or
- * <code>J2EEVersionConstants.J2EE_1_4_ID</code>.
- * @since WTP 1.0
- */
- public static void createProject(String projectName, IPath projectLocation, int applicationVersion) {
- EnterpriseApplicationCreationDataModel dataModel = new EnterpriseApplicationCreationDataModel();
- dataModel.setProperty(PROJECT_NAME, projectName);
- if (null != projectLocation) {
- dataModel.setProperty(PROJECT_LOCATION, projectLocation.toOSString());
- }
- dataModel.setIntProperty(APPLICATION_VERSION, applicationVersion);
- try {
- dataModel.getDefaultOperation().run(null);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- }
- }
-
-
- public WTPOperation getDefaultOperation() {
- return new EnterpriseApplicationCreationOperation(this);
- }
-
- protected void init() {
- super.init();
- setProperty(EDIT_MODEL_ID, IEARNatureConstants.EDIT_MODEL_ID);
- getServerTargetDataModel().setIntProperty(ServerTargetDataModel.DEPLOYMENT_TYPE_ID, XMLResource.APPLICATION_TYPE);
- getProjectDataModel().setProperty(ProjectCreationDataModel.PROJECT_NATURES, new String[]{IEARNatureConstants.NATURE_ID});
- setProperty(APPLICATION_VERSION, getDefaultProperty(APPLICATION_VERSION));
- //set it so it pushes it down to ServerTargeting
- }
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(APPLICATION_VERSION);
- addValidBaseProperty(UI_SHOW_FIRST_PAGE_ONLY);
- }
-
- protected void initNestedModels() {
- super.initNestedModels();
- addModulesToEARDataModel = new AddArchiveProjectsToEARDataModel();
- addNestedModel(NESTED_MODEL_ADD_ARCHIVE_TO_EAR, addModulesToEARDataModel);
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(APPLICATION_VERSION)) {
- return getDefaultJ2EEVersion();
- } else if (propertyName.equals(UI_SHOW_FIRST_PAGE_ONLY)) {
- return Boolean.FALSE;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- /*
- * @return Returns the default J2EE spec level based on the Global J2EE Preference
- */
- private Object getDefaultJ2EEVersion() {
- int highestJ2EEPref = J2EEPlugin.getDefault().getJ2EEPreferences().getHighestJ2EEVersionID();
- switch (highestJ2EEPref) {
- case (J2EEVersionConstants.J2EE_1_4_ID) :
- return new Integer(J2EEVersionConstants.J2EE_1_4_ID);
- case (J2EEVersionConstants.J2EE_1_3_ID) :
- return new Integer(J2EEVersionConstants.J2EE_1_3_ID);
- case (J2EEVersionConstants.J2EE_1_2_ID) :
- return new Integer(J2EEVersionConstants.J2EE_1_2_ID);
- default :
- return new Integer(J2EEVersionConstants.J2EE_1_4_TEXT);
- }
- }
-
- /**
- * Returns the String representation of <code>J2EEVersionConstants.J2EE_1_2_ID</code>,
- * <code>J2EEVersionConstants.J2EE_1_3_ID</code>, or
- * <code>J2EEVersionConstants.J2EE_1_4_ID</code>.
- *
- * @param applicationVersion
- * @return The String representation of <code>applicationVersion</code>
- */
- public final static String getVersionString(int applicationVersion) {
- switch (applicationVersion) {
- case J2EEVersionConstants.J2EE_1_2_ID :
- return J2EEVersionConstants.VERSION_1_2_TEXT;
- case J2EEVersionConstants.J2EE_1_3_ID :
- return J2EEVersionConstants.VERSION_1_3_TEXT;
- case J2EEVersionConstants.J2EE_1_4_ID :
- default :
- return J2EEVersionConstants.VERSION_1_4_TEXT;
- }
- }
-
- protected WTPPropertyDescriptor[] doGetValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(APPLICATION_VERSION)) {
- return getValidJ2EEVersionDescriptors();
- }
- return super.doGetValidPropertyDescriptors(propertyName);
- }
-
- protected WTPPropertyDescriptor doGetPropertyDescriptor(String propertyName) {
- if (propertyName.equals(APPLICATION_VERSION)) {
- int version = getIntProperty(APPLICATION_VERSION);
- WTPPropertyDescriptor descriptor = null;
- switch (version) {
- case (J2EEVersionConstants.J2EE_1_2_ID) :
- descriptor = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_3_ID) :
- descriptor = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_4_ID) :
- default :
- descriptor = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_4_ID), J2EEVersionConstants.VERSION_1_4_TEXT);
- break;
-
- }
- return descriptor;
- }
- return super.doGetPropertyDescriptor(propertyName);
- }
-
- /**
- * @return Return a String[] of the valid J2EE versions for the selected J2EE Preference Level.
- */
- protected WTPPropertyDescriptor[] getValidJ2EEVersionDescriptors() {
- 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.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_3_ID) :
- descriptors = new WTPPropertyDescriptor[2];
- descriptors[0] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- descriptors[1] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_4_ID) :
- default :
- descriptors = new WTPPropertyDescriptor[3];
- descriptors[0] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- descriptors[1] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT);
- descriptors[2] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_4_ID), J2EEVersionConstants.VERSION_1_4_TEXT);
- }
- return descriptors;
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- super.doSetProperty(propertyName, propertyValue);
- if (EditModelOperationDataModel.PROJECT_NAME.equals(propertyName)) {
- addModulesToEARDataModel.setProperty(AddArchiveProjectsToEARDataModel.PROJECT_NAME, propertyValue);
- } else if (propertyName.equals(APPLICATION_VERSION)) {
- getServerTargetDataModel().setProperty(ServerTargetDataModel.J2EE_VERSION_ID, propertyValue);
- } else if (MODULE_LIST.equals(propertyName)) {
- addModulesToEARDataModel.setProperty(AddArchiveProjectsToEARDataModel.MODULE_LIST, propertyValue);
- }
- return true;
- }
-
- public AddArchiveProjectsToEARDataModel getAddModulesToEARDataModel() {
- return addModulesToEARDataModel;
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- if (event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG) {
- if (AddArchiveProjectsToEARDataModel.PROJECT_NAME.equals(event.getPropertyName())) {
- setProperty(PROJECT_NAME, event.getProperty());
- return;
- }
- }
- super.propertyChanged(event);
- }
-
- public void enableValidation() {
- super.enableValidation();
- }
-
- public void disableValidation() {
- super.disableValidation();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModelOld.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModelOld.java
deleted file mode 100644
index 9a3cef0e3..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationDataModelOld.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/***************************************************************************************************
- * 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 27, 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.IPath;
-import org.eclipse.jst.j2ee.common.XMLResource;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-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.internal.emfworkbench.operation.EditModelOperationDataModel;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * This dataModel is used for to create Enterprise Applications.
- *
- * 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 final class EnterpriseApplicationCreationDataModelOld extends J2EEArtifactCreationDataModelOld {
- /**
- * An optional dataModel propertyName for an Integer type. It is used to specify the J2EE
- * Version for the new Enterprise Application. The default value is computed based on the
- * highest J2EE version specified in the J2EE Properties.
- *
- * @since WTP 1.0
- */
- public static final String APPLICATION_VERSION = "J2EEApplicationCreationDataModel.APPLICATION_VERSION"; //$NON-NLS-1$
-
- /*
- * A List containing IProjects
- */
- public static final String MODULE_LIST = AddArchiveProjectsToEARDataModel.MODULE_LIST;
- /*
- * UI only, type Boolean, default false.
- */
- public static final String UI_SHOW_FIRST_PAGE_ONLY = "J2EEApplicationCreationDataModel.UI_SHOW_FIRST_PAGE_ONLY"; //$NON-NLS-1$
-
- private static final String NESTED_MODEL_ADD_ARCHIVE_TO_EAR = "J2EEApplicationCreationDataModel.NESTED_MODEL_ADD_ARCHIVE_TO_EAR"; //$NON-NLS-1$
- private AddArchiveProjectsToEARDataModel addModulesToEARDataModel;
-
- /**
- * Creates an Enterprise Application project with the specified name and version in the
- * specified location.
- *
- * @param projectName
- * The name of the Enterprise Application project to create.
- * @param projectLocation
- * Sets the local file system location for the described project. The path must be
- * either an absolute file system path, or a relative path whose first segment is the
- * name of a defined workspace path variable. If <code>null</code> is specified,
- * the default location is used.
- * @param applicationVersion
- * Sets the J2EE Version for the descibed project. The version must be one of
- * <code>J2EEVersionConstants.J2EE_1_2_ID</code>,
- * <code>J2EEVersionConstants.J2EE_1_3_ID</code>, or
- * <code>J2EEVersionConstants.J2EE_1_4_ID</code>.
- * @since WTP 1.0
- */
- public static void createProject(String projectName, IPath projectLocation, int applicationVersion) {
- EnterpriseApplicationCreationDataModelOld dataModel = new EnterpriseApplicationCreationDataModelOld();
- dataModel.setProperty(PROJECT_NAME, projectName);
- if (null != projectLocation) {
- dataModel.setProperty(PROJECT_LOCATION, projectLocation.toOSString());
- }
- dataModel.setIntProperty(APPLICATION_VERSION, applicationVersion);
- try {
- dataModel.getDefaultOperation().run(null);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- }
- }
-
-
- public WTPOperation getDefaultOperation() {
- return new EnterpriseApplicationCreationOperationOld(this);
- }
-
- protected void init() {
- super.init();
- setProperty(EDIT_MODEL_ID, IEARNatureConstants.EDIT_MODEL_ID);
- getServerTargetDataModel().setIntProperty(ServerTargetDataModel.DEPLOYMENT_TYPE_ID, XMLResource.APPLICATION_TYPE);
- getProjectDataModel().setProperty(ProjectCreationDataModel.PROJECT_NATURES, new String[]{IEARNatureConstants.NATURE_ID});
- setProperty(APPLICATION_VERSION, getDefaultProperty(APPLICATION_VERSION));
- //set it so it pushes it down to ServerTargeting
- }
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(APPLICATION_VERSION);
- addValidBaseProperty(UI_SHOW_FIRST_PAGE_ONLY);
- }
-
- protected void initNestedModels() {
- super.initNestedModels();
- addModulesToEARDataModel = new AddArchiveProjectsToEARDataModel();
- addNestedModel(NESTED_MODEL_ADD_ARCHIVE_TO_EAR, addModulesToEARDataModel);
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(APPLICATION_VERSION)) {
- return getDefaultJ2EEVersion();
- } else if (propertyName.equals(UI_SHOW_FIRST_PAGE_ONLY)) {
- return Boolean.FALSE;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- /*
- * @return Returns the default J2EE spec level based on the Global J2EE Preference
- */
- private Object getDefaultJ2EEVersion() {
- int highestJ2EEPref = J2EEPlugin.getDefault().getJ2EEPreferences().getHighestJ2EEVersionID();
- switch (highestJ2EEPref) {
- case (J2EEVersionConstants.J2EE_1_4_ID) :
- return new Integer(J2EEVersionConstants.J2EE_1_4_ID);
- case (J2EEVersionConstants.J2EE_1_3_ID) :
- return new Integer(J2EEVersionConstants.J2EE_1_3_ID);
- case (J2EEVersionConstants.J2EE_1_2_ID) :
- return new Integer(J2EEVersionConstants.J2EE_1_2_ID);
- default :
- return new Integer(J2EEVersionConstants.J2EE_1_4_TEXT);
- }
- }
-
- /**
- * Returns the String representation of <code>J2EEVersionConstants.J2EE_1_2_ID</code>,
- * <code>J2EEVersionConstants.J2EE_1_3_ID</code>, or
- * <code>J2EEVersionConstants.J2EE_1_4_ID</code>.
- *
- * @param applicationVersion
- * @return The String representation of <code>applicationVersion</code>
- */
- public final static String getVersionString(int applicationVersion) {
- switch (applicationVersion) {
- case J2EEVersionConstants.J2EE_1_2_ID :
- return J2EEVersionConstants.VERSION_1_2_TEXT;
- case J2EEVersionConstants.J2EE_1_3_ID :
- return J2EEVersionConstants.VERSION_1_3_TEXT;
- case J2EEVersionConstants.J2EE_1_4_ID :
- default :
- return J2EEVersionConstants.VERSION_1_4_TEXT;
- }
- }
-
- protected WTPPropertyDescriptor[] doGetValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(APPLICATION_VERSION)) {
- return getValidJ2EEVersionDescriptors();
- }
- return super.doGetValidPropertyDescriptors(propertyName);
- }
-
- protected WTPPropertyDescriptor doGetPropertyDescriptor(String propertyName) {
- if (propertyName.equals(APPLICATION_VERSION)) {
- int version = getIntProperty(APPLICATION_VERSION);
- WTPPropertyDescriptor descriptor = null;
- switch (version) {
- case (J2EEVersionConstants.J2EE_1_2_ID) :
- descriptor = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_3_ID) :
- descriptor = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_4_ID) :
- default :
- descriptor = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_4_ID), J2EEVersionConstants.VERSION_1_4_TEXT);
- break;
-
- }
- return descriptor;
- }
- return super.doGetPropertyDescriptor(propertyName);
- }
-
- /**
- * @return Return a String[] of the valid J2EE versions for the selected J2EE Preference Level.
- */
- protected WTPPropertyDescriptor[] getValidJ2EEVersionDescriptors() {
- 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.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_3_ID) :
- descriptors = new WTPPropertyDescriptor[2];
- descriptors[0] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- descriptors[1] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT);
- break;
- case (J2EEVersionConstants.J2EE_1_4_ID) :
- default :
- descriptors = new WTPPropertyDescriptor[3];
- descriptors[0] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT);
- descriptors[1] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT);
- descriptors[2] = new WTPPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_4_ID), J2EEVersionConstants.VERSION_1_4_TEXT);
- }
- return descriptors;
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- super.doSetProperty(propertyName, propertyValue);
- if (EditModelOperationDataModel.PROJECT_NAME.equals(propertyName)) {
- addModulesToEARDataModel.setProperty(AddArchiveProjectsToEARDataModel.PROJECT_NAME, propertyValue);
- } else if (propertyName.equals(APPLICATION_VERSION)) {
- getServerTargetDataModel().setProperty(ServerTargetDataModel.J2EE_VERSION_ID, propertyValue);
- } else if (MODULE_LIST.equals(propertyName)) {
- addModulesToEARDataModel.setProperty(AddArchiveProjectsToEARDataModel.MODULE_LIST, propertyValue);
- }
- return true;
- }
-
- public AddArchiveProjectsToEARDataModel getAddModulesToEARDataModel() {
- return addModulesToEARDataModel;
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- if (event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG) {
- if (AddArchiveProjectsToEARDataModel.PROJECT_NAME.equals(event.getPropertyName())) {
- setProperty(PROJECT_NAME, event.getProperty());
- return;
- }
- }
- super.propertyChanged(event);
- }
-
- public void enableValidation() {
- super.enableValidation();
- }
-
- public void disableValidation() {
- super.disableValidation();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperation.java
deleted file mode 100644
index 0a11969f0..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperation.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/***************************************************************************************************
- * 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 27, 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.earcreation.EAREditModel;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EENature;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationOperation;
-import org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperation;
-
-/**
- * @deprecated
- *
- */
-public class EnterpriseApplicationCreationOperation extends J2EEArtifactCreationOperationOld {
-
- public EnterpriseApplicationCreationOperation(EnterpriseApplicationCreationDataModel dataModel) {
- super(dataModel);
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EnterpriseApplicationCreationDataModel dataModel = (EnterpriseApplicationCreationDataModel) operationDataModel;
-
- createProject(monitor);
- setVersion((J2EENature) dataModel.getProjectDataModel().getProject().getNature(IEARNatureConstants.NATURE_ID), monitor);
- addServerTarget(monitor);
- if (dataModel.getBooleanProperty(EnterpriseApplicationCreationDataModel.CREATE_DEFAULT_FILES)) {
- createApplication(dataModel, monitor);
- }
- addModules(dataModel.getAddModulesToEARDataModel(), monitor);
- }
-
- protected void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- ProjectCreationDataModel projectModel = ((J2EEArtifactCreationDataModelOld) operationDataModel).getProjectDataModel();
- ProjectCreationOperation projectOperation = new ProjectCreationOperation(projectModel);
- projectOperation.doRun(monitor);
- }
-
- private void addModules(AddArchiveProjectsToEARDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- if (null != model) {
- AddArchiveProjectsToEAROperation modulesOperation = new AddArchiveProjectsToEAROperation(model);
- modulesOperation.doRun(monitor);
- }
- }
-
- private void createApplication(EnterpriseApplicationCreationDataModel dataModel, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EditModelOperation op = new EditModelOperation(dataModel) {
- protected void execute(IProgressMonitor aMonitor) throws CoreException, InvocationTargetException, InterruptedException {
- EAREditModel earEditModel = (EAREditModel) editModel;
- earEditModel.makeDeploymentDescriptorWithRoot();
- }
- };
- op.doRun(monitor);
- }
-
- protected void setVersion(J2EENature nature, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EnterpriseApplicationCreationDataModel dataModel = (EnterpriseApplicationCreationDataModel) operationDataModel;
- nature.setModuleVersion(dataModel.getIntProperty(EnterpriseApplicationCreationDataModel.APPLICATION_VERSION));
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperationOld.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperationOld.java
deleted file mode 100644
index cc8cd4e57..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationCreationOperationOld.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/***************************************************************************************************
- * 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 27, 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.earcreation.EAREditModel;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EENature;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationOperation;
-import org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperation;
-
-public class EnterpriseApplicationCreationOperationOld extends J2EEArtifactCreationOperationOld {
-
- public EnterpriseApplicationCreationOperationOld(EnterpriseApplicationCreationDataModelOld dataModel) {
- super(dataModel);
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EnterpriseApplicationCreationDataModelOld dataModel = (EnterpriseApplicationCreationDataModelOld) operationDataModel;
-
- createProject(monitor);
- setVersion((J2EENature) dataModel.getProjectDataModel().getProject().getNature(IEARNatureConstants.NATURE_ID), monitor);
- addServerTarget(monitor);
- if (dataModel.getBooleanProperty(EnterpriseApplicationCreationDataModelOld.CREATE_DEFAULT_FILES)) {
- createApplication(dataModel, monitor);
- }
- addModules(dataModel.getAddModulesToEARDataModel(), monitor);
- }
-
- protected void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- ProjectCreationDataModel projectModel = ((J2EEArtifactCreationDataModelOld) operationDataModel).getProjectDataModel();
- ProjectCreationOperation projectOperation = new ProjectCreationOperation(projectModel);
- projectOperation.doRun(monitor);
- }
-
- private void addModules(AddArchiveProjectsToEARDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- if (null != model) {
- AddArchiveProjectsToEAROperation modulesOperation = new AddArchiveProjectsToEAROperation(model);
- modulesOperation.doRun(monitor);
- }
- }
-
- private void createApplication(EnterpriseApplicationCreationDataModelOld dataModel, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EditModelOperation op = new EditModelOperation(dataModel) {
- protected void execute(IProgressMonitor aMonitor) throws CoreException, InvocationTargetException, InterruptedException {
- EAREditModel earEditModel = (EAREditModel) editModel;
- earEditModel.makeDeploymentDescriptorWithRoot();
- }
- };
- op.doRun(monitor);
- }
-
- protected void setVersion(J2EENature nature, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EnterpriseApplicationCreationDataModelOld dataModel = (EnterpriseApplicationCreationDataModelOld) operationDataModel;
- nature.setModuleVersion(dataModel.getIntProperty(EnterpriseApplicationCreationDataModelOld.APPLICATION_VERSION));
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationExportDataModel.java
deleted file mode 100644
index 1417c8926..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationExportDataModel.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.jst.j2ee.internal.archive.operations.EnterpriseApplicationExportOperation;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * This dataModel is used to export Enterprise Applications to EAR files.
- *
- * 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 final class EnterpriseApplicationExportDataModel extends J2EEArtifactExportDataModel {
-
- /**
- * Exports the specified Enterprise Appliction project to the specified EAR file.
- *
- * @param earProjectName
- * The name of the Enterprise Application project to export.
- * @param earFileName
- * The fully qualified EAR file location to export the specified Enterprise
- * Application project.
- * @param overwriteExisting
- * If this is <code>true</code> then an existing file at the location specified by
- * <code>earFileName</code> will be overwritten.
- * @param exportSource
- * If this is <code>true</code> then all source files in the specified Enterprise
- * Application Project and all its modules will be included in the resulting EAR
- * file.
- * @since WTP 1.0
- */
- public static void exportProject(String earProjectName, String earFileName, boolean overwriteExisting, boolean exportSource) {
- EnterpriseApplicationExportDataModel dataModel = new EnterpriseApplicationExportDataModel();
- dataModel.setProperty(PROJECT_NAME, earProjectName);
- dataModel.setBooleanProperty(OVERWRITE_EXISTING, overwriteExisting);
- dataModel.setProperty(ARCHIVE_DESTINATION, earFileName);
- dataModel.setBooleanProperty(EXPORT_SOURCE_FILES, exportSource);
- try {
- dataModel.getDefaultOperation().run(null);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- }
- }
-
- public WTPOperation getDefaultOperation() {
- return new EnterpriseApplicationExportOperation(this);
- }
-
- /*
- * Optional, type boolean
- */
- public static final String INCLUDE_BUILD_PATH_AND_META_FILES = "J2EEExportDataModel.INCLUDE_BUILD_PATH_AND_META_FILES"; //$NON-NLS-1$
-
- protected void init() {
- super.init();
- }
-
- protected void initValidBaseProperties() {
- addValidBaseProperty(INCLUDE_BUILD_PATH_AND_META_FILES);
- super.initValidBaseProperties();
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(INCLUDE_BUILD_PATH_AND_META_FILES))
- return Boolean.FALSE;
- return super.getDefaultProperty(propertyName);
- }
-
- protected String getModuleExtension() {
- return ".ear"; //$NON-NLS-1$
- }
-
- protected String getNatureID() {
- return IEARNatureConstants.NATURE_ID;
- }
-
- protected String getWrongProjectTypeString(String projectName) {
- return EARCreationResourceHandler.getString(EARCreationResourceHandler.NOT_AN_EAR, new Object[]{projectName});
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationImportDataModel.java
deleted file mode 100644
index c6be50af6..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/EnterpriseApplicationImportDataModel.java
+++ /dev/null
@@ -1,819 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.eclipse.core.internal.localstore.CoreFileSystemLibrary;
-import org.eclipse.core.internal.resources.ProjectDescription;
-import org.eclipse.core.internal.resources.ProjectDescriptionReader;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.application.WebModule;
-import org.eclipse.jst.j2ee.applicationclient.creation.AppClientModuleImportDataModel;
-import org.eclipse.jst.j2ee.applicationclient.creation.IApplicationClientNatureConstants;
-import org.eclipse.jst.j2ee.common.XMLResource;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.FileImpl;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.WARFileImpl;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.internal.archive.operations.EnterpriseApplicationImportOperation;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.EAREditModel;
-import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleManager;
-import org.eclipse.jst.j2ee.internal.moduleextension.EjbModuleExtension;
-import org.eclipse.jst.j2ee.internal.moduleextension.JcaModuleExtension;
-import org.eclipse.jst.j2ee.internal.moduleextension.WebModuleExtension;
-import org.eclipse.jst.j2ee.internal.project.IConnectorNatureConstants;
-import org.eclipse.jst.j2ee.internal.project.IEJBNatureConstants;
-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.WTPOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelListener;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-import org.xml.sax.InputSource;
-
-/**
- * This dataModel is used for to import Enterprise Applications(from EAR files) into the workspace.
- *
- * 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 final class EnterpriseApplicationImportDataModel extends J2EEArtifactImportDataModel implements IAnnotationsDataModel {
- /**
- * Optional, type Boolean, default true, This flag is set to allow the EAR project to be
- * imported or not. If it is not imported, it is still possible for the nested projects (moduel &
- * utility projects) to be imported.
- */
- public static final String IMPORT_EAR_PROJECT = "EARImportDataModel.IMPORT_EAR_PROJECT"; //$NON-NLS-1$
-
- /**
- * Optional, type Boolean, default false, This flag is set to allow nested projects (module
- * projects & utility projects to be overwritten or not.
- */
- public static final String OVERWRITE_NESTED_PROJECTS = "EARImportDataModel.OVERWRITE_NESTED_PROJECTS"; //$NON-NLS-1$
-
- /*
- * Optional, type IPath default is ear location
- */
- public static final String NESTED_MODULE_ROOT = "EARImportDataModel.NESTED_MODULE_ROOT"; //$NON-NLS-1$
-
- /*
- * Optional, A List containing utililty jars;
- */
- public static final String UTILITY_LIST = "EARImportDataModel.UTILITY_LIST"; //$NON-NLS-1$
-
- public static final String SELECTED_MODELS_LIST = "EARImportDataModel.SELECTED_MODELS_LIST"; //$NON-NLS-1$
-
- private static final String EJB_CLIENT_LIST = "EARImportDataModel.EJB_CLIENT_LIST"; //$NON-NLS-1$
-
- /**
- * Booleam, default is true. When all the module projects are added to the ear, this controls
- * whether their server targets will be set to be the same as the one set on the ear.
- */
- public static final String SYNC_SERVER_TARGETS_WITH_EAR = "EARImportDataModel.SYNC_SERVER_TARGETS_WITH_EAR"; //$NON-NLS-1$
-
- /**
- * Optional. This is a list of data models. This list must contain all non-utilty projects in
- * the ear to be imported
- */
- private static final String MODULE_MODELS_LIST = "EARImportDataModel.MODULE_MODELS_LIST"; //$NON-NLS-1$
-
- /**
- * Optional. This is a list of data models. This list must contain all utility jars selected to
- * be imported
- */
- private static final String UTILITY_MODELS_LIST = "EARImportDataModel.UTILITY_MODELS_LIST"; //$NON-NLS-1$
-
- /**
- * This is only to force validation for the nested projects; do not set.
- */
- public static final String NESTED_PROJECTS_VALIDATION = "EARImportDataModel.NESTED_PROJECTS_VALIDATION"; //$NON-NLS-1$
-
-
- private WTPOperationDataModelListener nestedListener = new WTPOperationDataModelListener() {
- public void propertyChanged(WTPOperationDataModelEvent event) {
- if (event.getPropertyName().equals(J2EEArtifactImportDataModel.PROJECT_NAME)) {
- notifyListeners(NESTED_PROJECTS_VALIDATION);
- }
- }
- };
-
- private Hashtable ejbJarToClientJarModels = new Hashtable();
-
- private Hashtable clientJarToEjbJarModels = new Hashtable();
-
- /**
- * Imports the specified Enterprise Application archive file into the specified Enterprise
- * Application project.
- *
- * @param earFileName
- * The path to the EAR file.
- * @param earProjectName
- * The name of the Enterprise Application project where the Enterprise Application
- * should be imported.
- * @since WTP 1.0
- */
- public static void importArchive(String earFileName, String earProjectName) {
- EnterpriseApplicationImportDataModel dataModel = new EnterpriseApplicationImportDataModel();
- dataModel.setProperty(FILE_NAME, earFileName);
- dataModel.setProperty(PROJECT_NAME, earProjectName);
- try {
- dataModel.getDefaultOperation().run(null);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEImportDataModel#initValidBaseProperties()
- */
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(NESTED_MODULE_ROOT);
- addValidBaseProperty(UTILITY_LIST);
- addValidBaseProperty(MODULE_MODELS_LIST);
- addValidBaseProperty(EJB_CLIENT_LIST);
- addValidBaseProperty(UTILITY_MODELS_LIST);
- addValidBaseProperty(NESTED_PROJECTS_VALIDATION);
- addValidBaseProperty(SELECTED_MODELS_LIST);
- addValidBaseProperty(OVERWRITE_NESTED_PROJECTS);
- addValidBaseProperty(IMPORT_EAR_PROJECT);
- addValidBaseProperty(SYNC_SERVER_TARGETS_WITH_EAR);
- addValidBaseProperty(USE_ANNOTATIONS);
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (NESTED_MODULE_ROOT.equals(propertyName)) {
- return getLocation().toOSString();
- } else if (MODULE_MODELS_LIST.equals(propertyName) || UTILITY_LIST.equals(propertyName) || UTILITY_MODELS_LIST.equals(propertyName) || SELECTED_MODELS_LIST.equals(propertyName) || EJB_CLIENT_LIST.equals(propertyName)) {
- return Collections.EMPTY_LIST;
- } else if (OVERWRITE_NESTED_PROJECTS.equals(propertyName)) {
- return Boolean.FALSE;
- } else if (IMPORT_EAR_PROJECT.equals(propertyName)) {
- return Boolean.TRUE;
- } else if (SYNC_SERVER_TARGETS_WITH_EAR.equals(propertyName)) {
- return Boolean.TRUE;
- } else if (USE_ANNOTATIONS.equals(propertyName)) {
- return Boolean.FALSE;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- super.propertyChanged(event);
- if (event.getPropertyName().equals(J2EEArtifactImportDataModel.PROJECT_NAME)) {
- changeModuleCreationLocationForNameChange(getProjectModels());
- }
- if (event.getPropertyName().equals(J2EEArtifactImportDataModel.SERVER_TARGET_ID)) {
- changeModuleServerTargets((List) getProperty(MODULE_MODELS_LIST));
- }
- }
-
- /**
- * @param list
- */
- private void changeModuleServerTargets(List projectModels) {
- J2EEArtifactImportDataModel nestedModel = null;
- for (int i = 0; i < projectModels.size(); i++) {
- nestedModel = (J2EEArtifactImportDataModel) projectModels.get(i);
- nestedModel.setProperty(J2EEArtifactImportDataModel.SERVER_TARGET_ID, getProperty(ServerTargetDataModel.RUNTIME_TARGET_ID));
- }
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- if (OVERWRITE_NESTED_PROJECTS.equals(propertyName)) {
- List projectModels = getProjectModels();
- J2EEArtifactImportDataModel nestedModel = null;
- for (int i = 0; i < projectModels.size(); i++) {
- nestedModel = (J2EEArtifactImportDataModel) projectModels.get(i);
- nestedModel.setProperty(J2EEArtifactImportDataModel.OVERWRITE_PROJECT, propertyValue);
- }
- }
- boolean doSet = super.doSetProperty(propertyName, propertyValue);
- if (NESTED_MODULE_ROOT.equals(propertyName)) {
- changeModuleCreationLocationForAll(getProjectModels(), (String) propertyValue);
- } else if (FILE_NAME.equals(propertyName)) {
- setProperty(MODULE_MODELS_LIST, getModuleModels());
- setBooleanProperty(PRESERVE_PROJECT_METADATA, false);
- setProperty(UTILITY_LIST, null);
- EnterpriseApplicationCreationDataModel earProjectModel = (EnterpriseApplicationCreationDataModel) getJ2eeArtifactCreationDataModel();
- if (getModuleFile() != null) {
- earProjectModel.setIntProperty(EnterpriseApplicationCreationDataModel.APPLICATION_VERSION, ArchiveUtil.getFastSpecVersion(getModuleFile()));
- }
- notifyValidValuesChange(PROJECT_NAME);
- if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3)
- setBooleanProperty(USE_ANNOTATIONS, false);
- notifyEnablementChange(USE_ANNOTATIONS);
- } else if (UTILITY_LIST.equals(propertyName)) {
- updateUtilityModels((List) propertyValue);
- } else if (PRESERVE_PROJECT_METADATA.equals(propertyName)) {
- if (getBooleanProperty(propertyName)) {
- setProperty(UTILITY_LIST, getUtilitiesForMetaDataImport(getEARFile()));
- }
- List projectModels = getProjectModels();
- J2EEArtifactImportDataModel nestedModel = null;
- for (int i = 0; i < projectModels.size(); i++) {
- nestedModel = (J2EEArtifactImportDataModel) projectModels.get(i);
- nestedModel.setProperty(J2EEArtifactImportDataModel.PRESERVE_PROJECT_METADATA, propertyValue);
- }
- } else if (SERVER_TARGET_ID.equals(propertyName)) {
- List projectModels = (List) getProperty(MODULE_MODELS_LIST);
- J2EEArtifactImportDataModel nestedModel = null;
- for (int i = 0; i < projectModels.size(); i++) {
- nestedModel = (J2EEArtifactImportDataModel) projectModels.get(i);
- nestedModel.setProperty(J2EEArtifactImportDataModel.SERVER_TARGET_ID, propertyValue);
- }
- } else if (USE_ANNOTATIONS.equals(propertyName)) {
- List projectModels = (List) getProperty(MODULE_MODELS_LIST);
- J2EEArtifactImportDataModel nestedModel = null;
- for (int i = 0; i < projectModels.size(); i++) {
- nestedModel = (J2EEArtifactImportDataModel) projectModels.get(i);
- if (nestedModel.getJ2eeArtifactCreationDataModel() instanceof J2EEModuleCreationDataModelOld)
- ((J2EEModuleCreationDataModelOld) nestedModel.getJ2eeArtifactCreationDataModel()).setProperty(J2EEModuleCreationDataModelOld.USE_ANNOTATIONS, propertyValue);
- }
- } else if (MODULE_MODELS_LIST.equals(propertyName)) {
- List newList = new ArrayList();
- newList.addAll(getProjectModels());
- setProperty(SELECTED_MODELS_LIST, newList);
- } else if (PROJECT_NAME.equals(propertyName)) {
- List nestedModels = (List) getProperty(MODULE_MODELS_LIST);
- J2EEArtifactImportDataModel nestedModel = null;
- for (int i = 0; i < nestedModels.size(); i++) {
- nestedModel = (J2EEModuleImportDataModel) nestedModels.get(i);
- nestedModel.setProperty(J2EEModuleImportDataModel.EAR_PROJECT, propertyValue);
- }
- nestedModels = (List) getProperty(UTILITY_MODELS_LIST);
- for (int i = 0; i < nestedModels.size(); i++) {
- nestedModel = (J2EEUtilityJarImportDataModel) nestedModels.get(i);
- nestedModel.setProperty(J2EEUtilityJarImportDataModel.EAR_PROJECT, propertyValue);
- }
- IProject project = ProjectCreationDataModel.getProjectHandleFromProjectName(getStringProperty(PROJECT_NAME));
- if (null != project && project.exists()) {
- IRuntime target = ServerCore.getProjectProperties(project).getRuntimeTarget();
- if (null != target) {
- setProperty(SERVER_TARGET_ID, target.getId());
- }
- }
- }
- if (OVERWRITE_PROJECT.equals(propertyName) || PROJECT_NAME.equals(propertyName) || DELETE_BEFORE_OVERWRITE_PROJECT.equals(propertyName)) {
- notifyEnablementChange(ServerTargetDataModel.RUNTIME_TARGET_ID);
- }
- return doSet;
- }
-
- private List getUtilitiesForMetaDataImport(EARFile earFile) {
- List list = getAllUtilitiesExceptEJBClients(earFile);
- for (int i = list.size() - 1; i > -1; i--) {
- Archive archive = (Archive) list.get(i);
- if (!archive.containsFile(".project")) { //$NON-NLS-1$
- list.remove(archive);
- }
- }
- return list;
- }
-
- public List getAllUtilitiesExceptEJBClients(EARFile earFile) {
- List clientList = (List) getProperty(EJB_CLIENT_LIST);
- List list = getAllUtilities(earFile);
- for (int i = list.size() - 1; i > -1; i--) {
- FileImpl file = (FileImpl) list.get(i);
- boolean shouldRemove = false;
- for (int j = 0; j < clientList.size() && !shouldRemove; j++) {
- J2EEUtilityJarImportDataModel model = (J2EEUtilityJarImportDataModel) clientList.get(j);
- if (model.getArchiveFile() == file) {
- shouldRemove = true;
- }
- }
-
- if (shouldRemove) {
- list.remove(i);
- }
- }
- return list;
- }
-
- public static List getAllUtilities(EARFile earFile) {
- List files = earFile.getFiles();
- List utilJars = new ArrayList();
- for (int i = 0; i < files.size(); i++) {
- FileImpl file = (FileImpl) files.get(i);
- if (file.isArchive() && !file.isModuleFile() && file.getURI().endsWith(".jar")) { //$NON-NLS-1$
- utilJars.add(file);
- }
- if (file.isWARFile()) {
- List webLib = ((WARFileImpl) file).getLibArchives();
- if (!webLib.isEmpty())
- utilJars.addAll(webLib);
- }
- }
- return utilJars;
- }
-
- protected boolean forceResetOnPreserveMetaData() {
- return false;
- }
-
- protected IStatus doValidateProperty(String propertyName) {
- if (propertyName.equals(NESTED_MODEL_VALIDATION_HOOK)) {
- return OK_STATUS;
- }
- if (propertyName.equals(NESTED_PROJECTS_VALIDATION) || (propertyName.equals(PRESERVE_PROJECT_METADATA) && getBooleanProperty(PRESERVE_PROJECT_METADATA))) {
- boolean overwrite = getBooleanProperty(OVERWRITE_NESTED_PROJECTS);
- String earProjectName = getStringProperty(PROJECT_NAME);
- List subProjects = getSelectedModels();
- J2EEArtifactImportDataModel subDataModel = null;
- String tempProjectName = null;
- Archive tempArchive = null;
- IStatus tempStatus = null;
- Hashtable projects = new Hashtable(4);
- for (int i = 0; i < subProjects.size(); i++) {
- subDataModel = (J2EEArtifactImportDataModel) subProjects.get(i);
- tempProjectName = subDataModel.getStringProperty(J2EEArtifactImportDataModel.PROJECT_NAME);
- IStatus status = ProjectCreationDataModel.validateProjectName(tempProjectName);
- if (!status.isOK()) {
- return status;
- }
- tempArchive = subDataModel.getArchiveFile();
- if (!overwrite && subDataModel.getProject().exists()) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("EARImportDataModel_UI_0", new Object[]{tempProjectName, tempArchive.getURI()})); //$NON-NLS-1$
- }
- tempStatus = subDataModel.validateDataModel();
- if (!tempStatus.isOK()) {
- return tempStatus;
- }
- if (tempProjectName.equals(earProjectName)) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("EARImportDataModel_UI_1", new Object[]{tempProjectName, tempArchive.getURI()})); //$NON-NLS-1$
- } else if (!CoreFileSystemLibrary.isCaseSensitive()) {
- if (tempProjectName.toLowerCase().equals(earProjectName.toLowerCase())) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("EARImportDataModel_UI_1", new Object[]{tempProjectName, tempArchive.getURI()})); //$NON-NLS-1$
- }
- }
- if (projects.containsKey(tempProjectName)) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("EARImportDataModel_UI_2", new Object[]{tempProjectName, tempArchive.getURI(), ((Archive) projects.get(tempProjectName)).getURI()})); //$NON-NLS-1$
- } else if (!CoreFileSystemLibrary.isCaseSensitive()) {
- String lowerCaseProjectName = tempProjectName.toLowerCase();
- String currentKey = null;
- Enumeration keys = projects.keys();
- while (keys.hasMoreElements()) {
- currentKey = (String) keys.nextElement();
- if (currentKey.toLowerCase().equals(lowerCaseProjectName)) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("EARImportDataModel_UI_2", new Object[]{tempProjectName, tempArchive.getURI(), ((Archive) projects.get(currentKey)).getURI()})); //$NON-NLS-1$
- }
- }
- }
- projects.put(tempProjectName, tempArchive);
- }
- } else if (propertyName.equals(PROJECT_NAME) && !getBooleanProperty(IMPORT_EAR_PROJECT)) {
- return OK_STATUS;
- }
- //TODO: check context root is not inside current working
- // directory...this is invalid
- return super.doValidateProperty(propertyName);
- }
-
- private void changeModuleCreationLocationForAll(List projects, String property) {
- J2EEArtifactImportDataModel model = null;
- for (int i = 0; null != projects && i < projects.size(); i++) {
- model = (J2EEArtifactImportDataModel) projects.get(i);
- IPath newPath = new Path(property);
- newPath = newPath.append((String) model.getProperty(J2EEArtifactCreationDataModelOld.PROJECT_NAME));
- model.setProperty(J2EEArtifactCreationDataModelOld.PROJECT_LOCATION, newPath.toOSString());
- }
- }
-
- private void changeModuleCreationLocationForNameChange(List projects) {
- J2EEArtifactImportDataModel model = null;
- for (int i = 0; null != projects && i < projects.size(); i++) {
- model = (J2EEArtifactImportDataModel) projects.get(i);
- if (isSet(NESTED_MODULE_ROOT)) {
- IPath newPath = new Path((String) getProperty(NESTED_MODULE_ROOT));
- newPath = newPath.append((String) model.getProperty(J2EEArtifactCreationDataModelOld.PROJECT_NAME));
- model.setProperty(J2EEArtifactCreationDataModelOld.PROJECT_LOCATION, newPath.toOSString());
- } else {
- model.setProperty(J2EEArtifactCreationDataModelOld.PROJECT_LOCATION, null);
- }
- }
- }
-
- private IPath getLocation() {
- return ResourcesPlugin.getWorkspace().getRoot().getLocation();
- }
-
- private void trimSelection() {
- boolean modified = false;
- List selectedList = getSelectedModels();
- List allList = getProjectModels();
- for (int i = selectedList.size() - 1; i > -1; i--) {
- if (!allList.contains(selectedList.get(i))) {
- modified = true;
- selectedList.remove(i);
- }
- }
- if (modified) {
- List newList = new ArrayList();
- newList.addAll(selectedList);
- setProperty(SELECTED_MODELS_LIST, newList);
- }
- }
-
- private void updateUtilityModels(List utilityJars) {
- updateUtilityModels(utilityJars, SELECTED_MODELS_LIST, UTILITY_MODELS_LIST);
- }
-
- private void updateUtilityModels(List utilityJars, String selectedProperty, String listTypeProperty) {
- boolean allSelected = true;
- List selectedList = (List) getProperty(selectedProperty);
- List allList = getProjectModels();
- if (selectedList.size() == allList.size()) {
- for (int i = 0; i < selectedList.size() && allSelected; i++) {
- if (!selectedList.contains(allList.get(i)) || !allList.contains(selectedList.get(i))) {
- allSelected = false;
- }
- }
- } else {
- allSelected = false;
- }
- List utilityModels = (List) getProperty(listTypeProperty);
- Archive currentArchive = null;
- J2EEArtifactImportDataModel currentUtilityModel = null;
- boolean utilityJarsModified = false;
- //Add missing
- for (int i = 0; null != utilityJars && i < utilityJars.size(); i++) {
- currentArchive = (Archive) utilityJars.get(i);
- boolean added = false;
- for (int j = 0; utilityModels != null && j < utilityModels.size() && !added; j++) {
- currentUtilityModel = (J2EEArtifactImportDataModel) utilityModels.get(j);
- if (currentUtilityModel.getArchiveFile() == currentArchive) {
- added = true;
- }
- }
- if (!added) {
- if (!isSet(listTypeProperty)) {
- utilityModels = new ArrayList();
- setProperty(listTypeProperty, utilityModels);
- }
- J2EEUtilityJarImportDataModel model = new J2EEUtilityJarImportDataModel();
- model.setProperty(J2EEUtilityJarImportDataModel.FILE, currentArchive);
- model.setProperty(J2EEUtilityJarImportDataModel.EAR_PROJECT, getStringProperty(PROJECT_NAME));
- model.getJ2eeArtifactCreationDataModel().setBooleanProperty(J2EEArtifactCreationDataModelOld.ADD_SERVER_TARGET, false);
- model.setProperty(PRESERVE_PROJECT_METADATA, getProperty(PRESERVE_PROJECT_METADATA));
- model.setProperty(OVERWRITE_PROJECT, getProperty(OVERWRITE_NESTED_PROJECTS));
- utilityModels.add(model);
- model.addListener(nestedListener);
- utilityJarsModified = true;
- }
- } //Remove extras
- for (int i = utilityModels.size() - 1; i >= 0; i--) {
- currentUtilityModel = (J2EEArtifactImportDataModel) utilityModels.get(i);
- currentArchive = currentUtilityModel.getArchiveFile();
- if (null == utilityJars || !utilityJars.contains(currentArchive)) {
- currentUtilityModel.removeListener(nestedListener);
- currentUtilityModel.dispose();
- utilityModels.remove(currentUtilityModel);
- utilityJarsModified = true;
- }
- }
- allList = getProjectModels();
- if (allSelected) {
- List newList = new ArrayList();
- newList.addAll(allList);
- setProperty(SELECTED_MODELS_LIST, newList);
- } else {
- trimSelection();
- }
- if (utilityJarsModified) {
- notifyListeners(NESTED_PROJECTS_VALIDATION);
- }
- }
-
- private List getModuleModels() {
- if (getArchiveFile() == null)
- return Collections.EMPTY_LIST;
- List moduleFiles = getEARFile().getModuleFiles();
- List moduleModels = new ArrayList();
- List clientJarArchives = new ArrayList();
- J2EEArtifactImportDataModel model;
- String earProjectName = getProject().getName();
- List defaultModuleNames = new ArrayList();
- List collidingModuleNames = null;
- Hashtable ejbJarsWithClients = new Hashtable();
- for (int i = 0; i < moduleFiles.size(); i++) {
- model = null;
- ModuleFile temp = (ModuleFile) moduleFiles.get(i);
- if (temp.isApplicationClientFile()) {
- model = new AppClientModuleImportDataModel();
- } else if (temp.isWARFile()) {
- WebModuleExtension webExt = EarModuleManager.getWebModuleExtension();
- if (webExt != null) {
- model = webExt.createImportDataModel();
- WebModule webModule = (WebModule) getEARFile().getModule(temp.getURI(), null);
- if (null != webModule && null != webModule.getContextRoot()) {
- model.setProperty(AddWebModuleToEARDataModel.CONTEXT_ROOT, webModule.getContextRoot());
- }
- }
- } else if (temp.isEJBJarFile()) {
- EjbModuleExtension ejbExt = EarModuleManager.getEJBModuleExtension();
- if (ejbExt != null) {
- model = ejbExt.createImportDataModel();
- }
- EJBJar jar = ((EJBJarFile) temp).getDeploymentDescriptor();
- if (jar != null) {
- if (jar.getEjbClientJar() != null) {
- String clientName = jar.getEjbClientJar();
- try {
- Archive clientArchive = (Archive) getEARFile().getFile(clientName);
- clientJarArchives.add(clientArchive);
- ejbJarsWithClients.put(model, clientArchive);
- } catch (Exception e) {
- // TODO: handle exception
- }
- }
- }
- } else if (temp.isRARFile()) {
- JcaModuleExtension rarExt = EarModuleManager.getJCAModuleExtension();
- if (rarExt != null) {
- model = rarExt.createImportDataModel();
- }
- }
- if (model != null) {
- model.setProperty(FILE, temp);
- model.setProperty(J2EEModuleImportDataModel.EAR_PROJECT, earProjectName);
- model.setBooleanProperty(J2EEModuleCreationDataModelOld.ADD_TO_EAR, false);
- model.setProperty(OVERWRITE_PROJECT, getProperty(OVERWRITE_PROJECT));
- model.setProperty(PRESERVE_PROJECT_METADATA, getProperty(PRESERVE_PROJECT_METADATA));
- model.setProperty(SERVER_TARGET_ID, getProperty(ServerTargetDataModel.RUNTIME_TARGET_ID));
- model.addListener(this);
- model.addListener(nestedListener);
- moduleModels.add(model);
- String moduleName = model.getStringProperty(J2EEModuleImportDataModel.PROJECT_NAME);
- if (defaultModuleNames.contains(moduleName)) {
- if (collidingModuleNames == null) {
- collidingModuleNames = new ArrayList();
- }
- collidingModuleNames.add(moduleName);
- } else {
- defaultModuleNames.add(moduleName);
- }
- }
- }
- updateUtilityModels(clientJarArchives, EJB_CLIENT_LIST, EJB_CLIENT_LIST);
- List clientModelList = (List) getProperty(EJB_CLIENT_LIST);
- Enumeration ejbModels = ejbJarsWithClients.keys();
- ejbJarToClientJarModels.clear();
- clientJarToEjbJarModels.clear();
- while (ejbModels.hasMoreElements()) {
- Object ejbModel = ejbModels.nextElement();
- Object archive = ejbJarsWithClients.get(ejbModel);
- Object clientModel = null;
- for (int i = 0; clientModel == null && i < clientModelList.size(); i++) {
- if (((J2EEArtifactImportDataModel) clientModelList.get(i)).getArchiveFile() == archive) {
- clientModel = clientModelList.get(i);
- }
- }
- ejbJarToClientJarModels.put(ejbModel, clientModel);
- clientJarToEjbJarModels.put(clientModel, ejbModel);
- }
-
- for (int i = 0; collidingModuleNames != null && i < moduleModels.size(); i++) {
- model = (J2EEModuleImportDataModel) moduleModels.get(i);
- String moduleName = model.getStringProperty(J2EEModuleImportDataModel.PROJECT_NAME);
- if (collidingModuleNames.contains(moduleName)) {
- ModuleFile module = model.getModuleFile();
- String suffix = null;
- if (module.isApplicationClientFile()) {
- suffix = "_AppClient"; //$NON-NLS-1$
- } else if (module.isWARFile()) {
- suffix = "_WEB"; //$NON-NLS-1$
- } else if (module.isEJBJarFile()) {
- suffix = "_EJB"; //$NON-NLS-1$
- } else if (module.isRARFile()) {
- suffix = "_JCA"; //$NON-NLS-1$
- }
- if (defaultModuleNames.contains(moduleName + suffix)) {
- int count = 1;
- for (; defaultModuleNames.contains(moduleName + suffix + count) && count < 10; count++);
- suffix += count;
- }
- model.setProperty(J2EEModuleImportDataModel.PROJECT_NAME, moduleName + suffix);
- }
- }
- return moduleModels;
- }
-
- protected J2EEArtifactCreationDataModelOld createJ2EEProjectCreationDataModel() {
- return new EnterpriseApplicationCreationDataModel();
- }
-
- protected int getType() {
- return XMLResource.APPLICATION_TYPE;
- }
-
- protected boolean openArchive(String uri) throws OpenFailureException {
- setArchiveFile(CommonarchiveFactory.eINSTANCE.openEARFile(getArchiveOptions(), uri));
- if (getArchiveFile() == null)
- return false;
- return true;
- }
-
- public final EARFile getEARFile() {
- return (EARFile) getModuleFile();
- }
-
- public WTPOperation getDefaultOperation() {
- return new EnterpriseApplicationImportOperation(this);
- }
-
- public boolean handlesArchive(Archive anArchive) {
- if (getBooleanProperty(PRESERVE_PROJECT_METADATA)) {
- if (anArchive.containsFile(".project")) { //$NON-NLS-1$
- return true;
- }
- }
- List temp = new ArrayList();
- List tempList = (List) getProperty(MODULE_MODELS_LIST);
- if (null != tempList) {
- temp.addAll(tempList);
- }
- tempList = (List) getProperty(EJB_CLIENT_LIST);
- if (null != tempList) {
- temp.addAll(tempList);
- }
- tempList = getSelectedModels();
- for (int i = 0; i < tempList.size(); i++) {
- if (!temp.contains(tempList.get(i))) {
- temp.add(tempList.get(i));
- }
- }
- J2EEArtifactImportDataModel importDM = null;
- for (int i = 0; i < temp.size(); i++) {
- importDM = (J2EEArtifactImportDataModel) temp.get(i);
- if (importDM.getArchiveFile() == anArchive) {
- return true;
- }
- }
- return false;
- }
-
- public List getProjectModels() {
- List temp = new ArrayList();
- List tempList = (List) getProperty(MODULE_MODELS_LIST);
- if (null != tempList) {
- temp.addAll(tempList);
- }
- tempList = (List) getProperty(UTILITY_MODELS_LIST);
- if (null != tempList) {
- temp.addAll(tempList);
- }
- tempList = (List) getProperty(EJB_CLIENT_LIST);
- if (null != tempList) {
- temp.addAll(tempList);
- }
- return temp;
- }
-
- public List getUnhandledProjectModels() {
- List handled = removeHandledModels(getProjectModels(), getProjectModels(), false);
- List all = getProjectModels();
- all.removeAll(handled);
- return all;
- }
-
- public List getSelectedModels() {
- return (List) getProperty(SELECTED_MODELS_LIST);
- }
-
- private List removeHandledModels(List listToPrune, List modelsToCheck, boolean addModels) {
- List newList = new ArrayList();
- newList.addAll(listToPrune);
- J2EEArtifactImportDataModel model = null;
- for (int i = 0; i < modelsToCheck.size(); i++) {
- model = (J2EEArtifactImportDataModel) modelsToCheck.get(i);
- model.extractHandled(newList, addModels);
- }
- return newList;
- }
-
- public List getHandledSelectedModels() {
- List selectedModels = getSelectedModels();
- return removeHandledModels(selectedModels, selectedModels, true);
- }
-
- public int getJ2EEVersion() {
- EARFile ef = getEARFile();
- return null == ef ? J2EEVersionConstants.J2EE_1_2_ID : ArchiveUtil.getFastSpecVersion(ef);
- }
-
- protected Boolean basicIsEnabled(String propertyName) {
- Boolean enabled = super.basicIsEnabled(propertyName);
- if (null != enabled && !enabled.booleanValue()) {
- return enabled;
- } else if (propertyName.equals(ServerTargetDataModel.RUNTIME_TARGET_ID)) {
- IProject project = ProjectCreationDataModel.getProjectHandleFromProjectName(getStringProperty(PROJECT_NAME));
- if (null == project || !project.exists()) {
- return Boolean.TRUE;
- }
- boolean createNew = getBooleanProperty(OVERWRITE_PROJECT) && getBooleanProperty(DELETE_BEFORE_OVERWRITE_PROJECT);
- if (!createNew) {
- return Boolean.FALSE;
- }
- } else if (propertyName.equals(PRESERVE_PROJECT_METADATA)) {
- EARFile earFile = getEARFile();
- if (null == earFile || !earFile.containsFile(EAREditModel.MODULE_MAP_URI)) {
- return Boolean.FALSE;
- }
- List moduleModels = (List) getProperty(MODULE_MODELS_LIST);
- ProjectDescriptionReader reader = new ProjectDescriptionReader();
- String[] natures = new String[]{IEJBNatureConstants.NATURE_ID, IApplicationClientNatureConstants.NATURE_ID, IWebNatureConstants.J2EE_NATURE_ID, IConnectorNatureConstants.NATURE_ID};
- for (int i = 0; i < moduleModels.size(); i++) {
- J2EEArtifactImportDataModel model = (J2EEArtifactImportDataModel) moduleModels.get(i);
- if (model.getArchiveFile().containsFile(ProjectDescription.DESCRIPTION_FILE_NAME)) {
- try {
- File dotProject = model.getArchiveFile().getFile(ProjectDescription.DESCRIPTION_FILE_NAME);
- ProjectDescription description = reader.read(new InputSource(dotProject.getInputStream()));
- boolean foundNature = false;
- for (int j = 0; !foundNature && j < natures.length; j++) {
- foundNature = description.hasNature(natures[j]);
- }
- if (!foundNature) {
- return Boolean.FALSE;
- }
- } catch (FileNotFoundException e) {
- return Boolean.FALSE;
- } catch (IOException e) {
- return Boolean.FALSE;
- }
- } else {
- return Boolean.FALSE;
- }
- }
- } else if (propertyName.equals(USE_ANNOTATIONS)) {
- if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3)
- return Boolean.FALSE;
- return Boolean.TRUE;
- }
- return Boolean.TRUE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEImportDataModel#dispose()
- */
- public void dispose() {
- super.dispose();
- List list = getProjectModels();
- for (int i = 0; i < list.size(); i++) {
- ((WTPOperationDataModel) list.get(i)).dispose();
- }
- EARFile earFile = getEARFile();
- if (earFile != null)
- earFile.close();
- }
-
- public J2EEArtifactImportDataModel getMatchingEJBJarOrClient(J2EEArtifactImportDataModel model) {
- if (clientJarToEjbJarModels.containsKey(model)) {
- return (J2EEArtifactImportDataModel) clientJarToEjbJarModels.get(model);
- } else if (ejbJarToClientJarModels.containsKey(model)) {
- return (J2EEArtifactImportDataModel) ejbJarToClientJarModels.get(model);
- } else {
- return null;
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportFactory.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportFactory.java
index f3a869cc4..84d80adc9 100644
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportFactory.java
+++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportFactory.java
@@ -17,6 +17,7 @@ package org.eclipse.jst.j2ee.application.operations;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jst.j2ee.application.internal.operations.J2EEModuleImportDataModel;
import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions;
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportRegistry.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportRegistry.java
index b6e7cb9e8..c75481a8e 100644
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportRegistry.java
+++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/ExtendedImportRegistry.java
@@ -19,10 +19,9 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-
import org.eclipse.jem.util.RegistryReader;
import org.eclipse.jem.util.logger.proxy.Logger;
+import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
/**
* @author jsholl
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJavaProjectCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJavaProjectCreationDataModel.java
deleted file mode 100644
index 22c2b13da..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleJavaProjectCreationDataModel.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004, 2005 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModel;
-
-public class FlexibleJavaProjectCreationDataModel extends FlexibleProjectCreationDataModel {
- protected void initProjectModel() {
- setProjectDataModel(new JavaProjectCreationDataModel());
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationDataModel.java
deleted file mode 100644
index 6635c1407..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationDataModel.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004, 2005 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
-import org.eclipse.jst.j2ee.internal.servertarget.J2EEProjectServerTargetDataModel;
-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.WTPOperationDataModel;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-public class FlexibleProjectCreationDataModel extends WTPOperationDataModel {
- /**
- * An optional dataModel property for a <code>Boolean</code> type. The default value is
- * <code>Boolean.TRUE</code>. If this property is set to <code>Boolean.TRUE</code> then the
- * server target specified by dataModel property <code>SERVER_TARGET_ID</code> will be set on
- * the generated artifact.
- *
- * @see SERVER_TARGET_ID
- */
- public static final String ADD_SERVER_TARGET = "FlexibleProjectCreationDataModel.ADD_SERVER_TARGET"; //$NON-NLS-1$
-
- /**
- * An optional dataModel property for a <code>java.lang.String</code> type. This is used to
- * specify the server target and is required if the <code>ADD_SERVER_TARGET</code> property is
- * set to <code>Boolean.TRUE</code>.
- *
- * @see ServerTargetDataModel.RUNTIME_TARGET_ID
- */
- public static final String SERVER_TARGET_ID = J2EEProjectServerTargetDataModel.RUNTIME_TARGET_ID;
-
- private J2EEProjectServerTargetDataModel serverTargetDataModel;
- private static final String NESTED_MODEL_SERVER_TARGET = "FlexibleProjectCreationDataModel.NESTED_MODEL_SERVER_TARGET"; //$NON-NLS-1$
-
- private ProjectCreationDataModel projectDataModel;
- public static final String PROJECT_NAME = "FlexibleProjectCreationDataModel.PROJECT_NAME";
- public static final String PROJECT_LOCATION = "FlexibleProjectCreationDataModel.PROJECT_LOCATION";
- private static final String NESTED_MODEL_PROJECT_CREATION = "FlexibleProjectCreationDataModel.NESTED_MODEL_PROJECT_CREATION"; //$NON-NLS-1$
-
- protected void initValidBaseProperties() {
- addValidBaseProperty(ADD_SERVER_TARGET);
- addValidBaseProperty(PROJECT_NAME);
- addValidBaseProperty(PROJECT_LOCATION);
- super.initValidBaseProperties();
- }
-
- protected IStatus doValidateProperty(String propertyName) {
- if (PROJECT_NAME.equals(propertyName)) {
- return validateProjectName();
- }
- return super.doValidateProperty(propertyName);
- }
-
- private IStatus validateProjectName() {
- String projectName = getStringProperty(PROJECT_NAME);
- if (projectName != null && projectName.length() != 0) {
- IProject project = ProjectUtilities.getProject(projectName);
- if (project != null && project.exists()) {
- String msg = J2EECommonMessages.getResourceString(J2EECommonMessages.ERR_PROJECT_NAME_EXISTS);
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- }
- return WTPCommonPlugin.OK_STATUS;
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (PROJECT_LOCATION.equals(propertyName)) {
- return getDefaultLocation();
- }
- if (propertyName.equals(ADD_SERVER_TARGET)) {
- return Boolean.TRUE;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- private String getDefaultLocation() {
- IPath path = getRootLocation();
- String projectName = (String) getProperty(PROJECT_NAME);
- if (projectName != null)
- path = path.append(projectName);
- return path.toOSString();
- }
-
- private IPath getRootLocation() {
- return ResourcesPlugin.getWorkspace().getRoot().getLocation();
- }
-
- public final J2EEProjectServerTargetDataModel getServerTargetDataModel() {
- return serverTargetDataModel;
- }
-
- protected void initNestedModels() {
- super.initNestedModels();
- initProjectModel();
- addNestedModel(NESTED_MODEL_PROJECT_CREATION, projectDataModel);
-
- serverTargetDataModel = new J2EEProjectServerTargetDataModel();
- addNestedModel(NESTED_MODEL_SERVER_TARGET, serverTargetDataModel);
- }
-
- protected void initProjectModel() {
- projectDataModel = new ProjectCreationDataModel();
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- super.doSetProperty(propertyName, propertyValue);
- if (PROJECT_NAME.equals(propertyName)) {
- projectDataModel.setProperty(ProjectCreationDataModel.PROJECT_NAME, propertyValue);
- serverTargetDataModel.setProperty(J2EEProjectServerTargetDataModel.PROJECT_NAME, propertyValue);
- }
- return true;
- }
-
- public WTPOperation getDefaultOperation() {
- return new FlexibleProjectCreationOperation(this);
- }
-
- protected final void setProjectDataModel(ProjectCreationDataModel projectDataModel) {
- this.projectDataModel = projectDataModel;
- }
-
- public final ProjectCreationDataModel getProjectDataModel() {
- return projectDataModel;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationOperation.java
deleted file mode 100644
index 332143087..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/FlexibleProjectCreationOperation.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004, 2005 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jst.j2ee.internal.servertarget.J2EEProjectServerTargetDataModel;
-import org.eclipse.jst.j2ee.internal.servertarget.J2EEProjectServerTargetOperation;
-import org.eclipse.wst.common.frameworks.internal.WTPProjectUtilities;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.modulecore.ModuleCore;
-import org.eclipse.wst.common.modulecore.ProjectComponents;
-import org.eclipse.wst.common.modulecore.internal.util.IModuleConstants;
-
-public class FlexibleProjectCreationOperation extends WTPOperation {
-
- public FlexibleProjectCreationOperation(FlexibleProjectCreationDataModel operationDataModel) {
- super(operationDataModel);
- // TODO Auto-generated constructor stub
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- createProject(monitor);
- addServerTarget(monitor);
- WTPProjectUtilities.addNatureToProjectLast(getProject(), IModuleConstants.MODULE_NATURE_ID);
- createInitialWTPModulesFile();
- }
-
- private void addServerTarget(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException{
- J2EEProjectServerTargetDataModel serverModel = ((FlexibleProjectCreationDataModel) operationDataModel).getServerTargetDataModel();
- J2EEProjectServerTargetOperation serverTargetOperation = (J2EEProjectServerTargetOperation)serverModel.getDefaultOperation();
- serverTargetOperation.doRun(monitor);
- }
-
- private void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- ProjectCreationDataModel projModel = ((FlexibleProjectCreationDataModel) operationDataModel).getProjectDataModel();
- WTPOperation op = projModel.getDefaultOperation();
- op.doRun(monitor);
- }
-
- private void createInitialWTPModulesFile() {
- ModuleCore moduleCore = null;
- try {
- IProject containingProject = getProject();
- moduleCore = ModuleCore.getModuleCoreForWrite(containingProject);
- moduleCore.prepareProjectModulesIfNecessary();
- ProjectComponents projectModules = moduleCore.getModuleModelRoot();
- moduleCore.saveIfNecessary(null);
- } finally {
- if(moduleCore != null)
- moduleCore.dispose();
- }
- }
-
- protected IProject getProject() {
- String name = (String) ((FlexibleProjectCreationDataModel) operationDataModel).getStringProperty(FlexibleProjectCreationDataModel.PROJECT_NAME);
- if (name != null && name.length() > 0)
- return ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- return null;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/IAnnotationsDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/IAnnotationsDataModel.java
deleted file mode 100644
index f907d3f59..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/IAnnotationsDataModel.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-/**
- * The IAnnotationsDataModel is data model interface used by other data models in
- * the WTP wizard and operation framework.
- * @see org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel
- * @see org.eclipse.wst.common.frameworks.operations.WTPOperation
- *
- * This provides the USE_ANNOTATIONS property which is used to determine whether or
- * not artifacts should be created using annotations or not.
- *
- * Subclasses may extend this interface to add their own properties.
- *
- * The use of this interface is EXPERIMENTAL and subject to substantial changes.
- *
- */
-public interface IAnnotationsDataModel {
-
- /**
- * Optional, type Boolean to determine whether an artifact should be created with annotated tags.
- * The default is set on the particular data model who implements this interface.
- */
- public static final String USE_ANNOTATIONS = "IAnnotationsDataModel.useAnnotations"; //$NON-NLS-1$
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationDataModelOld.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationDataModelOld.java
deleted file mode 100644
index 8993eca96..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationDataModelOld.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/***************************************************************************************************
- * 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 org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModel;
-import org.eclipse.jst.j2ee.internal.project.J2EECreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
-import org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperationDataModel;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-/**
- * This dataModel is a common super class used to create J2EE Components.
- *
- * 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 abstract class J2EEArtifactCreationDataModelOld extends EditModelOperationDataModel {
- /**
- * An optional dataModel propertyName for a <code>Boolean</code> type. The default value is
- * <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 CREATE_DEFAULT_FILES = "J2EEArtifactCreationDataModel.CREATE_DEFAULT_FILES"; //$NON-NLS-1$
-
- /**
- * An optional dataModel property for a <code>Boolean</code> type. The default value is
- * <code>Boolean.TRUE</code>. If this property is set to <code>Boolean.TRUE</code> then the
- * server target specified by dataModel property <code>SERVER_TARGET_ID</code> will be set on
- * the generated artifact.
- *
- * @see SERVER_TARGET_ID
- */
- public static final String ADD_SERVER_TARGET = "J2EEArtifactCreationDataModel.ADD_SERVER_TARGET"; //$NON-NLS-1$
-
- /**
- * Optional, type String
- */
- public static final String FINAL_PERSPECTIVE = "J2EEArtifactCreationDataModel.FINAL_PERSPECTIVE"; //$NON-NLS-1$
-
- /**
- * An optonal dataModel propertyName for a <code>java.lang.String</code> type. Sets the local
- * file system location for the described project. The path must be either an absolute file
- * system path, or a relative path whose first segment is the name of a defined workspace path
- * variable. The default value is the workspace's default location.
- *
- * @see ProjectCreationDataModel.PROJECT_LOCATION
- */
- public static final String PROJECT_LOCATION = ProjectCreationDataModel.PROJECT_LOCATION;
-
- /**
- * An optional dataModel property for a <code>java.lang.String</code> type. This is used to
- * specify the server target and is required if the <code>ADD_SERVER_TARGET</code> property is
- * set to <code>Boolean.TRUE</code>.
- *
- * @see ServerTargetDataModel.RUNTIME_TARGET_ID
- */
- public static final String SERVER_TARGET_ID = ServerTargetDataModel.RUNTIME_TARGET_ID;
- public static final String CLASSPATH_ENTRIES = JavaProjectCreationDataModel.CLASSPATH_ENTRIES;
-
- protected static final String IS_ENABLED = "J2EEArtifactCreationDataModel.IS_ENABLED"; //$NON-NLS-1$
-
- private static final String NESTED_MODEL_PROJECT_CREATION = "J2EEArtifactCreationDataModel.NESTED_MODEL_PROJECT_CREATION"; //$NON-NLS-1$
- private static final String NESTED_MODEL_SERVER_TARGET = "J2EEArtifactCreationDataModel.NESTED_MODEL_SERVER_TARGET"; //$NON-NLS-1$
-
- private ProjectCreationDataModel projectDataModel;
- private ServerTargetDataModel serverTargetDataModel;
-
- protected void initValidBaseProperties() {
- addValidBaseProperty(CREATE_DEFAULT_FILES);
- addValidBaseProperty(ADD_SERVER_TARGET);
- addValidBaseProperty(IS_ENABLED);
- addValidBaseProperty(FINAL_PERSPECTIVE);
- super.initValidBaseProperties();
- }
-
- protected void initNestedModels() {
- super.initNestedModels();
- initProjectModel();
- addNestedModel(NESTED_MODEL_PROJECT_CREATION, projectDataModel);
-
- serverTargetDataModel = new ServerTargetDataModel();
- addNestedModel(NESTED_MODEL_SERVER_TARGET, serverTargetDataModel);
- }
-
- protected void initProjectModel() {
- projectDataModel = new ProjectCreationDataModel();
- }
-
- /**
- * @param projectDataModel
- * The projectDataModel to set.
- */
- protected final void setProjectDataModel(ProjectCreationDataModel projectDataModel) {
- this.projectDataModel = projectDataModel;
- }
-
- public final ProjectCreationDataModel getProjectDataModel() {
- return projectDataModel;
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- super.doSetProperty(propertyName, propertyValue);
- if (EditModelOperationDataModel.PROJECT_NAME.equals(propertyName)) {
- projectDataModel.setProperty(ProjectCreationDataModel.PROJECT_NAME, propertyValue);
- serverTargetDataModel.setProperty(ServerTargetDataModel.PROJECT_NAME, propertyValue);
- } else if (IS_ENABLED.equals(propertyName)) {
- notifyEnablementChange(SERVER_TARGET_ID);
- notifyEnablementChange(PROJECT_NAME);
- }
- return true;
- }
-
- public final ServerTargetDataModel getServerTargetDataModel() {
- return serverTargetDataModel;
- }
-
- protected Boolean basicIsEnabled(String propertyName) {
- return (Boolean) getProperty(IS_ENABLED);
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- if (event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG) {
- WTPOperationDataModel dm = event.getDataModel();
- if (dm == projectDataModel || dm == serverTargetDataModel) {
- 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);
- }
-
- protected IStatus doValidateProperty(String propertyName) {
- if (propertyName.equals(PROJECT_NAME)) {
- IStatus status = projectDataModel.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;
-
- } else if (propertyName.equals(NESTED_MODEL_VALIDATION_HOOK)) {
- return OK_STATUS;
- }
- return super.doValidateProperty(propertyName);
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(CREATE_DEFAULT_FILES) || propertyName.equals(ADD_SERVER_TARGET) || propertyName.equals(IS_ENABLED)) {
- return Boolean.TRUE;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- protected boolean isResultProperty(String propertyName) {
- if (propertyName.equals(FINAL_PERSPECTIVE))
- return true;
- return super.isResultProperty(propertyName);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationOperationOld.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationOperationOld.java
deleted file mode 100644
index 78bde6daf..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactCreationOperationOld.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * @deprecated Use J2EECreationOperation
- *
- */
-public abstract class J2EEArtifactCreationOperationOld extends WTPOperation {
-
- public J2EEArtifactCreationOperationOld(J2EEArtifactCreationDataModelOld dataModel) {
- super(dataModel);
- }
-
- public J2EEArtifactCreationOperationOld() {
- super();
- }
-
- protected abstract void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException;
-
- protected void addServerTarget(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- if (operationDataModel.getBooleanProperty(J2EEArtifactCreationDataModelOld.ADD_SERVER_TARGET)) {
- ServerTargetDataModel model = ((J2EEArtifactCreationDataModelOld) operationDataModel).getServerTargetDataModel();
- ServerTargetOperation serverTargetOperation = new ServerTargetOperation(model);
- serverTargetOperation.doRun(monitor);
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactExportDataModel.java
deleted file mode 100644
index 5b61998e1..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactExportDataModel.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.internal.project.J2EENature;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPPropertyDescriptor;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonMessages;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-
-/**
- * This dataModel is an common super class used to export J2EE components.
- *
- * 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 abstract class J2EEArtifactExportDataModel extends WTPOperationDataModel {
-
- /**
- * Required, type String
- */
- public static final String PROJECT_NAME = "J2EEExportDataModel.PROJECT_NAME"; //$NON-NLS-1$
- /**
- * Required, type String
- *
- */
- public static final String ARCHIVE_DESTINATION = "J2EEExportDataModel.ARCHIVE_DESTINATION"; //$NON-NLS-1$
- /*
- * Optional, type boolean
- */
- public static final String EXPORT_SOURCE_FILES = "J2EEExportDataModel.EXPORT_SOURCE_FILES"; //$NON-NLS-1$
- /*
- * Optional, type boolean
- */
- public static final String OVERWRITE_EXISTING = "J2EEExportDataModel.OVERWRITE_EXISTING"; //$NON-NLS-1$
-
- /*
- * Optional, type boolean, default true
- */
- public static final String RUN_BUILD = "J2EEExportDataModel.RUN_BUILD"; //$NON-NLS-1$
-
- protected void init() {
- super.init();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#getTargetProject()
- */
- public IProject getTargetProject() {
- return ProjectCreationDataModel.getProjectHandleFromProjectName(getStringProperty(PROJECT_NAME));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperationDataModel#initValidBaseProperties()
- */
- protected void initValidBaseProperties() {
- addValidBaseProperty(PROJECT_NAME);
- addValidBaseProperty(ARCHIVE_DESTINATION);
- addValidBaseProperty(EXPORT_SOURCE_FILES);
- addValidBaseProperty(OVERWRITE_EXISTING);
- addValidBaseProperty(RUN_BUILD);
- super.initValidBaseProperties();
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(ARCHIVE_DESTINATION)) {
- return ""; //$NON-NLS-1$
- } else if (propertyName.equals(EXPORT_SOURCE_FILES)) {
- return Boolean.FALSE;
- } else if (propertyName.equals(OVERWRITE_EXISTING)) {
- return Boolean.FALSE;
- } else if (propertyName.equals(RUN_BUILD)) {
- return Boolean.TRUE;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- protected WTPPropertyDescriptor[] doGetValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(PROJECT_NAME)) {
- return getValidProjectDescriptors();
- }
- return super.doGetValidPropertyDescriptors(propertyName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doValidateProperty(java.lang.String)
- */
- protected IStatus doValidateProperty(String propertyName) {
- if (PROJECT_NAME.equals(propertyName)) {
- String projectName = (String) getProperty(PROJECT_NAME);
- IStatus status = ProjectCreationDataModel.validateProjectName(projectName);
- if (!status.isOK()) {
- return status;
- }
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (!project.exists()) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_NOT_EXISTS_ERROR, new Object[]{projectName}));
- }
- try {
- if (!project.hasNature(getNatureID())) {
- return WTPCommonPlugin.createErrorStatus(getWrongProjectTypeString(project.getName()));
- }
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
-
- } else if (ARCHIVE_DESTINATION.equals(propertyName)) {
- String archiveLocation = (String) getProperty(ARCHIVE_DESTINATION);
- if (!isSet(ARCHIVE_DESTINATION) || archiveLocation.equals("")) { //$NON-NLS-1$
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.DESTINATION_INVALID)); //$NON-NLS-1$);
- } else if (isSet(ARCHIVE_DESTINATION) && !validateModuleType(archiveLocation)) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.DESTINATION_ARCHIVE_SHOULD_END_WITH, new Object[]{getModuleExtension()})); //$NON-NLS-1$);
- } else if (isSet(ARCHIVE_DESTINATION)) {
- IStatus tempStatus = validateLocation(archiveLocation);
- if (tempStatus != OK_STATUS)
- return tempStatus;
- }
- }
- if (ARCHIVE_DESTINATION.equals(propertyName) || OVERWRITE_EXISTING.equals(propertyName)) {
- String location = (String) getProperty(ARCHIVE_DESTINATION);
- if (checkForExistingFileResource(location)) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.RESOURCE_EXISTS_ERROR, new Object[]{location}));
- }
- }
- return super.doValidateProperty(propertyName);
- }
-
- protected abstract String getNatureID();
-
- protected abstract String getWrongProjectTypeString(String projectName);
-
- private IStatus validateLocation(String archiveLocation) {
- IPath path = null;
- try {
- path = new Path(archiveLocation);
- } catch (IllegalArgumentException ex) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.DESTINATION_INVALID));
- }
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IStatus status = workspace.validateName(path.lastSegment(), IResource.FILE);
- if (!status.isOK()) {
- return status;
- }
- String device = path.getDevice();
- if (device == null)
- return OK_STATUS;
- if (path == null || device.length() == 1 && device.charAt(0) == Path.DEVICE_SEPARATOR)
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.DESTINATION_INVALID));
-
- if (!path.toFile().canWrite()) {
- if (path.toFile().exists()) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.IS_READ_ONLY));
- }
- boolean OK = false;
- path = path.removeLastSegments(1);
- for (int i = 1; !OK && i < 20 && path.segmentCount() > 0; i++) {
- if (path.toFile().exists()) {
- OK = true;
- }
- status = workspace.validateName(path.lastSegment(), IResource.FOLDER);
- if (!status.isOK()) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.DESTINATION_INVALID));
- }
- path = path.removeLastSegments(1);
- }
- }
-
- return OK_STATUS;
- }
-
- private boolean checkForExistingFileResource(String fileName) {
- if (!getBooleanProperty(J2EEArtifactExportDataModel.OVERWRITE_EXISTING)) {
- java.io.File externalFile = new java.io.File(fileName);
- if (externalFile != null && externalFile.exists())
- return true;
- }
- return false;
- }
-
- /**
- *
- */
- private boolean validateModuleType(String archive) {
- if ((archive.length() < 4) || (!(archive.substring(archive.length() - 4, archive.length()).equalsIgnoreCase(getModuleExtension())))) {
- return false;
- }
- return true;
- }
-
- /**
- * Populate the resource name combo with connector projects that are not encrypted.
- */
- private WTPPropertyDescriptor[] getValidProjectDescriptors() {
- List projects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
- List projectsWithNature = new ArrayList();
-
- for (int i = 0; i < projects.size(); i++) {
- IProject project = (IProject) projects.get(i);
- if (J2EENature.hasRuntime(project, getNatureID()) && project.isOpen()) {
- projectsWithNature.add(project.getFullPath().toString());
- } // if
- } // for
- return WTPPropertyDescriptor.createDescriptors(ProjectUtilities.getProjectNamesWithoutForwardSlash((String[]) projectsWithNature.toArray(new String[projectsWithNature.size()])));
- }
-
- protected abstract String getModuleExtension();
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactImportDataModel.java
deleted file mode 100644
index b6f19a070..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEArtifactImportDataModel.java
+++ /dev/null
@@ -1,462 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.internal.resources.ProjectDescription;
-import org.eclipse.core.internal.resources.ProjectDescriptionReader;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.applicationclient.creation.IApplicationClientNatureConstants;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.SaveFilter;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.project.IConnectorNatureConstants;
-import org.eclipse.jst.j2ee.internal.project.IEJBNatureConstants;
-import org.eclipse.jst.j2ee.internal.project.IWebNatureConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EENature;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
-import org.eclipse.wst.common.frameworks.operations.WTPPropertyDescriptor;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonMessages;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-import org.xml.sax.InputSource;
-
-/**
- * This dataModel is a common super class used to import J2EE Components.
- *
- * 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 abstract class J2EEArtifactImportDataModel extends WTPOperationDataModel {
- /**
- * Required, type String
- */
- public static final String FILE_NAME = "J2EEImportDataModel.FILE_NAME"; //$NON-NLS-1$
- /**
- * Optional, type Archive, used when a file is available as an object rather than a url (i.e.
- * using the FILE_NAME property will not work).
- */
- public static final String FILE = "J2EEImportDataModel.FILE"; //$NON-NLS-1$
- /**
- * Optional, type Boolean defaults to false
- */
- public static final String OVERWRITE_PROJECT = "J2EEImportDataModel.OVERWRITE_PROJECT"; //$NON-NLS-1$
- /**
- * Optional, type Boolean defaults to false
- */
- public static final String DELETE_BEFORE_OVERWRITE_PROJECT = "J2EEImportDataModel.DELETE_BEFORE_OVERWRITE_PROJECT"; //$NON-NLS-1$
- /**
- * Optional, type SaveFilter, default is null
- */
- public static final String SAVE_FILTER = "J2EEImportDataModel.SAVE_FILTER"; //$NON-NLS-1$
- /**
- * Optional, type Boolean, default false this is used only when importing modules in with an ear
- */
- public static final String PRESERVE_PROJECT_METADATA = "J2EEImportDataModel.IS_LIBRARY"; //$NON-NLS-1$
- /**
- * Do not set this property.
- */
- public static final String BINARY = "J2EEImportDataModel.BINARY"; //$NON-NLS-1$
- public static final String OVERWRITE_HANDLER = "J2EEImportDataModel.OVERWRITE_HANDLER"; //$NON-NLS-1$
- public static final String PROJECT_NAME = "J2EEImportDataModel.PROJECT_NAME"; //$NON-NLS-1$
- public static final String NESTED_MODEL_J2EE_PROJECT_CREATION = "J2EEImportDataModel.NESTED_MODEL_J2EE_PROJECT_CREATION"; //$NON-NLS-1$
- /**
- * Optional - Should the archive be closed on dispose?
- *
- * @type - Boolean, default is True
- */
- public static final String CLOSE_ARCHIVE_ON_DISPOSE = "J2EEImportDataModel.closeArchiveOnDispose"; //$NON-NLS-1$
- /**
- * Optiona - type String, default = getArchiveFile().getURI() or "" if getArchivefile() is null
- * This is used when adding a module to the ear.
- */
- public static final String URI_FOR_MODULE_MAPPING = "J2EEImportDataModel.URI_FOR_MODULE_MAPPING"; //$NON-NLS-1$
-
- public static final String FILE_SELECTION_HISTORY = "J2EEImportDataModel.FILE_SELECTION_HISTORY"; //$NON-NLS-1$
-
- private static final String DEFAULT_PROJECT_NAME = "J2EEImportDataModel.DEFAULT_PROJECT_NAME"; //$NON-NLS-1$
-
- /**
- * Extended attributes
- */
- public static final String SERVER_TARGET_ID = J2EEArtifactCreationDataModelOld.SERVER_TARGET_ID;
-
- private J2EEArtifactCreationDataModelOld j2eeArtifactCreationDataModel;
- private Archive archiveFile;
- private OpenFailureException cachedOpenFailureException = null;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.internal.emfworkbench.operation.EditModelOperationDataModel#initValidBaseProperties()
- */
- protected void initValidBaseProperties() {
- addValidBaseProperty(FILE_NAME);
- addValidBaseProperty(FILE);
- addValidBaseProperty(OVERWRITE_PROJECT);
- addValidBaseProperty(DELETE_BEFORE_OVERWRITE_PROJECT);
- addValidBaseProperty(SAVE_FILTER);
- addValidBaseProperty(PRESERVE_PROJECT_METADATA);
- addValidBaseProperty(BINARY);
- addValidBaseProperty(OVERWRITE_HANDLER);
- addValidBaseProperty(PROJECT_NAME);
- addValidBaseProperty(CLOSE_ARCHIVE_ON_DISPOSE);
- addValidBaseProperty(URI_FOR_MODULE_MAPPING);
- addValidBaseProperty(FILE_SELECTION_HISTORY);
- addValidBaseProperty(DEFAULT_PROJECT_NAME);
- super.initValidBaseProperties();
- }
-
- protected void initNestedModels() {
- super.initNestedModels();
- j2eeArtifactCreationDataModel = createJ2EEProjectCreationDataModel();
- j2eeArtifactCreationDataModel.setBooleanProperty(J2EEArtifactCreationDataModelOld.CREATE_DEFAULT_FILES, false);
- j2eeArtifactCreationDataModel.addListener(this);
- addNestedModel(NESTED_MODEL_J2EE_PROJECT_CREATION, j2eeArtifactCreationDataModel);
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(BINARY)) {
- return getProperty(PRESERVE_PROJECT_METADATA);
- }
- if (propertyName.equals(PRESERVE_PROJECT_METADATA) || propertyName.equals(OVERWRITE_PROJECT) || propertyName.equals(DELETE_BEFORE_OVERWRITE_PROJECT)) {
- return Boolean.FALSE;
- } else if (propertyName.equals(PROJECT_NAME)) {
- return j2eeArtifactCreationDataModel.getProperty(J2EEArtifactCreationDataModelOld.PROJECT_NAME);
- } else if (propertyName.equals(CLOSE_ARCHIVE_ON_DISPOSE)) {
- return Boolean.TRUE;
- } else if (propertyName.equals(URI_FOR_MODULE_MAPPING)) {
- if (null == getArchiveFile()) {
- return ""; //$NON-NLS-1$
- }
- return getArchiveFile().getURI();
- } else if (propertyName.equals(DEFAULT_PROJECT_NAME)) {
- return Boolean.TRUE;
- }
- return super.getDefaultProperty(propertyName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doSetProperty(java.lang.String,
- * java.lang.Object)
- */
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- if (propertyName.equals(BINARY)) {
- throw new RuntimeException("Property " + BINARY + " may not be set."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (propertyName.equals(FILE)) {
- setProperty(FILE_NAME, null);
- super.doSetProperty(propertyName, propertyValue);
- archiveFile = (Archive) propertyValue;
- updateDefaultProjectName();
- return true;
- }
- boolean doSet = super.doSetProperty(propertyName, propertyValue);
- if (propertyName.equals(FILE_SELECTION_HISTORY)) {
- notifyValidValuesChange(FILE_NAME);
- }
-
- if (propertyName.equals(PRESERVE_PROJECT_METADATA) && forceResetOnPreserveMetaData()) {
- if (getBooleanProperty(PRESERVE_PROJECT_METADATA) && null != getArchiveFile()) {
- if (getArchiveFile().containsFile(ProjectDescription.DESCRIPTION_FILE_NAME)) {
- try {
- File dotProject = getArchiveFile().getFile(ProjectDescription.DESCRIPTION_FILE_NAME);
- ProjectDescriptionReader reader = new ProjectDescriptionReader();
- ProjectDescription description = reader.read(new InputSource(dotProject.getInputStream()));
- setProperty(PROJECT_NAME, description.getName());
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
- }
- }
- }
- }
-
- // if (propertyName.equals(PRESERVE_PROJECT_METADATA) && forceResetOnPreserveMetaData() &&
- // isSet(PROJECT_NAME)) {
- // if (null != moduleFile) {
- //
- //
- // Path path = new Path(moduleFile.getURI());
- // String defaultProjectName = path.segment(path.segmentCount() - 1);
- // if (defaultProjectName.indexOf(".") > 0) { //$NON-NLS-1$
- // defaultProjectName = defaultProjectName.substring(0, defaultProjectName.indexOf("."));
- // //$NON-NLS-1$
- // }
- // if (!getBooleanProperty(PRESERVE_PROJECT_METADATA)) {
- // String baseName = defaultProjectName;
- // IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- // for (int i = 1; i < 10 && root.getProject(defaultProjectName).exists(); i++) {
- // defaultProjectName = baseName + Integer.toString(i);
- // }
- // }
- // setProperty(PROJECT_NAME, defaultProjectName);
- // }
- // }
- // if (propertyName.equals(OVERWRITE_PROJECT)) {
- // updateDefaultProjectName();
- // }
- if (propertyName.equals(PROJECT_NAME)) {
- j2eeArtifactCreationDataModel.setProperty(J2EEArtifactCreationDataModelOld.PROJECT_NAME, propertyValue);
- } else if (propertyName.equals(SAVE_FILTER) && archiveFile != null) {
- archiveFile.setSaveFilter(getSaveFilter());
- }
- if (doSet) {
- if (FILE_NAME.equals(propertyName)) {
- boolean success = false;
- try {
- cachedOpenFailureException = null;
- success = handleArchiveSetup((String) propertyValue);
- } catch (OpenFailureException oe) {
- cachedOpenFailureException = oe;
- }
- if (success)
- updateDefaultProjectName();
- }
- }
- return doSet;
- }
-
- protected boolean forceResetOnPreserveMetaData() {
- return true;
- }
-
- private void updateDefaultProjectName() {
- if (null != archiveFile && getBooleanProperty(DEFAULT_PROJECT_NAME)) {
- Path path = new Path(archiveFile.getURI());
- String defaultProjectName = path.segment(path.segmentCount() - 1);
- if (defaultProjectName.indexOf('.') > 0) {
- defaultProjectName = defaultProjectName.substring(0, defaultProjectName.lastIndexOf('.'));
- if (defaultProjectName.indexOf('.') > 0) {
- defaultProjectName = defaultProjectName.replace('.', '_');
- }
- }
- if (!getBooleanProperty(OVERWRITE_PROJECT)) {
- String baseName = defaultProjectName;
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- for (int i = 1; i < 10 && root.getProject(defaultProjectName).exists(); i++) {
- defaultProjectName = baseName + Integer.toString(i);
- }
- }
- j2eeArtifactCreationDataModel.setProperty(J2EEArtifactCreationDataModelOld.PROJECT_NAME, defaultProjectName);
- notifyDefaultChange(PROJECT_NAME);
- setBooleanProperty(DEFAULT_PROJECT_NAME, true);
- }
- }
-
- private boolean handleArchiveSetup(String fileName) throws OpenFailureException {
- boolean archiveStatus = true;
- if (archiveFile != null) {
- archiveFile.close();
- archiveFile = null;
- }
- String uri = getStringProperty(FILE_NAME);
- if (!archiveExistsOnFile())
- return false;
- archiveStatus = openArchive(uri);
- archiveFile.setSaveFilter(getSaveFilter());
- return archiveStatus;
- }
-
- protected abstract boolean openArchive(String uri) throws OpenFailureException;
-
- private boolean closeModuleFile() {
- if (null != archiveFile) {
- archiveFile.close();
- archiveFile = null;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doValidateProperty(java.lang.String)
- */
- protected IStatus doValidateProperty(String propertyName) {
- if (NESTED_MODEL_VALIDATION_HOOK.equals(propertyName)) {
- return OK_STATUS;
- }
- if (PROJECT_NAME.equals(propertyName)) {
- ProjectCreationDataModel projectDataModel = j2eeArtifactCreationDataModel.getProjectDataModel();
- IStatus status = ProjectCreationDataModel.validateProjectName(projectDataModel.getStringProperty(ProjectCreationDataModel.PROJECT_NAME));
- if (!status.isOK()) {
- return status;
- }
- IProject project = projectDataModel.getProject();
- if (null != project && !project.exists() || !getBooleanProperty(OVERWRITE_PROJECT)) {
- status = projectDataModel.validateDataModel();
- if (!status.isOK()) {
- status = WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("EARImportDataModel_UI_3", new Object[]{project.getName()}));//$NON-NLS-1$
- }
- return status;
- }
- if (!getBooleanProperty(DELETE_BEFORE_OVERWRITE_PROJECT)) {
- //now we have an existing project we are going to overwrite
- String[] natures = (String[]) projectDataModel.getProperty(ProjectCreationDataModel.PROJECT_NATURES);
- for (int i = 0; null != natures && i < natures.length; i++) {
- try {
- if (!project.hasNature(natures[i])) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("importWrongType", new Object[]{project.getName()}));//$NON-NLS-1$
- }
- } catch (CoreException e) {
- }
- }
- J2EENature nature = J2EENature.getRegisteredRuntime(project);
- if (null != nature && nature.getJ2EEVersion() < getJ2EEVersion()) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("importWrongVersion", new Object[]{project.getName()}));//$NON-NLS-1$
- }
- } else {
- String name = getStringProperty(PROJECT_NAME);
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- return workspace.validateName(name, IResource.PROJECT);
- }
- return OK_STATUS;
- }
- if (FILE_NAME.equals(propertyName)) {
- String fileName = (String) getProperty(FILE_NAME);
- if (fileName != null && fileName.equals("")) { //$NON-NLS-1$
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.ARCHIVE_FILE_NAME_EMPTY_ERROR, new Object[]{ArchiveUtil.getModuleFileTypeName(getType())})); //$NON-NLS-1$);
- } else if (cachedOpenFailureException != null) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(cachedOpenFailureException.getMessage())); //$NON-NLS-1$);
- } else if (fileName != null && !archiveExistsOnFile()) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.FILE_DOES_NOT_EXIST_ERROR, new Object[]{ArchiveUtil.getModuleFileTypeName(getType())}));
- }
- }
- return super.doValidateProperty(propertyName);
- }
-
- protected int getJ2EEVersion() {
- return 0;
- }
-
- protected abstract J2EEArtifactCreationDataModelOld createJ2EEProjectCreationDataModel();
-
- /*
- * @see XMLResource#APP_CLIENT_TYPE
- * @see XMLResource#APPLICATION_TYPE
- * @see XMLResource#EJB_TYPE
- * @see XMLResource#WEB_APP_TYPE
- * @see XMLResource#RAR_TYPE
- */
- protected abstract int getType();
-
- public final J2EEArtifactCreationDataModelOld getJ2eeArtifactCreationDataModel() {
- return j2eeArtifactCreationDataModel;
- }
-
- private boolean archiveExistsOnFile() {
- String jarName = (String) getProperty(FILE_NAME);
- if (jarName != null && jarName.length() > 0) {
- java.io.File file = new java.io.File(jarName);
- return file.exists() && !file.isDirectory();
- }
- return false;
- }
-
- public void dispose() {
- if (getBooleanProperty(CLOSE_ARCHIVE_ON_DISPOSE))
- closeModuleFile();
- super.dispose();
- }
-
- protected final void setArchiveFile(Archive archiveFile) {
- this.archiveFile = archiveFile;
- }
-
- public final Archive getArchiveFile() {
- return archiveFile;
- }
-
- public final ModuleFile getModuleFile() {
- return (ModuleFile) archiveFile;
- }
-
- public IProject getProject() {
- return j2eeArtifactCreationDataModel.getTargetProject();
- }
-
- protected final ArchiveOptions getArchiveOptions() {
- ArchiveOptions opts = new ArchiveOptions();
- opts.setIsReadOnly(true);
- return opts;
- }
-
- private SaveFilter getSaveFilter() {
- return (SaveFilter) getProperty(SAVE_FILTER);
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- if (event.getDataModel().equals(j2eeArtifactCreationDataModel) && event.getPropertyName().equals(J2EEArtifactCreationDataModelOld.PROJECT_NAME)) {
- setProperty(PROJECT_NAME, j2eeArtifactCreationDataModel.getStringProperty(J2EEArtifactCreationDataModelOld.PROJECT_NAME));
- setBooleanProperty(DEFAULT_PROJECT_NAME, false);
- }
- super.propertyChanged(event);
- }
-
- public void extractHandled(List newList, boolean addModels) {
- }
-
- protected WTPPropertyDescriptor[] doGetValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(PROJECT_NAME)) {
- int j2eeVersion = getJ2EEVersion();
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList projectList = new ArrayList();
- String[] natureIds = (String[]) j2eeArtifactCreationDataModel.getProjectDataModel().getProperty(ProjectCreationDataModel.PROJECT_NATURES);
- String j2eeNatureID = null;
- for (int j = 0; null == j2eeNatureID && j < natureIds.length; j++) {
- if (IEARNatureConstants.NATURE_ID.equals(natureIds[j]) || IEJBNatureConstants.NATURE_ID.equals(natureIds[j]) || IWebNatureConstants.J2EE_NATURE_ID.equals(natureIds[j]) || IConnectorNatureConstants.NATURE_ID.equals(natureIds[j]) || IApplicationClientNatureConstants.NATURE_ID.equals(natureIds[j])) {
- j2eeNatureID = natureIds[j];
- }
- }
- J2EENature j2eeNature = null;
- for (int i = 0; i < projects.length && j2eeNatureID != null; i++) {
- try {
- j2eeNature = (J2EENature) projects[i].getNature(j2eeNatureID);
- if (j2eeNature != null) {
- if (j2eeVersion <= j2eeNature.getJ2EEVersion()) {
- projectList.add(projects[i].getName());
- }
- }
- } catch (CoreException e) {
- }
- }
- String[] projectNames = new String[projectList.size()];
- for (int i = 0; i < projectNames.length; i++) {
- projectNames[i] = (String) projectList.get(i);
- }
- return WTPPropertyDescriptor.createDescriptors(projectNames);
- } else if (propertyName.equals(FILE_NAME)) {
- String[] sourceNames = (String[]) getProperty(FILE_SELECTION_HISTORY);
- return WTPPropertyDescriptor.createDescriptors(sourceNames);
- }
- return super.doGetValidPropertyDescriptors(propertyName);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationDataModel.java
deleted file mode 100644
index f1b3fd981..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationDataModel.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jst.j2ee.internal.earcreation.EARComponentCreationDataModel;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEdit;
-import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
-import org.eclipse.wst.common.frameworks.operations.WTPPropertyDescriptor;
-import org.eclipse.wst.common.modulecore.ModuleCore;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.impl.WTPEntityResolver;
-import org.eclipse.wst.common.modulecore.internal.operation.ArtifactEditOperationDataModel;
-import org.eclipse.wst.common.modulecore.internal.operation.ComponentCreationDataModel;
-import org.eclipse.wst.common.modulecore.internal.util.IModuleConstants;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-/**
- * This dataModel is a common super class used for to create Flexibile J2EE Components.
- *
- * 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 abstract class J2EEComponentCreationDataModel extends ComponentCreationDataModel implements IAnnotationsDataModel {
-
- /**
- * type Boolean, default false
- */
- public static final String ADD_TO_EAR = "J2EEComponentCreationDataModel.ADD_TO_EAR"; //$NON-NLS-1$
-
- /**
- * type String
- */
- public static final String EAR_MODULE_NAME = "J2EEComponentCreationDataModel.EAR_MODULE_NAME"; //$NON-NLS-1$
-
- /**
- * type boolean
- */
- private static final String NESTED_MODEL_ADD_TO_EAR = "J2EEComponentCreationDataModel.NESTED_MODEL_ADD_TO_EAR"; //$NON-NLS-1$
-
- private static final String NESTED_MODEL_EAR_CREATION = "J2EEComponentCreationDataModel.NESTED_MODEL_EAR_CREATION"; //$NON-NLS-1$
-
- /**
- * type boolean
- */
- private static final String NESTED_MODEL_JAR_DEPENDENCY = "J2EEComponentCreationDataModel.NESTED_MODEL_JAR_DEPENDENCY"; //$NON-NLS-1$
-
- /**
- * type Boolean; default true, UI only
- */
- public static final String UI_SHOW_EAR_SECTION = "J2EEComponentCreationDataModel.UI_SHOW_EAR_SECTION"; //$NON-NLS-1$
-
- /**
- * type String
- */
- public static final String DD_FOLDER = "J2EEComponentCreationDataModel.DD_FOLDER"; //$NON-NLS-1$
-
-
- /**
- * type String
- */
- public static final String JAVASOURCE_FOLDER = "J2EEComponentCreationDataModel.JAVASOURCE_FOLDER"; //$NON-NLS-1$
-
- /**
- * This corresponds to the J2EE versions of 1.2, 1.3, 1.4, etc. Each subclass will convert this
- * version to its corresponding highest module version supported by the J2EE version and set the
- * J2EE_MODULE_VERSION property.
- *
- * type Integer
- */
- public static final String J2EE_VERSION = "J2EEComponentCreationDataModel.J2EE_VERSION"; //$NON-NLS-1$
-
- public AddComponentToEnterpriseApplicationDataModel addComponentToEARDataModel;
-
- protected EARComponentCreationDataModel earComponentCreationDataModel;
- /**
- * type String
- */
- public static final String MANIFEST_FOLDER = "J2EEComponentCreationDataModel.MANIFEST_FOLDER"; //$NON-NLS-1$
-
- private UpdateManifestDataModel jarDependencyDataModel;
-
- private ClassPathSelection cachedSelection;
-
- protected void init() {
- super.init();
- }
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(EAR_MODULE_NAME);
- addValidBaseProperty(ADD_TO_EAR);
- addValidBaseProperty(USE_ANNOTATIONS);
- addValidBaseProperty(UI_SHOW_EAR_SECTION);
- addValidBaseProperty(DD_FOLDER);
- addValidBaseProperty(JAVASOURCE_FOLDER);
- addValidBaseProperty(J2EE_VERSION);
- addValidBaseProperty(MANIFEST_FOLDER);
- addValidBaseProperty(NESTED_MODEL_VALIDATION_HOOK);
- }
-
- protected void initNestedModels() {
- super.initNestedModels();
- earComponentCreationDataModel = new EARComponentCreationDataModel();
- if(earComponentCreationDataModel != null)
- addNestedModel(NESTED_MODEL_EAR_CREATION, earComponentCreationDataModel);
- addComponentToEARDataModel = createModuleNestedModel();
- if (addComponentToEARDataModel != null)
- addNestedModel(NESTED_MODEL_ADD_TO_EAR, addComponentToEARDataModel);
- jarDependencyDataModel = new UpdateManifestDataModel();
- addNestedModel(NESTED_MODEL_JAR_DEPENDENCY, jarDependencyDataModel);
- }
-
- protected AddComponentToEnterpriseApplicationDataModel createModuleNestedModel() {
- return new AddComponentToEnterpriseApplicationDataModel();
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(ADD_TO_EAR)) {
- return Boolean.FALSE;
- } else if (propertyName.equals(USE_ANNOTATIONS)) {
- return Boolean.FALSE;
- } else if (propertyName.equals(UI_SHOW_EAR_SECTION)) {
- return Boolean.TRUE;
- } else if (propertyName.equals(EAR_MODULE_NAME)) {
- return getStringProperty(COMPONENT_NAME)+"EAR";
- } else {
- return super.getDefaultProperty(propertyName);
- }
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- boolean returnValue = super.doSetProperty(propertyName, propertyValue);
-
- if (propertyName.equals(EAR_MODULE_NAME)) {
- getAddModuleToApplicationDataModel().setProperty(ArtifactEditOperationDataModel.PROJECT_NAME, propertyValue);
- } else if(propertyName.equals(COMPONENT_NAME)){
- if (!isSet(EAR_MODULE_NAME))
- notifyDefaultChange(EAR_MODULE_NAME);
- } else if (propertyName.equals(PROJECT_NAME)) {
- WorkbenchComponent workbenchComp = getTargetWorkbenchComponent();
- setEARComponentIfJ2EEModuleCreationOnly(workbenchComp,propertyValue);
- } else if (propertyName.equals(ADD_TO_EAR)) {
- notifyEnablementChange(ADD_TO_EAR);
- } else if (propertyName.equals(J2EE_VERSION)) {
- Integer modVersion = convertJ2EEVersionToModuleVersion((Integer) propertyValue);
- setProperty(COMPONENT_VERSION, modVersion);
- return false;
- }
- return returnValue;
- }
-
- /**
- * @param workbenchComp
- */
- protected void setEARComponentIfJ2EEModuleCreationOnly(WorkbenchComponent workbenchComp, Object propertyValue) {
- getAddModuleToApplicationDataModel().setProperty(AddComponentToEnterpriseApplicationDataModel.ARCHIVE_MODULE, workbenchComp);
- getAddModuleToApplicationDataModel().setProperty(AddComponentToEnterpriseApplicationDataModel.PROJECT_NAME,getStringProperty(PROJECT_NAME));
- getAddModuleToApplicationDataModel().setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME,getStringProperty(EAR_MODULE_NAME));
- if (!isSet(EAR_MODULE_NAME)) {
- String earModuleName = getStringProperty(EAR_MODULE_NAME);
- notifyListeners(EAR_MODULE_NAME);
-
- }
- jarDependencyDataModel.setProperty(UpdateManifestDataModel.PROJECT_NAME, propertyValue);
- }
-
- protected Boolean basicIsEnabled(String propertyName) {
- Boolean enabled = super.basicIsEnabled(propertyName);
- if (enabled.booleanValue()) {
- if (propertyName.equals(EAR_MODULE_NAME)) {
- enabled = (Boolean) getProperty(ADD_TO_EAR);
- }
- }
- return enabled;
- }
-
- protected final AddComponentToEnterpriseApplicationDataModel getAddModuleToApplicationDataModel() {
- return addComponentToEARDataModel;
- }
-
- protected WTPPropertyDescriptor[] doGetValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(EAR_MODULE_NAME)) {
- int j2eeVersion = getJ2EEVersion();
- ModuleCore mc = null;
- try {
- IProject flexProject = getProject();
- if(flexProject != null) {
- mc = ModuleCore.getModuleCoreForRead(getProject());
- WorkbenchComponent[] components = mc.getWorkbenchModules();
- ArrayList earModuleList = new ArrayList();
- int earVersion = 0;
- for (int i = 0; i < components.length; i++) {
- EARArtifactEdit earArtifactEdit = null;
- try {
- WorkbenchComponent wc = (WorkbenchComponent)components[i];
- if(wc.getComponentType().getModuleTypeId().equals(IModuleConstants.JST_EAR_MODULE)) {
- earArtifactEdit = EARArtifactEdit.getEARArtifactEditForRead(wc);
- if(j2eeVersion <= earArtifactEdit.getJ2EEVersion())
- earModuleList.add(wc.getName());
- }
- } finally {
- if(earArtifactEdit != null)
- earArtifactEdit.dispose();
- }
-
- }
- WTPPropertyDescriptor[] descriptors = new WTPPropertyDescriptor[earModuleList.size()];
- for (int i = 0; i < descriptors.length; i++) {
- descriptors[i] = new WTPPropertyDescriptor(earModuleList.get(i));
- }
- return descriptors;
- }
- } finally {
- if(mc != null)
- mc.dispose();
- }
- }
- return super.doGetValidPropertyDescriptors(propertyName);
- }
-
- public IProject getProject() {
- String projName = getStringProperty(J2EEComponentCreationDataModel.PROJECT_NAME );
- if(projName != null && projName.length() > 0)
- return ProjectUtilities.getProject( projName );
- return null;
- }
-
- public WorkbenchComponent getTargetWorkbenchComponent() {
- ModuleCore core = null;
- try {
- IProject flexProject = getProject();
- if(flexProject != null) {
- core = ModuleCore.getModuleCoreForRead(getProject());
- if(core != null) {
- WorkbenchComponent component = core.findWorkbenchModuleByDeployName(COMPONENT_NAME);
- return component;
- }
- }
- } finally {
- if(core != null)
- core.dispose();
- }
- return null;
- }
-
- protected IStatus doValidateProperty(String propertyName) {
- if (EAR_MODULE_NAME.equals(propertyName) && getBooleanProperty(ADD_TO_EAR)) {
- return validateEARModuleNameProperty();
- } else if (NESTED_MODEL_VALIDATION_HOOK.equals(propertyName))
- return OK_STATUS;
-
- return super.doValidateProperty(propertyName);
- }
-
- public EARComponentCreationDataModel getEarComponentCreationDataModel() {
- return earComponentCreationDataModel;
- }
-
- private IStatus validateEARModuleNameProperty() {
-// IProject earProject = applicationCreationDataModel.getTargetProject();
-// if (null != earProject && earProject.exists()) {
-// if (earProject.isOpen()) {
-// try {
-// EARNatureRuntime earNature = (EARNatureRuntime) earProject.getNature(IEARNatureConstants.NATURE_ID);
-// if (earNature == null) {
-// return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_NOT_EAR, new Object[]{earProject.getName()}));
-// } else if (earNature.getJ2EEVersion() < getJ2EEVersion()) {
-// String earVersion = EnterpriseApplicationCreationDataModel.getVersionString(earNature.getJ2EEVersion());
-// return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.INCOMPATABLE_J2EE_VERSIONS, new Object[]{earProject.getName(), earVersion}));
-// }
-// return OK_STATUS;
-// } catch (CoreException e) {
-// return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, -1, null, e);
-// }
-// }
-// return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_ClOSED, new Object[]{earProject.getName()}));
-// } else if (null != earProject && null != getTargetProject()) {
-// if (earProject.getName().equals(getTargetProject().getName())) {
-// return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.SAME_MODULE_AND_EAR_NAME, new Object[]{earProject.getName()}));
-// } else if (!CoreFileSystemLibrary.isCaseSensitive()) {
-// if (earProject.getName().toLowerCase().equals(getTargetProject().getName().toLowerCase())) {
-// return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.SAME_MODULE_AND_EAR_NAME, new Object[]{earProject.getName()}));
-// }
-// }
-// }
-// IStatus status = applicationCreationDataModel.validateProperty(EnterpriseApplicationCreationDataModel.PROJECT_NAME);
-// if (status.isOK()) {
-// status = applicationCreationDataModel.validateProperty(EnterpriseApplicationCreationDataModel.PROJECT_LOCATION);
-// }
-// return status;
-
- return WTPCommonPlugin.OK_STATUS;
- }
-
- /**
- * @return
- */
- public final UpdateManifestDataModel getUpdateManifestDataModel() {
- return jarDependencyDataModel;
- }
-
-
-
- public final ClassPathSelection getClassPathSelection() {
-// boolean createNew = false;
-// if (null == cachedSelection || !getApplicationCreationDataModel().getTargetProject().getName().equals(cachedSelection.getEARFile().getURI())) {
-// createNew = true;
-// }
-// // close an existing cachedSelection
-// if (createNew && cachedSelection != null) {
-// EARFile earFile = cachedSelection.getEARFile();
-// if (earFile != null)
-// earFile.close();
-// }
-//
-// if (createNew && getTargetProject() != null) {
-// cachedSelection = ClasspathSelectionHelper.createClasspathSelection(getTargetProject(), getModuleExtension(), getApplicationCreationDataModel().getTargetProject(), getModuleType());
-// }
- return cachedSelection;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#dispose()
- */
- public void dispose() {
- if (cachedSelection != null)
- cachedSelection.getEARFile().close();
- super.dispose();
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- super.propertyChanged(event);
- if (event.getDataModel() == addComponentToEARDataModel && event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG && event.getPropertyName().equals(ArtifactEditOperationDataModel.PROJECT_NAME)) {
- earComponentCreationDataModel.setProperty(EARComponentCreationDataModel.COMPONENT_NAME, event.getProperty());
- }
- }
-
- public String getModuleName() {
- return getStringProperty(COMPONENT_NAME);
- }
-
- public final int getJ2EEVersion() {
- return convertModuleVersionToJ2EEVersion(getIntProperty(COMPONENT_VERSION));
- }
-
- /**
- * Subclasses should override to convert the j2eeVersion to a module version id. By default we
- * return the j2eeVersion which is fine if no conversion is necessary.
- *
- * @param integer
- * @return
- */
- protected Integer convertJ2EEVersionToModuleVersion(Integer j2eeVersion) {
- return j2eeVersion;
- }
-
- protected abstract int convertModuleVersionToJ2EEVersion(int moduleVersion);
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationOperation.java
deleted file mode 100644
index 7ba0ac197..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEComponentCreationOperation.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*******************************************************************************
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IContainer;
-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.emf.common.util.EList;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.earcreation.EARComponentCreationDataModel;
-import org.eclipse.jst.j2ee.internal.project.ManifestFileCreationAction;
-import org.eclipse.wst.common.modulecore.ComponentType;
-import org.eclipse.wst.common.modulecore.ModuleCore;
-import org.eclipse.wst.common.modulecore.ModuleCoreFactory;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.operation.ComponentCreationOperation;
-import org.eclipse.wst.common.modulecore.resources.IVirtualContainer;
-
-public abstract class J2EEComponentCreationOperation extends ComponentCreationOperation {
- /**
- * 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 J2EEComponentCreationOperation(J2EEComponentCreationDataModel dataModel) {
- super(dataModel);
- }
-
- public J2EEComponentCreationOperation() {
- super();
- }
-
- protected void execute( String componentType, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- J2EEComponentCreationDataModel dataModel = (J2EEComponentCreationDataModel) operationDataModel;
-
- createAndLinkJ2EEComponents();
- setupComponentType(componentType);
-
- if (dataModel.getBooleanProperty(J2EEComponentCreationDataModel.CREATE_DEFAULT_FILES)) {
- createDeploymentDescriptor(monitor);
- createManifest(monitor);
- }
-
- addSrcFolderToProject();
- if (((J2EEComponentCreationDataModel) operationDataModel).getBooleanProperty(IAnnotationsDataModel.USE_ANNOTATIONS))
- addAnnotationsBuilder();
-
- linkToEARIfNecessary(dataModel, monitor);
- }
-
- protected abstract void createAndLinkJ2EEComponents() throws CoreException;
-
-
-
- protected abstract void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException;
-
- public void linkToEARIfNecessary(J2EEComponentCreationDataModel moduleModel, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- if (moduleModel.getBooleanProperty(J2EEComponentCreationDataModel.ADD_TO_EAR)) {
- createEARComponentIfNecessary(moduleModel, monitor);
- runAddToEAROperation(moduleModel, monitor);
- }
- }
-
- /**
- * @param moduleModel
- * @param monitor
- * @throws CoreException
- * @throws InvocationTargetException
- * @throws InterruptedException
- */
- protected void runAddToEAROperation(J2EEComponentCreationDataModel moduleModel, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- ModuleCore core = null;
- try {
- core = ModuleCore.getModuleCoreForWrite(getProject());
- WorkbenchComponent wc = core.findWorkbenchModuleByDeployName((String)moduleModel.getProperty(J2EEComponentCreationDataModel.COMPONENT_DEPLOY_NAME));
- AddComponentToEnterpriseApplicationDataModel dm = moduleModel.addComponentToEARDataModel;
- dm.setProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_NAME,wc.getName());
- dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME,moduleModel.getProperty(J2EEComponentCreationDataModel.EAR_MODULE_NAME));
- List modulesList = new ArrayList();
- modulesList.add(wc);
- dm.setProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST,modulesList);
- AddComponentToEnterpriseApplicationOperation addModuleOp = new AddComponentToEnterpriseApplicationOperation(moduleModel.addComponentToEARDataModel);
- addModuleOp.doRun(monitor);
- } finally {
- if(core != null)
- core.dispose();
- }
- }
-
- /**
- * @param moduleModel
- * @param monitor
- * @throws CoreException
- * @throws InvocationTargetException
- * @throws InterruptedException
- */
- protected void createEARComponentIfNecessary(J2EEComponentCreationDataModel moduleModel, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- EARComponentCreationDataModel earModel = moduleModel.getEarComponentCreationDataModel();
- earModel.setProperty(EARComponentCreationDataModel.COMPONENT_NAME, moduleModel.getStringProperty(J2EEComponentCreationDataModel.EAR_MODULE_NAME));
- earModel.setProperty(EARComponentCreationDataModel.PROJECT_NAME, moduleModel.getStringProperty(J2EEComponentCreationDataModel.PROJECT_NAME));
- if (!doesEARComponentExist(moduleModel.getStringProperty(J2EEComponentCreationDataModel.EAR_MODULE_NAME))) {
- EARComponentCreationOperation earOp = new EARComponentCreationOperation(earModel);
- earOp.doRun(monitor);
- }
- }
-
- public boolean doesEARComponentExist(String earComponentName) {
- ModuleCore moduleCore = null;
- try{
- moduleCore = ModuleCore.getModuleCoreForRead(getProject());
- return (moduleCore.findWorkbenchModuleByDeployName(earComponentName) != null);
- } finally {
- if(moduleCore != null)
- moduleCore.dispose();
- }
- }
-
- public IProject getProject() {
- String projName = operationDataModel.getStringProperty(J2EEComponentCreationDataModel.PROJECT_NAME );
- return ProjectUtilities.getProject( projName );
- }
-
- public String getModuleName() {
- return (String)operationDataModel.getProperty(J2EEComponentCreationDataModel.COMPONENT_NAME);
- }
-
- public String getModuleDeployName() {
- return (String)operationDataModel.getProperty(J2EEComponentCreationDataModel.COMPONENT_DEPLOY_NAME);
- }
-
- protected abstract String getVersion();
-
- protected void setupComponentType(String typeID) {
- IVirtualContainer component = ModuleCore.create(getProject(), getModuleDeployName());
- ComponentType componentType = ModuleCoreFactory.eINSTANCE.createComponentType();
- componentType.setModuleTypeId(typeID);
- componentType.setVersion(getVersion());
- List newProps = getProperties();
- if (newProps != null && !newProps.isEmpty()) {
- EList existingProps = componentType.getProperties();
- for (int i = 0; i < newProps.size(); i++) {
- existingProps.add(newProps.get(i));
- }
- }
- ModuleCore.setComponentType(component, componentType);
- }
-
- // Should return null if no additional properties needed
- protected List getProperties() {
- return null;
- }
-
- /**
- * @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(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
-
- String manifestFolder = operationDataModel.getStringProperty(J2EEComponentCreationDataModel.MANIFEST_FOLDER);
- IContainer container = getProject().getFolder( manifestFolder );
-
- IFile file = container.getFile( new Path(J2EEConstants.MANIFEST_SHORT_NAME));
-
- try {
- ManifestFileCreationAction.createManifestFile(file, getProject());
- }
- catch (CoreException e) {
- Logger.getLogger().log(e);
- }
- catch (IOException e) {
- Logger.getLogger().log(e);
- }
-// 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 = ((J2EEComponentCreationDataModel)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
- }
- }
-
- /**
- * @return
- */
- public String getJavaSourceSourceFolder() {
- return getOperationDataModel().getStringProperty(J2EEComponentCreationDataModel.JAVASOURCE_FOLDER);
- }
-
- /**
- * @return
- */
- public String getDeploymentDescriptorFolder() {
- return getOperationDataModel().getStringProperty(J2EEComponentCreationDataModel.DD_FOLDER);
- }
-
- public String getJavaSourceSourcePath() {
- return getOperationDataModel().getStringProperty(J2EEComponentCreationDataModel.JAVASOURCE_FOLDER);
- }
-
-
- private IClasspathEntry[] getClasspathEntries() {
- IClasspathEntry[] sourceEntries = null;
- sourceEntries = getSourceClasspathEntries();
- return sourceEntries;
- }
-
- private IClasspathEntry[] getSourceClasspathEntries() {
- String sourceFolder = getJavaSourceSourcePath();
- ArrayList list = new ArrayList();
- list.add(JavaCore.newSourceEntry(getProject().getFullPath().append(sourceFolder)));
-
- IClasspathEntry[] classpath = new IClasspathEntry[list.size()];
- for (int i = 0; i < classpath.length; i++) {
- classpath[i] = (IClasspathEntry) list.get(i);
- }
- return classpath;
- }
-
- private void addSrcFolderToProject() {
- IJavaProject javaProject = JavaCore.create( this.getProject());
- try {
-
- IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
- IClasspathEntry[] newEntries = getClasspathEntries();
-
- int oldSize = oldEntries.length;
- int newSize = newEntries.length;
-
- IClasspathEntry[] classpathEnties = new IClasspathEntry[oldSize + newSize];
- int k = 0;
- for (int i = 0; i < oldEntries.length; i++) {
- classpathEnties[i] = oldEntries[i];
- k++;
- }
- for( int j=0; j< newEntries.length; j++){
- classpathEnties[k] = newEntries[j];
- k++;
- }
- javaProject.setRawClasspath(classpathEnties, null);
- }
- catch (JavaModelException e) {
- Logger.getLogger().logError(e);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationDataModelOld.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationDataModelOld.java
deleted file mode 100644
index ff144913c..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationDataModelOld.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/***************************************************************************************************
- * 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.util.ArrayList;
-
-import org.eclipse.core.internal.localstore.CoreFileSystemLibrary;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModel;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
-import org.eclipse.wst.common.frameworks.operations.WTPPropertyDescriptor;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonMessages;
-import org.eclispe.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-/**
- * This dataModel is a common super class used for to create J2EE 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 abstract class J2EEModuleCreationDataModelOld extends J2EEArtifactCreationDataModelOld implements IAnnotationsDataModel {
-
- /**
- * type Integer
- */
- public static final String J2EE_MODULE_VERSION = "J2EEModuleCreationDataModel.J2EE_MODULE_VERSION"; //$NON-NLS-1$
-
- /**
- * This corresponds to the J2EE versions of 1.2, 1.3, 1.4, etc. Each subclass will convert this
- * version to its corresponding highest module version supported by the J2EE version and set the
- * J2EE_MODULE_VERSION property.
- *
- * type Integer
- */
- public static final String J2EE_VERSION = "J2EEModuleCreationDataModel.J2EE_VERSION"; //$NON-NLS-1$
-
- /**
- * type Boolean, default false
- */
- public static final String ADD_TO_EAR = "J2EEModuleCreationDataModel.ADD_TO_EAR"; //$NON-NLS-1$
-
- /**
- * type String
- */
- public static final String EAR_PROJECT_NAME = "J2EEModuleCreationDataModel.EAR_PROJECT_NAME"; //$NON-NLS-1$
-
- /**
- * type boolean
- */
- public static final String IS_FLEXIBLE_PROJECT = "J2EEModuleCreationDataModel.IS_FLEXIBLE_PROJECT"; //$NON-NLS-1$
-
- public static final String JAR_LIST = UpdateManifestDataModel.JAR_LIST;
-
- public static String JAR_LIST_TEXT_UI = UpdateManifestDataModel.JAR_LIST_TEXT_UI;
-
- private static final String NESTED_MODEL_APPLICATION_CREATION = "J2EEModuleCreationDataModel.NESTED_MODEL_APPLICATION_CREATION"; //$NON-NLS-1$
-
- private static final String NESTED_MODEL_ADD_TO_EAR = "J2EEModuleCreationDataModel.NESTED_MODEL_ADD_TO_EAR"; //$NON-NLS-1$
-
- private static final String NESTED_MODEL_JAR_DEPENDENCY = "J2EEModuleCreationDataModel.NESTED_MODEL_JAR_DEPENDENCY"; //$NON-NLS-1$
-
- /**
- * type Boolean; default true, UI only
- */
- public static final String UI_SHOW_EAR_SECTION = "J2EEModuleCreationDataModel.UI_SHOW_EAR_SECTION"; //$NON-NLS-1$
-
- private EnterpriseApplicationCreationDataModel applicationCreationDataModel;
-
- private AddModuleToEARDataModel addModuleToEARDataModel;
-
- private UpdateManifestDataModel jarDependencyDataModel;
-
- private String J2EENatureID;
-
- protected void init() {
- super.init();
- //getJavaProjectCreationDataModel().setProperty(ProjectCreationDataModel.PROJECT_NATURES,
- // new String[]{J2EENatureID});
- //set it so it pushes it down to ServerTargeting
- setProperty(J2EE_MODULE_VERSION, getDefaultProperty(J2EE_MODULE_VERSION));
- applicationCreationDataModel.addListener(this);
- }
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(J2EE_MODULE_VERSION);
- addValidBaseProperty(J2EE_VERSION);
- addValidBaseProperty(EAR_PROJECT_NAME);
- addValidBaseProperty(ADD_TO_EAR);
- addValidBaseProperty(UI_SHOW_EAR_SECTION);
- addValidBaseProperty(USE_ANNOTATIONS);
- addValidBaseProperty(PROJECT_LOCATION);
- addValidBaseProperty(IS_FLEXIBLE_PROJECT);
- }
-
- protected void initNestedModels() {
- super.initNestedModels();
- applicationCreationDataModel = new EnterpriseApplicationCreationDataModel();
- addNestedModel(NESTED_MODEL_APPLICATION_CREATION, applicationCreationDataModel);
- addModuleToEARDataModel = createModuleNestedModel();
- if (addModuleToEARDataModel != null)
- addNestedModel(NESTED_MODEL_ADD_TO_EAR, addModuleToEARDataModel);
- jarDependencyDataModel = new UpdateManifestDataModel();
- addNestedModel(NESTED_MODEL_JAR_DEPENDENCY, jarDependencyDataModel);
- }
-
- protected AddModuleToEARDataModel createModuleNestedModel() {
- return new AddModuleToEARDataModel();
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(ADD_TO_EAR)) {
- return Boolean.FALSE;
- } else if (propertyName.equals(EAR_PROJECT_NAME)) {
- return getDefaultEARName(getStringProperty(PROJECT_NAME));
- } else if (propertyName.equals(UI_SHOW_EAR_SECTION)) {
- return Boolean.TRUE;
- } else if (propertyName.equals(USE_ANNOTATIONS)) {
- return Boolean.FALSE;
- } else if (propertyName.equals(J2EE_MODULE_VERSION)) {
- return getDefaultJ2EEModuleVersion();
- } else if (propertyName.equals(IS_FLEXIBLE_PROJECT)) {
- return Boolean.FALSE;
- } else {
- return super.getDefaultProperty(propertyName);
- }
- }
-
- protected abstract Integer getDefaultJ2EEModuleVersion();
-
- private String getDefaultEARName(String baseName) {
- return baseName + "EAR"; //TODO //$NON-NLS-1$
- }
-
- public final void notifyUpdatedEARs() {
- notifyListeners(EAR_PROJECT_NAME, WTPOperationDataModelEvent.VALID_VALUES_CHG);
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- if (propertyName.equals(PROJECT_NAME)) {
- if (!isSet(EAR_PROJECT_NAME)) {
- boolean disableNotification = isNotificationEnabled();
- try {
- if (disableNotification) {
- setNotificationEnabled(false);
- }
- String earProjectName = getDefaultEARName((String) propertyValue);
- applicationCreationDataModel.setProperty(EnterpriseApplicationCreationDataModel.PROJECT_NAME, earProjectName);
- getAddModuleToApplicationDataModel().setProperty(AddModuleToEARDataModel.PROJECT_NAME, earProjectName);
- } finally {
- if (disableNotification) {
- setNotificationEnabled(true);
- }
- }
- }
- }
- boolean returnValue = super.doSetProperty(propertyName, propertyValue);
- if (propertyName.equals(J2EE_MODULE_VERSION)) {
- int j2eeVersion = getJ2EEVersion();
- boolean shouldModifyServerTarget = true;
- if (getBooleanProperty(J2EEModuleCreationDataModelOld.ADD_TO_EAR)) {
- String earProjectName = getStringProperty(J2EEModuleCreationDataModelOld.EAR_PROJECT_NAME);
- IProject earProject = ProjectCreationDataModel.getProjectHandleFromProjectName(earProjectName);
- if (null != earProject && earProject.exists()) {
- shouldModifyServerTarget = false;
- }
- }
- if (shouldModifyServerTarget) {
- getServerTargetDataModel().setIntProperty(ServerTargetDataModel.J2EE_VERSION_ID, j2eeVersion);
- applicationCreationDataModel.setIntProperty(EnterpriseApplicationCreationDataModel.APPLICATION_VERSION, j2eeVersion);
- }
- notifyUpdatedEARs();
- return true;
- }
- if (propertyName.equals(J2EE_VERSION)) {
- Integer modVersion = convertJ2EEVersionToModuleVersion((Integer) propertyValue);
- setProperty(J2EE_MODULE_VERSION, modVersion);
- return false;
- }
- if (propertyName.equals(EAR_PROJECT_NAME)) {
- if (checkForNewEARProjectName((String) propertyValue))
- applicationCreationDataModel.enableValidation();
- else
- applicationCreationDataModel.disableValidation();
- applicationCreationDataModel.setProperty(EnterpriseApplicationCreationDataModel.PROJECT_NAME, propertyValue);
- getAddModuleToApplicationDataModel().setProperty(AddModuleToEARDataModel.PROJECT_NAME, propertyValue);
- } else if (PROJECT_LOCATION.equals(propertyName)) {
- getProjectDataModel().setProperty(ProjectCreationDataModel.PROJECT_LOCATION, propertyValue);
- }
-
-
- if (propertyName.equals(PROJECT_NAME)) {
- IProject project = getTargetProject();
- //getAddModuleToApplicationDataModel().setProperty(AddModuleToEARDataModel.ARCHIVE_PROJECT, project);
- if (!isSet(EAR_PROJECT_NAME)) {
- notifyListeners(EAR_PROJECT_NAME);
- synchUPServerTargetWithEAR();
- }
- jarDependencyDataModel.setProperty(UpdateManifestDataModel.PROJECT_NAME, propertyValue);
- }
-
- if (ADD_TO_EAR.equals(propertyName) || EAR_PROJECT_NAME.equals(propertyName)) {
- synchUPServerTargetWithEAR();
- }
-
- if (IS_ENABLED.equals(propertyName) || ADD_TO_EAR.equals(propertyName)) {
- notifyEnablementChange(ADD_TO_EAR);
- }
- if (IS_FLEXIBLE_PROJECT.equals(propertyName)) {
- if (((Boolean) propertyValue).booleanValue())
- setProperty(ADD_TO_EAR, Boolean.FALSE);
- else
- setProperty(ADD_TO_EAR, Boolean.TRUE);
- notifyEnablementChange(ADD_TO_EAR);
- }
- return returnValue;
- }
-
- private boolean checkForNewEARProjectName(String projectName) {
- IProject project = ProjectCreationDataModel.getProjectHandleFromProjectName(projectName);
- if (project != null && project.exists())
- return false;
- return true;
- }
-
- private void synchUPServerTargetWithEAR() {
- if (getBooleanProperty(J2EEModuleCreationDataModelOld.ADD_TO_EAR)) {
- String earProjectName = getStringProperty(J2EEModuleCreationDataModelOld.EAR_PROJECT_NAME);
- IProject earProject = ProjectCreationDataModel.getProjectHandleFromProjectName(earProjectName);
- if (null != earProject && earProject.exists() && earProject.isAccessible()) {
- EARNatureRuntime earNature = EARNatureRuntime.getRuntime(earProject);
- if (earNature != null) {
- int j2eeVersion = earNature.getJ2EEVersion();
- getServerTargetDataModel().setIntProperty(ServerTargetDataModel.J2EE_VERSION_ID, j2eeVersion);
- applicationCreationDataModel.setIntProperty(EnterpriseApplicationCreationDataModel.APPLICATION_VERSION, j2eeVersion);
- IRuntime target = ServerCore.getProjectProperties(earProject).getRuntimeTarget();
- if (null != target) {
- setProperty(SERVER_TARGET_ID, target.getId());
- }
- }
- notifyUpdatedEARs();
-
- } else {
- int j2eeVersion = getJ2EEVersion();
- getServerTargetDataModel().setIntProperty(ServerTargetDataModel.J2EE_VERSION_ID, j2eeVersion);
- applicationCreationDataModel.setIntProperty(EnterpriseApplicationCreationDataModel.APPLICATION_VERSION, j2eeVersion);
- notifyUpdatedEARs();
- }
- } else {
- int j2eeVersion = getJ2EEVersion();
- getServerTargetDataModel().setIntProperty(ServerTargetDataModel.J2EE_VERSION_ID, j2eeVersion);
- applicationCreationDataModel.setIntProperty(EnterpriseApplicationCreationDataModel.APPLICATION_VERSION, j2eeVersion);
- notifyUpdatedEARs();
- }
- notifyEnablementChange(SERVER_TARGET_ID);
- }
-
- protected Boolean basicIsEnabled(String propertyName) {
- Boolean enabled = super.basicIsEnabled(propertyName);
- if (enabled.booleanValue()) {
- if (propertyName.equals(EAR_PROJECT_NAME)) {
- enabled = (Boolean) getProperty(ADD_TO_EAR);
- } else if (propertyName.equals(SERVER_TARGET_ID)) {
- if (!getBooleanProperty(J2EEModuleCreationDataModelOld.ADD_TO_EAR)) {
- return Boolean.TRUE;
- }
- String earProjectName = getStringProperty(J2EEModuleCreationDataModelOld.EAR_PROJECT_NAME);
- IProject earProject = ProjectCreationDataModel.getProjectHandleFromProjectName(earProjectName);
- enabled = new Boolean(null == earProject || !earProject.exists());
- } else if (propertyName.equals(ADD_TO_EAR)) {
- if (getBooleanProperty(IS_FLEXIBLE_PROJECT))
- return Boolean.FALSE;
- else
- return Boolean.TRUE;
- }
- }
- return enabled;
- }
-
- /**
- * Subclasses should override to convert the j2eeVersion to a module version id. By default we
- * return the j2eeVersion which is fine if no conversion is necessary.
- *
- * @param integer
- * @return
- */
- protected Integer convertJ2EEVersionToModuleVersion(Integer j2eeVersion) {
- return j2eeVersion;
- }
-
- /**
- * @return
- */
- public final EnterpriseApplicationCreationDataModel getApplicationCreationDataModel() {
- return applicationCreationDataModel;
- }
-
- protected final AddModuleToEARDataModel getAddModuleToApplicationDataModel() {
- return addModuleToEARDataModel;
- }
-
- public final JavaProjectCreationDataModel getJavaProjectCreationDataModel() {
- return (JavaProjectCreationDataModel) getProjectDataModel();
- }
-
- protected void initProjectModel() {
- setProjectDataModel(new JavaProjectCreationDataModel());
- }
-
-
- protected final void setJ2EENatureID(String J2EENatureID) {
- this.J2EENatureID = J2EENatureID;
- }
-
- public final String getJ2EENatureID() {
- return J2EENatureID;
- }
-
- protected WTPPropertyDescriptor[] doGetValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(J2EE_MODULE_VERSION)) {
- return getValidJ2EEModuleVersionDescriptors();
- } else if (propertyName.equals(EAR_PROJECT_NAME)) {
- int j2eeVersion = getJ2EEVersion();
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList projectList = new ArrayList();
- int earVersion = 0;
- EARNatureRuntime earNature = null;
- for (int i = 0; i < projects.length; i++) {
- try {
- earNature = (EARNatureRuntime) projects[i].getNature(IEARNatureConstants.NATURE_ID);
- if (earNature != null) {
- earVersion = earNature.getJ2EEVersion();
- if (j2eeVersion <= earVersion) {
- projectList.add(projects[i].getName());
- }
- }
- } catch (CoreException e) {
- }
- }
- WTPPropertyDescriptor[] descriptors = new WTPPropertyDescriptor[projectList.size()];
- for (int i = 0; i < descriptors.length; i++) {
- descriptors[i] = new WTPPropertyDescriptor(projectList.get(i));
- }
- return descriptors;
- }
- return super.doGetValidPropertyDescriptors(propertyName);
- }
-
- public final int getJ2EEVersion() {
- return convertModuleVersionToJ2EEVersion(getIntProperty(J2EE_MODULE_VERSION));
- }
-
- protected IStatus doValidateProperty(String propertyName) {
- if (EAR_PROJECT_NAME.equals(propertyName) && getBooleanProperty(ADD_TO_EAR)) {
- return validateEARProjectNameProperty();
- } else if (J2EE_MODULE_VERSION.equals(propertyName)) {
- return validateJ2EEModuleVersionProperty();
- } else if (NESTED_MODEL_VALIDATION_HOOK.equals(propertyName)) {
- IStatus status = getServerTargetDataModel().validateProperty(ServerTargetDataModel.RUNTIME_TARGET_ID);
- if (!status.isOK()) {
- return status;
- }
- if (getBooleanProperty(ADD_TO_EAR)) {
- status = applicationCreationDataModel.validateProperty(ServerTargetDataModel.RUNTIME_TARGET_ID);
- if (!status.isOK() || getServerTargetDataModel().getRuntimeTarget() != applicationCreationDataModel.getServerTargetDataModel().getRuntimeTarget()) {
- return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString(EARCreationResourceHandler.SERVER_TARGET_NOT_SUPPORT_EAR));
- }
- }
- }
-
- return super.doValidateProperty(propertyName);
- }
-
- private IStatus validateJ2EEModuleVersionProperty() {
- int j2eeVersion = getIntProperty(J2EE_MODULE_VERSION);
- if (j2eeVersion == -1)
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.SPEC_LEVEL_NOT_FOUND));
- return OK_STATUS;
- }
-
- private IStatus validateEARProjectNameProperty() {
- IProject earProject = applicationCreationDataModel.getTargetProject();
- if (null != earProject && earProject.exists()) {
- if (earProject.isOpen()) {
- try {
- EARNatureRuntime earNature = (EARNatureRuntime) earProject.getNature(IEARNatureConstants.NATURE_ID);
- if (earNature == null) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_NOT_EAR, new Object[]{earProject.getName()}));
- } else if (earNature.getJ2EEVersion() < getJ2EEVersion()) {
- String earVersion = EnterpriseApplicationCreationDataModel.getVersionString(earNature.getJ2EEVersion());
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.INCOMPATABLE_J2EE_VERSIONS, new Object[]{earProject.getName(), earVersion}));
- }
- return OK_STATUS;
- } catch (CoreException e) {
- return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, -1, null, e);
- }
- }
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_ClOSED, new Object[]{earProject.getName()}));
- } else if (null != earProject && null != getTargetProject()) {
- if (earProject.getName().equals(getTargetProject().getName())) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.SAME_MODULE_AND_EAR_NAME, new Object[]{earProject.getName()}));
- } else if (!CoreFileSystemLibrary.isCaseSensitive()) {
- if (earProject.getName().toLowerCase().equals(getTargetProject().getName().toLowerCase())) {
- return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.SAME_MODULE_AND_EAR_NAME, new Object[]{earProject.getName()}));
- }
- }
- }
- IStatus status = applicationCreationDataModel.validateProperty(EnterpriseApplicationCreationDataModel.PROJECT_NAME);
- if (status.isOK()) {
- status = applicationCreationDataModel.validateProperty(EnterpriseApplicationCreationDataModel.PROJECT_LOCATION);
- }
- return status;
- }
-
- protected abstract WTPPropertyDescriptor[] getValidJ2EEModuleVersionDescriptors();
-
- protected abstract int convertModuleVersionToJ2EEVersion(int moduleVersion);
-
- protected abstract EClass getModuleType();
-
- protected abstract String getModuleExtension();
-
- /**
- * @return
- */
- public final UpdateManifestDataModel getUpdateManifestDataModel() {
- return jarDependencyDataModel;
- }
-
- private ClassPathSelection cachedSelection;
-
- public final ClassPathSelection getClassPathSelection() {
- boolean createNew = false;
- if (null == cachedSelection || !getApplicationCreationDataModel().getTargetProject().getName().equals(cachedSelection.getEARFile().getURI())) {
- createNew = true;
- }
- // close an existing cachedSelection
- if (createNew && cachedSelection != null) {
- EARFile earFile = cachedSelection.getEARFile();
- if (earFile != null)
- earFile.close();
- }
-
- if (createNew && getTargetProject() != null) {
- cachedSelection = ClasspathSelectionHelper.createClasspathSelection(getTargetProject(), getModuleExtension(), getApplicationCreationDataModel().getTargetProject(), getModuleType());
- }
- return cachedSelection;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#dispose()
- */
- public void dispose() {
- if (cachedSelection != null)
- cachedSelection.getEARFile().close();
- super.dispose();
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- super.propertyChanged(event);
- if (event.getDataModel() == getServerTargetDataModel() && event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG && event.getPropertyName().equals(ServerTargetDataModel.RUNTIME_TARGET_ID)) {
- applicationCreationDataModel.setProperty(event.getPropertyName(), event.getProperty());
- notifyListeners(NESTED_MODEL_VALIDATION_HOOK);
- } else if (event.getDataModel() == applicationCreationDataModel && event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG && event.getPropertyName().equals(EnterpriseApplicationCreationDataModel.PROJECT_NAME)) {
- synchUPServerTargetWithEAR();
- } else if (event.getDataModel() == addModuleToEARDataModel && event.getFlag() == WTPOperationDataModelEvent.PROPERTY_CHG && event.getPropertyName().equals(AddModuleToEARDataModel.PROJECT_NAME)) {
- applicationCreationDataModel.setProperty(EnterpriseApplicationCreationDataModel.PROJECT_NAME, event.getProperty());
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationOperationOld.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationOperationOld.java
deleted file mode 100644
index d8198d588..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleCreationOperationOld.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * 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 java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-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.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModel;
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationOperation;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EENature;
-import org.eclipse.jst.j2ee.internal.project.ManifestFileCreationAction;
-import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-
-public abstract class J2EEModuleCreationOperationOld extends J2EEArtifactCreationOperationOld {
- /**
- * 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 J2EEModuleCreationOperationOld(J2EEModuleCreationDataModelOld dataModel) {
- super(dataModel);
- }
-
- public J2EEModuleCreationOperationOld() {
- super();
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- J2EEModuleCreationDataModelOld dataModel = (J2EEModuleCreationDataModelOld) operationDataModel;
- createProject(monitor);
- if (dataModel.getBooleanProperty(J2EEArtifactCreationDataModelOld.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(J2EEModuleCreationDataModelOld moduleModel, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- if (moduleModel.getBooleanProperty(J2EEModuleCreationDataModelOld.ADD_TO_EAR)) {
- EnterpriseApplicationCreationDataModel earModel = moduleModel.getApplicationCreationDataModel();
- if (!earModel.getTargetProject().exists()) {
- EnterpriseApplicationCreationOperation earOp = new EnterpriseApplicationCreationOperation(earModel);
- earOp.doRun(monitor);
- }
- AddArchiveToEARDataModel addModuleModel = moduleModel.getAddModuleToApplicationDataModel();
- AddArchiveProjectToEAROperation addModuleOp = new AddArchiveProjectToEAROperation(addModuleModel);
- addModuleOp.doRun(monitor);
- }
- }
-
- protected void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- JavaProjectCreationDataModel projectModel = ((J2EEModuleCreationDataModelOld) operationDataModel).getJavaProjectCreationDataModel();
- JavaProjectCreationOperation javaProjectOperation = new JavaProjectCreationOperation(projectModel);
- javaProjectOperation.doRun(monitor);
- updateClasspath(projectModel);
- J2EEModuleCreationDataModelOld dataModel = (J2EEModuleCreationDataModelOld) operationDataModel;
- //setVersion(nature, monitor);
- addServerTarget(monitor);
- }
-
- /**
- * @param projectModel
- * @throws JavaModelException
- */
- private void updateClasspath(JavaProjectCreationDataModel projectModel) throws JavaModelException {
- ClassPathSelection classpath = ((J2EEModuleCreationDataModelOld) 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) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ioe);
- return;
- }
- UpdateManifestOperation op = new UpdateManifestOperation(((J2EEModuleCreationDataModelOld) operationDataModel).getUpdateManifestDataModel());
- op.doRun(monitor);
- }
- }
-
- protected void setVersion(WorkbenchComponent module, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- J2EEModuleCreationDataModelOld dataModel = (J2EEModuleCreationDataModelOld) operationDataModel;
- //TODO set module version?
- //module.setModuleVersion(dataModel.getIntProperty(J2EEModuleCreationDataModel.J2EE_MODULE_VERSION));
- }
-
-
- /*
- * (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 = ((J2EEModuleCreationDataModelOld)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/J2EEModuleExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleExportDataModel.java
deleted file mode 100644
index 37a2829c7..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleExportDataModel.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-/**
- * This dataModel is a common super class used to export J2EE 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 abstract class J2EEModuleExportDataModel extends J2EEArtifactExportDataModel {
- public J2EEModuleExportDataModel() {
- super();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleImportDataModel.java
deleted file mode 100644
index 30f5b85d3..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEModuleImportDataModel.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModel;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.ServerCore;
-
-/**
- * This dataModel is a common super class used to import J2EE 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 abstract class J2EEModuleImportDataModel extends J2EEArtifactImportDataModel {
-
- /**
- * nested
- */
- public static final String EAR_PROJECT = J2EEModuleCreationDataModelOld.EAR_PROJECT_NAME;
- public static final String ADD_TO_EAR = J2EEModuleCreationDataModelOld.ADD_TO_EAR;
-
- public static final String EXTENDED_IMPORT_FACTORY = "J2EEModuleImportDataModel.EXTENDED_IMPORT_FACTORY"; //$NON-NLS-1$
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(EXTENDED_IMPORT_FACTORY);
- }
-
- private int getModuleSpecVersion() {
- if (!isSet(EXTENDED_IMPORT_FACTORY)) {
- return ArchiveUtil.getFastSpecVersion(getModuleFile());
- }
- ExtendedImportFactory factory = (ExtendedImportFactory) getProperty(EXTENDED_IMPORT_FACTORY);
- return factory.getSpecVersion(getModuleFile());
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- if (propertyName.equals(PROJECT_NAME)) {
- IProject project = ProjectCreationDataModel.getProjectHandleFromProjectName((String) propertyValue);
- getJ2EEModuleCreationDataModel().setBooleanProperty(J2EEArtifactCreationDataModelOld.IS_ENABLED, null == project || !project.exists());
- }
- boolean doSet = super.doSetProperty(propertyName, propertyValue);
- if (doSet && (propertyName.equals(J2EEArtifactImportDataModel.FILE_NAME) || (propertyName.equals(J2EEArtifactImportDataModel.FILE)))) {
- J2EEModuleCreationDataModelOld moduleDM = getJ2EEModuleCreationDataModel();
- if (getModuleFile() != null) {
- moduleDM.setIntProperty(J2EEModuleCreationDataModelOld.J2EE_VERSION, getModuleSpecVersion());
- notifyValidValuesChange(PROJECT_NAME);
- }
- } else if (propertyName.equals(PROJECT_NAME)) {
- IProject project = getProject();
- if (null != project && project.exists()) {
- String[] requiredNatures = (String[]) getJ2EEModuleCreationDataModel().getProjectDataModel().getProperty(ProjectCreationDataModel.PROJECT_NATURES);
- if (null != requiredNatures) {
- try {
- for (int i = 0; i < requiredNatures.length; i++) {
- if (!project.hasNature(requiredNatures[i])) {
- return doSet;
- }
- }
- } catch (CoreException e) {
- return doSet;
- }
- IRuntime target = ServerCore.getProjectProperties(project).getRuntimeTarget();
- if (null != target) {
- setProperty(SERVER_TARGET_ID, target.getId());
- }
- setBooleanProperty(ADD_TO_EAR, false);
- }
- }
- getJ2EEModuleCreationDataModel().setBooleanProperty(J2EEArtifactCreationDataModelOld.IS_ENABLED, null == project || !project.exists());
- } else if (propertyName.equals(PRESERVE_PROJECT_METADATA)) {
- JavaProjectCreationDataModel jdm = getJ2EEModuleCreationDataModel().getJavaProjectCreationDataModel();
- jdm.setBooleanProperty(JavaProjectCreationDataModel.CREATE_SOURCE_FOLDERS, !getBooleanProperty(BINARY));
- }
- return doSet;
- }
-
- public final J2EEModuleCreationDataModelOld getJ2EEModuleCreationDataModel() {
- return (J2EEModuleCreationDataModelOld) getJ2eeArtifactCreationDataModel();
- }
-
- protected final int getJ2EEVersion() {
- return getJ2EEModuleCreationDataModel().getJ2EEVersion();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportDataModel.java
deleted file mode 100644
index ce941aae0..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportDataModel.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * 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 Dec 15, 2003
- *
- * To change the template for this generated file go to Window - Preferences -
- * Java - Code Generation - Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModel;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-
-public final class J2EEUtilityJarImportDataModel extends J2EEArtifactImportDataModel {
-
- public static final String EAR_PROJECT = "J2EEUtilityJarImportDataModel.EAR_PROJECT"; //$NON-NLS-1$
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(EAR_PROJECT);
- }
-
- protected boolean openArchive(String uri) throws OpenFailureException {
- return false;
- }
-
- protected J2EEArtifactCreationDataModelOld createJ2EEProjectCreationDataModel() {
- return new J2EEArtifactCreationDataModelOld() {
- public void initProjectModel() {
- setProjectDataModel(new JavaProjectCreationDataModel());
- }
-
- public WTPOperation getDefaultOperation() {
- return null;
- }
- };
- }
-
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
- boolean returnVal = super.doSetProperty(propertyName, propertyValue);
- if (propertyName.equals(PRESERVE_PROJECT_METADATA)) {
- JavaProjectCreationDataModel jdm = (JavaProjectCreationDataModel) getJ2eeArtifactCreationDataModel().getProjectDataModel();
- jdm.setBooleanProperty(JavaProjectCreationDataModel.CREATE_SOURCE_FOLDERS, !getBooleanProperty(BINARY));
- }
- return returnVal;
- }
-
- protected int getType() {
- return 0;
- }
-
- public WTPOperation getDefaultOperation() {
- return new J2EEUtilityJarImportOperation(this);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportOperation.java
deleted file mode 100644
index 476a7fa61..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarImportOperation.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException;
-import org.eclipse.jst.j2ee.internal.archive.operations.BinaryProjectHelper;
-import org.eclipse.jst.j2ee.internal.archive.operations.JavaProjectSaveStrategyImpl;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-
-/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to Window - Preferences - Java - Code
- * Generation - Code and Comments
- */
-public class J2EEUtilityJarImportOperation extends WTPOperation {
-
- public J2EEUtilityJarImportOperation(J2EEUtilityJarImportDataModel dataModel) {
- super(dataModel);
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- J2EEUtilityJarImportDataModel dataModel = (J2EEUtilityJarImportDataModel) operationDataModel;
- if (dataModel.getBooleanProperty(J2EEUtilityJarImportDataModel.OVERWRITE_PROJECT)) {
- IProject project = dataModel.getProject();
- if (project.exists()) {
- project.delete(true, true, new NullProgressMonitor());
- }
- }
-
- if (!dataModel.getJ2eeArtifactCreationDataModel().getTargetProject().exists()) {
- JavaUtilityJARProjectCreationOperationOld javaProjectCreationOp = new JavaUtilityJARProjectCreationOperationOld(dataModel.getJ2eeArtifactCreationDataModel());
- javaProjectCreationOp.run(monitor);
- }
-
- IProject javaProject = dataModel.getProject();
- Archive jarFile = dataModel.getArchiveFile();
-
- if (dataModel.getBooleanProperty(J2EEUtilityJarImportDataModel.PRESERVE_PROJECT_METADATA)) {
- BinaryProjectHelper binaryHelper = new BinaryProjectHelper();
- binaryHelper.importArchiveAsBinary(dataModel.getArchiveFile(), dataModel.getProject(), monitor);
- try {
- JavaProjectUtilities.forceClasspathReload(javaProject);
- } catch (JavaModelException ex) {
- Logger.getLogger().logError(ex);
- }
-
- } else {
- JavaProjectSaveStrategyImpl strat = new JavaProjectSaveStrategyImpl(javaProject);
- strat.setIncludeProjectMetaFiles(false);
- strat.setShouldIncludeImportedClasses(true);
- strat.setProgressMonitor(new SubProgressMonitor(monitor, 1));
- try {
- jarFile.save(strat);
- JavaProjectUtilities.appendJavaClassPath(javaProject, JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER"))); //$NON-NLS-1$)
- JavaProjectUtilities.forceClasspathReload(javaProject);
- } catch (SaveFailureException e) {
- Logger.getLogger().logError(e);
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportDataModel.java
deleted file mode 100644
index fd6480d21..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportDataModel.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*******************************************************************************
- * 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 May 13, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IPathVariableManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPPropertyDescriptor;
-
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-
-/**
- * @author mdelder
- *
- * TODO To change the template for this generated type comment go to Window - Preferences - Java -
- * Code Generation - Code and Comments
- */
-public class J2EEUtilityJarListImportDataModel extends WTPOperationDataModel {
-
- /**
- * Required. The EAR Project to which Utility Jars should be added.
- */
- public static final String EAR_PROJECT = J2EEUtilityJarImportDataModel.EAR_PROJECT;
-
- /**
- * Optional. Boolean Property. True indicates to create a Project Can be used with
- * LINK_IMPORT="true|"false" or BINARY_IMPORT="true|false" The default value is true.
- */
- public static final String CREATE_PROJECT = "J2EEUtilityJarListImportDataModel.CREATE_PROJECT"; //$NON-NLS-1$
-
- /**
- * Optional. Boolean property. True indicates to import the jar as a linked project Can be
- * specified with BINARY_IMPORT="true|false" and/or CREATE_PROJECT="true|false" The default
- * value is false.
- */
- public static final String LINK_IMPORT = "J2EEUtilityJarListImportDataModel.LINK_IMPORT"; //$NON-NLS-1$
-
- /**
- * Optional. Boolean Property. True indicates to create a Project Can be used with
- * LINK_IMPORT="true|"false" or BINARY_IMPORT="true|false" The default value is true.
- */
- public static final String CREATE_LINKED_PROJECT = "J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT"; //$NON-NLS-1$
-
- /**
- * Optional. Boolean property. True indicates to import the jar as a linked project Can be
- * specified with BINARY_IMPORT="true|false" and/or CREATE_PROJECT="true|false" The default
- * value is false.
- */
- public static final String COPY = "J2EEUtilityJarListImportDataModel.COPY"; //$NON-NLS-1$
-
- /**
- * Optional. Boolean property. True indicates to import the jar as a binary project Can be
- * specified with LINK_IMPORT="true|false" and/or CREATE_PROJECT="true|false" The default value
- * is false.
- */
- public static final String BINARY_IMPORT = "J2EEUtilityJarListImportDataModel.BINARY_IMPORT"; //$NON-NLS-1$
-
- /**
- * Required. A java.util.List of fully qualified file names for each Utility Jar that should be
- * imported.
- */
- public static final String UTILITY_JAR_LIST = "J2EEUtilityJarListImportDataModel.UTILITY_JAR_LIST"; //$NON-NLS-1$
-
- public static final String AVAILABLE_JARS_DIRECTORY = "J2EEUtilityJarListImportDataModel.AVAILABLE_JARS_DIRECTORY"; //$NON-NLS-1$
-
- public static final String PROJECT_ROOT = "J2EEUtilityJarListImportDataModel.PROJECT_ROOT"; //$NON-NLS-1$
-
- public static final String OVERRIDE_PROJECT_ROOT = "J2EEUtilityJarListImportDataModel.OVERRIDE_PROJECT_ROOT"; //$NON-NLS-1$
-
- public static final String OVERWRITE_IF_NECESSARY = "J2EEUtilityJarListImportDataModel.OVERWRITE_IF_NECESSARY"; //$NON-NLS-1$
-
- public static final String CREATE_LINKED_PATH_VARIABLE = "J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH"; //$NON-NLS-1$
-
- public static final String LINKED_PATH_VARIABLE = "J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE"; //$NON-NLS-1$
-
- private static final Object[] EMPTY_ARRAY = new Object[0];
-
- public J2EEUtilityJarListImportDataModel() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#initValidBaseProperties()
- */
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(EAR_PROJECT);
- addValidBaseProperty(CREATE_PROJECT);
- addValidBaseProperty(LINK_IMPORT);
- addValidBaseProperty(CREATE_LINKED_PROJECT);
- addValidBaseProperty(COPY);
- addValidBaseProperty(BINARY_IMPORT);
- addValidBaseProperty(UTILITY_JAR_LIST);
- addValidBaseProperty(AVAILABLE_JARS_DIRECTORY);
- addValidBaseProperty(PROJECT_ROOT);
- addValidBaseProperty(OVERRIDE_PROJECT_ROOT);
- addValidBaseProperty(OVERWRITE_IF_NECESSARY);
- addValidBaseProperty(CREATE_LINKED_PATH_VARIABLE);
- addValidBaseProperty(LINKED_PATH_VARIABLE);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#getDefaultOperation()
- */
- public WTPOperation getDefaultOperation() {
-
- return new J2EEUtilityJarListImportOperation(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doSetProperty(java.lang.String,
- * java.lang.Object)
- */
- protected boolean doSetProperty(String propertyName, Object propertyValue) {
-
- boolean result = super.doSetProperty(propertyName, propertyValue);
-
- if (AVAILABLE_JARS_DIRECTORY.equals(propertyName)) {
- setProperty(UTILITY_JAR_LIST, EMPTY_ARRAY);
- } else if (UTILITY_JAR_LIST.equals(propertyName)) {
- if (propertyValue == null)
- setProperty(UTILITY_JAR_LIST, EMPTY_ARRAY);
- else
- super.doSetProperty(UTILITY_JAR_LIST, propertyValue);
-
- } else if (PROJECT_ROOT.equals(propertyName)) {
- if (propertyValue == null || ((String) propertyValue).length() == 0)
- setBooleanProperty(OVERRIDE_PROJECT_ROOT, false);
- else
- setBooleanProperty(OVERRIDE_PROJECT_ROOT, true);
-
- } else if (J2EEUtilityJarListImportDataModel.CREATE_PROJECT.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_PROJECT)) {
-
- setBooleanProperty(LINK_IMPORT, false);
- setBooleanProperty(CREATE_LINKED_PROJECT, false);
- setBooleanProperty(COPY, false);
-
- notifyEnablementChange(BINARY_IMPORT);
- notifyEnablementChange(OVERRIDE_PROJECT_ROOT);
- notifyEnablementChange(PROJECT_ROOT);
- notifyEnablementChange(CREATE_LINKED_PATH_VARIABLE);
- notifyEnablementChange(LINKED_PATH_VARIABLE);
-
- } else if (J2EEUtilityJarListImportDataModel.LINK_IMPORT.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModel.LINK_IMPORT)) {
-
- setBooleanProperty(CREATE_PROJECT, false);
- setBooleanProperty(CREATE_LINKED_PROJECT, false);
- setBooleanProperty(COPY, false);
-
- notifyEnablementChange(BINARY_IMPORT);
- notifyEnablementChange(OVERRIDE_PROJECT_ROOT);
- notifyEnablementChange(PROJECT_ROOT);
- notifyEnablementChange(CREATE_LINKED_PATH_VARIABLE);
- notifyEnablementChange(LINKED_PATH_VARIABLE);
-
- } else if (J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT)) {
-
- setBooleanProperty(LINK_IMPORT, false);
- setBooleanProperty(CREATE_PROJECT, false);
- setBooleanProperty(COPY, false);
-
- notifyEnablementChange(BINARY_IMPORT);
- notifyEnablementChange(OVERRIDE_PROJECT_ROOT);
- notifyEnablementChange(PROJECT_ROOT);
- notifyEnablementChange(CREATE_LINKED_PATH_VARIABLE);
- notifyEnablementChange(LINKED_PATH_VARIABLE);
-
- } else if (J2EEUtilityJarListImportDataModel.COPY.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModel.COPY)) {
-
- setBooleanProperty(CREATE_PROJECT, false);
- setBooleanProperty(LINK_IMPORT, false);
- setBooleanProperty(CREATE_LINKED_PROJECT, false);
-
- notifyEnablementChange(BINARY_IMPORT);
- notifyEnablementChange(OVERRIDE_PROJECT_ROOT);
- notifyEnablementChange(PROJECT_ROOT);
- notifyEnablementChange(CREATE_LINKED_PATH_VARIABLE);
- notifyEnablementChange(LINKED_PATH_VARIABLE);
-
-
- } else if (J2EEUtilityJarListImportDataModel.OVERRIDE_PROJECT_ROOT.equals(propertyName)) {
- notifyEnablementChange(PROJECT_ROOT);
- } else if (J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH_VARIABLE.equals(propertyName)) {
-
- if (isLinkedPathVariableInvalid())
- setProperty(J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE, "TEAM_SHARED_DIRECTORY"); //$NON-NLS-1$
-
- notifyEnablementChange(J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE);
- notifyEnablementChange(AVAILABLE_JARS_DIRECTORY);
-
- } else if (J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE.equals(propertyName)) {
- // will only set if necessary
- setProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH_VARIABLE, Boolean.TRUE);
-
- if (linkedPathExists()) {
- String linkedPathVariable = getStringProperty(J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE);
- IPathVariableManager manager = ResourcesPlugin.getWorkspace().getPathVariableManager();
- IPath availableJarsPath = manager.getValue(linkedPathVariable);
- setProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH_VARIABLE, Boolean.valueOf(availableJarsPath != null));
-
- String availableJarsPathString = availableJarsPath.toOSString();
- if (availableJarsPathString != null && availableJarsPathString.length() > 0)
- setProperty(J2EEUtilityJarListImportDataModel.AVAILABLE_JARS_DIRECTORY, availableJarsPathString);
- }
-
- notifyEnablementChange(AVAILABLE_JARS_DIRECTORY);
- }
- return result;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#basicIsEnabled(java.lang.String)
- */
- protected Boolean basicIsEnabled(String propertyName) {
- if (J2EEUtilityJarListImportDataModel.BINARY_IMPORT.equals(propertyName)) {
- return Boolean.valueOf(getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_PROJECT) || getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT));
- } else if (J2EEUtilityJarListImportDataModel.OVERRIDE_PROJECT_ROOT.equals(propertyName)) {
- return Boolean.valueOf(getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_PROJECT) || getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT));
- } else if (J2EEUtilityJarListImportDataModel.PROJECT_ROOT.equals(propertyName)) {
- return Boolean.valueOf((getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_PROJECT) || getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT)) && getBooleanProperty(J2EEUtilityJarListImportDataModel.OVERRIDE_PROJECT_ROOT));
- } else if (J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH_VARIABLE.equals(propertyName)) {
- return Boolean.valueOf((getBooleanProperty(J2EEUtilityJarListImportDataModel.LINK_IMPORT) || getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT)));
- } else if (J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE.equals(propertyName)) {
- return Boolean.valueOf(getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH_VARIABLE));
- } else if (J2EEUtilityJarListImportDataModel.AVAILABLE_JARS_DIRECTORY.equals(propertyName)) {
- boolean createPath = getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH_VARIABLE);
- return Boolean.valueOf(!createPath || !linkedPathExists());
- }
- return super.basicIsEnabled(propertyName);
- }
-
- private boolean linkedPathExists() {
- String linkedPathVariable = getStringProperty(J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE);
- if (linkedPathVariable == null || linkedPathVariable.trim().length() == 0)
- return false;
-
- IPathVariableManager manager = ResourcesPlugin.getWorkspace().getPathVariableManager();
- IPath availableJarsPath = manager.getValue(linkedPathVariable);
- return availableJarsPath != null;
- }
-
- private boolean isLinkedPathVariableInvalid() {
- boolean createPath = getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PATH_VARIABLE);
- String linkedPathVariable = getStringProperty(J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE);
- return (createPath && (linkedPathVariable == null || linkedPathVariable.trim().length() == 0));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEImportDataModel#getDefaultProperty(java.lang.String)
- */
- protected Object getDefaultProperty(String propertyName) {
- if (CREATE_PROJECT.equals(propertyName))
- return Boolean.TRUE;
- else if (LINK_IMPORT.equals(propertyName))
- return Boolean.FALSE;
- else if (COPY.equals(propertyName))
- return Boolean.FALSE;
- else if (CREATE_LINKED_PROJECT.equals(propertyName))
- return Boolean.FALSE;
- else if (CREATE_LINKED_PATH_VARIABLE.equals(propertyName))
- return Boolean.FALSE;
- else if (OVERRIDE_PROJECT_ROOT.equals(propertyName))
- return Boolean.FALSE;
- else if (BINARY_IMPORT.equals(propertyName))
- return Boolean.FALSE;
- else if (PROJECT_ROOT.equals(propertyName))
- return ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString();
- else if (EAR_PROJECT.equals(propertyName))
- return ""; //$NON-NLS-1$
- else if (AVAILABLE_JARS_DIRECTORY.equals(propertyName))
- return ""; //$NON-NLS-1$
- else if (LINKED_PATH_VARIABLE.equals(propertyName))
- return ""; //$NON-NLS-1$
- else if (UTILITY_JAR_LIST.equals(propertyName))
- return EMPTY_ARRAY;
- else
- return super.getDefaultProperty(propertyName);
- }
-
- protected WTPPropertyDescriptor[] doGetValidPropertyDescriptors(String propertyName) {
- if (EAR_PROJECT.equals(propertyName)) {
- return WTPPropertyDescriptor.createDescriptors(getValidProjectNames());
- } else if (LINKED_PATH_VARIABLE.equals(propertyName)) {
- IPathVariableManager manager = ResourcesPlugin.getWorkspace().getPathVariableManager();
- return WTPPropertyDescriptor.createDescriptors(manager.getPathVariableNames());
- } else
- return super.doGetValidPropertyDescriptors(propertyName);
- }
-
- /**
- * Populate the resource name combo with connector projects that are not encrypted.
- */
- protected Object[] getValidProjectNames() {
- List projects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
- List projectsWithNature = new ArrayList();
-
- for (int i = 0; i < projects.size(); i++) {
- IProject project = (IProject) projects.get(i);
- if (EMFNature.hasRuntime(project, IEARNatureConstants.NATURE_ID) && project.isOpen()) {
- projectsWithNature.add(project.getFullPath().toString());
- }
- }
-
- return ProjectUtilities.getProjectNamesWithoutForwardSlash((String[]) projectsWithNature.toArray(new String[projectsWithNature.size()]));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doValidateProperty(java.lang.String)
- */
- protected IStatus doValidateProperty(String propertyName) {
- if (EAR_PROJECT.equals(propertyName) /* && isSet(EAR_PROJECT) */) {
- String earProjectName = getStringProperty(EAR_PROJECT);
- if (earProjectName != null && earProjectName.length() > 0) {
- IProject earProject = ResourcesPlugin.getWorkspace().getRoot().getProject(earProjectName);
- try {
- if (!earProject.isAccessible() || !earProject.hasNature(IEARNatureConstants.NATURE_ID))
- return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.getString("J2EEUtilityJarListImportDataModel_Specify_Valid_Project"), null); //$NON-NLS-1$
- return Status.OK_STATUS;
- } catch (CoreException e) {
- return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.getString("J2EEUtilityJarListImportDataModel_Specify_Valid_Project"), e); //$NON-NLS-1$
- }
- }
- return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.getString("J2EEUtilityJarListImportDataModel_Specify_Valid_Project"), null); //$NON-NLS-1$
-
- } else if (UTILITY_JAR_LIST.equals(propertyName) || J2EEUtilityJarListImportDataModel.OVERWRITE_IF_NECESSARY.equals(propertyName)) {
-
- Object[] list = (Object[]) getProperty(UTILITY_JAR_LIST);
- if (list == null || list.length == 0)
- return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.getString("J2EEUtilityJarListImportDataModel_Select_Jar"), null); //$NON-NLS-1$
-
- /* return validateExistingProjects(); */
-
- return Status.OK_STATUS;
- } else if (LINKED_PATH_VARIABLE.equals(propertyName)) {
- if (isLinkedPathVariableInvalid())
- return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.getString("J2EEUtilityJarListImportDataModel_Specify_Linked_Path"), null); //$NON-NLS-1$
- } else if (PROJECT_ROOT.equals(propertyName)) {
- return validateProjectRoot();
- }
- return super.doValidateProperty(propertyName);
- }
-
- private IStatus validateProjectRoot() {
- if (isSet(PROJECT_ROOT) && getBooleanProperty(OVERRIDE_PROJECT_ROOT)) {
- String loc = (String) getProperty(PROJECT_ROOT);
- File file = new File(loc);
- if (!file.canWrite() || !file.isDirectory())
- return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.getString("J2EEUtilityJarListImportDataModel.0"), null); //$NON-NLS-1$
- }
- return OK_STATUS;
- }
-
- // private IStatus validateExistingProjects() {
- // boolean createProject = (getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_PROJECT)
- // || getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT));
- // boolean overwrite =
- // getBooleanProperty(J2EEUtilityJarListImportDataModel.OVERWRITE_IF_NECESSARY);
- // if (createProject && !overwrite) {
- // File jarFile = null;
- // String nameWithoutJar = null;
- // Object[] selectedJars = (Object[]) getProperty(UTILITY_JAR_LIST);
- // for (int i = 0; i < selectedJars.length; i++) {
- // jarFile = (File) selectedJars[i];
- // int start = jarFile.getName().indexOf(".jar");
- // nameWithoutJar = jarFile.getName().substring(0, start);
- // if (ProjectUtilities.getProject(nameWithoutJar).exists())
- // return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, "Existing projects with the derived
- // names already exist (\"{0}\").", null); // {0}
- // // nameWithoutJar
- //
- // }
- // }
- // return Status.OK_STATUS;
- // }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportOperation.java
deleted file mode 100644
index 4ce6b3674..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/J2EEUtilityJarListImportOperation.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * 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 May 13, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.jst.j2ee.application.operations;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IPathVariableManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel;
-
-/**
- * @author mdelder
- *
- * TODO To change the template for this generated type comment go to Window - Preferences - Java -
- * Code Generation - Code and Comments
- */
-public class J2EEUtilityJarListImportOperation extends WTPOperation {
-
- /**
- * @param operationDataModel
- */
- public J2EEUtilityJarListImportOperation(WTPOperationDataModel operationDataModel) {
- super(operationDataModel);
- }
-
- /**
- *
- */
- public J2EEUtilityJarListImportOperation() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
-
- J2EEUtilityJarListImportDataModel model = (J2EEUtilityJarListImportDataModel) getOperationDataModel();
- Object[] utilityJars = (Object[]) model.getProperty(J2EEUtilityJarListImportDataModel.UTILITY_JAR_LIST);
- if (utilityJars == null || utilityJars.length == 0)
- return;
-
- monitor.beginTask(EARCreationResourceHandler.getString("J2EEUtilityJarListImportOperation_UI_0"), utilityJars.length); //$NON-NLS-1$
-
- String earProject = model.getStringProperty(J2EEUtilityJarListImportDataModel.EAR_PROJECT);
- boolean isBinary = model.getBooleanProperty(J2EEUtilityJarListImportDataModel.BINARY_IMPORT);
- // if model.getBooleanProperty(J2EEUtilityJarListImportDataModel.COPY) then isLinked =
- // createProject = false;
- boolean isLinked = (model.getBooleanProperty(J2EEUtilityJarListImportDataModel.LINK_IMPORT) || model.getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT));
- boolean createProject = (model.getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_PROJECT) || model.getBooleanProperty(J2EEUtilityJarListImportDataModel.CREATE_LINKED_PROJECT));
- ;
- boolean overrideProjectRoot = model.getBooleanProperty(J2EEUtilityJarListImportDataModel.OVERRIDE_PROJECT_ROOT);
- String projectRoot = model.getStringProperty(J2EEUtilityJarListImportDataModel.PROJECT_ROOT);
-
- File utilityJar = null;
- J2EEUtilityJarImportDataModel importModel = null;
- IWorkspace root = ResourcesPlugin.getWorkspace();
- for (int i = 0; i < utilityJars.length; i++) {
- utilityJar = (File) utilityJars[i];
- monitor.subTask(EARCreationResourceHandler.getString("J2EEUtilityJarListImportOperation_UI_1") + utilityJar.getAbsolutePath()); //$NON-NLS-1$
-
- try {
-
- if (createProject) {
-
- if (!isLinked) {
- Archive archive = CommonarchiveFactory.eINSTANCE.primOpenArchive(utilityJar.getAbsolutePath());
-
- importModel = new J2EEUtilityJarImportDataModel();
- importModel.setBooleanProperty(J2EEUtilityJarImportDataModel.PRESERVE_PROJECT_METADATA, isBinary);
- importModel.setProperty(J2EEUtilityJarImportDataModel.FILE, archive);
-
- if (overrideProjectRoot && projectRoot != null && projectRoot.length() > 0)
- importModel.getJ2eeArtifactCreationDataModel().setProperty(J2EEArtifactCreationDataModelOld.PROJECT_LOCATION, projectRoot);
-
- importModel.getJ2eeArtifactCreationDataModel().setBooleanProperty(J2EEArtifactCreationDataModelOld.ADD_SERVER_TARGET, true);
- importModel.setBooleanProperty(J2EEArtifactImportDataModel.OVERWRITE_PROJECT, model.getBooleanProperty(J2EEUtilityJarListImportDataModel.OVERWRITE_IF_NECESSARY));
- importModel.setProperty(J2EEUtilityJarImportDataModel.EAR_PROJECT, earProject);
-
- importModel.getDefaultOperation().run(new SubProgressMonitor(monitor, 1));
- } else {
- createProjectWithLinkedJar(utilityJar, new SubProgressMonitor(monitor, 1));
- }
-
- String utilityJarProjectName = (importModel != null) ? importModel.getStringProperty(J2EEArtifactImportDataModel.PROJECT_NAME) : getUtilityJarProjectName(utilityJar);
-
- IProject utilityJarProject = root.getRoot().getProject(utilityJarProjectName);
- linkArchiveToEAR(earProject, utilityJar.getName(), utilityJarProject, new SubProgressMonitor(monitor, 1));
- importModel = null;
- } else {
-
- IProject targetEARProject = root.getRoot().getProject(earProject);
- if (!isLinked)
- createCopiedArchive(targetEARProject, utilityJar.getName(), utilityJar, new SubProgressMonitor(monitor, 1));
- else
- createLinkedArchive(targetEARProject, utilityJar.getName(), utilityJar, new SubProgressMonitor(monitor, 1));
-
- }
-
- } catch (OpenFailureException e) {
- Logger.getLogger().logError(e);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- } catch (Exception e) {
- Logger.getLogger().logError(e);
- }
-
- monitor.worked(1);
- }
- monitor.done();
- }
-
- /**
- * @param utilityJar
- * @return
- */
- private String getUtilityJarProjectName(File utilityJar) {
- String name = null;
- if (utilityJar != null) {
- int len = utilityJar.getName().indexOf('.');
- name = utilityJar.getName().substring(0, len);
- }
- return name;
- }
-
- protected IPath getLinkedPath(File archiveFile) throws CoreException {
- String linkedPathVariable = getOperationDataModel().getStringProperty(J2EEUtilityJarListImportDataModel.LINKED_PATH_VARIABLE);
-
- if (linkedPathVariable == null || linkedPathVariable.length() == 0)
- return new Path(archiveFile.getAbsolutePath());
- createLinkedPathVariableIfNecessary(linkedPathVariable, archiveFile.getParentFile());
- return new Path(linkedPathVariable).append(archiveFile.getName());
- }
-
- /**
- * @param linkedPathVariable
- * @param archiveFile
- */
- protected void createLinkedPathVariableIfNecessary(String linkedPathVariable, File archiveFile) throws CoreException {
- IPathVariableManager manager = ResourcesPlugin.getWorkspace().getPathVariableManager();
- IPath linkedPath = new Path(archiveFile.getAbsolutePath());
- manager.setValue(linkedPathVariable, linkedPath);
-
- }
-
- protected void createProjectWithLinkedJar(File jarFile, IProgressMonitor monitor) throws CoreException {
- try {
- boolean overrideProjectRoot = getOperationDataModel().getBooleanProperty(J2EEUtilityJarListImportDataModel.OVERRIDE_PROJECT_ROOT);
- String projectRoot = getOperationDataModel().getStringProperty(J2EEUtilityJarListImportDataModel.PROJECT_ROOT);
-
- IWorkspace root = ResourcesPlugin.getWorkspace();
- IProject project = root.getRoot().getProject(getUtilityJarProjectName(jarFile));
- IProjectDescription description = null;
- if (project.exists()) {
- if (!project.isOpen())
- return;
- description = project.getDescription();
- ProjectUtilities.addNatureToProject(project, JavaCore.NATURE_ID);
- } else {
- project.create(new SubProgressMonitor(monitor, 1));
- description = root.newProjectDescription(project.getName());
- description.setNatureIds(new String[]{JavaCore.NATURE_ID});
- if (overrideProjectRoot)
- description.setLocation(new Path(projectRoot));
- else
- description.setLocation(null);
- project.open(new SubProgressMonitor(monitor, 1));
- project.setDescription(description, new SubProgressMonitor(monitor, 1));
- }
- createLinkedArchive(project, jarFile.getName(), jarFile, monitor);
-
- JavaProjectUtilities.forceClasspathReload(project);
- } catch (Exception e) {
- Logger.getLogger().logError(e);
- throw new CoreException(new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.getString("J2EEUtilityJarListImportOperation_UI_2"), e)); //$NON-NLS-1$
- }
- }
-
- protected void createLinkedArchive(IProject project, String linkedFileName, File archiveFile, IProgressMonitor monitor) throws Exception {
- IFile linkedJarFile = null;
- IPath pathToArchive = getLinkedPath(archiveFile);
- boolean overwriteIfNecessary = getOperationDataModel().getBooleanProperty(J2EEUtilityJarListImportDataModel.OVERWRITE_IF_NECESSARY);
- linkedJarFile = project.getFile(linkedFileName);
- if (linkedJarFile.exists()) {
- if (overwriteIfNecessary)
- linkedJarFile.delete(true, true, new SubProgressMonitor(monitor, 1));
- else
- return;
- }
- linkedJarFile.createLink(pathToArchive, IResource.ALLOW_MISSING_LOCAL, new SubProgressMonitor(monitor, 1));
-
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IClasspathEntry entry = new ClasspathEntry(IPackageFragmentRoot.K_BINARY, IClasspathEntry.CPE_LIBRARY, linkedJarFile.getFullPath(), ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, // source
- // attachment
- null, // source attachment root
- null, // custom output location
- false);
-
- JavaProjectUtilities.appendJavaClassPath(project, entry);
- }
- }
-
- protected void createCopiedArchive(IProject project, String jarFileName, File archiveFile, IProgressMonitor monitor) throws Exception {
-
- IPath pathToArchive = new Path(archiveFile.getAbsolutePath());
-
- boolean overwriteIfNecessary = getOperationDataModel().getBooleanProperty(J2EEUtilityJarListImportDataModel.OVERWRITE_IF_NECESSARY);
- IFile copiedJarFile = project.getFile(jarFileName);
- if (copiedJarFile.exists()) {
- if (overwriteIfNecessary)
- copiedJarFile.delete(true, true, new SubProgressMonitor(monitor, 1));
- else
- return;
- }
- FileInputStream fileInputStream = null;
- ByteArrayOutputStream bos = null;
- ByteArrayInputStream jarFileInputStream = null;
- try {
- fileInputStream = new FileInputStream(pathToArchive.toOSString());
- bos = new ByteArrayOutputStream();
- byte[] data = new byte[4096];
- try {
- int bytesRead = 0;
- while ((bytesRead = fileInputStream.read(data)) > 0)
- bos.write(data, 0, bytesRead);
- // clear space for GC
- data = null;
- } finally {
- fileInputStream.close();
- }
-
- jarFileInputStream = new ByteArrayInputStream(bos.toByteArray());
- copiedJarFile.create(jarFileInputStream, 0, new SubProgressMonitor(monitor, 1));
-
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IClasspathEntry entry = new ClasspathEntry(IPackageFragmentRoot.K_BINARY, IClasspathEntry.CPE_LIBRARY, copiedJarFile.getFullPath(), ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, // source
- // attachment
- null, // source attachment root
- null, // custom output location
- false);
-
- JavaProjectUtilities.appendJavaClassPath(project, entry);
- }
- } finally {
- if (bos != null)
- bos.close();
- if (jarFileInputStream != null)
- jarFileInputStream.close();
- }
- }
-
- public void linkArchiveToEAR(String earProjectName, String uriMapping, IProject utlityProject, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AddUtilityProjectToEARDataModel addArchiveProjectToEARDataModel = AddUtilityProjectToEARDataModel.createAddToEARDataModel(earProjectName, utlityProject);
- addArchiveProjectToEARDataModel.setProperty(AddModuleToEARDataModel.ARCHIVE_URI, uriMapping);
- addArchiveProjectToEARDataModel.setBooleanProperty(AddArchiveToEARDataModel.SYNC_TARGET_RUNTIME, true);
- addArchiveProjectToEARDataModel.getDefaultOperation().run(monitor);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JARDependencyTraverser.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JARDependencyTraverser.java
deleted file mode 100644
index d5a783767..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JARDependencyTraverser.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * 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 Sep 13, 2004
- *
- * 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.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.RuntimeClasspathEntry;
-import org.eclipse.jst.j2ee.internal.common.ClasspathModel;
-import org.eclipse.jst.j2ee.internal.earcreation.EAREditModel;
-import org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-
-
-/**
- * @author schacher Helper class used to compute all the dependencies for a JAR being added to an
- * EAR
- */
-class JARDependencyTraverser {
-
- private IProject archiveProject;
- private IProject earProject;
- private Map result;
- private EAREditModel earEditModel;
-
- public JARDependencyTraverser(IProject anArchiveProject, IProject anEarProject) {
- super();
- this.archiveProject = anArchiveProject;
- this.earProject = anEarProject;
- }
-
- //Returns a map where the keys are instances of IResource, and the values
- // are uris within an EAR
- public Map run() {
- EARNatureRuntime[] earNatures = J2EEProjectUtilities.getReferencingEARProjects(archiveProject);
- if (earNatures == null || earNatures.length == 0 || (earNatures.length == 1 && earNatures[0].getProject() == earProject))
- return Collections.EMPTY_MAP;
-
- result = new HashMap();
- EARNatureRuntime runtime = EARNatureRuntime.getRuntime(earProject);
- if (runtime == null)
- return Collections.EMPTY_MAP;
-
- earEditModel = runtime.getEarEditModelForRead(this);
- try {
- for (int i = 0; i < earNatures.length; i++) {
- if (earNatures[i].getProject() != earProject) {
- traverseClasspath(earNatures[i]);
- }
- }
- return result;
- } finally {
- if (earEditModel != null)
- earEditModel.releaseAccess(this);
- }
- }
-
- private void traverseClasspath(EARNatureRuntime anEARNature) {
- ClasspathModel model = new ClasspathModel(null);
- model.setProject(archiveProject);
- model.setSelectedEARNature(anEARNature);
- ClassPathSelection cpSelection = model.getClassPathSelection();
- Archive anArchive = model.getArchive();
- RuntimeClasspathEntry[] entries = anArchive.getDependencyClassPath();
- Archive referencedArchive = null;
- for (int i = 0; i < entries.length; i++) {
- RuntimeClasspathEntry entry = entries[i];
- referencedArchive = entry.getReferencedArchive();
- if (entry.isWebLib() || referencedArchive == null)
- continue;
- String uri = referencedArchive.getURI();
- if (uri == null)
- continue;
- ClasspathElement elmt = cpSelection.getClasspathElement(uri);
- if (elmt == null)
- continue;
- IResource resource = elmt.getResource();
- if (resource != null)
- addResult(resource, uri);
- }
- }
-
- private void addResult(IResource res, String uri) {
- if (result.containsKey(res))
- return;
- boolean exists = false;
- switch (res.getType()) {
- case IResource.FILE :
- exists = containsJARFile((IFile) res, uri);
- break;
- case IResource.PROJECT :
- exists = earEditModel.hasMappingToProject((IProject) res);
- break;
- default :
- return;
- }
- if (!exists)
- result.put(res, uri);
- }
-
-
- /**
- * @param file
- * @param uri
- * @return
- */
- private boolean containsJARFile(IFile file, String uri) {
- IPath path = null;
- try {
- path = new Path(uri);
- } catch (IllegalArgumentException tooBad) {
- return true;
- }
- IFile existing = earProject.getFile(path);
- return (existing != null && existing.exists());
-
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JavaUtilityJARProjectCreationOperationOld.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JavaUtilityJARProjectCreationOperationOld.java
deleted file mode 100644
index 95c6685b1..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/JavaUtilityJARProjectCreationOperationOld.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/***************************************************************************************************
- * 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 19, 2003
- *
- * To change the template for this generated file go to Window>Preferences>Java>Code Generation>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.common.jdt.internal.integration.JavaProjectCreationDataModel;
-import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationOperation;
-
-public class JavaUtilityJARProjectCreationOperationOld extends J2EEArtifactCreationOperationOld {
- /**
- * @param dataModel
- */
- public JavaUtilityJARProjectCreationOperationOld(J2EEArtifactCreationDataModelOld dataModel) {
- super(dataModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEProjectCreationOperation#createProject(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- JavaProjectCreationDataModel projectModel = (JavaProjectCreationDataModel) ((J2EEArtifactCreationDataModelOld) operationDataModel).getProjectDataModel();
- JavaProjectCreationOperation javaProjectOperation = new JavaProjectCreationOperation(projectModel);
- javaProjectOperation.doRun(monitor);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- createProject(monitor);
- addServerTarget(monitor);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestDataModel.java
deleted file mode 100644
index 20a994cae..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestDataModel.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * 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 13, 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.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModel;
-import org.eclipse.wst.common.frameworks.operations.WTPOperationDataModelEvent;
-
-/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class UpdateManifestDataModel extends WTPOperationDataModel {
-
- /**
- * Project name with manifest to update, type String required.
- */
- public static final String PROJECT_NAME = "UpdateManifestDataModel.PROJECT_NAME"; //$NON-NLS-1$
-
- /**
- * java.util.List of Strings
- */
- public static final String JAR_LIST = "UpdateManifestDataModel.CLASSPATH_LIST"; //$NON-NLS-1$
-
- /**
- * String. This is build from the JAR_LIST property. Never set this property.
- */
- public static final String JAR_LIST_TEXT_UI = "UpdateManifestDataModel.CLASSPATH_LIST_TEXT_UI"; //$NON-NLS-1$
-
- /**
- * Boolean, true merges, false replaces, default is true
- */
- public static final String MERGE = "UpdateManifestDataModel.MERGE"; //$NON-NLS-1$
-
- /**
- * String, no default.
- */
- public static final String MAIN_CLASS = "UpdateManifestDataModel.MAIN_CLASS"; //$NON-NLS-1$
-
- /**
- * String, no default.
- */
- public static final String MANIFEST_FOLDER = "UpdateManifestDataModel.MANIFEST_FOLDER"; //$NON-NLS-1$
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#getDefaultOperation()
- */
- public WTPOperation getDefaultOperation() {
- return new UpdateManifestOperation(this);
- }
-
- protected void init() {
- super.init();
- }
-
- protected void initValidBaseProperties() {
- super.initValidBaseProperties();
- addValidBaseProperty(PROJECT_NAME);
- addValidBaseProperty(JAR_LIST);
- addValidBaseProperty(JAR_LIST_TEXT_UI);
- addValidBaseProperty(MERGE);
- addValidBaseProperty(MAIN_CLASS);
- addValidBaseProperty(MANIFEST_FOLDER);
- }
-
- protected Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(MERGE)) {
- return Boolean.TRUE;
- } else if (propertyName.equals(JAR_LIST)) {
- return new ArrayList();
- } else if (propertyName.equals(JAR_LIST_TEXT_UI)) {
- return getClasspathAsString();
- }
- return super.getDefaultProperty(propertyName);
- }
-
- public void propertyChanged(WTPOperationDataModelEvent event) {
- super.propertyChanged(event);
- if (event.getPropertyName().equals(JAR_LIST)) {
- String text = getClasspathAsString();
- propertyChanged(new WTPOperationDataModelEvent(this, JAR_LIST_TEXT_UI, event.getFlag()));
- }
- }
-
- public IProject getProject() {
- String projectName = (String) getProperty(PROJECT_NAME);
- return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
-
- public String getClasspathAsString() {
- List classpathList = (List) getProperty(JAR_LIST);
- return convertClasspathListToString(classpathList);
- }
-
- public static String convertClasspathListToString(List list) {
- String classpathString = ""; //$NON-NLS-1$
- for (int i = 0; i < list.size(); i++) {
- classpathString += ((String) list.get(i)) + " "; //$NON-NLS-1$
- }
- return classpathString.trim();
- }
-
- public static List convertClasspathStringToList(String string) {
- List list = new ArrayList();
- StringTokenizer tokenizer = new StringTokenizer(string, " "); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- list.add(tokenizer.nextToken());
- }
- return list;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestOperation.java
deleted file mode 100644
index a08eeb7c3..000000000
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/operations/UpdateManifestOperation.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * 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 13, 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.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException;
-import org.eclipse.wst.common.frameworks.operations.WTPOperation;
-
-
-/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class UpdateManifestOperation extends WTPOperation {
-
- public UpdateManifestOperation(UpdateManifestDataModel dataModel) {
- super(dataModel);
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
- UpdateManifestDataModel dataModel = (UpdateManifestDataModel) operationDataModel;
- IProject project = dataModel.getProject();
-
-
- String manifestFolder = dataModel.getStringProperty(UpdateManifestDataModel.MANIFEST_FOLDER);
- IContainer container = project.getFolder( manifestFolder );
- IFile file = container.getFile( new Path(J2EEConstants.MANIFEST_SHORT_NAME));
-
-
-
- String classPathValue = dataModel.getClasspathAsString();
- try {
- ArchiveManifest mf = J2EEProjectUtilities.readManifest(file);
-
- if (mf == null)
- mf = new ArchiveManifestImpl();
- mf.addVersionIfNecessary();
- if (dataModel.getBooleanProperty(UpdateManifestDataModel.MERGE)) {
- mf.mergeClassPath(ArchiveUtil.getTokens(classPathValue));
- } else {
- mf.setClassPath(classPathValue);
- }
- if (dataModel.isSet(UpdateManifestDataModel.MAIN_CLASS)) {
- mf.setMainClass(dataModel.getStringProperty(UpdateManifestDataModel.MAIN_CLASS));
- }
-
- J2EEProjectUtilities.writeManifest(file, mf);
- } catch (java.io.IOException ex) {
- throw new WFTWrappedException(ex);
- }
- }
-
-} \ No newline at end of file

Back to the top