diff options
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/earproject/org')
94 files changed, 0 insertions, 16377 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddArchiveProjectToEAROperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddArchiveProjectToEAROperation.java deleted file mode 100644 index ed69316b8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddArchiveProjectToEAROperation.java +++ /dev/null @@ -1,324 +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.internal.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.jem.util.logger.proxy.Logger; -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.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.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; - -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(AddArchiveToEARDataModel.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(AddArchiveToEARDataModel.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/internal/operations/AddArchiveProjectsToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddArchiveProjectsToEARDataModel.java deleted file mode 100644 index 462ab5ebf..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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.internal.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/internal/operations/AddArchiveProjectsToEAROperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddArchiveProjectsToEAROperation.java deleted file mode 100644 index 028425e5f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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/internal/operations/AddArchiveToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddArchiveToEARDataModel.java deleted file mode 100644 index 9cee842f9..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddArchiveToEARDataModel.java +++ /dev/null @@ -1,187 +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.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.earcreation.IEARNatureConstants; -import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEditOperationDataModel; -import org.eclipse.jst.j2ee.internal.servertarget.ServerTargetDataModel; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; - -/** - * @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; - modProject = StructureEdit.getContainingProject(wbComp); - 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/internal/operations/AddComponentToEnterpriseApplicationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationDataModel.java deleted file mode 100644 index d62823c32..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationDataModel.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.util.ArrayList; - -import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEditOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.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 static final String EAR_PROJECT_NAME = "AddComponentToEnterpriseApplicationDataModel.EAR_PROJECT_NAME"; - //Used for adding module componenet to Enterprise Application during module creation - - public AddComponentToEnterpriseApplicationDataModel() { - super(); - - } - protected void initValidBaseProperties() { - super.initValidBaseProperties(); - addValidBaseProperty(MODULE_LIST); - addValidBaseProperty(EAR_MODULE_NAME); - addValidBaseProperty(ARCHIVE_MODULE); - addValidBaseProperty(EAR_PROJECT_NAME); - } - - 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/internal/operations/AddComponentToEnterpriseApplicationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOperation.java deleted file mode 100644 index e7331571b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOperation.java +++ /dev/null @@ -1,169 +0,0 @@ -package org.eclipse.jst.j2ee.application.internal.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.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.application.WebModule; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.application.ApplicationPackage; -import org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEditOperation; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditOperationDataModel; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; - -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) { - StructureEdit moduleCore = null; - try{ - String earProj = operationDataModel.getStringProperty(AddComponentToEnterpriseApplicationDataModel.EAR_PROJECT_NAME); - IProject proj = ProjectUtilities.getProject(earProj); - - moduleCore = StructureEdit.getStructureEditForWrite(proj); - WorkbenchComponent earComp = moduleCore.findComponentByName(operationDataModel.getStringProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME)); - - AddComponentToEnterpriseApplicationDataModel dm = (AddComponentToEnterpriseApplicationDataModel)getOperationDataModel(); - IPath runtimePath = new Path(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 = ComponentcoreFactory.eINSTANCE.createReferencedComponent(); - WorkbenchComponent wc = (WorkbenchComponent)list.get(i); - rc.setHandle(normalize(earComp, wc)); - rc.setRuntimePath(runtimePath); - earComp.getReferencedComponents().add(rc); - } - } - moduleCore.saveIfNecessary(monitor); - } finally { - if (null != moduleCore) { - moduleCore.dispose(); - } - } - updateEARDD(monitor); - } - - protected void updateEARDD(IProgressMonitor monitor){ - - EARArtifactEdit earEdit = null; - try { - String earProj = operationDataModel.getStringProperty(AddComponentToEnterpriseApplicationDataModel.EAR_PROJECT_NAME); - IProject proj = ProjectUtilities.getProject(earProj); - ComponentHandle handle = ComponentHandle.create(proj,operationDataModel.getStringProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME)); - earEdit = EARArtifactEdit.getEARArtifactEditForWrite(handle); - if(earEdit != null){ - Application application = earEdit.getApplication(); - AddComponentToEnterpriseApplicationDataModel dm = (AddComponentToEnterpriseApplicationDataModel)getOperationDataModel(); - List list = (List)dm.getProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST); - if (list != null && list.size() > 0) { - for (int i = 0; i < list.size(); i++) { - WorkbenchComponent wc = (WorkbenchComponent)list.get(i); - addModule(application, wc); - } - } - } - earEdit.saveIfNecessary(monitor); - } - catch(Exception e){ - Logger.getLogger().logError(e); - } finally { - if(earEdit != null) - earEdit.dispose(); - } - } - protected Module createNewModule(WorkbenchComponent wc) { - - String type = wc.getComponentType().getComponentTypeId(); - if ( type.equals(IModuleConstants.JST_WEB_MODULE) ){ - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createWebModule(); - }else if ( type.equals(IModuleConstants.JST_EJB_MODULE)) { - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createEjbModule(); - }else if ( type.equals(IModuleConstants.JST_APPCLIENT_MODULE)) { - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createJavaClientModule(); - }else if ( type.equals(IModuleConstants.JST_CONNECTOR_MODULE)) { - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createConnectorModule(); - } - return null; - } - - protected void addModule(Application application, WorkbenchComponent wc) { - Application dd = application; - - Module m = createNewModule(wc); - - String name = wc.getName(); - String type = wc.getComponentType().getComponentTypeId(); - - if ( type.equals(IModuleConstants.JST_WEB_MODULE) ){ - name += ".war"; //$NON-NLS-1$ - }else if ( type.equals(IModuleConstants.JST_EJB_MODULE)) { - name += ".jar"; //$NON-NLS-1$ - }else if ( type.equals(IModuleConstants.JST_APPCLIENT_MODULE)) { - name += ".jar"; //$NON-NLS-1$ - }else if ( type.equals(IModuleConstants.JST_CONNECTOR_MODULE)) { - name += ".rar"; //$NON-NLS-1$ - } - - if( m!= null){ - m.setUri(name); - if (m instanceof WebModule) { - - List props = wc.getComponentType().getProperties(); - String contextroot = ""; //$NON-NLS-1$ - for( int i=0; i< props.size(); i++){ - Property prop = (Property)props.get(i); - if( prop.getName().equals(J2EEConstants.CONTEXTROOT)){ - contextroot = prop.getValue(); - break; - } - } - ((WebModule) m).setContextRoot(contextroot); - } - dd.getModules().add(m); - } - } - - - - private URI normalize(WorkbenchComponent aComponent, WorkbenchComponent aReferencedComponent) { - // same project doesn't matter - if(StructureEdit.getContainingProject(aComponent) == StructureEdit.getContainingProject(aReferencedComponent)) - return aReferencedComponent.getHandle(); - // different project, fully qualify - return ModuleURIUtil.fullyQualifyURI(aReferencedComponent); - - } - - public IProject getProject() { - String projName = operationDataModel.getStringProperty(ArtifactEditOperationDataModel.PROJECT_NAME ); - return ProjectUtilities.getProject( projName ); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddModuleToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddModuleToEARDataModel.java deleted file mode 100644 index 8907c7352..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.operations; - -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditOperationDataModel; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; - -/** - * - */ -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().getComponentTypeId() == IModuleConstants.JST_WEB_MODULE) { - //model = AddWebModuleToEARDataModel.createAddWebModuleToEARDataModel(getStringProperty(COMPONENT_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().getComponentTypeId() == IModuleConstants.JST_WEB_MODULE) - return "war"; //$NON-NLS-1$ - if (wbComp != null && wbComp.getComponentType().getComponentTypeId() == 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/internal/operations/AddUtilityProjectToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddUtilityProjectToEARDataModel.java deleted file mode 100644 index 621d738ed..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.internal.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.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; - -/** - * @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().getComponentTypeId().equals(IModuleConstants.JST_UTILITY_MODULE); - } - - private boolean isWebOrClientModule(WorkbenchComponent wbComp) { - String typeID = wbComp.getComponentType().getComponentTypeId(); - 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/internal/operations/AddWebModuleToEARDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddWebModuleToEARDataModel.java deleted file mode 100644 index 8acf9243b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.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/internal/operations/AppClientModuleExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AppClientModuleExportDataModel.java deleted file mode 100644 index 6657f1f0d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jst.j2ee.applicationclient.internal.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.internal.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/internal/operations/ClassPathSelection.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java deleted file mode 100644 index beaf8317b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java +++ /dev/null @@ -1,600 +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.internal.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.jem.util.logger.proxy.Logger; -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; - - -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/internal/operations/ClasspathElement.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClasspathElement.java deleted file mode 100644 index 0db4f2cc8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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/internal/operations/ClasspathSelectionHelper.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClasspathSelectionHelper.java deleted file mode 100644 index 0f749f4dc..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClasspathSelectionHelper.java +++ /dev/null @@ -1,118 +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>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.application.internal.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.jem.util.logger.proxy.Logger; -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; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>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/internal/operations/DefaultJ2EEComponentCreationOp.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultJ2EEComponentCreationOp.java deleted file mode 100644 index db9c78a4b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultJ2EEComponentCreationOp.java +++ /dev/null @@ -1,113 +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.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.earcreation.IDefaultJ2EEComponentCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.activities.WTPActivityBridge; - -public class DefaultJ2EEComponentCreationOp extends AbstractDataModelOperation implements IDefaultJ2EEComponentCreationDataModelProperties { - - 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$ - - public DefaultJ2EEComponentCreationOp(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - IDataModel model = getDataModel(); - if (model.getBooleanProperty(CREATE_EJB)) { - IDataModel ejbModel = model.getNestedModel(NESTED_MODEL_EJB); - ejbModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_NAME, model.getStringProperty(EJB_COMPONENT_NAME)); - ejbModel.setProperty(IJ2EEComponentCreationDataModelProperties.ADD_TO_EAR, Boolean.FALSE); - createEJBComponent(ejbModel, monitor); - } - if (model.getBooleanProperty(CREATE_WEB)) { - IDataModel webModel = model.getNestedModel(NESTED_MODEL_WEB); - webModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_NAME, model.getStringProperty(WEB_COMPONENT_NAME)); - webModel.setProperty(IJ2EEComponentCreationDataModelProperties.ADD_TO_EAR, Boolean.FALSE); - createWebJ2EEComponent(webModel, monitor); - } - if (model.getBooleanProperty(CREATE_CONNECTOR)) { - IDataModel conModel = model.getNestedModel(NESTED_MODEL_JCA); - conModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_NAME, model.getStringProperty(CONNECTOR_COMPONENT_NAME)); - conModel.setProperty(IJ2EEComponentCreationDataModelProperties.ADD_TO_EAR, Boolean.FALSE); - createRarJ2EEComponent(conModel, monitor); - } - if (model.getBooleanProperty(CREATE_APPCLIENT)) { - IDataModel clientModel = model.getNestedModel(NESTED_MODEL_CLIENT); - clientModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_NAME, model.getStringProperty(APPCLIENT_COMPONENT_NAME)); - clientModel.setProperty(IJ2EEComponentCreationDataModelProperties.ADD_TO_EAR, Boolean.FALSE); - createAppClientComponent(clientModel, monitor); - } - } catch (Exception e) { - Logger.getLogger().log(e.getMessage()); - } - return OK_STATUS; - } - - /** - * @param model - */ - private void createEJBComponent(IDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException, ExecutionException { - model.getDefaultOperation().execute(monitor, null); - WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true); - } - - /** - * @param model - */ - private void createWebJ2EEComponent(IDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException, ExecutionException { - model.getDefaultOperation().execute(monitor, null); - WTPActivityBridge.getInstance().enableActivity(WEB_DEV_ACTIVITY_ID, true); - } - - /** - * @param model - */ - private void createRarJ2EEComponent(IDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException, ExecutionException { - model.getDefaultOperation().execute(monitor, null); - WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true); - } - - /** - * @param model - */ - private void createAppClientComponent(IDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException, ExecutionException { - model.getDefaultOperation().execute(monitor, null); - WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true); - - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultJ2EEComponentCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultJ2EEComponentCreationOperation.java deleted file mode 100644 index de7b26d14..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultJ2EEComponentCreationOperation.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Created on Mar 23, 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.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentCreationDataModel; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentCreationOperation; -import org.eclipse.jst.j2ee.internal.earcreation.DefaultJ2EEComponentCreationDataModel; -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.internal.operations.WTPOperation; - -public class DefaultJ2EEComponentCreationOperation 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 DefaultJ2EEComponentCreationOperation(DefaultJ2EEComponentCreationDataModel 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 { - DefaultJ2EEComponentCreationDataModel model = (DefaultJ2EEComponentCreationDataModel) operationDataModel; - if (model.getBooleanProperty(DefaultJ2EEComponentCreationDataModel.CREATE_EJB)){ - J2EEComponentCreationDataModel ejbModel = model.getEjbModel(); - ejbModel.setProperty(J2EEComponentCreationDataModel.PROJECT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.PROJECT_NAME)); - ejbModel.setProperty(J2EEComponentCreationDataModel.COMPONENT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EJB_COMPONENT_NAME)); - ejbModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - ejbModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_DEPLOY_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - ejbModel.setProperty(J2EEComponentCreationDataModel.ADD_TO_EAR, - Boolean.TRUE); - createEJBComponent(ejbModel, monitor); - } - if (model.getBooleanProperty(DefaultJ2EEComponentCreationDataModel.CREATE_WEB)){ - J2EEComponentCreationDataModel webModel = model.getWebModel(); - webModel.setProperty(J2EEComponentCreationDataModel.PROJECT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.PROJECT_NAME)); - webModel.setProperty(J2EEComponentCreationDataModel.COMPONENT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.WEB_COMPONENT_NAME)); - webModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - webModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_DEPLOY_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - webModel.setProperty(J2EEComponentCreationDataModel.ADD_TO_EAR, - Boolean.TRUE); - createWebJ2EEComponent(webModel, monitor); - } - if (model.getBooleanProperty(DefaultJ2EEComponentCreationDataModel.CREATE_CONNECTOR)){ - J2EEComponentCreationDataModel conModel = model.getJCAModel(); - conModel.setProperty(J2EEComponentCreationDataModel.PROJECT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.PROJECT_NAME)); - conModel.setProperty(J2EEComponentCreationDataModel.COMPONENT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.CONNECTOR_COMPONENT_NAME)); - conModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - conModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_DEPLOY_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - conModel.setProperty(J2EEComponentCreationDataModel.ADD_TO_EAR, - Boolean.TRUE); - createRarJ2EEComponent(conModel, monitor); - } - if (model.getBooleanProperty(DefaultJ2EEComponentCreationDataModel.CREATE_APPCLIENT)) { - AppClientComponentCreationDataModel clientModel = model.getClientModel(); - clientModel.setProperty(J2EEComponentCreationDataModel.PROJECT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.PROJECT_NAME)); - clientModel.setProperty(J2EEComponentCreationDataModel.COMPONENT_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.APPCLIENT_COMPONENT_NAME)); - clientModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - clientModel.setProperty(J2EEComponentCreationDataModel.EAR_MODULE_DEPLOY_NAME, - model.getStringProperty(DefaultJ2EEComponentCreationDataModel.EAR_COMPONENT_NAME)); - clientModel.setProperty(J2EEComponentCreationDataModel.ADD_TO_EAR, - Boolean.TRUE); - createAppClientComponent(clientModel, monitor); - } - } - /** - * @param model - */ - private void createEJBComponent(J2EEComponentCreationDataModel 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 createWebJ2EEComponent(J2EEComponentCreationDataModel 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 createRarJ2EEComponent(J2EEComponentCreationDataModel 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, J2EEComponentCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - if (extension != null) { - J2EEComponentCreationOperation op = extension.createProjectCreationOperation(model); - if (op != null) - op.doRun(monitor); - } - } - - /** - * @param model - */ - private void createAppClientComponent(J2EEComponentCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - AppClientComponentCreationOperation op = new AppClientComponentCreationOperation((AppClientComponentCreationDataModel) 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/internal/operations/DefaultModuleProjectCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultModuleProjectCreationDataModel.java deleted file mode 100644 index a121e6d48..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultModuleProjectCreationDataModel.java +++ /dev/null @@ -1,546 +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.internal.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.internal.creation.AppClientComponentCreationDataModel; -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.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.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 J2EEComponentCreationDataModel ejbModel; - private J2EEComponentCreationDataModel webModel; - private J2EEComponentCreationDataModel jcaModel; - private J2EEComponentCreationDataModel 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 AppClientComponentCreationDataModel(); - addNestedModel(NESTED_MODEL_CLIENT, clientModel); - EjbModuleExtension ejbExt = EarModuleManager.getEJBModuleExtension(); - if (ejbExt != null) { - //TODO: port to idatamodel structure - // ejbModel = ejbExt.createProjectDataModel(); - if (ejbModel != null) - addNestedModel(NESTED_MODEL_EJB, ejbModel); - } - WebModuleExtension webExt = EarModuleManager.getWebModuleExtension(); - if (webExt != null) { - //TODO: port to idatamodel structure - // webModel = webExt.createProjectDataModel(); - if (webModel != null) - addNestedModel(NESTED_MODEL_WEB, webModel); - } - JcaModuleExtension rarExt = EarModuleManager.getJCAModuleExtension(); - if (rarExt != null) { - //TODO: port to idatamodel structure - //jcaModel = rarExt.createProjectDataModel(); - if (jcaModel != null) - addNestedModel(NESTED_MODEL_JCA, jcaModel); - } - } - - private void addNestedModel(String modelName, J2EEComponentCreationDataModel moduleModel) { - moduleModel.setProperty(J2EEComponentCreationDataModel.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(J2EEComponentCreationDataModel.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) { - J2EEComponentCreationDataModel modModule = getNestedModel(flag); - if (modModule != null) { - String projName = ensureUniqueProjectName(name); - modModule.setProperty(J2EEComponentCreationDataModel.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(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - if (webModel != null) - webModel.setProperty(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - if (jcaModel != null) - jcaModel.setProperty(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - clientModel.setProperty(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - } - - /** - * @param flag - * @param projectName - */ - private void setNestedProjectName(int flag, String projectName) { - J2EEComponentCreationDataModel model = getNestedModel(flag); - if (model != null) { - model.setProperty(J2EEComponentCreationDataModel.PROJECT_NAME, projectName); - } - } - - /** - * @param flag - */ - private IStatus validateNestedProjectName(int flag) { - J2EEComponentCreationDataModel 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(J2EEComponentCreationDataModel.PROJECT_NAME); - } - } - return J2EEPlugin.OK_STATUS; - } - - private Object getNestedProjectName(int flag) { - J2EEComponentCreationDataModel model = getNestedModel(flag); - if (model != null) - return model.getProperty(J2EEComponentCreationDataModel.PROJECT_NAME); - return null; - } - - private J2EEComponentCreationDataModel 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 AppClientComponentCreationDataModel getClientModel() { - return (AppClientComponentCreationDataModel)clientModel; - } - - /** - * @return Returns the ejbModel. - */ - public J2EEComponentCreationDataModel getEjbModel() { - return ejbModel; - } - - /** - * @return Returns the rarModel. - */ - public J2EEComponentCreationDataModel getJCAModel() { - return jcaModel; - } - - /** - * @return Returns the webModel. - */ - public J2EEComponentCreationDataModel 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/internal/operations/DefaultModuleProjectCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultModuleProjectCreationOperation.java deleted file mode 100644 index b30acfb1a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentCreationDataModel; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentCreationOperation; -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.internal.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(J2EEComponentCreationDataModel 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(J2EEComponentCreationDataModel 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(J2EEComponentCreationDataModel 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, J2EEComponentCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - if (extension != null) { - J2EEComponentCreationOperation op = extension.createProjectCreationOperation(model); - if (op != null) - op.doRun(monitor); - } - } - - /** - * @param model - */ - private void createAppClientModuleProject(J2EEComponentCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - AppClientComponentCreationOperation op = new AppClientComponentCreationOperation((AppClientComponentCreationDataModel) 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/internal/operations/EARComponentCreationOp.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentCreationOp.java deleted file mode 100644 index ea44eaaa0..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentCreationOp.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.lang.reflect.InvocationTargetException; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -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.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.datamodel.properties.IEarComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.J2EEVersionUtil; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationOperationEx; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class EARComponentCreationOp extends ComponentCreationOperationEx implements IEarComponentCreationDataModelProperties{ - - public EARComponentCreationOp(IDataModel model) { - super(model); - } - /* (non-Javadoc) - * @see org.eclipse.jst.j2ee.application.operations.J2EEComponentCreationOperation#createAndLinkJ2EEComponents() - */ - protected void createAndLinkJ2EEComponents() throws CoreException { - IVirtualComponent component = ComponentCore.createComponent(getProject(), getModuleDeployName()); - component.create(0, null); - //create and link META-INF folder - IVirtualFolder root = component.getFolder(new Path("/")); //$NON-NLS-1$ - root.createLink(new Path("/" + getModuleName()), 0, null); //$NON-NLS-1$ - - IVirtualFolder metaInfFolder = root.getFolder(J2EEConstants.META_INF); - metaInfFolder.create(IResource.FORCE, null); - } - - public IProject getProject() { - String projName = model.getStringProperty(PROJECT_NAME); - return ProjectUtilities.getProject( projName ); - } - - protected void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - EARArtifactEdit earEdit = null; - try { - ComponentHandle handle = ComponentHandle.create(getProject(),getDataModel().getStringProperty(COMPONENT_DEPLOY_NAME)); - earEdit = EARArtifactEdit.getEARArtifactEditForWrite(handle); - Integer version = (Integer)getDataModel().getProperty(COMPONENT_VERSION); - earEdit.createModelRoot(version.intValue()); - earEdit.save(monitor); - } finally { - if (earEdit != null) - earEdit.dispose(); - } - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - super.execute(IModuleConstants.JST_EAR_MODULE, monitor, info); - if (getDataModel().getBooleanProperty(CREATE_DEFAULT_FILES)) { - createDeploymentDescriptor(monitor); - } - addModulesToEAR(monitor); - } catch (CoreException e) { - Logger.getLogger().log(e.getMessage()); - } catch (InvocationTargetException e) { - Logger.getLogger().log(e.getMessage()); - } catch (InterruptedException e) { - Logger.getLogger().log(e.getMessage()); - } - return OK_STATUS; - } - - private void addModulesToEAR(IProgressMonitor monitor) { - try{ - AddComponentToEnterpriseApplicationDataModel dm = new AddComponentToEnterpriseApplicationDataModel(); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.PROJECT_NAME, model.getProperty(PROJECT_NAME)); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_PROJECT_NAME, model.getProperty(PROJECT_NAME)); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME, model.getProperty(COMPONENT_NAME)); - List modulesList = (List)model.getProperty(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 ){ - //Default - } - - /* (non-Javadoc) - * @see org.eclipse.jst.j2ee.application.operations.J2EEComponentCreationOperation#getVersion() - */ - protected String getVersion() { - int version = getDataModel().getIntProperty(COMPONENT_VERSION); - return J2EEVersionUtil.getJ2EETextVersion(version); - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - -/* protected void setupComponentType(String typeID) { - IVirtualComponent component = ComponentCore.createComponent(getProject(), getModuleDeployName()); - ComponentType componentType = ComponentcoreFactory.eINSTANCE.createComponentType(); - componentType.setComponentTypeId(typeID); - componentType.setVersion(getVersion()); - StructureEdit.setComponentType(component, componentType); - }*/ - - public String getModuleName() { - return getDataModel().getStringProperty(COMPONENT_NAME); - } - - public String getModuleDeployName() { - return getDataModel().getStringProperty(COMPONENT_DEPLOY_NAME); - } - protected List getProperties() { - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentCreationOperation.java deleted file mode 100644 index 9984f9c05..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentCreationOperation.java +++ /dev/null @@ -1,131 +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.internal.operations; - -import java.lang.reflect.InvocationTargetException; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentCreationDataModel; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -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.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.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 { - IVirtualComponent component = ComponentCore.createComponent(getProject(), getModuleDeployName()); - component.create(0, null); - //create and link META-INF folder - IVirtualFolder root = component.getFolder(new Path("/")); //$NON-NLS-1$ - root.createLink(new Path("/" + getModuleName()), 0, null); - - IVirtualFolder metaInfFolder = root.getFolder(J2EEConstants.META_INF); - metaInfFolder.create(IResource.FORCE, null); - } - - public IProject getProject() { - String projName = operationDataModel.getStringProperty(EARComponentCreationDataModel.PROJECT_NAME ); - return ProjectUtilities.getProject( projName ); - } - - protected void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - EARArtifactEdit earEdit = null; - try { - EARComponentCreationDataModel dm = (EARComponentCreationDataModel)getOperationDataModel(); - ComponentHandle handle = ComponentHandle.create(getProject(), operationDataModel.getStringProperty(EARComponentCreationDataModel.COMPONENT_DEPLOY_NAME)); - earEdit = EARArtifactEdit.getEARArtifactEditForWrite(handle); - Integer version = (Integer)operationDataModel.getProperty(AppClientComponentCreationDataModel.COMPONENT_VERSION); - earEdit.createModelRoot(version.intValue()); - earEdit.save(monitor); - } finally { - if (earEdit != null) - earEdit.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, - getOperationDataModel().getProperty(EARComponentCreationDataModel.PROJECT_NAME)); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_PROJECT_NAME, - getOperationDataModel().getProperty(EARComponentCreationDataModel.PROJECT_NAME)); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME, - getOperationDataModel().getProperty(EARComponentCreationDataModel.COMPONENT_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); - } - public URI getComponentHandle(){ - StructureEdit moduleCore = null; - - try { - EARComponentCreationDataModel dm = (EARComponentCreationDataModel)getOperationDataModel(); - moduleCore = StructureEdit.getStructureEditForRead(getProject()); - WorkbenchComponent earComp = moduleCore.findComponentByName(operationDataModel.getStringProperty(EARComponentCreationDataModel.COMPONENT_DEPLOY_NAME)); - return earComp.getHandle(); - - } finally { - if (null != moduleCore) { - moduleCore.dispose(); - } - - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EnterpriseApplicationExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EnterpriseApplicationExportDataModel.java deleted file mode 100644 index 77b3642c1..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EnterpriseApplicationExportDataModel.java +++ /dev/null @@ -1,96 +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.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jem.util.logger.proxy.Logger; -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.internal.operations.WTPOperation; - -/** - * 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/internal/operations/EnterpriseApplicationImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EnterpriseApplicationImportDataModel.java deleted file mode 100644 index c044b959b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EnterpriseApplicationImportDataModel.java +++ /dev/null @@ -1,820 +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.internal.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.internal.creation.AppClientModuleImportDataModel; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.IApplicationClientNatureConstants; -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.common.XMLResource; -import org.eclipse.jst.j2ee.internal.earcreation.EARComponentCreationDataModel; -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.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelEvent; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelListener; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; -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); - EARComponentCreationDataModel earProjectModel = (EARComponentCreationDataModel) getJ2eeArtifactCreationDataModel(); - if (getModuleFile() != null) { - earProjectModel.setIntProperty(EARComponentCreationDataModel.COMPONENT_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 J2EEComponentCreationDataModel) - ((J2EEComponentCreationDataModel) nestedModel.getJ2eeArtifactCreationDataModel()).setProperty(J2EEComponentCreationDataModel.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_NAME, 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(J2EEComponentCreationDataModel.PROJECT_NAME)); - //model.setProperty(J2EEComponentCreationDataModel.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(J2EEComponentCreationDataModel.PROJECT_NAME)); - //model.setProperty(J2EEComponentCreationDataModel.PROJECT_LOCATION, newPath.toOSString()); - } else { - //model.setProperty(J2EEComponentCreationDataModel.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(J2EEComponentCreationDataModel.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_NAME, earProjectName); - model.setBooleanProperty(J2EEComponentCreationDataModel.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 J2EEComponentCreationDataModel createJ2EEProjectCreationDataModel() { - return new EARComponentCreationDataModel(); - } - - 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/internal/operations/ExtendedImportFactory.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ExtendedImportFactory.java deleted file mode 100644 index 1c1113c77..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ExtendedImportFactory.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 - *******************************************************************************/ -/* - * Created on Jun 21, 2004 - * @author jsholl - */ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -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; - - -/** - * @author jsholl - */ -public interface ExtendedImportFactory { - - public Archive openArchive(ArchiveOptions archiveOptions, String uri) throws OpenFailureException; - - public void importModuleFile(J2EEModuleImportDataModel model, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException; - - public int getSpecVersion(Archive archive); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ExtendedImportRegistry.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ExtendedImportRegistry.java deleted file mode 100644 index bd18c95d8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ExtendedImportRegistry.java +++ /dev/null @@ -1,95 +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 Jun 21, 2004 - * @author jsholl - */ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jem.util.RegistryReader; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; - -/** - * @author jsholl - */ -public class ExtendedImportRegistry extends RegistryReader { - - private static final String PLUGIN_ID = J2EEPlugin.PLUGIN_ID; - - private static final String EXTENSION_ID = "ExtendedModuleImport"; //$NON-NLS-1$ - - private static final String FACTORY_CLASS = "factoryClass"; //$NON-NLS-1$ - - private static final String MODULE_TYPE = "moduleType"; //$NON-NLS-1$ - - public static final String EJB_TYPE = "EJB"; //$NON-NLS-1$ - - private List ejbConfigurationElements = null; - - private List ejbFactories = null; - - private static ExtendedImportRegistry instance = null; - - public static ExtendedImportRegistry getInstance() { - //if (null == instance) { - instance = new ExtendedImportRegistry(); - //} - return instance; - } - - private ExtendedImportRegistry() { - super(PLUGIN_ID, EXTENSION_ID); - readRegistry(); - } - - /** - * returns a List of ExtendedFactories; - * - * @param type - * @return - */ - public List getFactories(String type) { - if (type.equals(EJB_TYPE)) { - if (ejbFactories == null) { - ejbFactories = new ArrayList(); - for (int i = 0; null != ejbConfigurationElements && i < ejbConfigurationElements.size(); i++) { - try { - ejbFactories.add(((IConfigurationElement) ejbConfigurationElements.get(i)).createExecutableExtension(FACTORY_CLASS)); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - } - return ejbFactories; - } - return null; - } - - public boolean readElement(IConfigurationElement element) { - String moduleType = element.getAttribute(MODULE_TYPE); - if (null != moduleType) { - if (moduleType.equals(EJB_TYPE)) { - if (ejbConfigurationElements == null) { - ejbConfigurationElements = new ArrayList(); - } - ejbConfigurationElements.add(element); - return true; - } - } - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationDataModel.java deleted file mode 100644 index b68a13ce2..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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/internal/operations/FlexibleJavaProjectCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationDataModelProvider.java deleted file mode 100644 index 2d237c6c0..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationDataModelProvider.java +++ /dev/null @@ -1,83 +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.internal.operations; - -import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.servertarget.J2EEProjectServerTargetDataModelProvider; -import org.eclipse.jst.j2ee.project.datamodel.properties.IFlexibleJavaProjectCreationDataModelProperties; -import org.eclipse.jst.j2ee.project.datamodel.properties.IJ2EEProjectServerTargetDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class FlexibleJavaProjectCreationDataModelProvider extends FlexibleProjectCreationDataModelProvider implements IFlexibleJavaProjectCreationDataModelProperties{ - - public FlexibleJavaProjectCreationDataModelProvider() { - super(); - } - public void init() { - super.init(); - IDataModel serverTargetModel = DataModelFactory.createDataModel(new J2EEProjectServerTargetDataModelProvider()); - model.addNestedModel(NESTED_MODEL_SERVER_TARGET, serverTargetModel); - } - - protected void initNestedProjectModel() { - IDataModel javaProjModel = DataModelFactory.createDataModel(new JavaProjectCreationDataModelProvider()); - model.addNestedModel(NESTED_MODEL_PROJECT_CREATION, javaProjModel); - } - - public String[] getPropertyNames() { - String[] props = new String[]{NESTED_MODEL_SERVER_TARGET, ADD_SERVER_TARGET, SERVER_TARGET_ID}; - return combineProperties(super.getPropertyNames(), props); - } - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(ADD_SERVER_TARGET)) { - return Boolean.TRUE; - } - return super.getDefaultProperty(propertyName); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean status = super.propertySet(propertyName, propertyValue); - if (PROJECT_NAME.equals(propertyName)) { - IDataModel projModel = (IDataModel)model.getNestedModel(NESTED_MODEL_SERVER_TARGET); - projModel.setProperty(IJ2EEProjectServerTargetDataModelProperties.PROJECT_NAME, propertyValue); - } else if (SERVER_TARGET_ID.equals(propertyName)) { - IDataModel projModel = (IDataModel)model.getNestedModel(NESTED_MODEL_SERVER_TARGET); - projModel.setProperty(IJ2EEProjectServerTargetDataModelProperties.RUNTIME_TARGET_ID, propertyValue); - } - return status; - } - public IDataModelOperation getDefaultOperation() { - return new FlexibleJavaProjectCreationOperation(model); - } - - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName){ - if (propertyName.equals(SERVER_TARGET_ID)) { - IDataModel serverTargetModel = model.getNestedModel(NESTED_MODEL_SERVER_TARGET); - return serverTargetModel.getValidPropertyDescriptors(IJ2EEProjectServerTargetDataModelProperties.RUNTIME_TARGET_ID); - } - return null; - } - -// public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) { -// if (propertyName.equals(SERVER_TARGET_ID)) { -// IDataModel serverTargetModel = model.getNestedModel(NESTED_MODEL_SERVER_TARGET); -// return serverTargetModel.getPropertyDescriptor(IJ2EEProjectServerTargetDataModelProperties.RUNTIME_TARGET_ID); -// -// //super.getPropertyDescriptor(propertyName); -// } -// return super.getPropertyDescriptor(propertyName); -// } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationOperation.java deleted file mode 100644 index 20221220d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationOperation.java +++ /dev/null @@ -1,54 +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.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.project.datamodel.properties.IFlexibleJavaProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class FlexibleJavaProjectCreationOperation extends FlexibleProjectCreationOp implements IFlexibleJavaProjectCreationDataModelProperties{ - - public FlexibleJavaProjectCreationOperation(IDataModel model) { - super(model); - } - private void addServerTarget(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException, ExecutionException{ - IDataModel serverModel = model.getNestedModel(NESTED_MODEL_SERVER_TARGET); - IDataModelOperation op = (IDataModelOperation)serverModel.getDefaultOperation(); - op.execute(monitor, null); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - IStatus status = super.execute(monitor, info); - try { - addServerTarget(monitor); - } catch (ExecutionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return status; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationDataModel.java deleted file mode 100644 index 748dcfdd6..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationDataModel.java +++ /dev/null @@ -1,158 +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.internal.operations; - -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.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.project.J2EECreationResourceHandler; -import org.eclipse.jst.j2ee.internal.servertarget.J2EEProjectServerTargetDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.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"; //$NON-NLS-1$ - public static final String PROJECT_LOCATION = "FlexibleProjectCreationDataModel.PROJECT_LOCATION"; //$NON-NLS-1$ - 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) { - return validateProjectName(projectName); - } - return WTPCommonPlugin.OK_STATUS; - } - - - protected IStatus validateProjectName(String projectName) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IStatus status = workspace.validateName(projectName, IResource.PROJECT); - if (!status.isOK()) - return status; - - if (ProjectUtilities.getProject(projectName).exists()) - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_EXISTS_ERROR, new Object[] { projectName })); - - if ( projectName.indexOf("#") != -1 ){ //$NON-NLS-1$ - String errorMessage = J2EECreationResourceHandler.getString("InvalidCharsError"); //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(errorMessage); - } - return 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); - }else if(PROJECT_LOCATION.equals(propertyName)) { - projectDataModel.setProperty(ProjectCreationDataModel.PROJECT_LOCATION, 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/internal/operations/FlexibleProjectCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationDataModelProvider.java deleted file mode 100644 index a22ca87ff..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationDataModelProvider.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.eclipse.jst.j2ee.application.internal.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.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.properties.IFlexibleProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationProperties; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class FlexibleProjectCreationDataModelProvider extends AbstractDataModelProvider - implements IFlexibleProjectCreationDataModelProperties { - - public FlexibleProjectCreationDataModelProvider() { - super(); - - } - public void init() { - super.init(); - initNestedProjectModel(); - } - protected void initNestedProjectModel() { - IDataModel projModel = DataModelFactory.createDataModel(new ProjectCreationDataModelProvider()); - model.addNestedModel(NESTED_MODEL_PROJECT_CREATION, projModel); - } - - public String[] getPropertyNames() { - return new String[] {PROJECT_NAME, PROJECT_LOCATION, NESTED_MODEL_PROJECT_CREATION}; - } - - public Object getDefaultProperty(String propertyName) { - if (PROJECT_LOCATION.equals(propertyName)) { - return getDefaultLocation(); - } - return super.getDefaultProperty(propertyName); - } - public boolean propertySet(String propertyName, Object propertyValue) { - boolean status = super.propertySet(propertyName, propertyValue); - if (PROJECT_NAME.equals(propertyName)) { - IDataModel projModel = (IDataModel)model.getNestedModel(NESTED_MODEL_PROJECT_CREATION); - projModel.setProperty(IProjectCreationProperties.PROJECT_NAME, propertyValue); - } - return status; - } - - public IStatus validate(String propertyName) { - if (PROJECT_NAME.equals(propertyName)) { - return validateProjectName(); - } - return super.validate(propertyName); - } - - private IStatus validateProjectName() { - String projectName = getStringProperty(PROJECT_NAME); - if (projectName != null && projectName.length() != 0) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if (project != null && project.exists()) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_EXISTS_AT_LOCATION_ERROR)); - } - } - return WTPCommonPlugin.OK_STATUS; - } - - 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(); - } -// -// 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(); -// } -// - public IDataModelOperation getDefaultOperation() { - return new FlexibleProjectCreationOp(model); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationOp.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationOp.java deleted file mode 100644 index 1ff57ae80..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationOp.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.properties.IFlexibleProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.internal.WTPProjectUtilities; - -public class FlexibleProjectCreationOp extends AbstractDataModelOperation { - - public FlexibleProjectCreationOp(IDataModel model) { - super(model); - // TODO Auto-generated constructor stub - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - createProject(monitor); - WTPProjectUtilities.addNatureToProjectLast(getProject(), IModuleConstants.MODULE_NATURE_ID); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - createInitialWTPModulesFile(); - return OK_STATUS; - } - - private void createProject(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException, ExecutionException { - IDataModel projModel = model.getNestedModel(IFlexibleProjectCreationDataModelProperties.NESTED_MODEL_PROJECT_CREATION); - IDataModelOperation op = (IDataModelOperation)projModel.getDefaultOperation(); - op.execute(monitor, null); - } - - private void createInitialWTPModulesFile() { - StructureEdit moduleCore = null; - try { - IProject containingProject = getProject(); - moduleCore = StructureEdit.getStructureEditForWrite(containingProject); - moduleCore.prepareProjectComponentsIfNecessary(); - ProjectComponents projectModules = moduleCore.getComponentModelRoot(); - moduleCore.saveIfNecessary(null); - } finally { - if(moduleCore != null) - moduleCore.dispose(); - } - } - - protected IProject getProject() { - String name = model.getStringProperty(IFlexibleProjectCreationDataModelProperties.PROJECT_NAME); - if (name != null && name.length() > 0) - return ResourcesPlugin.getWorkspace().getRoot().getProject(name); - return null; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // TODO Auto-generated method stub - return null; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // TODO Auto-generated method stub - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleProjectCreationOperation.java deleted file mode 100644 index 6a6edb990..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.internal.WTPProjectUtilities; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; - -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() { - StructureEdit moduleCore = null; - try { - IProject containingProject = getProject(); - moduleCore = StructureEdit.getStructureEditForWrite(containingProject); - moduleCore.prepareProjectComponentsIfNecessary(); - ProjectComponents projectModules = moduleCore.getComponentModelRoot(); - 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/internal/operations/IAnnotationsDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IAnnotationsDataModel.java deleted file mode 100644 index d636f870f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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.internal.operations.WTPOperationDataModel - * @see org.eclipse.wst.common.frameworks.internal.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/internal/operations/J2EEArtifactExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactExportDataModel.java deleted file mode 100644 index 875d0c18a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactExportDataModel.java +++ /dev/null @@ -1,237 +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.internal.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.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -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.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPPropertyDescriptor; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * 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/internal/operations/J2EEArtifactImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactImportDataModel.java deleted file mode 100644 index c59d14e86..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactImportDataModel.java +++ /dev/null @@ -1,450 +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.internal.operations; - -import java.io.FileNotFoundException; -import java.io.IOException; -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.IProjectDescription; -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.IStatus; -import org.eclipse.core.runtime.Path; -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.wst.common.componentcore.internal.operation.ComponentCreationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelEvent; -import org.eclipse.wst.common.frameworks.internal.operations.WTPPropertyDescriptor; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.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 = FlexibleProjectCreationDataModel.SERVER_TARGET_ID; - - private J2EEComponentCreationDataModel 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(ComponentCreationDataModel.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(FlexibleProjectCreationDataModel.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(IProjectDescription.DESCRIPTION_FILE_NAME)) { - try { - File dotProject = getArchiveFile().getFile(IProjectDescription.DESCRIPTION_FILE_NAME); - ProjectDescriptionReader reader = new ProjectDescriptionReader(); - ProjectDescription description = reader.read(new InputSource(dotProject.getInputStream())); - setProperty(PROJECT_NAME, description.getName()); - } catch (FileNotFoundException e) { - //Ignore - } catch (IOException e) { - //Ignore - } - } - } - } - - // 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(ComponentCreationDataModel.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(ComponentCreationDataModel.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)) { - IProject proj = j2eeArtifactCreationDataModel.getProject(); - IStatus status = ProjectCreationDataModel.validateProjectName(proj.getName()); - if (!status.isOK()) { - 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 (!proj.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 J2EEComponentCreationDataModel 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 J2EEComponentCreationDataModel 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(ComponentCreationDataModel.PROJECT_NAME)) { - setProperty(PROJECT_NAME, j2eeArtifactCreationDataModel.getStringProperty(ComponentCreationDataModel.PROJECT_NAME)); - setBooleanProperty(DEFAULT_PROJECT_NAME, false); - } - super.propertyChanged(event); - } - - public void extractHandled(List newList, boolean addModels) { - //Default - } - - 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/internal/operations/J2EEComponentCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationDataModel.java deleted file mode 100644 index fecb83de2..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationDataModel.java +++ /dev/null @@ -1,514 +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.internal.operations; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.archive.operations.JavaComponentCreationDataModel; -import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages; -import org.eclipse.jst.j2ee.internal.earcreation.EARComponentCreationDataModel; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditOperationDataModel; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelEvent; -import org.eclipse.wst.common.frameworks.internal.operations.WTPPropertyDescriptor; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.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 JavaComponentCreationDataModel 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$ - - public static final String EAR_MODULE_DEPLOY_NAME = "J2EEComponentCreationDataModel.EAR_MODULE_DEPLOY_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$ - - - /** - * 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; - private UpdateManifestDataModel jarDependencyDataModel; - - private ClassPathSelection cachedSelection; - /** - * This needs to be set up to ensure that other j2ee component is properly added as dependent - * component of ear - */ - private URI earComponentHandle; - - protected void init() { - super.init(); - } - - protected void initValidBaseProperties() { - super.initValidBaseProperties(); - addValidBaseProperty(EAR_MODULE_NAME); - addValidBaseProperty(EAR_MODULE_DEPLOY_NAME); - addValidBaseProperty(ADD_TO_EAR); - addValidBaseProperty(USE_ANNOTATIONS); - addValidBaseProperty(UI_SHOW_EAR_SECTION); - addValidBaseProperty(DD_FOLDER); - addValidBaseProperty(J2EE_VERSION); - 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)) { - earComponentHandle = computeEARHandle((String) propertyValue); - } else if (propertyName.equals(COMPONENT_NAME)) { - if (isProperty(EAR_MODULE_NAME) && !isSet(EAR_MODULE_NAME)) { - notifyDefaultChange(EAR_MODULE_NAME); - setEARDeployNameProperty(getStringProperty(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; - } - - private URI computeEARHandle(String earHandle) { - if (earHandle == null || earHandle.equals("")) - return null; - URI uri = URI.createURI(earHandle); - - if (uri != null) { - boolean isValidURI = false; - try { - isValidURI = ModuleURIUtil.ensureValidFullyQualifiedModuleURI(uri); - String deployeName = ModuleURIUtil.getDeployedName(uri); - setEARDeployNameProperty(deployeName); - } catch (UnresolveableURIException e) { - } - if (isValidURI) { - earComponentHandle = uri; - return earComponentHandle; - } - } - return null; - } - - private void setEARDeployNameProperty(Object propertyValue) { - setProperty(EAR_MODULE_DEPLOY_NAME, propertyValue); - } - - /** - * @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(COMPONENT_VERSION)) { - return getValidComponentVersionDescriptors(); - } - if (propertyName.equals(EAR_MODULE_NAME)) { - int j2eeVersion = getJ2EEVersion(); - return getEARPropertyDescriptor(j2eeVersion); - } - return super.doGetValidPropertyDescriptors(propertyName); - } - - - private WTPPropertyDescriptor[] getEARPropertyDescriptor(int j2eeVersion) { - - StructureEdit mc = null; - ArrayList earDescriptorList = new ArrayList(); - - IProject[] projs = ProjectUtilities.getAllProjects(); - - for (int index = 0; index < projs.length; index++) { - IProject flexProject = projs[index]; - try { - if (flexProject != null) { - mc = StructureEdit.getStructureEditForRead(flexProject); - if (mc != null) { - WorkbenchComponent[] components = mc.getWorkbenchModules(); - - for (int i = 0; i < components.length; i++) { - EARArtifactEdit earArtifactEdit = null; - try { - WorkbenchComponent wc = components[i]; - if (wc.getComponentType() != null && wc.getComponentType().getComponentTypeId().equals(IModuleConstants.JST_EAR_MODULE)) { - ComponentHandle handle = ComponentHandle.create(flexProject,wc.getName()); - earArtifactEdit = EARArtifactEdit.getEARArtifactEditForRead(handle); - if (j2eeVersion <= earArtifactEdit.getJ2EEVersion()) { - WTPPropertyDescriptor desc = new WTPPropertyDescriptor(wc.getHandle().toString(), wc.getName()); - earDescriptorList.add(desc); - } - } - } finally { - if (earArtifactEdit != null) - earArtifactEdit.dispose(); - } - - } - } - } - } finally { - if (mc != null) - mc.dispose(); - } - } - WTPPropertyDescriptor[] descriptors = new WTPPropertyDescriptor[earDescriptorList.size()]; - for (int i = 0; i < descriptors.length; i++) { - WTPPropertyDescriptor desc = (WTPPropertyDescriptor) earDescriptorList.get(i); - descriptors[i] = new WTPPropertyDescriptor(desc.getPropertyValue(), desc.getPropertyDescription()); - } - return descriptors; - - } - - - - public IProject getProject() { - String projName = getStringProperty(J2EEComponentCreationDataModel.PROJECT_NAME); - if (projName != null && projName.length() > 0) - return ProjectUtilities.getProject(projName); - return null; - } - - public WorkbenchComponent getTargetWorkbenchComponent() { - StructureEdit core = null; - try { - IProject flexProject = getProject(); - if (flexProject != null) { - core = StructureEdit.getStructureEditForRead(getProject()); - if (core != null) { - String componentName = getProperty(COMPONENT_NAME) != null ? getProperty(COMPONENT_NAME).toString() : null; - if (componentName != null) - return core.findComponentByName(componentName); - } - } - } 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; - } else if (propertyName.equals(COMPONENT_VERSION)) { - int componentVersion = getIntProperty(COMPONENT_VERSION); - int j2eeVer = convertModuleVersionToJ2EEVersion(componentVersion); - String j2eeText = J2EEVersionUtil.getJ2EETextVersion(j2eeVer); - - String[] validModuleVersions = (String[]) getProperty(VALID_MODULE_VERSIONS_FOR_PROJECT_RUNTIME); - - if (validModuleVersions != null) { - boolean found = false; - for (int i = 0; i < validModuleVersions.length; i++) { - String text = validModuleVersions[i]; - if (text.equals("*") || text.equals(j2eeText)) { - found = true; - break; - } - } - IStatus status = OK_STATUS; - if (!found) { - String errorMessage = J2EECommonMessages.getResourceString(J2EECommonMessages.ERR_VERSION_NOT_SUPPORTED); - status = WTPCommonPlugin.createErrorStatus(errorMessage); - } - return status; - } else { - String errorMessage = J2EECommonMessages.getResourceString(J2EECommonMessages.ERR_NOT_SUPPORTED); - IStatus status = WTPCommonPlugin.createErrorStatus(errorMessage); - return status; - } - - - } - return super.doValidateProperty(propertyName); - } - - public EARComponentCreationDataModel getEarComponentCreationDataModel() { - return earComponentCreationDataModel; - } - - private IStatus validateEARModuleNameProperty() { - IStatus status = OK_STATUS; - String earName = getStringProperty(EAR_MODULE_NAME); - if (status.isOK()) { - if (earName.indexOf("#") != -1) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_INVALID_CHARS); //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(errorMessage); - } else if (earName == null || earName.equals("")) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_EMPTY_MODULE_NAME); - return WTPCommonPlugin.createErrorStatus(errorMessage); - } - } else - return status; - // 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); - } - - protected abstract WTPPropertyDescriptor[] getValidComponentVersionDescriptors(); - - 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); - - /** - * @return Returns the addComponentToEARDataModel. - */ - public AddComponentToEnterpriseApplicationDataModel getAddComponentToEARDataModel() { - return addComponentToEARDataModel; - } - - - /** - * @param addComponentToEARDataModel - * The addComponentToEARDataModel to set. - */ - public void setAddComponentToEARDataModel(AddComponentToEnterpriseApplicationDataModel addComponentToEARDataModel) { - this.addComponentToEARDataModel = addComponentToEARDataModel; - } - - - public URI getEarComponentHandle() { - return earComponentHandle; - } - - public void setEarComponentHandle(URI earComponentHandle) { - this.earComponentHandle = earComponentHandle; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationDataModelProvider.java deleted file mode 100644 index 4ed4e415c..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationDataModelProvider.java +++ /dev/null @@ -1,350 +0,0 @@ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.archive.operations.JavaComponentCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.earcreation.EarComponentCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.datamodel.properties.IComponentCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPPropertyDescriptor; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IProjectProperties; -import org.eclipse.wst.server.core.ServerCore; - -public abstract class J2EEComponentCreationDataModelProvider extends JavaComponentCreationDataModelProvider implements IJ2EEComponentCreationDataModelProperties, IAnnotationsDataModel { - - public void init() { - super.init(); - model.setProperty(COMPONENT_VERSION, getDefaultProperty(COMPONENT_VERSION)); - model.setProperty(NESTED_ADD_COMPONENT_TO_EAR_DM, new AddComponentToEnterpriseApplicationDataModel()); - propertySet(CLASSPATH_SELECTION, null); - model.setProperty(NESTED_UPDATE_MANIFEST_DM, new UpdateManifestDataModel()); - model.setProperty(USE_ANNOTATIONS, Boolean.FALSE); - } - - public String[] getPropertyNames() { - String[] props = new String[]{EAR_COMPONENT_NAME, EAR_COMPONENT_DEPLOY_NAME, ADD_TO_EAR, - UI_SHOW_EAR_SECTION, DD_FOLDER, COMPONENT_VERSION, VALID_COMPONENT_VERSIONS_FOR_PROJECT_RUNTIME, - NESTED_ADD_COMPONENT_TO_EAR_DM, CLASSPATH_SELECTION, NESTED_EAR_COMPONENT_CREATION_DM, - NESTED_UPDATE_MANIFEST_DM, EAR_COMPONENT_HANDLE, USE_ANNOTATIONS }; - return combineProperties(super.getPropertyNames(), props); - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(ADD_TO_EAR)) { - return Boolean.FALSE; - } else if (propertyName.equals(UI_SHOW_EAR_SECTION)) { - return Boolean.TRUE; - } else if (propertyName.equals(EAR_COMPONENT_NAME)) { - return getDataModel().getStringProperty(COMPONENT_NAME)+"EAR"; - } else if (propertyName.equals(COMPONENT_VERSION)) { - return getDefaultComponentVersion(); - } else if (propertyName.equals(NESTED_EAR_COMPONENT_CREATION_DM)) { - return DataModelFactory.createDataModel(new EarComponentCreationDataModelProvider()); - } - return super.getDefaultProperty(propertyName); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean status = super.propertySet(propertyName, propertyValue); - if (PROJECT_NAME.equals(propertyName) && propertyValue !=null && ((String)propertyValue).length()!=0) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject((String)propertyValue); - if (project != null) { - IProjectProperties projProperties = ServerCore.getProjectProperties(project); - if( projProperties.getRuntimeTarget() != null ){ - String[] validModuleVersions = getServerVersions(getComponentID(), projProperties.getRuntimeTarget().getRuntimeType()); - model.setProperty(VALID_COMPONENT_VERSIONS_FOR_PROJECT_RUNTIME, validModuleVersions); - } - } - } - else if (propertyName.equals(EAR_COMPONENT_NAME)) { - model.setProperty(EAR_COMPONENT_HANDLE, computeEARHandle((String)propertyValue)); - model.setProperty(EAR_COMPONENT_DEPLOY_NAME, propertyValue); - IDataModel earDM = (IDataModel)model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - earDM.setProperty(PROJECT_NAME, propertyValue); - } else if(propertyName.equals(COMPONENT_NAME)){ - if (!model.isPropertySet(EAR_COMPONENT_NAME)) { - model.notifyPropertyChange(EAR_COMPONENT_NAME, IDataModel.VALID_VALUES_CHG); - model.setProperty(EAR_COMPONENT_DEPLOY_NAME, getProperty(EAR_COMPONENT_NAME)); - } - } else if (propertyName.equals(PROJECT_NAME)) { - WorkbenchComponent workbenchComp = getTargetWorkbenchComponent(); - setEARComponentIfJ2EEModuleCreationOnly(workbenchComp,propertyValue); - } else if (propertyName.equals(ADD_TO_EAR)) { - model.notifyPropertyChange(NESTED_EAR_COMPONENT_CREATION_DM, IDataModel.DEFAULT_CHG); - model.notifyPropertyChange(ADD_TO_EAR, IDataModel.VALID_VALUES_CHG); - } -// else if (propertyName.equals(J2EE_VERSION)) { -// Integer modVersion = convertJ2EEVersionToModuleVersion((Integer) propertyValue); -// propertySet(COMPONENT_VERSION, modVersion); -// return false; -// } - return status; - } - - private URI computeEARHandle(String earHandle){ - URI uri = URI.createURI(earHandle); - - if( uri != null ){ - boolean isValidURI = false; - try { - isValidURI = ModuleURIUtil.ensureValidFullyQualifiedModuleURI(uri); - String deployeName = ModuleURIUtil.getDeployedName(uri); - } - catch (UnresolveableURIException e) { - } - if(isValidURI){ - return uri; - } - } - return null; - } - /** - * @param workbenchComp - */ - protected void setEARComponentIfJ2EEModuleCreationOnly(WorkbenchComponent workbenchComp, Object propertyValue) { - getAddComponentToEARDataModel().setProperty(AddComponentToEnterpriseApplicationDataModel.ARCHIVE_MODULE, workbenchComp); - getAddComponentToEARDataModel().setProperty(AddComponentToEnterpriseApplicationDataModel.PROJECT_NAME, model.getStringProperty(PROJECT_NAME)); - getAddComponentToEARDataModel().setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME,model.getStringProperty(EAR_COMPONENT_NAME)); - if (!model.isPropertySet(EAR_COMPONENT_NAME)) { - String earModuleName = model.getStringProperty(EAR_COMPONENT_NAME); - model.notifyPropertyChange(EAR_COMPONENT_NAME, IDataModel.VALID_VALUES_CHG); - - } - ((UpdateManifestDataModel)model.getProperty(NESTED_UPDATE_MANIFEST_DM)).setProperty(UpdateManifestDataModel.PROJECT_NAME, propertyValue); - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - if (propertyName.equals(COMPONENT_VERSION)) { - return getValidComponentVersionDescriptors(); - } - if (propertyName.equals(EAR_COMPONENT_NAME)) { - int j2eeVersion = getJ2EEVersion(); - return getEARPropertyDescriptor(j2eeVersion); - } - return super.getValidPropertyDescriptors(propertyName); - } - - private DataModelPropertyDescriptor[] getEARPropertyDescriptor(int j2eeVersion){ - StructureEdit mc = null; - ArrayList earDescriptorList = new ArrayList(); - - IProject[] projs = ProjectUtilities.getAllProjects(); - - for( int index=0; index< projs.length; index++){ - IProject flexProject = projs[index]; - try { - if(flexProject != null) { - mc = StructureEdit.getStructureEditForRead(flexProject); - if( mc != null ){ - WorkbenchComponent[] components = mc.getWorkbenchModules(); - - int earVersion = 0; - for (int i = 0; i < components.length; i++) { - EARArtifactEdit earArtifactEdit = null; - try { - WorkbenchComponent wc = components[i]; - if(wc.getComponentType() != null && wc.getComponentType().getComponentTypeId().equals(IModuleConstants.JST_EAR_MODULE)) { - ComponentHandle handle = ComponentHandle.create(flexProject,wc.getName()); - earArtifactEdit = EARArtifactEdit.getEARArtifactEditForRead(handle); - if(j2eeVersion <= earArtifactEdit.getJ2EEVersion()){ - WTPPropertyDescriptor desc = new WTPPropertyDescriptor(wc.getHandle().toString(), wc.getName()); - earDescriptorList.add(desc); - } - } - } finally { - if(earArtifactEdit != null) - earArtifactEdit.dispose(); - } - } - } - } - } finally { - if(mc != null) - mc.dispose(); - } - } - DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[earDescriptorList.size()]; - for (int i = 0; i < descriptors.length; i++) { - WTPPropertyDescriptor desc = (WTPPropertyDescriptor)earDescriptorList.get(i); - descriptors[i] = new DataModelPropertyDescriptor(desc.getPropertyDescription(), desc.getPropertyDescription()); - } - return descriptors; - } - - public IProject getProject() { - String projName = getDataModel().getStringProperty(IComponentCreationDataModelProperties.PROJECT_NAME ); - if(projName != null && projName.length() > 0) - return ProjectUtilities.getProject( projName ); - return null; - } - - public WorkbenchComponent getTargetWorkbenchComponent() { - StructureEdit core = null; - try { - IProject flexProject = getProject(); - if(flexProject != null) { - core = StructureEdit.getStructureEditForRead(getProject()); - if(core != null) { - String componentName = getProperty(COMPONENT_NAME) != null ? getProperty(COMPONENT_NAME).toString() : null; - if(componentName!=null) - return core.findComponentByName(componentName); - } - } - } finally { - if(core != null) - core.dispose(); - } - return null; - } - - public IStatus validate(String propertyName) { - if (EAR_COMPONENT_NAME.equals(propertyName) && getBooleanProperty(ADD_TO_EAR)) { - return validateEARModuleNameProperty(); - } else if (COMPONENT_VERSION.equals(propertyName)) { - return validateComponentVersionProperty(); - } else if(propertyName.equals(VALID_COMPONENT_VERSIONS_FOR_PROJECT_RUNTIME)){ - return OK_STATUS; - } - return super.validate(propertyName); - } - private IStatus validateComponentVersionProperty() { - int componentVersion = model.getIntProperty(COMPONENT_VERSION); - if (componentVersion == -1) - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.SPEC_LEVEL_NOT_FOUND)); - return OK_STATUS; - } - - private IStatus validateEARModuleNameProperty() { - IStatus status = OK_STATUS; - String earName = getStringProperty(EAR_COMPONENT_NAME); - if (status.isOK()) { - if (earName.indexOf("#") != -1 || earName.indexOf("/") != -1) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_INVALID_CHARS); //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(errorMessage); - } else if (earName == null || earName.equals("")) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_EMPTY_MODULE_NAME); - return WTPCommonPlugin.createErrorStatus(errorMessage); - } - } else - return status; -// 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; - } - - 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; - return null; - } - - - /* - * (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()); -// } -// } - protected final AddComponentToEnterpriseApplicationDataModel getAddComponentToEARDataModel() { - return (AddComponentToEnterpriseApplicationDataModel) model.getProperty(NESTED_ADD_COMPONENT_TO_EAR_DM); - } - - protected final UpdateManifestDataModel getUpdateManifestDataModel() { - return (UpdateManifestDataModel) model.getProperty(NESTED_UPDATE_MANIFEST_DM); - } - - public String getModuleName() { - return getDataModel().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); - - protected abstract DataModelPropertyDescriptor[] getValidComponentVersionDescriptors(); - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationOp.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationOp.java deleted file mode 100644 index f6656f908..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationOp.java +++ /dev/null @@ -1,318 +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.internal.operations; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -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.emf.common.util.URI; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.datamodel.properties.IEarComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.common.UpdateProjectClasspath; -import org.eclipse.jst.j2ee.internal.project.ManifestFileCreationAction; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationOperationEx; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public abstract class J2EEComponentCreationOp extends ComponentCreationOperationEx implements IJ2EEComponentCreationDataModelProperties, IAnnotationsDataModel { - /** - * 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 J2EEComponentCreationOp(IDataModel model) { - super(model); - // TODO Auto-generated constructor stub - } - - protected void execute(String componentType, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - super.execute(componentType, monitor, null); - - if (model.getBooleanProperty(CREATE_DEFAULT_FILES)) { - createDeploymentDescriptor(monitor); - createManifest(monitor); - } - - addSrcFolderToProject(); - if (model.getBooleanProperty(USE_ANNOTATIONS)) - addAnnotationsBuilder(); - - linkToEARIfNecessary(monitor); - } - - protected abstract void createDeploymentDescriptor(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException; - - public void linkToEARIfNecessary(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - if (model.getBooleanProperty(ADD_TO_EAR)) { - createEARComponentIfNecessary(monitor); - runAddToEAROperation(monitor); - } - } - - /** - * @param moduleModel - * @param monitor - * @throws CoreException - * @throws InvocationTargetException - * @throws InterruptedException - */ - protected void runAddToEAROperation(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - - URI uri = (URI) model.getProperty(EAR_COMPONENT_HANDLE); - IProject proj = null; - try { - proj = StructureEdit.getContainingProject(uri); - } catch (UnresolveableURIException e) { - Logger.getLogger().log(e); - } - - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForRead(getProject()); - WorkbenchComponent wc = core.findComponentByName((String) model.getProperty(COMPONENT_DEPLOY_NAME)); - AddComponentToEnterpriseApplicationDataModel dm = (AddComponentToEnterpriseApplicationDataModel) model.getProperty(NESTED_ADD_COMPONENT_TO_EAR_DM); - - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_PROJECT_NAME, proj.getName()); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.PROJECT_NAME, model.getProperty(PROJECT_NAME)); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_NAME, wc.getName()); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME, model.getProperty(EAR_COMPONENT_DEPLOY_NAME)); - List modList = (List) dm.getProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST); - modList.add(wc); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST, modList); - AddComponentToEnterpriseApplicationOperation addModuleOp = new AddComponentToEnterpriseApplicationOperation(dm); - addModuleOp.doRun(monitor); - } finally { - if (core != null) - core.dispose(); - } - } - - /** - * @param moduleModel - * @param monitor - * @throws CoreException - * @throws InvocationTargetException - * @throws InterruptedException - */ - protected void createEARComponentIfNecessary(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - IDataModel earModel = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - earModel.setProperty(IEarComponentCreationDataModelProperties.COMPONENT_NAME, model.getStringProperty(EAR_COMPONENT_NAME)); - //earModel.setProperty(IEarComponentCreationDataModelProperties.PROJECT_NAME, model.getStringProperty(PROJECT_NAME)); - if (!doesEARComponentExist()) { - try { - earModel.getDefaultOperation().execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().log(e.getMessage()); - } - model.setProperty(EAR_COMPONENT_HANDLE, getEARComponentHandle(earModel)); - } - } - - public URI getEARComponentHandle(IDataModel earModel){ - StructureEdit moduleCore = null; - try { - IProject earProject = ProjectUtilities.getProject((String)earModel.getProperty(IEarComponentCreationDataModelProperties.PROJECT_NAME)); - moduleCore = StructureEdit.getStructureEditForRead(earProject); - WorkbenchComponent earComp = moduleCore.findComponentByName(earModel.getStringProperty(IEarComponentCreationDataModelProperties.COMPONENT_DEPLOY_NAME)); - return earComp.getHandle(); - - } finally { - if (null != moduleCore) { - moduleCore.dispose(); - } - } - } - - public boolean doesEARComponentExist() { - URI uri = (URI)model.getProperty(EAR_COMPONENT_HANDLE); - - boolean isValidURI = false; - try { - if (uri != null) - isValidURI = ModuleURIUtil.ensureValidFullyQualifiedModuleURI(uri); - } catch (UnresolveableURIException e) { - - } - if (isValidURI) { - IProject proj = null; - try { - proj = StructureEdit.getContainingProject(uri); - - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForRead(proj); - if ((moduleCore.findComponentByURI(uri)) != null) { - return true; - } - } finally { - if (moduleCore != null) - moduleCore.dispose(); - } - } catch (UnresolveableURIException e) { - Logger.getLogger().log(e); - } - } - return false; - } - - public IProject getProject() { - String projName = model.getStringProperty(PROJECT_NAME); - return ProjectUtilities.getProject(projName); - } - - public String getModuleName() { - return (String) model.getProperty(COMPONENT_NAME); - } - - public String getModuleDeployName() { - return (String) model.getProperty(COMPONENT_DEPLOY_NAME); - } - - protected abstract String getVersion(); - - protected void setupComponentType(String typeID) { - IVirtualComponent component = ComponentCore.createComponent(getProject(), getModuleDeployName()); - ComponentType componentType = ComponentcoreFactory.eINSTANCE.createComponentType(); - componentType.setComponentTypeId(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)); - } - } - StructureEdit.setComponentType(component, componentType); - } - - // Should return null if no additional properties needed - protected List getProperties() { - return null; - } - - /** - * @param monitor - */ - protected void createManifest(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - - String manifestFolder = model.getStringProperty(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); - - } - - /** - * 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 = ProjectUtilities.getProject(model.getProperty(PROJECT_NAME)); - 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 model.getStringProperty(JAVASOURCE_FOLDER); - } - - /** - * @return - */ - public String getDeploymentDescriptorFolder() { - return model.getStringProperty(DD_FOLDER); - } - - public String getJavaSourceSourcePath() { - return model.getStringProperty(JAVASOURCE_FOLDER); - } - - private void addSrcFolderToProject() { - UpdateProjectClasspath update = new UpdateProjectClasspath(model.getStringProperty(JAVASOURCE_FOLDER), ProjectUtilities.getProject(model.getStringProperty(PROJECT_NAME))); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationOperation.java deleted file mode 100644 index 20847d30f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationOperation.java +++ /dev/null @@ -1,337 +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>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -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.emf.common.util.URI; -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.archive.operations.JavaComponentCreationDataModel; -import org.eclipse.jst.j2ee.internal.common.UpdateProjectClasspath; -import org.eclipse.jst.j2ee.internal.earcreation.EARComponentCreationDataModel; -import org.eclipse.jst.j2ee.internal.project.ManifestFileCreationAction; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationOperation; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -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(JavaComponentCreationDataModel 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 { - - URI uri = moduleModel.getEarComponentHandle(); - IProject proj = null; - try { - proj = StructureEdit.getContainingProject(uri); - } - catch (UnresolveableURIException e) { - Logger.getLogger().log(e); - } - - - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForRead(getProject()); - WorkbenchComponent wc = core.findComponentByName((String)moduleModel.getProperty(J2EEComponentCreationDataModel.COMPONENT_DEPLOY_NAME)); - AddComponentToEnterpriseApplicationDataModel dm = moduleModel.getAddComponentToEARDataModel(); - - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_PROJECT_NAME, proj.getName()); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.PROJECT_NAME, moduleModel.getProject().getName()); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_NAME,wc.getName()); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.EAR_MODULE_NAME,moduleModel.getProperty(J2EEComponentCreationDataModel.EAR_MODULE_DEPLOY_NAME)); - List modList = (List)dm.getProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST); - modList.add(wc); - dm.setProperty(AddComponentToEnterpriseApplicationDataModel.MODULE_LIST,modList); - AddComponentToEnterpriseApplicationOperation addModuleOp = new AddComponentToEnterpriseApplicationOperation(dm); - 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.COMPONENT_DEPLOY_NAME, moduleModel.getStringProperty(J2EEComponentCreationDataModel.EAR_MODULE_DEPLOY_NAME)); - earModel.setProperty(EARComponentCreationDataModel.PROJECT_NAME, moduleModel.getStringProperty(J2EEComponentCreationDataModel.PROJECT_NAME)); - if (!doesEARComponentExist()) { - EARComponentCreationOperation earOp = new EARComponentCreationOperation(earModel); - earOp.doRun(monitor); - moduleModel.setEarComponentHandle( earOp.getComponentHandle() ); - } - } - - public boolean doesEARComponentExist() { - J2EEComponentCreationDataModel model = (J2EEComponentCreationDataModel)operationDataModel; - URI uri = model.getEarComponentHandle(); - - boolean isValidURI = false; - try { - if( uri != null ) - isValidURI = ModuleURIUtil.ensureValidFullyQualifiedModuleURI(uri); - }catch (UnresolveableURIException e) { - - } - if( isValidURI ){ - IProject proj = null; - try { - proj = StructureEdit.getContainingProject(uri); - - StructureEdit moduleCore = null; - try{ - moduleCore = StructureEdit.getStructureEditForRead(proj); - if((moduleCore.findComponentByURI(uri)) != null ){ - return true; - } - } finally { - if(moduleCore != null) - moduleCore.dispose(); - } - } - catch (UnresolveableURIException e) { - Logger.getLogger().log(e); - } - } - return false; - } - - 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) { - IVirtualComponent component = ComponentCore.createComponent(getProject(), getModuleDeployName()); - ComponentType componentType = ComponentcoreFactory.eINSTANCE.createComponentType(); - componentType.setComponentTypeId(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)); - } - } - StructureEdit.setComponentType(component, componentType); - } - - // Should return null if no additional properties needed - protected List getProperties() { - return null; - } - - - /** - * @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 void addSrcFolderToProject() { - JavaComponentCreationDataModel dm = (JavaComponentCreationDataModel)operationDataModel; - UpdateProjectClasspath update = new UpdateProjectClasspath(dm.getJavaSourceFolder(), dm.getProject()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEModuleExportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEModuleExportDataModel.java deleted file mode 100644 index 288965525..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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.internal.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/internal/operations/J2EEModuleImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEModuleImportDataModel.java deleted file mode 100644 index 84cfb345a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEModuleImportDataModel.java +++ /dev/null @@ -1,89 +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.internal.operations; - -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; - -/** - * 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_NAME = J2EEComponentCreationDataModel.EAR_MODULE_NAME; - public static final String ADD_TO_EAR = J2EEComponentCreationDataModel.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) { - - boolean doSet = super.doSetProperty(propertyName, propertyValue); - if (doSet && (propertyName.equals(J2EEArtifactImportDataModel.FILE_NAME) || (propertyName.equals(J2EEArtifactImportDataModel.FILE)))) { - J2EEComponentCreationDataModel moduleDM = getJ2EEModuleCreationDataModel(); - if (getModuleFile() != null) { - moduleDM.setIntProperty(J2EEComponentCreationDataModel.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 J2EEComponentCreationDataModel getJ2EEModuleCreationDataModel() { - return 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/internal/operations/J2EEUtilityJarImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportDataModel.java deleted file mode 100644 index 3ebfdaa54..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportDataModel.java +++ /dev/null @@ -1,55 +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.internal.operations; - -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.wst.common.frameworks.internal.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 J2EEComponentCreationDataModel createJ2EEProjectCreationDataModel() { - 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/internal/operations/J2EEUtilityJarImportOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportOperation.java deleted file mode 100644 index cd16085a7..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportOperation.java +++ /dev/null @@ -1,84 +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.internal.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.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.internal.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(J2EEArtifactImportDataModel.OVERWRITE_PROJECT)) { - IProject project = dataModel.getProject(); - if (project.exists()) { - project.delete(true, true, new NullProgressMonitor()); - } - } - - if (!dataModel.getJ2eeArtifactCreationDataModel().getTargetProject().exists()) { - JavaUtilityComponentCreationOperation javaProjectCreationOp = new JavaUtilityComponentCreationOperation(dataModel.getJ2eeArtifactCreationDataModel()); - javaProjectCreationOp.run(monitor); - } - - IProject javaProject = dataModel.getProject(); - Archive jarFile = dataModel.getArchiveFile(); - - if (dataModel.getBooleanProperty(J2EEArtifactImportDataModel.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/internal/operations/J2EEUtilityJarListImportDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportDataModel.java deleted file mode 100644 index c20e6409a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportDataModel.java +++ /dev/null @@ -1,417 +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.internal.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.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.emf.workbench.nature.EMFNature; -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.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPPropertyDescriptor; - -/** - * @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/internal/operations/J2EEUtilityJarListImportOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportOperation.java deleted file mode 100644 index 88eaf5680..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportOperation.java +++ /dev/null @@ -1,323 +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.internal.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.IAccessRule; -import org.eclipse.jdt.core.IClasspathAttribute; -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.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.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(J2EEComponentCreationDataModel.PROJECT_LOCATION, projectRoot); -// -// importModel.getJ2eeArtifactCreationDataModel().setBooleanProperty(J2EEComponentCreationDataModel.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, - null, - false, - null); - - 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, - null, - false, - null); - - 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/internal/operations/JARDependencyTraverser.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/JARDependencyTraverser.java deleted file mode 100644 index 476488a3d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/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>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.application.internal.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/internal/operations/JavaUtilityComponentCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/JavaUtilityComponentCreationOperation.java deleted file mode 100644 index 648e2d9e5..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/JavaUtilityComponentCreationOperation.java +++ /dev/null @@ -1,100 +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.internal.operations; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.archive.operations.JavaComponentCreationDataModel; -import org.eclipse.jst.j2ee.internal.common.UpdateProjectClasspath; -import org.eclipse.jst.j2ee.internal.project.ManifestFileCreationAction; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationOperation; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; - -public class JavaUtilityComponentCreationOperation extends ComponentCreationOperation { - /** - * @param dataModel - */ - public JavaUtilityComponentCreationOperation(JavaComponentCreationDataModel dataModel) { - super(dataModel); - } - - - protected void execute(String componentType, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - JavaComponentCreationDataModel dm = (JavaComponentCreationDataModel)operationDataModel; - super.execute(IModuleConstants.JST_UTILITY_MODULE, monitor); - createManifest(monitor); - addSrcFolderToProject(); - } - - protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - execute(IModuleConstants.JST_UTILITY_MODULE, monitor); - } - - protected void createComponent() { - - JavaComponentCreationDataModel dm = (JavaComponentCreationDataModel)operationDataModel; - IVirtualComponent component = ComponentCore.createComponent(dm.getProject(), dm.getComponentDeployName()); - try { - component.create(0, null); - //create and link javaSource Source Folder - IVirtualFolder javaSourceFolder = component.getFolder(new Path("/")); //$NON-NLS-1$ - javaSourceFolder.createLink(new Path("/" + dm.getJavaSourceFolder()), 0, null); - - //create and link META-INF folder - IVirtualFolder metaInfFolder = component.getFolder(new Path("/" + J2EEConstants.META_INF)); //$NON-NLS-1$ - metaInfFolder.createLink(new Path("/" + dm.getComponentName() + "/" + J2EEConstants.META_INF), 0, null); - } - catch (CoreException e) { - Logger.getLogger().log(e); - } - } - - protected void createManifest(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - - JavaComponentCreationDataModel dm = (JavaComponentCreationDataModel)operationDataModel; - String manifestFolder = dm.getStringProperty(J2EEComponentCreationDataModel.MANIFEST_FOLDER); - IContainer container = dm.getProject().getFolder( manifestFolder ); - - IFile file = container.getFile( new Path(J2EEConstants.MANIFEST_SHORT_NAME)); - - try { - ManifestFileCreationAction.createManifestFile(file, dm.getProject()); - } - catch (CoreException e) { - Logger.getLogger().log(e); - } - catch (IOException e) { - Logger.getLogger().log(e); - } - - } - - - private void addSrcFolderToProject() { - JavaComponentCreationDataModel dm = (JavaComponentCreationDataModel)operationDataModel; - UpdateProjectClasspath update = new UpdateProjectClasspath(dm.getJavaSourceFolder(), dm.getProject()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/JavaUtilityComponentCreationOperationEx.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/JavaUtilityComponentCreationOperationEx.java deleted file mode 100644 index bedd8f078..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/JavaUtilityComponentCreationOperationEx.java +++ /dev/null @@ -1,118 +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.internal.operations; - -import java.io.IOException; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -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.datamodel.properties.IJavaComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.common.UpdateProjectClasspath; -import org.eclipse.jst.j2ee.internal.project.ManifestFileCreationAction; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationOperationEx; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class JavaUtilityComponentCreationOperationEx extends ComponentCreationOperationEx implements IJavaComponentCreationDataModelProperties{ - /** - * @param dataModel - */ - public JavaUtilityComponentCreationOperationEx(IDataModel dataModel) { - super(dataModel); - } - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus execute(IProgressMonitor monitor, IAdaptable info) { - super.execute(IModuleConstants.JST_UTILITY_MODULE, monitor, info); - createManifest(monitor); - addSrcFolderToProject(); - return OK_STATUS; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus redo(IProgressMonitor monitor, IAdaptable info) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus undo(IProgressMonitor monitor, IAdaptable info) { - return null; - } - - protected void createAndLinkJ2EEComponents() throws CoreException { - IVirtualComponent component = ComponentCore.createComponent(getProject(), getComponentDeployName()); - component.create(0, null); - //create and link javaSource Source Folder - IVirtualFolder javaSourceFolder = component.getFolder(new Path("/")); //$NON-NLS-1$ - javaSourceFolder.createLink(new Path("/" + getJavaSourceFolder()), 0, null); - - //create and link META-INF folder - IVirtualFolder metaInfFolder = component.getFolder(new Path("/" + J2EEConstants.META_INF)); //$NON-NLS-1$ - metaInfFolder.createLink(new Path("/" + getComponentName() + "/" + J2EEConstants.META_INF), 0, null); - } - - protected void createManifest(IProgressMonitor monitor) { - IContainer container = getProject().getFolder( getManifestFolder() ); - 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); - } - } - - private void addSrcFolderToProject() { - UpdateProjectClasspath update = new UpdateProjectClasspath(getJavaSourceFolder(), getProject()); - } - - String getJavaSourceFolder(){ - return model.getStringProperty(JAVASOURCE_FOLDER); - } - - String getManifestFolder(){ - return model.getStringProperty(MANIFEST_FOLDER); - } - /* (non-Javadoc) - * @see org.eclipse.wst.common.modulecore.internal.operation.ComponentCreationOperationEx#getVersion() - */ - protected String getVersion() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.modulecore.internal.operation.ComponentCreationOperationEx#getProperties() - */ - protected List getProperties() { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModel.java deleted file mode 100644 index add0b2d7c..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModel.java +++ /dev/null @@ -1,137 +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.internal.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.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelEvent; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>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_FILE = "UpdateManifestDataModel.MANIFEST_FILE"; //$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_FILE); - } - - 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/internal/operations/UpdateManifestOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestOperation.java deleted file mode 100644 index a628dbd27..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestOperation.java +++ /dev/null @@ -1,70 +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.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -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.project.J2EEProjectUtilities; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException; -import org.eclipse.wst.common.frameworks.internal.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 UpdateManifestOperation extends WTPOperation { - - public UpdateManifestOperation(UpdateManifestDataModel dataModel) { - super(dataModel); - } - - protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - UpdateManifestDataModel dataModel = (UpdateManifestDataModel) operationDataModel; - IFile file = (IFile)dataModel.getProperty(UpdateManifestDataModel.MANIFEST_FILE); - - 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 diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARArtifactEdit.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARArtifactEdit.java deleted file mode 100644 index 56491a7bd..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARArtifactEdit.java +++ /dev/null @@ -1,441 +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.componentcore.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.application.ApplicationFactory; -import org.eclipse.jst.j2ee.application.ApplicationResource; -import org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - -/** - * <p> - * EARArtifactEdit obtains an {@see org.eclipse.jst.j2ee.application.Application} metamodel. - * The {@see org.eclipse.jst.j2ee.application.ApplicationResource} which stores the metamodel - * is retrieved from the {@see org.eclipse.wst.common.modulecore.ArtifactEditModel} using a - * cached constant (@see - * org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants#APPLICATION_DD_URI). The - * defined methods extract data or manipulate the contents of the underlying resource. - * </p> - */ - -public class EARArtifactEdit extends EnterpriseArtifactEdit { - - public static final Class ADAPTER_TYPE = EARArtifactEdit.class; - /** - * <p> - * Identifier used to group and query common artifact edits. - * </p> - */ - public static String TYPE_ID = "jst.ear"; //$NON-NLS-1$ - - - /** - * @param aHandle - * @param toAccessAsReadOnly - * @throws IllegalArgumentException - */ - public EARArtifactEdit(ComponentHandle aHandle, boolean toAccessAsReadOnly) throws IllegalArgumentException { - super(aHandle, toAccessAsReadOnly); - // TODO Auto-generated constructor stub - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will not be used for editing. Invocations of any save*() API on an instance returned from - * this method will throw exceptions. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may only be used to read the underlying content - * model - */ - public static EARArtifactEdit getEARArtifactEditForRead(ComponentHandle aHandle) { - EARArtifactEdit artifactEdit = null; - try { - artifactEdit = new EARArtifactEdit(aHandle, true); - } catch (IllegalArgumentException iae) { - artifactEdit = null; - } - return artifactEdit; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will be used for editing. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may be used to modify and persist changes to the - * underlying content model - */ - public static EARArtifactEdit getEARArtifactEditForWrite(ComponentHandle aHandle) { - EARArtifactEdit artifactEdit = null; - try { - artifactEdit = new EARArtifactEdit(aHandle, false); - } catch (IllegalArgumentException iae) { - artifactEdit = null; - } - return artifactEdit; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of EARArtifactEdit that are returned through this - * method must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an EARArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will not be used for editing. Invocations of any save*() API on an instance returned from - * this method will throw exceptions. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * <p> - * Note: This method is for internal use only. Clients should not call this method. - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of EARArtifactEdit that may only be used to read the underlying content - * model - * @throws UnresolveableURIException - * could not resolve uri. - */ - public static EARArtifactEdit getEARArtifactEditForRead(IVirtualComponent aModule) { - try { - if (isValidEARModule(aModule)) { - IProject project = aModule.getProject(); - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(project); - return new EARArtifactEdit(nature, aModule, true); - } - } catch (UnresolveableURIException uue) { - //Ignore - } - return null; - } - - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of WebArtifactEdit that are returned through this - * method must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an EARArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will be used for editing. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * <p> - * Note: This method is for internal use only. Clients should not call this method. - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of EARArtifactEdit that may be used to modify and persist changes to the - * underlying content model - */ - public static EARArtifactEdit getEARArtifactEditForWrite(IVirtualComponent aModule) { - try { - if (isValidEARModule(aModule)) { - IProject project = aModule.getProject(); - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(project); - return new EARArtifactEdit(nature, aModule, false); - } - } catch (UnresolveableURIException uue) { - //Ignore - } - return null; - } - - /** - * @param module - * A {@see WorkbenchComponent} - * @return True if the supplied module - * {@see ArtifactEdit#isValidEditableModule(WorkbenchComponent)}and the moduleTypeId is - * a JST module - */ - public static boolean isValidEARModule(IVirtualComponent aModule) throws UnresolveableURIException { - if (!isValidEditableModule(aModule)) - return false; - /* and match the JST_WEB_MODULE type */ - if (!TYPE_ID.equals(aModule.getComponentTypeId())) - return false; - return true; - } - - /** - * <p> - * Creates an instance facade for the given {@see ArtifactEditModel}. - * </p> - * - * @param anArtifactEditModel - */ - public EARArtifactEdit(ArtifactEditModel model) { - super(model); - } - - /** - * <p> - * Creates an instance facade for the given {@see ArtifactEditModel} - * </p> - * <p> - * Note: This method is for internal use only. Clients should not call this method. - * </p> - * - * @param aNature - * A non-null {@see ModuleCoreNature}for an accessible project - * @param aModule - * A non-null {@see WorkbenchComponent}pointing to a module from the given - * {@see ModuleCoreNature} - */ - - - public EARArtifactEdit(ModuleCoreNature aNature, IVirtualComponent aModule, boolean toAccessAsReadOnly) { - super(aNature, aModule, toAccessAsReadOnly); - } - - /** - * <p> - * Retrieves J2EE version information from ApplicationResource. - * </p> - * - * @return an integer representation of a J2EE Spec version - * - */ - public int getJ2EEVersion() { - return getApplicationXmiResource().getJ2EEVersionID(); - } - - /** - * - * @return ApplicationResource from (@link getDeploymentDescriptorResource()) - * - */ - - public ApplicationResource getApplicationXmiResource() { - return (ApplicationResource) getDeploymentDescriptorResource(); - } - - /** - * <p> - * Obtains the Application {@see Application}root object from the {@see ApplicationResource}, - * the root object contains all other resource defined objects. - * </p> - * - * @return Application - * - */ - - public Application getApplication() { - return (Application) getDeploymentDescriptorRoot(); - } - - /** - * <p> - * Retrieves the resource from the {@see ArtifactEditModel} - * </p> - * - * @return Resource - * - */ - - public Resource getDeploymentDescriptorResource() { - return getArtifactEditModel().getResource(URI.createURI(J2EEConstants.APPLICATION_DD_URI)); - } - - - /** - * <p> - * Creates a deployment descriptor root object (Application) and populates with data. Adds the - * root object to the deployment descriptor resource. - * </p> - * - * <p> - * - * @param aModule - * A non-null pointing to a {@see XMLResource} - * @param version - * Version to be set on resource....if null default is taken - * - * Note: This method is typically used for JUNIT - move? - * </p> - */ - protected void addApplicationIfNecessary(XMLResource aResource) { - if (aResource != null) { - if (aResource.getContents() == null || aResource.getContents().isEmpty()) { - Application newApp = ApplicationFactory.eINSTANCE.createApplication(); - aResource.getContents().add(newApp); - } - Application application = (Application) aResource.getContents().get(0); - URI moduleURI = getArtifactEditModel().getModuleURI(); - try { - application.setDisplayName(StructureEdit.getDeployedName(moduleURI)); - } catch (UnresolveableURIException e) { - //Ignore - } - aResource.setID(application, J2EEConstants.APPL_ID); - // TODO add more mandatory elements - } - } - - /** - * Checks if the uri mapping already exists. - * - * @param String - * currentURI - The current uri of the module. - * @return boolean - */ - public boolean uriExists(String currentURI) { - if (currentURI != null) { - IVirtualComponent comp = ComponentCore.createComponent(getComponentHandle().getProject(), getComponentHandle().getName()); - IVirtualReference[] refComponents = comp.getReferences(); - if (refComponents.length == 0) - return false; - for (int i = 0; i < refComponents.length; i++) { - if (refComponents[i].getRuntimePath().equals(currentURI)) - return true; - } - } // if - return false; - } // uriExists - - - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.modulecore.util.EnterpriseArtifactEdit#createModelRoot() - */ - public EObject createModelRoot() { - return createModelRoot(getJ2EEVersion()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.modulecore.util.EnterpriseArtifactEdit#createModelRoot(java.lang.Integer) - */ - public EObject createModelRoot(int version) { - ApplicationResource res = (ApplicationResource) getDeploymentDescriptorResource(); - res.setModuleVersionID(version); - addApplicationIfNecessary(res); - return ((ApplicationResource) getDeploymentDescriptorResource()).getRootObject(); - } - - /** - * This method will return the list of IVirtualReferences for all of the utility modules - * contained in the EAR application - * - * @return - a list of IVirtualReferences for utility modules in the EAR - */ - public List getUtilityModuleReferences() { - List utilityModuleTypes = new ArrayList(); - utilityModuleTypes.add(IModuleConstants.JST_UTILITY_MODULE); - return getComponentReferences(utilityModuleTypes); - } - - /** - * This method will return the list of IVirtualReferences for the J2EE module components - * contained in this EAR application. - * - * @return - a list of IVirtualReferences for J2EE modules in the EAR - */ - public List getJ2EEModuleReferences() { - List j2eeTypes = new ArrayList(); - j2eeTypes.add(IModuleConstants.JST_APPCLIENT_MODULE); - j2eeTypes.add(IModuleConstants.JST_CONNECTOR_MODULE); - j2eeTypes.add(IModuleConstants.JST_EJB_MODULE); - j2eeTypes.add(IModuleConstants.JST_WEB_MODULE); - return getComponentReferences(j2eeTypes); - } - - /** - * This method will return the list of IVirtualReferences for all of the components - * contained in this EAR application. - * - * @return - a list of IVirtualReferences for components in the EAR - */ - public List getComponentReferences() { - return getComponentReferences(Collections.EMPTY_LIST); - } - - private List getComponentReferences(List componentTypes) { - List components = new ArrayList(); - IProject project = getComponentHandle().getProject(); - String compName = getComponentHandle().getName(); - IVirtualComponent earComponent = ComponentCore.createComponent(project,compName); - if (earComponent.getComponentTypeId().equals(IModuleConstants.JST_EAR_MODULE)) { - IVirtualReference[] refComponents = earComponent.getReferences(); - for (int i = 0; i < refComponents.length; i++) { - IVirtualComponent module = refComponents[i].getReferencedComponent(); - if (componentTypes == null || componentTypes.size()==0) - components.add(refComponents[i]); - else { - for (int j=0;j<componentTypes.size(); j++) { - if (module.getComponentTypeId().equals(componentTypes.get(j))) { - components.add(refComponents[i]); - break; - } - } - } - } - } - return components; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddModuleMapCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddModuleMapCommand.java deleted file mode 100644 index 4ed59c1a6..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddModuleMapCommand.java +++ /dev/null @@ -1,93 +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.internal.earcreation; - - - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.AbstractCommand; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping; - - -public class AddModuleMapCommand extends AbstractCommand { - protected EAREditModel editModel; - protected Module module; - protected IProject project; - protected ModuleMapping map; - - /** - * AddModuleMapCommand constructor comment. - */ - protected AddModuleMapCommand() { - super(); - } - - /** - * AddModuleMapCommand constructor comment. - */ - public AddModuleMapCommand(EAREditModel earEditModel, Module aModule, IProject aProject) { - this(EARCreationResourceHandler.getString("Set_project_UI_")); //$NON-NLS-1$ - editModel = earEditModel; - module = aModule; - project = aProject; - } - - /** - * AddModuleMapCommand constructor comment. - * - * @param label - * java.lang.String - */ - protected AddModuleMapCommand(String label) { - super(label); - } - - /** - * AddModuleMapCommand constructor comment. - * - * @param label - * java.lang.String - * @param description - * java.lang.String - */ - protected AddModuleMapCommand(String label, String description) { - super(label, description); - } - - public boolean canUndo() { - return map != null; - } - - /** - * This will perform the command activity required for the effect. The effect of calling execute - * when canExecute returns false, or when canExecute hasn't been called, is undefined. - */ - public void execute() { - map = editModel.addModuleMapping(module, project); - } - - protected boolean prepare() { - return true; - } - - /** - * This will again perform the command activity required to redo the effect after undoing the - * effect. The effect, if any, of calling redo before undo is called is undefined. Note that if - * you implement redo to call execute then any derived class will be restricted to by that - * decision also. - */ - public void redo() { - execute(); - } - - public void undo() { - editModel.getModuleMappings().remove(map); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddModuleToEARProjectCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddModuleToEARProjectCommand.java deleted file mode 100644 index bfab7dd2a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddModuleToEARProjectCommand.java +++ /dev/null @@ -1,66 +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.internal.earcreation; - - - -import org.eclipse.core.resources.IProject; - - - -/** - * Insert the type's description here. Creation date: (03/29/01 4:48:46 PM) - * - * @author: Administrator - */ -public class AddModuleToEARProjectCommand extends ModuleInEARProjectCommand { - public AddModuleToEARProjectCommand(IProject aNestedJ2EEProject, IProject anEarProject, String uri, String contextRoot, String altDD) { - super(aNestedJ2EEProject, anEarProject, uri, contextRoot, altDD); - } - - protected void addModule() { - - super.addModule(); - moduleSuccessful = true; - } - - protected void addModuleMapping() { - mapSuccessful = true; // Set this first, because failure in super will turn it to false - super.addModuleMapping(); - } - - public boolean canExecute() { - return super.canExecute() && EARNatureRuntime.getRuntime(getEarProject()) != null && org.eclipse.jst.j2ee.internal.project.J2EENature.getRegisteredRuntime(getNestedJ2EEProject()) != null; - } - - protected void primExecute() { - addModule(); - if (moduleSuccessful) - addModuleMapping(); - } - - protected void primUndo() { - if (mapSuccessful) { - removeModuleMapping(); - mapSuccessful = false; - } - if (moduleSuccessful) { - removeModule(); - moduleSuccessful = false; - } - - } - - // override - public String getLabel() { - return label == null ? EARCreationResourceHandler.getString("Add_Module_Command_Label_UI_") : label;//$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddUtilityJARMapCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddUtilityJARMapCommand.java deleted file mode 100644 index e9d70ccc4..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/AddUtilityJARMapCommand.java +++ /dev/null @@ -1,50 +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.internal.earcreation; - - -import org.eclipse.core.resources.IProject; - - -public class AddUtilityJARMapCommand extends UtilityJARInEARProjectCommand { - - public static final String LABEL = EARCreationResourceHandler.getString("Add_Utility_JAR_UI"); //$NON-NLS-1$ - - /** - * AddModuleMapCommand constructor comment. - */ - public AddUtilityJARMapCommand(EAREditModel earEditModel, String aUri, IProject aProject) { - super(earEditModel, aUri, aProject, LABEL); - } - - public AddUtilityJARMapCommand(IProject anEarProject, String aUri, IProject aProject) { - super(anEarProject, aUri, aProject, LABEL); - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.earcreation.UtilityJARInEARProjectCommand#primExecute() - */ - protected void primExecute() { - addMapping(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.earcreation.UtilityJARInEARProjectCommand#primUndo() - */ - protected void primUndo() { - removeMapping(); - } - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/DefaultJ2EEComponentCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/DefaultJ2EEComponentCreationDataModel.java deleted file mode 100644 index 55f446c9d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/DefaultJ2EEComponentCreationDataModel.java +++ /dev/null @@ -1,535 +0,0 @@ -package org.eclipse.jst.j2ee.internal.earcreation; -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.application.internal.operations.DefaultJ2EEComponentCreationOperation; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationDataModel; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentCreationDataModel; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -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.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelEvent; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/* - * Created on Mar 23, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ - -public class DefaultJ2EEComponentCreationDataModel extends WTPOperationDataModel { - private static final String WEB_SUFFIX = "Web"; //$NON-NLS-1$ - private static final String EJB_SUFFIX = "EJB"; //$NON-NLS-1$ - private static final String CLIENT_SUFFIX = "Client"; //$NON-NLS-1$ - private static final String CONNECTOR_SUFFIX = "Connector"; //$NON-NLS-1$ - /** - * Required - This is the name of the project. type String - */ - public static final String PROJECT_NAME = "DefaultJ2EEComponentCreationDataModel.PROJECT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the ear. type String - */ - public static final String EAR_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.EAR_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the app client. type String - */ - public static final String APPCLIENT_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.APPCLIENT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the WEB. type String - */ - public static final String WEB_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.WEB_COMPONENT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the EJB. type String - */ - public static final String EJB_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.EJB_COMPONENT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the connector. type String - */ - public static final String CONNECTOR_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.CONNECTOR_COMPONENT_NAME"; //$NON-NLS-1$ - - public static final String J2EE_VERSION = "DefaultJ2EEComponentCreationDataModel.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 = "DefaultJ2EEComponentCreationDataModel.CREATE_"; //$NON-NLS-1$ - /** - * Default is true. type Boolean - */ - public static final String CREATE_EJB = CREATE_BASE + EJB; - /** - * Default is true. type Boolean - */ - public static final String CREATE_WEB = CREATE_BASE + WEB; - /** - * Default is true. type Boolean - */ - public static final String CREATE_APPCLIENT = CREATE_BASE + CLIENT; - /** - * Default is true. type Boolean - */ - public static final String CREATE_CONNECTOR = CREATE_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 = "DefaultJ2EEComponentCreationDataModel.MODULE_NAME_COLLISIONS_VALIDATION"; //$NON-NLS-1$ - - /** - * Default is true. type Boolean - */ - public static final String ENABLED = "DefaultJ2EEComponentCreationDataModel.ENABLED"; //$NON-NLS-1$ - - private static final String NESTED_MODEL_EJB = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_EJB"; //$NON-NLS-1$ - private static final String NESTED_MODEL_WEB = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_WEB"; //$NON-NLS-1$ - private static final String NESTED_MODEL_JCA = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_JCA"; //$NON-NLS-1$ - private static final String NESTED_MODEL_CLIENT = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_CLIENT"; //$NON-NLS-1$ - - private J2EEComponentCreationDataModel ejbModel; - private J2EEComponentCreationDataModel webModel; - private J2EEComponentCreationDataModel jcaModel; - private AppClientComponentCreationDataModel clientModel; - - /** - * - */ - public DefaultJ2EEComponentCreationDataModel() { - super(); - } - - public WTPOperation getDefaultOperation() { - return new DefaultJ2EEComponentCreationOperation(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#initValidBaseProperties() - */ - protected void initValidBaseProperties() { - addValidBaseProperty(PROJECT_NAME); - addValidBaseProperty(EAR_COMPONENT_NAME); - addValidBaseProperty(APPCLIENT_COMPONENT_NAME); - addValidBaseProperty(CONNECTOR_COMPONENT_NAME); - addValidBaseProperty(EJB_COMPONENT_NAME); - addValidBaseProperty(WEB_COMPONENT_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 AppClientComponentCreationDataModel(); - 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); - } - } - - /* - * (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.equals(J2EE_VERSION)) { - updatedJ2EEVersion((Integer) propertyValue); - return true; - } - if (propertyName.startsWith(CREATE_BASE)) - notifyEnablement(convertPropertyNameToInt(propertyName)); - if (propertyName.equals(EAR_COMPONENT_NAME)){ - setDefaultComponentNames((String)propertyValue); - } - return notify; - } - - public void propertyChanged(WTPOperationDataModelEvent event) { - if (event.getPropertyName().equals(J2EEComponentCreationDataModel.PROJECT_NAME)) { - Object source = event.getDataModel(); - String propertyName = null; - if (ejbModel == source) { - propertyName = EJB_COMPONENT_NAME; - } else if (webModel == source) { - propertyName = WEB_COMPONENT_NAME; - } else if (jcaModel == source) { - propertyName = CONNECTOR_COMPONENT_NAME; - } else - 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_COMPONENT_NAME; - break; - case WEB : - propertyName = WEB_COMPONENT_NAME; - break; - case CLIENT : - propertyName = APPCLIENT_COMPONENT_NAME; - break; - case RAR : - propertyName = CONNECTOR_COMPONENT_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.equals(APPCLIENT_COMPONENT_NAME)){ - return validateComponentName(getStringProperty(APPCLIENT_COMPONENT_NAME)); - } - if(propertyName.equals(WEB_COMPONENT_NAME)){ - return validateComponentName(getStringProperty(WEB_COMPONENT_NAME)); - } - if(propertyName.equals(EJB_COMPONENT_NAME)){ - return validateComponentName(getStringProperty(EJB_COMPONENT_NAME)); - } - if(propertyName.equals(CONNECTOR_COMPONENT_NAME)){ - return validateComponentName(getStringProperty(CONNECTOR_COMPONENT_NAME)); - } - return super.doValidateProperty(propertyName); - } - - private IStatus validateComponentName(String componentName) { - IStatus status = OK_STATUS; - if (status.isOK()) { - if (componentName.indexOf("#") != -1) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_INVALID_CHARS); //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(errorMessage); - } else if (componentName==null || componentName.equals("")) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_EMPTY_MODULE_NAME); - return WTPCommonPlugin.createErrorStatus(errorMessage); - } - } - return status; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doGetProperty(java.lang.String) - */ - protected Object doGetProperty(String componentName) { - return super.doGetProperty(componentName); - } - - private void setDefaultNestedComponentName(String name, int flag) { - J2EEComponentCreationDataModel modModule = getNestedModel(flag); - if (modModule != null) { - String compName = ensureUniqueProjectName(name); - modModule.setProperty(IJ2EEComponentCreationDataModelProperties.PROJECT_NAME, getStringProperty(PROJECT_NAME)); - modModule.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_NAME, compName); - } - } - - /** - * @param string - */ - private void setDefaultComponentNames(String base) { - String componentName; - if (base.endsWith(EJB_SUFFIX)) - componentName = base; - else - componentName = base + EJB_SUFFIX; - setDefaultNestedComponentName(componentName, EJB); - setProperty(EJB_COMPONENT_NAME, componentName); - if (base.endsWith(WEB_SUFFIX)) - componentName = base; - else - componentName = base + WEB_SUFFIX; - setDefaultNestedComponentName(componentName, WEB); - setProperty(WEB_COMPONENT_NAME, componentName); - if (base.endsWith(CLIENT_SUFFIX)) - componentName = base; - else - componentName = base + CLIENT_SUFFIX; - setDefaultNestedComponentName(componentName, CLIENT); - setProperty(APPCLIENT_COMPONENT_NAME, componentName); - if (base.endsWith(CONNECTOR_SUFFIX)) - componentName = base; - else - componentName = base + CONNECTOR_SUFFIX; - setDefaultNestedComponentName(componentName, RAR); - setProperty(CONNECTOR_COMPONENT_NAME, componentName); - } - - /** - * @param j2eeVersion - */ - private void setNestedJ2EEVersion(Object j2eeVersion) { - if (ejbModel != null) - ejbModel.setProperty(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - if (webModel != null) - webModel.setProperty(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - if (jcaModel != null) - jcaModel.setProperty(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - clientModel.setProperty(J2EEComponentCreationDataModel.J2EE_VERSION, j2eeVersion); - } - - /** - * @param flag - * @param projectName - */ - private void setNestedComponentName(int flag, String compName) { - J2EEComponentCreationDataModel model = getNestedModel(flag); - if (model != null) { - model.setProperty(J2EEComponentCreationDataModel.COMPONENT_NAME, compName); - } - } - - /** - * @param flag - */ - private IStatus validateNestedProjectName(int flag) { - J2EEComponentCreationDataModel 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(J2EEComponentCreationDataModel.PROJECT_NAME); - } - } - return J2EEPlugin.OK_STATUS; - } - - private J2EEComponentCreationDataModel getNestedModel(int flag) { - switch (flag) { - case EJB : - return ejbModel; - case WEB : - return webModel; - case RAR : - return jcaModel; - case CLIENT : - return clientModel; - } - return null; - } - - /** - * @return Returns the clientModel. - */ - public AppClientComponentCreationDataModel getClientModel() { - return clientModel; - } - - /** - * @return Returns the ejbModel. - */ - public J2EEComponentCreationDataModel getEjbModel() { - return ejbModel; - } - - /** - * @return Returns the rarModel. - */ - public J2EEComponentCreationDataModel getJCAModel() { - return jcaModel; - } - - /** - * @return Returns the webModel. - */ - public J2EEComponentCreationDataModel 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_COMPONENT_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_COMPONENT_NAME)) - return (Boolean) getProperty(CREATE_APPCLIENT); - if (propertyName.equals(EJB_COMPONENT_NAME)) - return (Boolean) getProperty(CREATE_EJB); - if (propertyName.equals(WEB_COMPONENT_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/internal/earcreation/DefaultJ2EEComponentCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/DefaultJ2EEComponentCreationDataModelProvider.java deleted file mode 100644 index a37bcbcf7..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/DefaultJ2EEComponentCreationDataModelProvider.java +++ /dev/null @@ -1,450 +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.internal.earcreation; - -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.application.internal.operations.DefaultJ2EEComponentCreationOp; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentCreationDataModelProvider; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -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.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class DefaultJ2EEComponentCreationDataModelProvider extends AbstractDataModelProvider implements IDefaultJ2EEComponentCreationDataModelProperties { - private static String CREATE_BASE = "DefaultJ2EEComponentCreationDataModel.CREATE_"; //$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 final String WEB_SUFFIX = "Web"; //$NON-NLS-1$ - private static final String EJB_SUFFIX = "EJB"; //$NON-NLS-1$ - private static final String CLIENT_SUFFIX = "Client"; //$NON-NLS-1$ - private static final String CONNECTOR_SUFFIX = "Connector"; //$NON-NLS-1$ - - public DefaultJ2EEComponentCreationDataModelProvider() { - super(); - } - - public String[] getPropertyNames() { - String[] props = new String[] { PROJECT_NAME, EAR_COMPONENT_NAME, APPCLIENT_COMPONENT_NAME, WEB_COMPONENT_NAME, EJB_COMPONENT_NAME, CONNECTOR_COMPONENT_NAME, J2EE_VERSION, CREATE_EJB, CREATE_WEB, CREATE_APPCLIENT, CREATE_CONNECTOR, MODULE_NAME_COLLISIONS_VALIDATION, ENABLED, - NESTED_MODEL_CLIENT, NESTED_MODEL_EJB, NESTED_MODEL_JCA, NESTED_MODEL_WEB }; - return props; - } - - private IDataModel ejbModel; - - private IDataModel webModel; - - private IDataModel jcaModel; - - private IDataModel clientModel; - - public IDataModelOperation getDefaultOperation() { - return new DefaultJ2EEComponentCreationOp(getDataModel()); - } - - public void init() { - initNestedCreationModels(); - super.init(); - } - protected void initNestedCreationModels() { - clientModel = DataModelFactory.createDataModel(new AppClientComponentCreationDataModelProvider()); - EjbModuleExtension ejbExt = EarModuleManager.getEJBModuleExtension(); - if (ejbExt != null) { - ejbModel = ejbExt.createProjectDataModel(); - if (ejbModel != null) - model.addNestedModel(NESTED_MODEL_EJB, ejbModel); - } - WebModuleExtension webExt = EarModuleManager.getWebModuleExtension(); - if (webExt != null) { - webModel = webExt.createProjectDataModel(); - if (webModel != null) - model.addNestedModel(NESTED_MODEL_WEB, webModel); - } - JcaModuleExtension rarExt = EarModuleManager.getJCAModuleExtension(); - if (rarExt != null) { - jcaModel = rarExt.createProjectDataModel(); - if (jcaModel != null) - model.addNestedModel(NESTED_MODEL_JCA, jcaModel); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#getDefaultProperty(java.lang.String) - */ - public 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) { - if(propertyName.equals(CREATE_WEB)){ - return WEB; - } else if(propertyName.equals(CREATE_EJB)){ - return EJB; - } else if(propertyName.equals(CREATE_CONNECTOR)){ - return RAR; - } else if(propertyName.equals(CREATE_APPCLIENT)){ - return CLIENT; - } - return -1; - } - - /** - * @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) - */ - public boolean propertySet(String propertyName, Object propertyValue) { - boolean notify = super.propertySet(propertyName, propertyValue); - if (propertyName.equals(J2EE_VERSION)) { - updatedJ2EEVersion((Integer) propertyValue); - return true; - } - if (propertyName.startsWith(CREATE_BASE)) - notifyEnablement(convertPropertyNameToInt(propertyName)); - if (propertyName.equals(EAR_COMPONENT_NAME)) { - setDefaultComponentNames((String) propertyValue); - } -// if (propertyName.equals(IJ2EEComponentCreationDataModelProperties.PROJECT_NAME)) { -// Object source = ge -// String propertyName = null; -// if (ejbModel == source) { -// propertyName = EJB_COMPONENT_NAME; -// } else if (webModel == source) { -// propertyName = WEB_COMPONENT_NAME; -// } else if (jcaModel == source) { -// propertyName = CONNECTOR_COMPONENT_NAME; -// } else if (null != propertyName) { -// setProperty(propertyName, event.getProperty()); -// return; -// } -// } - return notify; - } - - private void notifyEnablement(int flag) { - String propertyName = null; - switch (flag) { - case EJB: - propertyName = EJB_COMPONENT_NAME; - break; - case WEB: - propertyName = WEB_COMPONENT_NAME; - break; - case CLIENT: - propertyName = APPCLIENT_COMPONENT_NAME; - break; - case RAR: - propertyName = CONNECTOR_COMPONENT_NAME; - } - if (propertyName != null) - model.notifyPropertyChange(propertyName, IDataModel.ENABLE_CHG); - } - - private void updatedJ2EEVersion(Integer version) { - setNestedJ2EEVersion(version); - if (version.intValue() < J2EEVersionConstants.J2EE_1_3_ID && model.isPropertySet(CREATE_CONNECTOR)) { - model.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.getStringProperty(IJ2EEComponentCreationDataModelProperties.PROJECT_NAME); - projectName = CoreFileSystemLibrary.isCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase(); - list.add(projectName); - errorNoSelection = false; - } - if (getBooleanProperty(CREATE_EJB)) { - actualProjectName = ejbModel.getStringProperty(IJ2EEComponentCreationDataModelProperties.PROJECT_NAME); - 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.getStringProperty(IJ2EEComponentCreationDataModelProperties.PROJECT_NAME); - 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.getStringProperty(IJ2EEComponentCreationDataModelProperties.PROJECT_NAME); - 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) - */ - public IStatus validate(String propertyName) { - if (propertyName.equals(APPCLIENT_COMPONENT_NAME)) { - return validateComponentName(getStringProperty(APPCLIENT_COMPONENT_NAME)); - } - if (propertyName.equals(WEB_COMPONENT_NAME)) { - return validateComponentName(getStringProperty(WEB_COMPONENT_NAME)); - } - if (propertyName.equals(EJB_COMPONENT_NAME)) { - return validateComponentName(getStringProperty(EJB_COMPONENT_NAME)); - } - if (propertyName.equals(CONNECTOR_COMPONENT_NAME)) { - return validateComponentName(getStringProperty(CONNECTOR_COMPONENT_NAME)); - } - return super.validate(propertyName); - } - - private IStatus validateComponentName(String componentName) { - IStatus status = OK_STATUS; - if (status.isOK()) { - if (componentName.indexOf("#") != -1) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_INVALID_CHARS); //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(errorMessage); - } else if (componentName == null || componentName.equals("")) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_EMPTY_MODULE_NAME); - return WTPCommonPlugin.createErrorStatus(errorMessage); - } - } - return status; - } - - private void setDefaultNestedComponentName(String name, int flag) { - IDataModel modModule = getNestedModel(flag); - if (modModule != null) { - String compName = ensureUniqueProjectName(name); - modModule.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_NAME, compName); - } - } - - /** - * @param string - */ - private void setDefaultComponentNames(String base) { - String componentName; - if (base.endsWith(EJB_SUFFIX)) - componentName = base; - else - componentName = base + EJB_SUFFIX; - setDefaultNestedComponentName(componentName, EJB); - setProperty(EJB_COMPONENT_NAME, componentName); - if (base.endsWith(WEB_SUFFIX)) - componentName = base; - else - componentName = base + WEB_SUFFIX; - setDefaultNestedComponentName(componentName, WEB); - setProperty(WEB_COMPONENT_NAME, componentName); - if (base.endsWith(CLIENT_SUFFIX)) - componentName = base; - else - componentName = base + CLIENT_SUFFIX; - setDefaultNestedComponentName(componentName, CLIENT); - setProperty(APPCLIENT_COMPONENT_NAME, componentName); - if (base.endsWith(CONNECTOR_SUFFIX)) - componentName = base; - else - componentName = base + CONNECTOR_SUFFIX; - setDefaultNestedComponentName(componentName, RAR); - setProperty(CONNECTOR_COMPONENT_NAME, componentName); - } - - /** - * @param j2eeVersion - */ - private void setNestedJ2EEVersion(Object j2eeVersion) { - if (ejbModel != null) - ejbModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_VERSION, j2eeVersion); - if (webModel != null) - webModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_VERSION, j2eeVersion); - if (jcaModel != null) - jcaModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_VERSION, j2eeVersion); - if (clientModel != null) - clientModel.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_VERSION, j2eeVersion); - } - - /** - * @param flag - * @param projectName - */ - private void setNestedComponentName(int flag, String compName) { - IDataModel model = getNestedModel(flag); - if (model != null) { - model.setProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_NAME, compName); - } - } - - /** - * @param flag - */ - private IStatus validateNestedProjectName(int flag) { - IDataModel 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(IJ2EEComponentCreationDataModelProperties.PROJECT_NAME); - } - } - return J2EEPlugin.OK_STATUS; - } - - private IDataModel getNestedModel(int flag) { - switch (flag) { - case EJB: - return ejbModel; - case WEB: - return webModel; - case RAR: - return jcaModel; - case CLIENT: - return clientModel; - } - return null; - } - /** - * @return Returns the clientModel. - */ - public IDataModel getClientModel() { - return clientModel; - } - /** - * @return Returns the ejbModel. - */ - public IDataModel getEjbModel() { - return ejbModel; - } - /** - * @return Returns the rarModel. - */ - public IDataModel getJCAModel() { - return jcaModel; - } - /** - * @return Returns the webModel. - */ - public IDataModel getWebModel() { - return webModel; - } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#basicIsEnabled(java.lang.String) - */ - public boolean isPropertyEnabled(String propertyName) { - if (propertyName.equals(CREATE_CONNECTOR) || propertyName.equals(CONNECTOR_COMPONENT_NAME)) { - int version = getIntProperty(J2EE_VERSION); - boolean result = version > J2EEVersionConstants.J2EE_1_2_ID; - if (result) - return getBooleanProperty(CREATE_CONNECTOR); - return result; - } - if (propertyName.equals(APPCLIENT_COMPONENT_NAME)) - return getBooleanProperty(CREATE_APPCLIENT); - if (propertyName.equals(EJB_COMPONENT_NAME)) - return getBooleanProperty(CREATE_EJB); - if (propertyName.equals(WEB_COMPONENT_NAME)) - return getBooleanProperty(CREATE_WEB); - return super.isPropertyEnabled(propertyName); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARComponentCreationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARComponentCreationDataModel.java deleted file mode 100644 index 556338d26..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARComponentCreationDataModel.java +++ /dev/null @@ -1,254 +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.internal.earcreation; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModel; -import org.eclipse.jst.j2ee.application.internal.operations.EARComponentCreationOperation; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationDataModel; -import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationDataModel; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelEvent; -import org.eclipse.wst.common.frameworks.internal.operations.WTPPropertyDescriptor; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.ServerCore; - -public class EARComponentCreationDataModel extends J2EEComponentCreationDataModel { - - /** - * Requred. This must be a list of WorkbenchComponent. - */ - public static final String J2EE_COMPONENT_LIST = "EARComponentCreationDataModel.J2EE_COMPONENT_LIST"; //$NON-NLS-1$ - - /** - * - */ - public WTPOperation getDefaultOperation() { - return new EARComponentCreationOperation(this); - } - - /** - * @return Returns the default J2EE spec level based on the Global J2EE Preference - */ - protected Integer getDefaultComponentVersion() { - 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_ID); - } - } - - /** - * - */ - protected void initValidBaseProperties() { - //Not calling super... EAR is not need EAR properties - addValidBaseProperty(PROJECT_NAME); - addValidBaseProperty(COMPONENT_NAME); - addValidBaseProperty(COMPONENT_DEPLOY_NAME); - addValidBaseProperty(CREATE_DEFAULT_FILES); - addValidBaseProperty(IS_ENABLED); - addValidBaseProperty(FINAL_PERSPECTIVE); - addValidBaseProperty(COMPONENT_VERSION); - addValidBaseProperty(VALID_MODULE_VERSIONS_FOR_PROJECT_RUNTIME); - addValidBaseProperty(JAVASOURCE_FOLDER); - addValidBaseProperty(MANIFEST_FOLDER); - addValidBaseProperty(USE_ANNOTATIONS); - addValidBaseProperty(DD_FOLDER); - addValidBaseProperty(J2EE_VERSION); - addValidBaseProperty(NESTED_MODEL_VALIDATION_HOOK); - addValidBaseProperty(UI_SHOW_EAR_SECTION); - addValidBaseProperty(J2EE_COMPONENT_LIST); - } - - /** - * @param workbenchComp - */ - protected void setEARComponentIfJ2EEModuleCreationOnly(WorkbenchComponent workbenchComp, Object propertyValue) { - //Overwritting super class method to do nothing for EAR component creation only needed for all other j2ee modules - } - - protected void initNestedModels() { - } - - /** - * - */ - protected AddComponentToEnterpriseApplicationDataModel createModuleNestedModel() { - return new AddComponentToEnterpriseApplicationDataModel(); - } - - /** - * - */ - protected Object getDefaultProperty(String propertyName) { - if (propertyName.equals(DD_FOLDER)) { - return IPath.SEPARATOR + this.getModuleName() + IPath.SEPARATOR + "META_INF"; //$NON-NLS-1$ - } else if (propertyName.equals(UI_SHOW_EAR_SECTION)) { - return Boolean.FALSE; - } - else if (propertyName.equals(J2EE_COMPONENT_LIST)) { - return Collections.EMPTY_LIST; - } - return super.getDefaultProperty(propertyName); - } - - /** - * - */ - protected WTPPropertyDescriptor doGetPropertyDescriptor(String propertyName) { - if (propertyName.equals(COMPONENT_VERSION)) { - Integer propertyValue = (Integer) getProperty(propertyName); - String description = null; - switch (propertyValue.intValue()) { - case J2EEVersionConstants.WEB_2_2_ID : - description = J2EEVersionConstants.VERSION_2_2_TEXT; - break; - case J2EEVersionConstants.WEB_2_3_ID : - description = J2EEVersionConstants.VERSION_2_3_TEXT; - break; - case J2EEVersionConstants.WEB_2_4_ID : - default : - description = J2EEVersionConstants.VERSION_2_4_TEXT; - break; - } - return new WTPPropertyDescriptor(propertyValue, description); - } - return super.doGetPropertyDescriptor(propertyName); - } - - /** - * - */ - protected WTPPropertyDescriptor[] getValidComponentVersionDescriptors() { - 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); - break; - } - return descriptors; - } - - /** - * - */ - protected int convertModuleVersionToJ2EEVersion(int moduleVersion) { - return moduleVersion; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEModuleCreationDataModel#getModuleType() - */ - protected EClass getComponentType() { - return CommonarchiveFactoryImpl.getPackage().getEARFile(); - } - - protected String getComponentExtension() { - return ".ear"; //$NON-NLS-1$ - } - - protected Boolean basicIsEnabled(String propertyName) { - if (USE_ANNOTATIONS.equals(propertyName)) { - if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3) - return Boolean.FALSE; - return Boolean.TRUE; - } - return super.basicIsEnabled(propertyName); - } - - protected IStatus doValidateProperty(String propertyName) { - - if (propertyName.equals(ComponentCreationDataModel.PROJECT_NAME)) { - // validate server target - String projectName = getStringProperty(ComponentCreationDataModel.PROJECT_NAME); - if (projectName != null && projectName.length() != 0) { - IProject project = ProjectUtilities.getProject(projectName); - if (project != null) { - IRuntime runtime = ServerCore.getProjectProperties(project) - .getRuntimeTarget(); - if (runtime != null) { - IRuntimeType type = runtime.getRuntimeType(); - String typeId = type.getId(); - if (typeId.startsWith("org.eclipse.jst.server.tomcat")) { //$NON-NLS-1$ - String msg = EARCreationResourceHandler - .getString(EARCreationResourceHandler.SERVER_TARGET_NOT_SUPPORT_EAR); - return WTPCommonPlugin.createErrorStatus(msg); - } - } - } - } - } else if (propertyName.equals(NESTED_MODEL_VALIDATION_HOOK)) - return OK_STATUS; - return super.doValidateProperty(propertyName); - } - - protected boolean doSetProperty(String propertyName, Object propertyValue) { - boolean returnValue = super.doSetProperty(propertyName, propertyValue); - - if (propertyName.equals(COMPONENT_NAME)){ - setProperty(COMPONENT_DEPLOY_NAME, getStringProperty(COMPONENT_NAME)); - } - return returnValue; - } - - public void propertyChanged(WTPOperationDataModelEvent event) { - super.propertyChanged(event); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.j2ee.application.operations.FlexibleJ2EECreationDataModel#getModuleID() - */ - protected String getComponentID() { - return IModuleConstants.JST_EAR_MODULE; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARCreationResourceHandler.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARCreationResourceHandler.java deleted file mode 100644 index 90c8f6f3d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARCreationResourceHandler.java +++ /dev/null @@ -1,83 +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.internal.earcreation; - - - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class EARCreationResourceHandler { - - public static final String ADD_MODULE_MODULE_TYPE = "1"; //$NON-NLS-1$ - public static final String ADD_MODULE_MODULE_EXISTS = "2"; //$NON-NLS-1$ - public static final String ADD_MODULE_MODULE_CLOSED = "3"; //$NON-NLS-1$ - public static final String ADD_MODULE_MODULE_NULL = "4"; //$NON-NLS-1$ - public static final String ADD_PROJECT_URI_EXISTS = "5"; //$NON-NLS-1$ - public static final String ADD_PROJECT_NOT_JAVA = "6"; //$NON-NLS-1$ - public static final String ADD_PROJECT_UTIL_URI = "7"; //$NON-NLS-1$ - public static final String ADD_PROJECT_UTIL_MAPPED = "8"; //$NON-NLS-1$ - public static final String ADD_PROJECT_NOT_EAR = "9"; //$NON-NLS-1$ - public static final String ADD_PROJECT_URI_EMPTY = "10"; //$NON-NLS-1$ - public static final String NOT_AN_APP_CLIENT = "11"; //$NON-NLS-1$ - public static final String NOT_AN_EAR = "12"; //$NON-NLS-1$ - public static final String NOT_AN_EJB = "13"; //$NON-NLS-1$ - public static final String NOT_A_RAR = "14"; //$NON-NLS-1$ - public static final String NOT_A_WAR = "15"; //$NON-NLS-1$ - public static final String SERVER_TARGET_NOT_SUPPORT_EAR = "16"; //$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle; - - - - /** - * Returns the resource bundle used by all classes in this Project - */ - public static ResourceBundle getResourceBundle() { - try { - return ResourceBundle.getBundle("earcreation");//$NON-NLS-1$ - } catch (MissingResourceException e) { - // does nothing - this method will return null and - // getString(String, String) will return the key - // it was called with - } - return null; - } - - public static String getString(String key) { - if (fgResourceBundle == null) { - fgResourceBundle = getResourceBundle(); - } - - if (fgResourceBundle != null) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - } - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - - public static String getString(String key, Object[] args) { - - try { - return MessageFormat.format(getString(key), args); - } catch (IllegalArgumentException e) { - return getString(key); - } - - } - - public static void nlsConcatenationFinder() { - // used to tag methods which have concatenated strings - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EAREditModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EAREditModel.java deleted file mode 100644 index 3098d228d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EAREditModel.java +++ /dev/null @@ -1,746 +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.internal.earcreation; - - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.common.util.WrappedException; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.xmi.XMIResource; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -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.application.internal.operations.DefaultModuleProjectCreationOperation; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.application.ApplicationPackage; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.EARProjectMap; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModulemapPackage; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; -import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleManager; -import org.eclipse.wst.common.frameworks.internal.SaveFailedException; -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelEvent; - -/** - * - * @deprecated - * Use - * <p> - * EARArtifactEdit - * </p> - * - */ -public class EAREditModel extends org.eclipse.jst.j2ee.internal.J2EEEditModel { - private boolean stopListenerNotifications = false; - //TODO this is a hack until the DOM adaptors are working - public static final String MODULE_MAP_URI = "META-INF/.modulemaps"; //$NON-NLS-1$ - public static final URI MODULE_MAP_URI_OBJ = URI.createURI(MODULE_MAP_URI); - - /** - * EJBSaveModel constructor comment. - * - * @param Object - * editModelID - An editModelID to identify the EditModel - */ - public EAREditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly) { - super(editModelID, context, readOnly); - }// EAREditModel - - /** - * EJBSaveModel constructor comment. - * - * @param Object - * editModelID - An editModelID to identify the EditModel - */ - public EAREditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly, boolean accessUnkownResourcesAsReadOnly) { - super(editModelID, context, readOnly, accessUnkownResourcesAsReadOnly); - }// EAREditModel - - /** - * Adds the module mapping to a project. - * - * @param Module - * module - The module to add - * @param IProject - * project - The current project. - * @return ModuleMapping - */ - public ModuleMapping addModuleMapping(Module module, IProject aProject) { - - ModuleMapping map = ((ModulemapPackage) EPackage.Registry.INSTANCE.getEPackage(ModulemapPackage.eNS_URI)).getModulemapFactory().createModuleMapping(); - map.setModule(module); - map.setProjectName(aProject.getName()); - getEARProjectMap().getMappings().add(map); - - return map; - }// ModuleMapping - - /** - * Adds a utility jar mapping to a project. - * - * @param String - * uri - Utility jar uri. - * @param IProject - * project - The current project. - * @return UtilityJARMapping - */ - public UtilityJARMapping addUtilityJARMapping(String uri, IProject aProject) { - - UtilityJARMapping map = ((ModulemapPackage) EPackage.Registry.INSTANCE.getEPackage(ModulemapPackage.eNS_URI)).getModulemapFactory().createUtilityJARMapping(); - map.setUri(uri); - map.setProjectName(aProject.getName()); - getEARProjectMap().getUtilityJARMappings().add(map); - - return map; - }// addUtilityJARMapping - - /** - * Return the root object, application, from the application.xml DD. - * - * @return Application - */ - public Application getApplication() { - ApplicationResource dd = getApplicationXmiResource(); - return dd == null ? null : dd.getApplication(); - } - - /** - * Gets the application resource. - * - * @return ApplicationResource - */ - public ApplicationResource getApplicationXmiResource() { - return (ApplicationResource) getResource(J2EEConstants.APPLICATION_DD_URI_OBJ); - }// getApplicationXmiResource - - /** - * Answer all the projects referenced by the .modulemaps file - * - * @return Set - */ - public Set getModuleMappedProjects() { - Set aSet = getModuleMappedModuleProjects(); - aSet.addAll(getModuleMappedUtilityJarProjects()); - return aSet; - } - - public Map getModuleMappedProjectsAsMap() { - Map aMap = getModuleMappedModuleProjectsAsMap(); - aMap.putAll(getModuleMappedUtilityJarProjectsAsMap()); - return aMap; - } - - - public Set getModuleMappedUtilityJarProjects() { - Set aSet = new HashSet(); - aSet.addAll(getModuleMappedUtilityJarProjectsAsMap().values()); - return aSet; - } - - public Map getModuleMappedUtilityJarProjectsAsMap() { - Map aMap = new HashMap(); - IProject aProject = null; - List utilityJARMappings = getUtilityJARMappings(); - for (int i = 0; i < utilityJARMappings.size(); i++) { - aProject = null; - UtilityJARMapping map = (UtilityJARMapping) utilityJARMappings.get(i); - if (map.getProjectName() != null && map.getProjectName().length() > 0) - aProject = getProject(map.getProjectName()); - if (aProject != null && map.getUri() != null && map.getUri().length() > 0) - aMap.put(map.getUri(), aProject); - } - return aMap; - } - - public Set getModuleMappedModuleProjects() { - Set aSet = new HashSet(); - aSet.addAll(getModuleMappedModuleProjectsAsMap().values()); - return aSet; - } - - public Map getModuleMappedModuleProjectsAsMap() { - Map aMap = new HashMap(); - List moduleMappings = getModuleMappings(); - IProject aProject = null; - for (int i = 0; i < moduleMappings.size(); i++) { - aProject = null; - ModuleMapping map = (ModuleMapping) moduleMappings.get(i); - if (map.getProjectName() != null && map.getProjectName().length() > 0) - aProject = getProject(map.getProjectName()); - Module module = map.getModule(); - if (aProject != null && module != null && module.getUri() != null && module.getUri().length() > 0) - aMap.put(module.getUri(), aProject); - } - return aMap; - } - - - /** - * Get a project - * - * @param String - * name - The project name. - * @return IProject - */ - protected IProject getProject(String name) { - if (name == null || name.length() == 0) - return null; - return ResourcesPlugin.getWorkspace().getRoot().getProject(name); - } - - protected IProject getProject(ModuleMapping mapping) { - if (mapping != null && mapping.getProjectName() != null && mapping.getProjectName().length() > 0) - return getProject(mapping.getProjectName()); - return null; - } - - /** - * Finds an existing UtilityJARMapping for the project and uri, if one exists - * - */ - public UtilityJARMapping getUtilityJARMapping(String uri, IProject aProject) { - if (aProject == null || uri == null) - return null; - List maps = getUtilityJARMappings(); - for (int i = 0; i < maps.size(); i++) { - UtilityJARMapping map = (UtilityJARMapping) maps.get(i); - if (aProject.getName().equals(map.getProjectName()) && uri.equals(map.getUri())) - return map; - } - return null; - } - - /** - * Insert the method's description here. Creation date: (4/11/2001 4:14:26 PM) - * - * @return EJBNatureRuntime - */ - public EARNatureRuntime getEARNature() { - return EARNatureRuntime.getRuntime(getProject()); - } - - /** - * The root object which contains the list of mappings from application modules to workbench - * projects - */ - public EARProjectMap getEARProjectMap() { - return getEARProjectMap(true); - } - - /** - * The root object which contains the list of mappings from application modules to workbench - * projects - */ - protected EARProjectMap getEARProjectMap(boolean createIfEmpty) { - Resource res = null; - try { - res = getOrCreateResource(MODULE_MAP_URI_OBJ); - } catch (WrappedException e) { - //Ignore - } - if (res == null) - return null; - if (res.getContents().isEmpty() && createIfEmpty) { - boolean dirtyFlag = res.isModified(); - res.getContents().add(ModulemapPackage.eINSTANCE.getModulemapFactory().createEARProjectMap()); - res.setModified(dirtyFlag); - }// if - if (res.getContents().isEmpty()) - return null; - return (EARProjectMap) res.getContents().get(0); - }// getEARProjectMap - - /** - * Get the module mappings from module - * - * @param Module - * module - The current module. - * @return ModuleMapping - */ - public ModuleMapping getModuleMapping(Module module) { - if (module == null) - return null; - List maps = getModuleMappings(); - for (int i = 0; i < maps.size(); i++) { - ModuleMapping map = (ModuleMapping) maps.get(i); - Module iModule = map.getModule(); - if (module.equals(iModule)) - return map; - }// for - return null; - }// getModuleMapping - - /** - * Get the utility jar mapping from an uri - * - * @param String - * uri - The current uri - * @return UtilityJARMapping - */ - public UtilityJARMapping getUtilityJARMapping(String uri) { - if (uri == null) - return null; - List maps = getUtilityJARMappings(); - for (int i = 0; i < maps.size(); i++) { - UtilityJARMapping map = (UtilityJARMapping) maps.get(i); - if (uri.equals(map.getUri())) - return map; - }// for - return null; - }// getUtilityJARMapping - - /** - * Return a Project for the given <code>uri</code>. This will return a Project for a utility - * JAR mapping or a module mapping. A project will be returned if the mapping has a project name - * even if the project does not exist or is not accessible. - * - * @param uri - * @return - */ - public IProject getMappedProject(String uri) { - UtilityJARMapping utilMapping = getUtilityJARMapping(uri); - if (utilMapping != null) { - return getProject(utilMapping.getProjectName()); - } - List moduleMappings = getModuleMappings(); - for (int i = 0; i < moduleMappings.size(); i++) { - ModuleMapping map = (ModuleMapping) moduleMappings.get(i); - Module mod = map.getModule(); - if (mod != null && uri.equals(mod.getUri())) - return getProject(map.getProjectName()); - } - return null; - } - - /** - * Get the module mapping based on a project. - * - * @param IProject - * project - The current project. - * @return ModuleMapping - */ - public ModuleMapping getModuleMapping(IProject aProject) { - if (aProject == null) - return null; - List maps = getModuleMappings(); - for (int i = 0; i < maps.size(); i++) { - ModuleMapping map = (ModuleMapping) maps.get(i); - if (aProject.getName().equals(map.getProjectName())) - return map; - }// for - return null; - }// getModuleMapping - - /** - * Checks if the uri mapping already exists. - * - * @param String - * currentName - The current uri of the module. - * @return boolean - */ - public boolean uriExists(String currentName) { - - if (currentName != null) { - return (this.moduleMappingExists(currentName) || this.utilJarMappingExists(currentName)); - } // if - return false; - } // uriExists - - /** - * Checks if the current uri conflicts with any of the existing module mappings. - * - * @param String - * currentUri - The uri to check to see if it exists. - * @return boolean - */ - public boolean moduleMappingExists(String currentUri) { - if (currentUri == null) - return false; - List maps = getModuleMappings(); - if (maps != null || !maps.isEmpty()) { - for (int i = 0; i < maps.size(); i++) { - ModuleMapping map = (ModuleMapping) maps.get(i); - if (currentUri.equals(map.getModule().getUri())) { - return true; - } - } - } - return false; - } - - /** - * Checks if the current uri conflicts with any of the existing utility jar mappings. - * - * @param String - * currentUri - The uri to check to see if it exists. - * @return boolean - */ - public boolean utilJarMappingExists(String currentUri) { - if (currentUri == null) - return false; - List utilMaps = this.getUtilityJARMappings(); - if (utilMaps != null || !utilMaps.isEmpty()) { - for (int i = 0; i < utilMaps.size(); i++) { - UtilityJARMapping utilMap = (UtilityJARMapping) utilMaps.get(i); - if (currentUri.equals(utilMap.getUri())) { - return true; - } // if - } // for - } // if - return false; - } // utilJarMappingExists - - /** - * Gets the utilityJARMapping bases on project. - * - * @param IProject - * project - The current project. - * @return UtilityJARMapping - */ - public UtilityJARMapping getUtilityJARMapping(IProject aProject) { - if (aProject == null) - return null; - List maps = getUtilityJARMappings(); - for (int i = 0; i < maps.size(); i++) { - UtilityJARMapping map = (UtilityJARMapping) maps.get(i); - if (aProject.getName().equals(map.getProjectName())) - return map; - }// for - return null; - }// getUtilityJARMapping - - /** - * Get a collection of module mappings. - * - * @return List - */ - public List getModuleMappings() { - EARProjectMap map = getEARProjectMap(); - if (map == null) - return java.util.Collections.EMPTY_LIST; - return map.getMappings(); - }//getModuleMappings - - /** - * Get a collection of utility mappings. - * - * @return List - */ - public List getUtilityJARMappings() { - EARProjectMap map = getEARProjectMap(); - if (map == null) - return java.util.Collections.EMPTY_LIST; - return map.getUtilityJARMappings(); - }// getUtilityJARMappings - - /** - * The resource which contains the mappings from application modules to workbench projects - * - * @return Resource - */ - protected Resource getModuleMapsXmiResource() { - return getResource(MODULE_MAP_URI_OBJ); - }// getModuleMapsXmiResource - - // TODO Removed to make way for the generic getRootObject() - // /** - // * Gets the root object. - // * - // * @return Application - // * @deprecated Please use getApplication() for consistency - // */ - // public org.eclipse.jst.j2ee.internal.internal.application.Application getRootObject() { - // return getApplication(); - // }// getRootObject - - - /** - * discription goes here - * - * @return Resource - */ - public Resource makeDeploymentDescriptorWithRoot() { - XMLResource res = (XMLResource) makeEarXmiResource(); - Application app = ApplicationPackage.eINSTANCE.getApplicationFactory().createApplication(); - res.getContents().add(app); - res.setID(app, J2EEConstants.APPL_ID); - res.setJ2EEVersionID(getEARNature().getJ2EEVersion()); - app.setDisplayName(getProject().getName()); - return res; - }// Resource - - /** - * discription goes here - * - * @return Resource - */ - public Resource makeEarXmiResource() { - return createResource(J2EEConstants.APPLICATION_DD_URI_OBJ); - }// makeEarXmiResource - - /** - * The resource which contains the mappings from application modules to workbench projects - * - * @return Resource - */ - protected Resource makeModuleMapsXmiResource() { - - if (isReadOnly()) - return null; - - Resource res = createResource(MODULE_MAP_URI_OBJ); - EARProjectMap root = ModulemapPackage.eINSTANCE.getModulemapFactory().createEARProjectMap(); - res.getContents().add(root); - res.setModified(false); - return res; - }// makeModuleMapsXmiResource - - /** - * makeRoot - * - * @param Resource - * deploymentDescriptor - The current deployment descriptor - */ - public Resource makeRoot(Resource deploymentDescriptor) { - - Application app = ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createApplication(); - app.setDisplayName(getProject().getName()); - ((XMIResource) app.eResource()).setID(app, J2EEConstants.APPL_ID); - deploymentDescriptor.getContents().add(app); - return deploymentDescriptor; - }// makeRoot - - //HACK TO BE REMOVED - protected void notifyListeners(EditModelEvent anEvent) { - if (!stopListenerNotifications) - super.notifyListeners(anEvent); - } - - //HACK TO BE REMOVED - public void resumeNotifications() { - stopListenerNotifications = false; - } - - //HACK TO BE REMOVED - public void stopNotifications() { - stopListenerNotifications = true; - } - - /** - * primSave - * - * @param IProgressMonitor - * monitor - Current progress monitor. - * @see EditModel#primSave(IProgressMonitor) - */ - public void primSave(IProgressMonitor monitor) { - removeInvalidModuleMaps(true); - super.primSave(monitor); - try { - updateProjectReferences(monitor); - } catch (CoreException ex) { - throw new SaveFailedException(EARCreationResourceHandler.getString("PROJ_DESC_UPDATE_ERROR_UI_"), ex); //$NON-NLS-1$ - }// try - } // primSave - - public void removeInvalidModuleMaps(boolean preserveModifiedFlag) { - if (!this.isReadOnly()) { - List moduleMaps = this.getExistingModuleMappings(); - if (!moduleMaps.isEmpty()) { - Resource mmResource = getModuleMapsXmiResource(); - boolean isDirty = mmResource.isModified(); - try { - Iterator mapIterator = moduleMaps.iterator(); - ModuleMapping mm = null; - Module m = null; - while (mapIterator.hasNext()) { - mm = (ModuleMapping) mapIterator.next(); - m = mm.getModule(); - if (m == null || m.eIsProxy()) - mapIterator.remove(); - } - } finally { - if (preserveModifiedFlag) - mmResource.setModified(isDirty); - } - } - } - } - - /** - * @return - */ - private List getExistingModuleMappings() { - EARProjectMap map = getEARProjectMap(false); - if (map == null) - return java.util.Collections.EMPTY_LIST; - return map.getMappings(); - } - - - - /** - * Updates the project references - * - * @param IProgressMonitor - * monitor - Current progress monitor. - */ - protected void updateProjectReferences(IProgressMonitor monitor) throws CoreException { - IProjectDescription description = getProject().getDescription(); - Set newProjects = new HashSet(); - newProjects.addAll(getModuleMappedProjects()); - if (!hasProjectReferenceChanges(description, newProjects)) - return; - IProject[] newArray = (IProject[]) newProjects.toArray(new IProject[newProjects.size()]); - description.setReferencedProjects(newArray); - int flags = IResource.FORCE | IResource.KEEP_HISTORY; - getProject().setDescription(description, flags, monitor); - }// updateProjectReferences - - /** - * Checks if there are reference changes. - * - * @return boolean - */ - public boolean hasProjectReferenceChanges() { - IProjectDescription description; - try { - description = getProject().getDescription(); - } catch (CoreException ex) { - return false; - }// try - - Set newProjects = new HashSet(); - newProjects.addAll(getModuleMappedProjects()); - return hasProjectReferenceChanges(description, newProjects); - }// hasProjectReferenceChanges - - /** - * Checks if any of the project references have changed. - * - * @param IProjectDescription - * description - Current project discription. - * @param Set - * newProjects - A set of new projects. - * @return boolean - */ - protected boolean hasProjectReferenceChanges(IProjectDescription description, Set newProjects) { - IProject[] projects = description.getReferencedProjects(); - Set oldProjects = new HashSet(); - oldProjects.addAll(Arrays.asList(projects)); - return !oldProjects.equals(newProjects); - }// hasProjectReferenceChanges - - /** - * Gets a list of non resource files. - * - * @return List - * @see org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateInputProvider#getNonResourceFiles() - */ - public List getNonResourceFiles() { - IFile aFile = getProject().getFile(ProjectUtilities.DOT_PROJECT); - return Collections.singletonList(aFile); - }// getNonResourceFiles - - /** - * Get the deployment descripto resource - * - * @return XMLResource - */ - public XMLResource getDeploymentDescriptorResource() { - return getApplicationXmiResource(); - }// getDeploymentDescriptorResource - - /** - * Answer whether there is either a module mapping or a utility JAR mapping to the project. - * - * @param IProject - * p - The current project. - * @return boolean - */ - public boolean hasMappingToProject(IProject p) { - return getModuleMapping(p) != null || getUtilityJARMapping(p) != null; - }// hasMappingToProject - - /** - * Returns a project based on a util jar mapping. - * - * @param UtilityJARMapping - * utilJarMapping - The current utilJarMapping - * @return IProject - */ - public IProject getProjectFromUtilJarMapping(UtilityJARMapping utilJarMapping) { - if (utilJarMapping != null) { - String projectName = utilJarMapping.getProjectName(); - return getProject(projectName); - } // if - return null; - } // getProjectFromUtilJarMapping - - public boolean isEjbClientJarMapping(UtilityJARMapping utilJarMapping) { - IProject aProject = getProjectFromUtilJarMapping(utilJarMapping); - if (aProject != null) - return isEjbClientJarProject(aProject); - return false; - } - - /** - * @param project - * @return - */ - public boolean isEjbClientJarProject(IProject utilProject) { - if (utilProject != null) { - List mappings = getModuleMappings(); - ModuleMapping mapping; - IProject ejbProject; - for (int i = 0; i < mappings.size(); i++) { - mapping = (ModuleMapping) mappings.get(i); - if (mapping.getModule() != null && mapping.getModule().isEjbModule()) { - ejbProject = getProject(mapping); - if (utilProject.equals(EarModuleManager.getEJBModuleExtension().getDefinedEJBClientJARProject(ejbProject))) - return true; - } - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.workbench.J2EEEditModel#getRootObject() - */ - public Object getRootObject() { - return getApplication(); - } - - public String getDevelopmentAcivityID() { - return DefaultModuleProjectCreationOperation.ENTERPRISE_JAVA; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EAREditModelFactory.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EAREditModelFactory.java deleted file mode 100644 index 904c4bd94..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EAREditModelFactory.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 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.earcreation; - -import java.util.Map; - -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory; - - - -/** - * @deprecated - * Use - * <p> - * EARArtifactEdit - * </p> - * - */ -public class EAREditModelFactory extends EditModelFactory { - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#createEditModelForRead(java.lang.Object, - * org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext) - */ - public EditModel createEditModelForRead(String editModelID, EMFWorkbenchContext context, Map params) { - return new EAREditModel(editModelID, context, true, isLoadKnownResourcesAsReadOnly()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#createEditModelForWrite(java.lang.Object, - * org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext) - */ - public EditModel createEditModelForWrite(String editModelID, EMFWorkbenchContext context, Map params) { - return new EAREditModel(editModelID, context, false, isLoadKnownResourcesAsReadOnly()); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARNatureRuntime.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARNatureRuntime.java deleted file mode 100644 index 13944b2c1..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARNatureRuntime.java +++ /dev/null @@ -1,631 +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.internal.earcreation; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.application.Module; -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.exception.OpenFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategy; -import org.eclipse.jst.j2ee.internal.J2EEEditModel; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.archive.operations.EARProjectLoadStrategyImpl; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; - -/** - * @deprecated - This class is deprecated. - * Use - * <pre> - * EARArtifactEdit instead. - * </pre> - * - */ - -public class EARNatureRuntime extends J2EENature { - - private static final String EAR_PROJECT_12_OVERLAY = "1_2_ovr"; //$NON-NLS-1$ - private static final String EAR_PROJECT_13_OVERLAY = "1_3_ovr"; //$NON-NLS-1$ - private static final String EAR_PROJECT_14_OVERLAY = "1_4_ovr"; //$NON-NLS-1$ - protected static final String ALT_ROOT_EDEFAULT = null; - - public static Map EMPTY_MAP = new HashMap(0); - - - /** - * WebNature constructor comment. - */ - public EARNatureRuntime() { - super(); - } - - /** - * Return the key for the sourcePath. - */ - public Archive asArchive() throws OpenFailureException { - return asEARFile(); - } - - /** - * Return the key for the sourcePath. - */ - public Archive asArchive(boolean shouldExportSource) throws OpenFailureException { - return null; - } - - public EARFile asEARFile() throws OpenFailureException { - IProject proj = getProject(); - if (proj == null) - return null; - ArchiveOptions options = new ArchiveOptions(); - options.setIsReadOnly(true); - LoadStrategy loader = new EARProjectLoadStrategyImpl(proj); - options.setLoadStrategy(loader); - loader.setResourceSet(getResourceSet()); - return CommonarchiveFactory.eINSTANCE.openEARFile(options, proj.getName()); - } - - /** - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.j2eeproject.J2EENature#getJ2EEVersion() - * @deprecated - * Use - * <p> - * EARArtifactEdit.getJ2EEVersion() - * </p> - */ - public int getJ2EEVersion() { - - return getModuleVersion(); - } - - public EARFile asEARFile(boolean exportSource, boolean mergeDependents) throws OpenFailureException { - IProject proj = getProject(); - if (proj == null) - return null; - ArchiveOptions options = new ArchiveOptions(); - options.setIsReadOnly(true); - EARProjectLoadStrategyImpl loader = new EARProjectLoadStrategyImpl(proj); - options.setLoadStrategy(loader); - loader.setResourceSet(getResourceSet()); - loader.setExportSource(true); - loader.setMergeDependentJars(false); - return CommonarchiveFactory.eINSTANCE.openEARFile(options, proj.getName()); - } - - /** - * True for all but the EAR Nature - */ - protected boolean projectIsJavaProject() { - return false; - } - - protected EditModel createCacheEditModel() { - return getEarEditModelForRead(this); - } - - /** - * Create the folders for the project we have just created. - * - * @exception com.ibm.itp.core.api.resources.CoreException - * The exception description. - */ - protected void createFolders() throws CoreException { - - //build for metapath - createFolder(getMetaPath()); - } - - /** - * Undefined for an ear project - */ - public Module createNewModule() { - return null; - } - - /** - * Return a list of all projects that have an ear nature - */ - public static List getAllEARProjectsInWorkbench() { - List allProjects = Arrays.asList(J2EEPlugin.getWorkspace().getRoot().getProjects()); - List earProjects = new ArrayList(); - for (int i = 0; i < allProjects.size(); i++) { - IProject p = (IProject) allProjects.get(i); - if (p.exists() && p.isOpen()) { - if (hasRuntime(p)) - earProjects.add(p); - } - } - return earProjects; - } - - /** - * @deprecated - * Use - * <pre> - * EARArtifactEdit.getApplication() - * </pre> - * - */ - - public Application getApplication() { - return ((EAREditModel) getCacheEditModel()).getApplication(); - } - - /** - * @deprecated - * Use - * <pre> - * EARArtifactEdit.getApplicationXmiResource() - * </pre> - * @return - */ - - public Resource getApplicationXmiResource() { - return getResource(URI.createURI(ArchiveConstants.APPLICATION_DD_URI)); - } - - /** - * Return the key for the classpath. - */ - public java.lang.String getClassPathKey() { - return null; - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.j2eeproject.J2EENature#getEditModelKey() - */ - public String getEditModelKey() { - return IEARNatureConstants.EDIT_MODEL_ID; - } - - /** - * Returns an application xml model that consists of the MOF model and the DOM model. - * Important!!! Calling this method increments the use count of this model. When you are done - * accessing the model, call releaseAccess()! - * - * @deprecated - use EARArtifactEdit.getArtifactEditForRead(WorkbenchComponent aModule) instead. - */ - public EAREditModel getEarEditModelForRead(Object accessorKey) { - return (EAREditModel) getEditModelForRead(IEARNatureConstants.EDIT_MODEL_ID, accessorKey); - } - - /** - * Returns an application xml model that consists of the MOF model and the DOM model. - * Important!!! Calling this method increments the use count of this model. When you are done - * accessing the model, call releaseAccess()! - * - * @deprecated - use EARArtifactEdit.getArtifactEditForWrite(WorkbenchComponent aModule) instead. - * - */ - public EAREditModel getEarEditModelForWrite(Object accessorKey) { - return (EAREditModel) getEditModelForWrite(IEARNatureConstants.EDIT_MODEL_ID, accessorKey); - } - - /** - * @deprecated - Use EJBArtifactEdit.getApplicationXmiResource() - */ - - public Resource getEjbXmiResource() { - return getResource(URI.createURI(ArchiveConstants.EJBJAR_DD_URI)); - } - - /** - * Return the key for the metaPath. - */ - public java.lang.String getMetaPathKey() { - return IEARNatureConstants.DEFAULT_META_PATH; - } - - public Module getModule(IProject referencedProject) { - EAREditModel model = (EAREditModel) getCacheEditModel(); - ModuleMapping map = model.getModuleMapping(referencedProject); - if (map != null) { - return map.getModule(); - } - return null; - } - - /** - * Return a Project for the given <code>uri</code>. This will return a Project for a utility - * JAR mapping or a module mapping. A project will be returned if the mapping has a project name - * even if the project does not exist or is not accessible. - * @param uri - * @return - * @deprecated - * Use - * <p> - * Get the enterprise application module workbench component and call getReferencedComponents() - * </p> - */ - public IProject getMappedProject(String uri) { - EAREditModel model = (EAREditModel) getCacheEditModel(); - return model.getMappedProject(uri); - } - - /** - * @return J2EENature - the nature for the project that represents - * @aModule in the ear; null if no such project exists - * @deprecated - * Use - * <p> - * ModuleCore.findWorkbenchModuleByModuleURI(URI aModuleURI) - * </p> - */ - public J2EENature getModuleProject(Module aModule) { - - IProject aProject = primGetModuleProject(aModule); - if (aProject != null) - return J2EENature.getRegisteredRuntime(aProject); - return null; - } - - /** - * @return J2EENature - the nature for the project that represents the module having - * @moduleURI in the ear; null if the application does not contain a module with - * @moduleURI or if no such project exists - * @deprecated - * Use - * <p> - * ModuleCore.findWorkbenchModuleByModuleURI(URI aModuleURI) - * </p> - */ - public J2EENature getModuleProject(String moduleURI) { - Application dd = getApplication(); - //You could have two modules with the same uri - right now we will take the first module it - // finds - return dd == null ? null : getModuleProject(dd.getFirstModule(moduleURI)); - } - - /** - * If the project is referenced by the EAR, return the URI of the JAR or module - */ - public String getJARUri(IProject aProject) { - EAREditModel model = (EAREditModel) getCacheEditModel(); - ModuleMapping moduleMap = model.getModuleMapping(aProject); - if (moduleMap != null) { - Module aModule = moduleMap.getModule(); - return aModule == null ? EARCreationResourceHandler.getString("UNKNOWN_UI_") : aModule.getUri(); //$NON-NLS-1$ - } - UtilityJARMapping jarMap = model.getUtilityJARMapping(aProject); - if (jarMap != null) - return jarMap.getUri(); - return null; - } - - /** - * Return all the projects which represent the modules in this ear; Note that it is possible by - * hand editing or otherwise for a module to be declared for which there is no such project. In - * this case the value in the map for the uri will be null, so clients should check the values - * for null. - * - * @return java.util.Map where the keys are the uris of all the modules (String), and the values - * are the natures (J2EENature) of the projects represented by the uris. - */ - public java.util.Map getModuleProjects() { - Application dd = getApplication(); - if (dd == null) - return EMPTY_MAP; - //Open an edit model here so we don't keep loading resources for each nested - // call to getModuleProject() - - List modules = getApplication().getModules(); - Map result = new HashMap(); - for (int i = 0; i < modules.size(); i++) { - Module m = (Module) modules.get(i); - J2EENature nature = getModuleProject(m); - result.put(m.getUri(), nature); - } - return result; - - } - - /** - * Return all the projects which represent the modules and project utility JARs in this ear; - * - * @return java.util.Map where the keys are the uris of all the modules and JARs (String), and - * the values are the projects represented by the uris. - * @deprecated - - * Use - * <p> - * WorkbenchComponent.getReferencedComponents() - * </p> - */ - public Map getAllMappedProjects() { - EAREditModel model = (EAREditModel) getCacheEditModel(); - return model.getModuleMappedProjectsAsMap(); - - } - - public IContainer getEMFRoot() { - return getProject(); - } - - /** - * Return the nature's ID. - * @deprecated - * Use - * <p> - * ModuleCoreNature.getNatureID() - * </p> - */ - public java.lang.String getNatureID() { - return IEARNatureConstants.NATURE_ID; - } - - /** - * Return the ID of the plugin that this nature is contained within. - * @deprecated - * Use - * <p> - * ModuleCoreNature.getPluginID() - * </p> - */ - protected java.lang.String getPluginID() { - return J2EEPlugin.PLUGIN_ID; - } - - /** - * @deprecated Referenced projects are no longer used to track modules in the ear; if you need - * the referenced projects, obtain them from the project itself - */ - public IProject[] getReferencedProjects() { - - try { - return getProject().getReferencedProjects(); - } catch (CoreException ex) { - return new IProject[]{}; - } - - } - - /** - * Get a WebNatureRuntime that corresponds to the supplied project. - * - * @return com.ibm.itp.wt.IWebNature - * @param project - * com.ibm.itp.core.api.resources.IProject - * @deprecated - * Use - * <p> - * EARArtifactEdit.getEARArtifactEditForRead(WorkbenchComponent) - * </p> - */ - public static EARNatureRuntime getRuntime(IProject project) { - return (EARNatureRuntime) getRuntime(project, IEARNatureConstants.NATURE_IDS); - } - - /** - * Return the key for the sourcePath. - */ - public java.lang.String getSourcePathKey() { - return null; - } - - /** - * Return whether or not the project has a runtime created on it. - * - * @return boolean - * @param project - * com.ibm.itp.core.api.resources.IProject - * @deprecated - * Use - * <p> - * - * </p> - */ - public static boolean hasRuntime(IProject project) { - return hasRuntime(project, IEARNatureConstants.NATURE_IDS); - } - - /** - * Update the receiver from the supplied info and then configure it. - * - * @param info - * EARProjctInfo - the info this was created from - * @exception CoreExeption - - * thrown if the project cannot be updated - */ - // public void initializeFromInfo(EARProjectInfo info) throws CoreException { - // createFolders(); - // J2EESettings j2eeSettings = getJ2EESettings(); - // j2eeSettings.setModuleVersion(info.getModuleVersion()); - // j2eeSettings.write(); - // } - - /** - * @deprecated - * Use - * <p> - * EARArtifactEdit.createModuleRoot - * </p> - */ - public Resource makeApplicationXmiResource() { - return createResource(URI.createURI(ArchiveConstants.APPLICATION_DD_URI)); - } - - /** - * This returns the project, whether it is open or closed, whereas - * {@link #getModuleProject() returns the nature, which is only validif the project is open. - * - * @return IProject - the project that represents - * @aModule in the ear; null if no such project exists - */ - public IProject primGetModuleProject(Module aModule) { - - try { - if (aModule == null) - return null; - EAREditModel model = (EAREditModel) getCacheEditModel(); - - ModuleMapping map = model.getModuleMapping(aModule); - if (map != null && map.getProjectName() != null && map.getProjectName().length() > 0) { - return J2EEPlugin.getWorkspace().getRoot().getProject(map.getProjectName()); - } - - return null; - } catch (java.lang.IllegalArgumentException ie) { - return null; - } - } - - /** - * Because of team support or moving the workspace, the absolute paths of the module extensions - * may be out of sync with the actual locations of the files; moreover, modules might contain no - * mapping or absolute path, or might be mapped to a non-existent project. If there are unsaved - * changes to the application, then a warning is returned and no other validation is executed. - * - * @return IStatus - code WARNING if there are unsaved changes or if a module project is closed, - * ERROR if there is a problem with one of the modules, OK otherwise - */ - public IStatus validateModuleProjects() { - //We're not going to write anything, but by using a write model, we can determine - // if there are pending changes; also, we'll keep it open for the execution of this method - // to ensure resources remain cached and reduce the performance hit - EAREditModel model = getEarEditModelForWrite(this); - try { - if (model.isShared() && model.isDirty()) { - String msg = EARCreationResourceHandler.getString("UNSAVED_CHANGES_WARN_", new Object[]{getProject().getName()}); //$NON-NLS-1$ - return J2EEPlugin.newStatus(IStatus.WARNING, 0, msg, (Throwable) null); - } - String message = EARCreationResourceHandler.getString("PROJECT_MAP_PROBLEMS_ERROR_", new Object[]{getProject().getName()}); //$NON-NLS-1$ - Application dd = model.getApplication(); - List modules = dd.getModules(); - boolean closedProject = false; - for (int i = 0; i < modules.size(); i++) { - Module m = (Module) modules.get(i); - IProject p = primGetModuleProject(m); - if (p == null) - return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, IResourceStatus.OPERATION_FAILED, message, (Throwable) null); - if (!p.isOpen()) - closedProject = true; - } - if (closedProject) { - String msg = EARCreationResourceHandler.getString("MODULE_PROJECTS_CLOSED_WARN_", new Object[]{getProject().getName()}); //$NON-NLS-1$ - return J2EEPlugin.newStatus(IStatus.WARNING, 0, msg, (Throwable) null); - } - return J2EEPlugin.newStatus(IStatus.OK, 0, "", (Throwable) null); //$NON-NLS-1$ - } finally { - model.releaseAccess(this); - } - } - - public String getOverlayIconName() { - switch (getJ2EEVersion()) { - case J2EEVersionConstants.J2EE_1_2_ID : - return EAR_PROJECT_12_OVERLAY; - case J2EEVersionConstants.J2EE_1_3_ID : - return EAR_PROJECT_13_OVERLAY; - case J2EEVersionConstants.J2EE_1_4_ID : - default : - return EAR_PROJECT_14_OVERLAY; - } - } - - /** - * @deprecated - * Use - * <p> - * EARArtifactEdit.getDeploymentDescriptorResource() - * </p> - */ - - public int getDeploymentDescriptorType() { - return XMLResource.APPLICATION_TYPE; - } - - /** - * @see org.eclipse.jem.internal.java.plugin.AbstractJavaMOFNatureRuntime#addJavaReflectionAdapterFactories(ResourceSet) - */ - protected void addJavaReflectionAdapterFactories(ResourceSet aContext) { - //do nothing since this is not a Java project - } - - /** - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.j2eeproject.J2EENature#getDeploymentDescriptorRoot() - * @deprecated - * Use - * <a> - * EARArtifactEdit.getDeploymentDescriptorResource() - * </a> - */ - public EObject getDeploymentDescriptorRoot() { - return getApplication(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.j2eeproject.J2EENature#getVersionFromModuleFile() - */ - protected int getVersionFromModuleFile() { - Application ddRoot = getApplication(); - if (ddRoot != null) { - return ddRoot.getVersionID(); - } - return J2EEVersionConstants.J2EE_1_4_ID; - } - - /** - * (non-Javadoc) - * @see org.eclipse.jst.j2ee.internal.internal.j2eeproject.J2EENature#getJ2EEEditModelForRead(java.lang.Object) - * @deprecated - * Use - * <p> - * EARArtifactEdit.getEARArtifactEditForRead(WorkbenchComponent) - * </p> - */ - public J2EEEditModel getJ2EEEditModelForRead(Object accessorKey) { - return getEarEditModelForRead(accessorKey); - } - - /** - * (non-Javadoc) - * @see org.eclipse.jst.j2ee.internal.internal.j2eeproject.J2EENature#getJ2EEEditModelForWrite(java.lang.Object) - * @deprecated - * Use - * <p> - * EARArtifactEdit.getEARArtifactEditForWrite(WorkbenchComponent) - * </p> - */ - public J2EEEditModel getJ2EEEditModelForWrite(Object accessorKey) { - return getEarEditModelForWrite(accessorKey); - } - - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarComponentCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarComponentCreationDataModelProvider.java deleted file mode 100644 index 275defd38..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarComponentCreationDataModelProvider.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.eclipse.jst.j2ee.internal.earcreation; - -import java.util.Collections; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModel; -import org.eclipse.jst.j2ee.application.internal.operations.EARComponentCreationOp; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationDataModelProvider; -import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl; -import org.eclipse.jst.j2ee.datamodel.properties.IEarComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.ServerCore; - -public class EarComponentCreationDataModelProvider extends J2EEComponentCreationDataModelProvider implements IEarComponentCreationDataModelProperties { - - public IDataModelOperation getDefaultOperation() { - return new EARComponentCreationOp(model); - } - - /** - * @return Returns the default J2EE spec level based on the Global J2EE - * Preference - */ - protected Integer getDefaultComponentVersion() { - 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_ID); - } - } - - public String[] getPropertyNames() { - String[] props = new String[] { J2EE_COMPONENT_LIST }; - return combineProperties(super.getPropertyNames(), props); - } - - protected AddComponentToEnterpriseApplicationDataModel createModuleNestedModel() { - return new AddComponentToEnterpriseApplicationDataModel(); - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(DD_FOLDER)) { - return IPath.SEPARATOR + this.getModuleName() + IPath.SEPARATOR + "META_INF"; //$NON-NLS-1$ - } else if (propertyName.equals(UI_SHOW_EAR_SECTION)) { - return Boolean.FALSE; - } else if (propertyName.equals(J2EE_COMPONENT_LIST)) { - return Collections.EMPTY_LIST; - } - return super.getDefaultProperty(propertyName); - } - - public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) { - if (propertyName.equals(COMPONENT_VERSION)) { - Integer propertyValue = (Integer) getProperty(propertyName); - String description = null; - switch (propertyValue.intValue()) { - case J2EEVersionConstants.WEB_2_2_ID: - description = J2EEVersionConstants.VERSION_2_2_TEXT; - break; - case J2EEVersionConstants.WEB_2_3_ID: - description = J2EEVersionConstants.VERSION_2_3_TEXT; - break; - case J2EEVersionConstants.WEB_2_4_ID: - default: - description = J2EEVersionConstants.VERSION_2_4_TEXT; - break; - } - return new DataModelPropertyDescriptor(propertyValue, description); - } - return super.getPropertyDescriptor(propertyName); - } - - public DataModelPropertyDescriptor[] getValidComponentVersionDescriptors() { - int highestJ2EEPref = J2EEPlugin.getDefault().getJ2EEPreferences().getHighestJ2EEVersionID(); - DataModelPropertyDescriptor[] descriptors = null; - switch (highestJ2EEPref) { - case J2EEVersionConstants.J2EE_1_2_ID: - descriptors = new DataModelPropertyDescriptor[1]; - descriptors[0] = new DataModelPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT); - break; - case J2EEVersionConstants.J2EE_1_3_ID: - descriptors = new DataModelPropertyDescriptor[2]; - descriptors[0] = new DataModelPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT); - descriptors[1] = new DataModelPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT); - break; - case J2EEVersionConstants.J2EE_1_4_ID: - default: - descriptors = new DataModelPropertyDescriptor[3]; - descriptors[0] = new DataModelPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_2_ID), J2EEVersionConstants.VERSION_1_2_TEXT); - descriptors[1] = new DataModelPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_3_ID), J2EEVersionConstants.VERSION_1_3_TEXT); - descriptors[2] = new DataModelPropertyDescriptor(new Integer(J2EEVersionConstants.J2EE_1_4_ID), J2EEVersionConstants.VERSION_1_4_TEXT); - break; - } - return descriptors; - } - - protected int convertModuleVersionToJ2EEVersion(int moduleVersion) { - return moduleVersion; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEModuleCreationDataModel#getModuleType() - */ - protected EClass getComponentType() { - return CommonarchiveFactoryImpl.getPackage().getEARFile(); - } - - protected String getComponentExtension() { - return ".ear"; //$NON-NLS-1$ - } - - public IStatus validate(String propertyName) { - if (propertyName.equals(PROJECT_NAME)) { - // validate server target - String projectName = getDataModel().getStringProperty(PROJECT_NAME); - if (projectName != null && projectName.length() != 0) { - IProject project = ProjectUtilities.getProject(projectName); - if (project != null) { - IRuntime runtime = ServerCore.getProjectProperties(project).getRuntimeTarget(); - if (runtime != null) { - IRuntimeType type = runtime.getRuntimeType(); - String typeId = type.getId(); - if (typeId.startsWith("org.eclipse.jst.server.tomcat")) { //$NON-NLS-1$ - String msg = EARCreationResourceHandler.getString(EARCreationResourceHandler.SERVER_TARGET_NOT_SUPPORT_EAR); - return WTPCommonPlugin.createErrorStatus(msg); - } - } - } - } - } - return super.validate(propertyName); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean returnValue = super.propertySet(propertyName, propertyValue); - if (propertyName.equals(COMPONENT_NAME)) { - setProperty(COMPONENT_DEPLOY_NAME, getDataModel().getStringProperty(COMPONENT_NAME)); - } - return returnValue; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.application.operations.FlexibleJ2EECreationDataModel#getModuleID() - */ - protected String getComponentID() { - return IModuleConstants.JST_EAR_MODULE; - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName){ - return super.getValidPropertyDescriptors(propertyName); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IDefaultJ2EEComponentCreationDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IDefaultJ2EEComponentCreationDataModelProperties.java deleted file mode 100644 index 57d499166..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IDefaultJ2EEComponentCreationDataModelProperties.java +++ /dev/null @@ -1,73 +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.internal.earcreation; - -public interface IDefaultJ2EEComponentCreationDataModelProperties { - /** - * Required - This is the name of the project. type String - */ - public static final String PROJECT_NAME = "DefaultJ2EEComponentCreationDataModel.PROJECT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the ear. type String - */ - public static final String EAR_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.EAR_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the app client. type String - */ - public static final String APPCLIENT_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.APPCLIENT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the WEB. type String - */ - public static final String WEB_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.WEB_COMPONENT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the EJB. type String - */ - public static final String EJB_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.EJB_COMPONENT_NAME"; //$NON-NLS-1$ - /** - * Required - This is the name of the connector. type String - */ - public static final String CONNECTOR_COMPONENT_NAME = "DefaultJ2EEComponentCreationDataModel.CONNECTOR_COMPONENT_NAME"; //$NON-NLS-1$ - - public static final String J2EE_VERSION = "DefaultJ2EEComponentCreationDataModel.J2EE_VERSION"; //$NON-NLS-1$ - /** - * Default is true. type Boolean - */ - public static final String CREATE_EJB = "DefaultJ2EEComponentCreationDataModel.CREATE_EJB"; - /** - * Default is true. type Boolean - */ - public static final String CREATE_WEB = "DefaultJ2EEComponentCreationDataModel.CREATE_WEB"; - /** - * Default is true. type Boolean - */ - public static final String CREATE_APPCLIENT = "DefaultJ2EEComponentCreationDataModel.CREATE_CLIENT"; - /** - * Default is true. type Boolean - */ - public static final String CREATE_CONNECTOR = "DefaultJ2EEComponentCreationDataModel.CREATE_CONNECTOR"; - - /** - * Used for validation only; validates no collsions between various module names. Do not set - * this value. - */ - public static final String MODULE_NAME_COLLISIONS_VALIDATION = "DefaultJ2EEComponentCreationDataModel.MODULE_NAME_COLLISIONS_VALIDATION"; //$NON-NLS-1$ - - /** - * Default is true. type Boolean - */ - public static final String ENABLED = "DefaultJ2EEComponentCreationDataModel.ENABLED"; //$NON-NLS-1$ - - public static final String NESTED_MODEL_EJB = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_EJB"; //$NON-NLS-1$ - public static final String NESTED_MODEL_WEB = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_WEB"; //$NON-NLS-1$ - public static final String NESTED_MODEL_JCA = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_JCA"; //$NON-NLS-1$ - public static final String NESTED_MODEL_CLIENT = "DefaultJ2EEComponentCreationDataModel.NESTED_MODEL_CLIENT"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IEARNatureConstants.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IEARNatureConstants.java deleted file mode 100644 index 2705fd9a0..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IEARNatureConstants.java +++ /dev/null @@ -1,30 +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.internal.earcreation; - -/** - * @deprecated - * Use - * <p> -* All nature constants interfaces are also deprecated along with nature runtime classes -* IModuleConstants need to be used. -* </p> -*/ - -public interface IEARNatureConstants { - - String PLUG_IN_ID = "org.eclipse.jst.j2ee"; //$NON-NLS-1$ - String NATURE_ID = PLUG_IN_ID + ".EARNature"; //$NON-NLS-1$ - String NO_NATURE_MESSAGE = EARCreationResourceHandler.getString("Not_an_ear_project_UI_"); //$NON-NLS-1$ - String NOT_OPEN_MESSAGE = EARCreationResourceHandler.getString("EAR_PROJECT_MUST_BE_OPEN_UI_"); //$NON-NLS-1$ - - String DEFAULT_META_PATH = "META-INF"; //$NON-NLS-1$ - String[] NATURE_IDS = {NATURE_ID}; - String EDIT_MODEL_ID = "org.eclipse.jst.j2ee.application.editModel"; //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ILooseConfigConstants.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ILooseConfigConstants.java deleted file mode 100644 index c0f3acfa5..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ILooseConfigConstants.java +++ /dev/null @@ -1,27 +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.internal.earcreation; - - -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseConfigRegister; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; - - -public interface ILooseConfigConstants { - /** - * The short name of the loose configuration file; will most often need to use - * {@link #CONFIG_PATH} - */ - String CONFIG_FILE_NAME = "looseconfig.xmi"; //$NON-NLS-1$ - /** The absolute path to the loose configuration file */ - String CONFIG_PATH = J2EEPlugin.getDefault().getStateLocation().append(CONFIG_FILE_NAME).toOSString(); - /** The property name used by WebSphere to lookup the loose configuration location to load */ - String WAS_PROPERTY = LooseConfigRegister.LOOSE_CONFIG_PROPERTY; - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/LooseConfigUpdateOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/LooseConfigUpdateOperation.java deleted file mode 100644 index 29ded7c0e..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/LooseConfigUpdateOperation.java +++ /dev/null @@ -1,211 +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.internal.earcreation; - - -import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.internal.core.JavaModel; -import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities; -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseApplication; -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseArchive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseConfiguration; -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseLibrary; -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseModule; -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseconfigFactory; -import org.eclipse.jst.j2ee.commonarchivecore.internal.looseconfig.LooseconfigPackage; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; -import org.eclipse.jst.j2ee.internal.project.J2EEModuleNature; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; - -public class LooseConfigUpdateOperation extends WTPOperation implements ILooseConfigConstants { - - protected Resource resource; - protected IProgressMonitor monitor; - protected LooseConfiguration looseConfig; - protected String uri; - protected EAREditModel currentEditModel; - - protected static final String UPDATING_MESSAGE = EARCreationResourceHandler.getString("Updating_absolute_paths_UI_"); //$NON-NLS-1$ - - public LooseConfigUpdateOperation() { - } - - protected LooseconfigFactory looseConfigFactory() { - return ((LooseconfigPackage) EPackage.Registry.INSTANCE.getEPackage(LooseconfigPackage.eNS_URI)).getLooseconfigFactory(); - } - - /* - * @see HeadlessJ2EEOperation#execute(IProgressMonitor) - */ - protected void execute(IProgressMonitor progressMonitor) throws CoreException, InvocationTargetException, InterruptedException { - monitor = progressMonitor; - monitor.beginTask(UPDATING_MESSAGE, IProgressMonitor.UNKNOWN); - initialize(); - addLooseApplications(); - save(); - } - - protected void initialize() { - resource = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI(CONFIG_PATH)).createResource(URI.createURI(CONFIG_PATH)); - resource.getContents().add(createLooseConfig()); - } - - protected LooseConfiguration createLooseConfig() { - looseConfig = looseConfigFactory().createLooseConfiguration(); - return looseConfig; - } - - protected void addLooseApplications() throws CoreException { - List earProjects = EARNatureRuntime.getAllEARProjectsInWorkbench(); - for (int i = 0; i < earProjects.size(); i++) { - IProject p = (IProject) earProjects.get(i); - EARNatureRuntime runtime = EARNatureRuntime.getRuntime(p); - addLooseApplication(runtime); - } - } - - protected void addLooseApplication(EARNatureRuntime runtime) throws CoreException { - monitor.subTask(runtime.getProject().getName()); - currentEditModel = runtime.getEarEditModelForRead(this); - try { - LooseApplication looseApp = createLooseApplication(runtime); - addLooseApplication(looseApp); - } finally { - currentEditModel.releaseAccess(this); - currentEditModel = null; - } - } - - protected void addLooseApplication(LooseApplication looseApp) throws CoreException { - addLooseModules(looseApp, currentEditModel.getModuleMappings()); - addLooseUtilityJARs(looseApp, currentEditModel.getUtilityJARMappings()); - looseConfig.getApplications().add(looseApp); - } - - protected LooseApplication createLooseApplication(EARNatureRuntime runtime) { - LooseApplication looseApp = looseConfigFactory().createLooseApplication(); - String absPath = getAbsolutePath(runtime); - looseApp.setUri(absPath); - setPaths(looseApp, absPath); - return looseApp; - } - - protected void addLooseModules(LooseApplication looseApp, List moduleMaps) { - List looseModules = looseApp.getLooseArchives(); - for (int i = 0; i < moduleMaps.size(); i++) { - ModuleMapping map = (ModuleMapping) moduleMaps.get(i); - LooseModule module = createLooseModule(map); - looseModules.add(module); - } - } - - protected LooseModule createLooseModule(ModuleMapping map) { - LooseModule loose = looseConfigFactory().createLooseModule(); - loose.setUri(map.getModule().getUri()); - setPaths(loose, getAbsolutePath(map)); - return loose; - } - - protected void setPaths(LooseArchive archive, String absPath) { - if (absPath == null) - return; - - archive.setBinariesPath(absPath); - archive.setResourcesPath(absPath); - } - - protected void save() throws InvocationTargetException { - try { - ResourceSet set = resource.getResourceSet(); - if (set != null) { - OutputStream out = set.getURIConverter().createOutputStream(resource.getURI()); - resource.save(out, Collections.EMPTY_MAP); - } - } catch (Exception ex) { - throw new WFTWrappedException(ex); - } - } - - protected String getAbsolutePath(ModuleMapping map) { - if (map.getProjectName() == null) - return null; - IProject p = getProject(map.getProjectName()); - J2EEModuleNature nature = (J2EEModuleNature) J2EENature.getRegisteredRuntime(p); - - return getAbsolutePath(nature); - } - - protected String getAbsolutePath(UtilityJARMapping map) throws CoreException { - if (map.getProjectName() == null) - return null; - IProject p = getProject(map.getProjectName()); - //JavaProject javaProj = JavaCore.get - - return getAbsolutePath(getJavaProject(p)); - } - - protected String getAbsolutePath(IJavaProject javaProj) throws CoreException { - IPath loc = javaProj.getOutputLocation(); - if (loc == null) - return null; - - return javaProj.getProject().getFile(loc).getLocation().toOSString(); - } - - protected IProject getProject(String projectName) { - return getWorkspace().getRoot().getProject(projectName); - } - - protected JavaModel getJavaModel() { - return JavaProjectUtilities.getJavaModel(); - } - - protected IJavaProject getJavaProject(IProject p) { - return getJavaModel().getJavaProject(p); - } - - protected String getAbsolutePath(J2EENature nature) { - if (nature == null) - return null; - return nature.getModuleServerRoot().getLocation().toOSString(); - } - - protected void addLooseUtilityJARs(LooseApplication looseApp, List utilMaps) throws CoreException { - List looseArchives = looseApp.getLooseArchives(); - for (int i = 0; i < utilMaps.size(); i++) { - UtilityJARMapping map = (UtilityJARMapping) utilMaps.get(i); - LooseLibrary lib = createLooseLibrary(map); - looseArchives.add(lib); - } - } - - protected LooseLibrary createLooseLibrary(UtilityJARMapping map) throws CoreException { - LooseLibrary loose = looseConfigFactory().createLooseLibrary(); - loose.setUri(map.getUri()); - setPaths(loose, getAbsolutePath(map)); - return loose; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ModuleInEARProjectCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ModuleInEARProjectCommand.java deleted file mode 100644 index 1a5b4b93f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ModuleInEARProjectCommand.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 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.earcreation; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.AbstractCommand; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.application.WebModule; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping; -import org.eclipse.jst.j2ee.internal.project.J2EEModuleNature; -import org.eclipse.jst.j2ee.internal.project.J2EENature; - - -/** - * Insert the type's description here. Creation date: (03/29/01 4:48:46 PM) - * - * @author: Administrator - */ -public abstract class ModuleInEARProjectCommand extends AbstractCommand { - protected EAREditModel editModel; - protected IProject earProject; - protected IProject nestedJ2EEProject; - protected String moduleUri; - protected String moduleAltDD; - protected String moduleContextRoot; - protected boolean moduleSuccessful; - protected boolean mapSuccessful; - protected Module module; - - /** - * AddModuleToEARProjectCommand constructor comment. - */ - protected ModuleInEARProjectCommand() { - super(); - } - - /** - * AddModuleToEARProjectCommand constructor comment. - * - * @param label - * java.lang.String - */ - protected ModuleInEARProjectCommand(String label) { - super(label); - } - - /** - * AddModuleToEARProjectCommand constructor comment. - * - * @param label - * java.lang.String - * @param description - * java.lang.String - */ - protected ModuleInEARProjectCommand(String label, String description) { - super(label, description); - } - - public ModuleInEARProjectCommand(IProject aNestedJ2EEProject, IProject anEarProject, String uri, String contextRoot, String altDD) { - super(); - setNestedJ2EEProject(aNestedJ2EEProject); - setEarProject(anEarProject); - setModuleUri(uri); - setModuleContextRoot(contextRoot); - setModuleAltDD(altDD); - } - - protected void addModule() { - Application dd = getApplication(); - if (dd == null) { - return; - } - Module m = dd.getFirstModule(moduleUri); - if (m == null) { - J2EEModuleNature j2eeNature = (J2EEModuleNature) J2EENature.getRegisteredRuntime(getNestedJ2EEProject()); - m = j2eeNature.createNewModule(); - - if (m == null) - return; - m.setUri(moduleUri); - m.setAltDD(moduleAltDD); - if (m instanceof WebModule) { - ((WebModule) m).setContextRoot(moduleContextRoot); - } - dd.getModules().add(m); - } - setModule(m); - } - - protected void addModuleMapping() { - if (module != null) { - ModuleMapping map = editModel.addModuleMapping(module, getNestedJ2EEProject()); - mapSuccessful = (map != null); - } - } - - public void dispose() { - setNestedJ2EEProject(null); - setEarProject(null); - } - - /** - * @see Command - */ - public void execute() { - try { - setupEditModel(); - if (editModel != null) { - primExecute(); - editModel.saveIfNecessary(this); - } else - moduleSuccessful = false; - } finally { - releaseEditModel(); - } - } - - protected Application getApplication() { - return editModel.getApplication(); - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @return org.eclipse.core.resources.IProject - */ - public org.eclipse.core.resources.IProject getEarProject() { - return earProject; - } - - /** - * Insert the method's description here. Creation date: (3/29/2001 11:44:01 PM) - * - * @return org.eclipse.jst.j2ee.internal.internal.application.Module - */ - public Module getModule() { - return module; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @return java.lang.String - */ - public java.lang.String getModuleAltDD() { - return moduleAltDD; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @return java.lang.String - */ - public java.lang.String getModuleContextRoot() { - return moduleContextRoot; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @return java.lang.String - */ - public java.lang.String getModuleUri() { - return moduleUri; - } - - protected EARNatureRuntime getNature() { - return EARNatureRuntime.getRuntime(getEarProject()); - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @return org.eclipse.core.resources.IProject - */ - public org.eclipse.core.resources.IProject getNestedJ2EEProject() { - return nestedJ2EEProject; - } - - public boolean isExecuteSuccess() { - return moduleSuccessful && mapSuccessful; - } - - protected boolean prepare() { - return true; - } - - protected abstract void primExecute(); - - protected abstract void primUndo(); - - /** - * @see Command - */ - public void redo() { - execute(); - } - - protected void releaseEditModel() { - if (editModel != null) { - editModel.releaseAccess(this); - editModel = null; - } - } - - protected void removeModule() { - getApplication().getModules().remove(getModule()); - } - - protected void removeModuleMapping() { - - org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping map = editModel.getModuleMapping(module); - if (map != null) - editModel.getModuleMappings().remove(map); - - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34: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: (3/29/2001 11:44:01 PM) - * - * @param newAddedModule - * org.eclipse.jst.j2ee.internal.internal.application.Module - */ - public void setModule(Module module) { - this.module = module; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @param newModuleUri - * java.lang.String - */ - public void setModuleAltDD(java.lang.String newModuleAltDD) { - moduleAltDD = newModuleAltDD; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @param newModuleUri - * java.lang.String - */ - public void setModuleContextRoot(java.lang.String newModuleContextRoot) { - moduleContextRoot = newModuleContextRoot; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @param newModuleUri - * java.lang.String - */ - public void setModuleUri(java.lang.String newModuleUri) { - moduleUri = newModuleUri; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @param newNestedJ2EEProject - * org.eclipse.core.resources.IProject - */ - public void setNestedJ2EEProject(org.eclipse.core.resources.IProject newNestedJ2EEProject) { - nestedJ2EEProject = newNestedJ2EEProject; - } - - protected void setupEditModel() { - EARNatureRuntime nature = getNature(); - if (nature != null) - editModel = nature.getEarEditModelForWrite(this); - else - editModel = null; // arived here with a valid project, but not an EAR nature. - } - - public void undo() { - try { - setupEditModel(); - primUndo(); - editModel.saveIfNecessary(this); - } finally { - releaseEditModel(); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ModuleMapHelper.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ModuleMapHelper.java deleted file mode 100644 index 7af3bbfc8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ModuleMapHelper.java +++ /dev/null @@ -1,170 +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.internal.earcreation; - - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.EARProjectMap; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; - -/** -* @deprecated -* Use -* <p> -* Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules -* as with the Flexible project changes a .modulemaps file will not exist in an EAR module and -* all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file -*/ - -public class ModuleMapHelper { - - /** - * Constructor for ModuleMapHelper. - */ - protected ModuleMapHelper() { - super(); - } - - public static ModuleMapping getModuleMapping(Module module, EARProjectMap projectMap) { - if (module == null) - return null; - List maps = getModuleMappings(projectMap); - for (int i = 0; i < maps.size(); i++) { - ModuleMapping map = (ModuleMapping) maps.get(i); - if (module.equals(map.getModule())) - return map; - } - return null; - } - - public static List getModuleMappings(EARProjectMap map) { - if (map == null) - return java.util.Collections.EMPTY_LIST; - return map.getMappings(); - } - - public static UtilityJARMapping getUtilityJARMapping(String uri, EARProjectMap projectMap) { - if (uri == null || projectMap == null) - return null; - List maps = getUtilityJARMappings(projectMap); - for (int i = 0; i < maps.size(); i++) { - UtilityJARMapping map = (UtilityJARMapping) maps.get(i); - if (uri.equals(map.getUri())) - return map; - } - return null; - } - - public static List getUtilityJARMappings(EARProjectMap map) { - if (map == null) - return java.util.Collections.EMPTY_LIST; - return map.getUtilityJARMappings(); - } - - public static EARProjectMap getEARProjectMap(Resource res) { - if (res == null || res.getContents().isEmpty()) - return null; - return (EARProjectMap) res.getContents().get(0); - } - - public static List getAllMappedJARs(EARFile ear) { - if (ear == null) - return Collections.EMPTY_LIST; - Resource res = null; - try { - res = ear.getMofResource(EAREditModel.MODULE_MAP_URI); - } catch (Exception ex) { - Logger.getLogger().logError(ex); - return Collections.EMPTY_LIST; - } - EARProjectMap map = getEARProjectMap(res); - if (map == null) - return Collections.EMPTY_LIST; - - List result = new ArrayList(); - List moduleMaps = getModuleMappings(map); - for (int i = 0; i < moduleMaps.size(); i++) { - ModuleMapping mMap = (ModuleMapping) moduleMaps.get(i); - Module m = mMap.getModule(); - if (m == null) - continue; - addArchiveIfNotNull(result, m.getUri(), ear); - } - List utilMaps = getUtilityJARMappings(map); - for (int i = 0; i < utilMaps.size(); i++) { - UtilityJARMapping uMap = (UtilityJARMapping) utilMaps.get(i); - addArchiveIfNotNull(result, uMap.getUri(), ear); - } - return result; - } - - protected static void addArchiveIfNotNull(List result, String uri, EARFile ear) { - Archive anArchive = getArchive(uri, ear); - if (anArchive != null) - result.add(anArchive); - } - - protected static Archive getArchive(String uri, EARFile ear) { - if (uri == null || uri.trim().length() == 0) - return null; - try { - return (Archive) ear.getFile(uri); - } catch (FileNotFoundException ex) { - Logger.getLogger().logError(ex); - } catch (ClassCastException ex2) { - Logger.getLogger().logError(ex2); - } - return null; - } - - public static IProject getProject(String uri, EARFile ear) { - if (uri == null || uri.length() == 0 || ear == null) - return null; - Resource res = null; - try { - res = ear.getMofResource(EAREditModel.MODULE_MAP_URI); - } catch (Exception ex) { - return null; - } - EARProjectMap map = getEARProjectMap(res); - if (map == null) - return null; - - String projectName = null; - UtilityJARMapping uMap = getUtilityJARMapping(uri, map); - if (uMap != null) - projectName = uMap.getProjectName(); - else { - Module m = ear.getDeploymentDescriptor().getFirstModule(uri); - if (m != null) { - ModuleMapping mMap = getModuleMapping(m, map); - if (mMap != null) - projectName = mMap.getProjectName(); - } - } - if (projectName != null && projectName.trim().length() > 0) - return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName.trim()); - return null; - } - - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RemoveModuleFromEARProjectCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RemoveModuleFromEARProjectCommand.java deleted file mode 100644 index 76b974464..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RemoveModuleFromEARProjectCommand.java +++ /dev/null @@ -1,93 +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.internal.earcreation; - - - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping; - - -/** - * Insert the type's description here. Creation date: (03/29/01 4:48:46 PM) - * - * @author: Administrator - */ -public class RemoveModuleFromEARProjectCommand extends ModuleInEARProjectCommand { - public RemoveModuleFromEARProjectCommand(Module module, IProject anEarProject) { - super(); - setEarProject(anEarProject); - setModuleUri(module.getUri()); - setModuleAltDD(module.getAltDD()); - setModule(module); - } - - public boolean canExecute() { - return super.canExecute() && EARNatureRuntime.getRuntime(getEarProject()) != null; - } - - protected void primExecute() { - //Required for validate edit support - refreshModule(); - // Set up nestedJ2EEProject before the map removed - // It is needed for undo remove - if (editModel != null) { - ModuleMapping map = editModel.getModuleMapping(module); - if (map != null) - setNestedJ2EEProject(ResourcesPlugin.getWorkspace().getRoot().getProject(map.getProjectName())); - } - removeModuleMapping(); - if (mapSuccessful) - removeModule(); - } - - /* - * If this was a deferred command, then the module object might be stale because a file was - * checked out - */ - protected void refreshModule() { - if (module == null) - return; - Module m = (Module) EcoreUtil.resolve(module, getApplication()); - if (m != null) - module = m; - } - - protected void primUndo() { - if (moduleSuccessful) { - addModule(); - moduleSuccessful = false; - } - if (mapSuccessful) { - addModuleMapping(); - mapSuccessful = false; - } - } - - protected void removeModule() { - - super.removeModule(); - moduleSuccessful = true; - } - - protected void removeModuleMapping() { - super.removeModuleMapping(); - mapSuccessful = true; - } - - // override - public String getLabel() { - return label == null ? EARCreationResourceHandler.getString("Remove_Module_Command_Label_UI_") : label;//$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RemoveUtilityJARMapCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RemoveUtilityJARMapCommand.java deleted file mode 100644 index 6cf53bd0b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RemoveUtilityJARMapCommand.java +++ /dev/null @@ -1,59 +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 Aug 14, 2003 - * - */ -package org.eclipse.jst.j2ee.internal.earcreation; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; - - -/** - * @author schacher - */ -public class RemoveUtilityJARMapCommand extends UtilityJARInEARProjectCommand { - - public static final String LABEL = EARCreationResourceHandler.getString("REM_UTIL_JAR_UI"); //$NON-NLS-1$ - - public RemoveUtilityJARMapCommand(EAREditModel earEditModel, String aUri, IProject aProject) { - super(earEditModel, aUri, aProject, LABEL); - } - - public RemoveUtilityJARMapCommand(IProject anEarProject, String aUri, IProject aProject) { - super(anEarProject, aUri, aProject, LABEL); - } - - public RemoveUtilityJARMapCommand(IProject anEarProject, UtilityJARMapping jarMapping, IProject moduleProject) { - super(anEarProject, null, moduleProject, LABEL); - map = jarMapping; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.earcreation.UtilityJARInEARProjectCommand#primUndo() - */ - protected void primUndo() { - addMapping(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.earcreation.UtilityJARInEARProjectCommand#primExecute() - */ - protected void primExecute() { - removeMapping(); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RollupRolesCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RollupRolesCommand.java deleted file mode 100644 index dd5a53817..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/RollupRolesCommand.java +++ /dev/null @@ -1,147 +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.internal.earcreation; - - -import java.io.OutputStream; -import java.util.HashMap; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.AbstractCommand; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; - - -/** - * Insert the type's description here. Creation date: (03/29/01 4:48:46 PM) - * - * @author: Administrator - */ -public class RollupRolesCommand extends AbstractCommand { - protected IProject earProject; - protected boolean saveResources; - - /** - * AddModuleToEARProjectCommand constructor comment. - */ - protected RollupRolesCommand() { - super(); - } - - /** - * AddModuleToEARProjectCommand constructor comment. - * - * @param label - * java.lang.String - */ - protected RollupRolesCommand(String label) { - super(label); - } - - /** - * AddModuleToEARProjectCommand constructor comment. - * - * @param label - * java.lang.String - * @param description - * java.lang.String - */ - protected RollupRolesCommand(String label, String description) { - super(label, description); - } - - public RollupRolesCommand(IProject earProject, boolean saveResources) { - super(); - this.earProject = earProject; - this.saveResources = saveResources; - } - - public boolean canExecute() { - return super.canExecute() && org.eclipse.jst.j2ee.internal.earcreation.EARNatureRuntime.getRuntime(getEarProject()) != null; - } - - public void dispose() { - // TODO Edit Model Rework This line does not make any sense. - //EARNatureRuntime.getRuntime(getEarProject()).getEarEditModelForWrite().releaseAccess(); - // setEarProject(null); - } - - /** - * @see Command - */ - public void execute() { - try { - EARFile earFile = EARNatureRuntime.getRuntime(getEarProject()).asEARFile(true, false); - earFile.rollUpRoles(); - } catch (OpenFailureException e) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e); - } - } - - protected Application getApplication() { - - EAREditModel earEditModel = null; - Application application = null; - try { - earEditModel = EARNatureRuntime.getRuntime(getEarProject()).getEarEditModelForWrite(this); - application = earEditModel.getApplication(); - } finally { - if (earEditModel != null) - earEditModel.releaseAccess(this); - } - return application; - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @return org.eclipse.core.resources.IProject - */ - public org.eclipse.core.resources.IProject getEarProject() { - return earProject; - } - - protected boolean prepare() { - return true; - } - - /** - * @see Command - */ - public void redo() { - execute(); - } - - protected void saveResources() throws Exception { - Resource resource = getApplication().eResource(); - ResourceSet set = resource.getResourceSet(); - if (set != null) { - OutputStream out = set.getURIConverter().createOutputStream(resource.getURI()); - resource.save(out, new HashMap()); - } - } - - /** - * Insert the method's description here. Creation date: (03/29/01 5:34:26 PM) - * - * @param newEarProject - * org.eclipse.core.resources.IProject - */ - public void setEarProject(org.eclipse.core.resources.IProject newEarProject) { - earProject = newEarProject; - } - - public void undo() { - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/UpdateModuleReferencesInEARProjectCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/UpdateModuleReferencesInEARProjectCommand.java deleted file mode 100644 index 260d1b21a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/UpdateModuleReferencesInEARProjectCommand.java +++ /dev/null @@ -1,180 +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.internal.earcreation; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientEditModel; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.ApplicationClientNatureRuntime; -import org.eclipse.jst.j2ee.client.ApplicationClient; -import org.eclipse.jst.j2ee.common.EjbRef; -import org.eclipse.jst.j2ee.internal.J2EEEditModel; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -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.J2EENature; - - -public class UpdateModuleReferencesInEARProjectCommand extends ModuleInEARProjectCommand { - protected List ejbRefernces; - protected String oldModuleUri; - protected List nestedEditModels; - - /** - * Constructor for UpdateModuleReferencesInEARProjectCommand. - * - * @param anEarProject - * @param uri - */ - public UpdateModuleReferencesInEARProjectCommand(IProject anEarProject, Module aModule, String newUri) { - setEarProject(anEarProject); - setModule(aModule); - setModuleUri(newUri); - } - - protected void primExecute() { - oldModuleUri = getModule().getUri(); - try { - initializeEjbReferencesToModule(); - if (ejbRefernces != null) - updateEjbReferences(); - } finally { - saveAndReleaseEditModels(); - } - } - - protected void initializeEjbReferencesToModule() { - EARNatureRuntime earNature = EARNatureRuntime.getRuntime(getEarProject()); - Collection modNatures = earNature.getModuleProjects().values(); - J2EENature nature; - Iterator it = modNatures.iterator(); - while (it.hasNext()) { - nature = (J2EENature) it.next(); - initializeEjbReferencesToModule(nature); - } - } - - /** - * Method initializeEjbReferencesToModule. - * - * @param nature - */ - protected void initializeEjbReferencesToModule(J2EENature moduleNature) { - if (moduleNature == null) - return; - switch (moduleNature.getDeploymentDescriptorType()) { - case XMLResource.EJB_TYPE : - EjbModuleExtension ejbExt = EarModuleManager.getEJBModuleExtension(); - ejbExt.initializeEjbReferencesToModule(moduleNature, this); - break; - case XMLResource.WEB_APP_TYPE : - WebModuleExtension webExt = EarModuleManager.getWebModuleExtension(); - webExt.initializeEjbReferencesToModule(moduleNature, this); - break; - case XMLResource.APP_CLIENT_TYPE : - initializeEjbReferencesToModule((ApplicationClientNatureRuntime) moduleNature); - break; - case XMLResource.RAR_TYPE : - JcaModuleExtension jcaExt = EarModuleManager.getJCAModuleExtension(); - jcaExt.initializeEjbReferencesToModule(moduleNature, this); - break; - } - } - - - - public boolean initializeEjbReferencesToModule(List someEjbReferences) { - if (!someEjbReferences.isEmpty()) { - EjbRef ref; - for (int i = 0; i < someEjbReferences.size(); i++) { - ref = (EjbRef) someEjbReferences.get(i); - if (hasModuleRefernces(ref.getLink())) { - addEjbReference(ref); - return true; - } - } - } - return false; - } - - public boolean hasModuleRefernces(String aString) { - return aString != null && aString.indexOf(oldModuleUri) > -1; - } - - private void addEjbReference(EjbRef ref) { - if (ejbRefernces == null) - ejbRefernces = new ArrayList(); - ejbRefernces.add(ref); - } - - public void addNestedEditModel(J2EEEditModel anEditModel) { - if (nestedEditModels == null) - nestedEditModels = new ArrayList(); - nestedEditModels.add(anEditModel); - } - - protected void initializeEjbReferencesToModule(ApplicationClientNatureRuntime moduleNature) { - AppClientEditModel anEditModel = moduleNature.getAppClientEditModelForWrite(this); - boolean foundRef = false; - try { - ApplicationClient appclient = anEditModel.getApplicationClient(); - if (appclient != null) - foundRef = initializeEjbReferencesToModule(appclient.getEjbReferences()); - if (foundRef) - addNestedEditModel(anEditModel); - } finally { - if (!foundRef) - anEditModel.releaseAccess(this); - } - } - - protected void updateEjbReferences() { - if (ejbRefernces != null && !ejbRefernces.isEmpty()) { - EjbRef ref; - for (int i = 0; i < ejbRefernces.size(); i++) { - ref = (EjbRef) ejbRefernces.get(i); - updateEjbReference(ref); - } - } - } - - protected void updateEjbReference(EjbRef ref) { - String uri = ref.getLink(); - int index = uri.indexOf(oldModuleUri); - String pre, post; - pre = uri.substring(0, index); - post = uri.substring(index + oldModuleUri.length()); - ref.setLink(pre + getModuleUri() + post); - } - - protected void saveAndReleaseEditModels() { - if (nestedEditModels != null) { - J2EEEditModel anEditModel; - for (int i = 0; i < nestedEditModels.size(); i++) { - anEditModel = (J2EEEditModel) nestedEditModels.get(i); - try { - anEditModel.saveIfNecessary(this); - } finally { - anEditModel.releaseAccess(this); - } - } - } - } - - protected void primUndo() { - //not undoable at this time. - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/UtilityJARInEARProjectCommand.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/UtilityJARInEARProjectCommand.java deleted file mode 100644 index 66a77249b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/UtilityJARInEARProjectCommand.java +++ /dev/null @@ -1,177 +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.internal.earcreation; - - -import org.eclipse.core.internal.resources.ResourceException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.common.command.AbstractCommand; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping; -import org.eclipse.jst.j2ee.internal.plugin.LibCopyBuilder; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; - -public abstract class UtilityJARInEARProjectCommand extends AbstractCommand { - protected EAREditModel editModel; - protected IProject earProject; - protected String uri; - protected IProject project; - protected UtilityJARMapping map; - - /** - * AddModuleMapCommand constructor comment. - */ - protected UtilityJARInEARProjectCommand() { - super(); - } - - /** - * AddModuleMapCommand constructor comment. - */ - public UtilityJARInEARProjectCommand(EAREditModel earEditModel, String aUri, IProject aProject, String label) { - super(label); - editModel = earEditModel; - if (earEditModel != null) - earProject = earEditModel.getProject(); - project = aProject; - uri = aUri; - } - - public UtilityJARInEARProjectCommand(IProject anEarProject, String aUri, IProject aProject, String label) { - super(label); - earProject = anEarProject; - project = aProject; - uri = aUri; - } - - /** - * @return - */ - protected IFile[] getAffectedFiles() { - return new IFile[]{earProject.getFile(EAREditModel.MODULE_MAP_URI), earProject.getFile(".project") //$NON-NLS-1$ - }; - } - - public boolean canUndo() { - return map != null; - } - - /** - * This will perform the command activity required for the effect. The effect of calling execute - * when canExecute returns false, or when canExecute hasn't been called, is undefined. - */ - public void execute() { - boolean createdEditModel = editModel == null; - setupEditModel(); - try { - primExecute(); - if (createdEditModel) - editModel.saveIfNecessary(this); - } finally { - if (createdEditModel) { - editModel.releaseAccess(this); - editModel = null; - } - } - } - - /** - * This will perform the command activity required for the effect. The effect of calling execute - * when canExecute returns false, or when canExecute hasn't been called, is undefined. - */ - public void undo() { - boolean createdEditModel = editModel == null; - setupEditModel(); - try { - primUndo(); - if (createdEditModel) - editModel.saveIfNecessary(this); - } finally { - if (createdEditModel) { - editModel.releaseAccess(this); - editModel = null; - } - } - } - - protected abstract void primUndo(); - - protected abstract void primExecute(); - - protected void setupEditModel() { - ResourcesPlugin.getWorkspace().validateEdit(getAffectedFiles(), null); - if (editModel == null && earProject != null) { - EARNatureRuntime nature = EARNatureRuntime.getRuntime(earProject); - if (nature != null) - editModel = nature.getEarEditModelForWrite(this); - } - } - - protected boolean prepare() { - return true; - } - - /** - * This will again perform the command activity required to redo the effect after undoing the - * effect. The effect, if any, of calling redo before undo is called is undefined. Note that if - * you implement redo to call execute then any derived class will be restricted to by that - * decision also. - */ - public void redo() { - execute(); - } - - protected void addLibCopyBuilder(IProject aProject) { - try { - ProjectUtilities.addToBuildSpec(LibCopyBuilder.BUILDER_ID, aProject); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - - protected void removeLibCopyBuilder(IProject aProject) { - //If this project is in other EARs, then leave the builder there - if (J2EEProjectUtilities.getFirstReferencingEARProject(aProject) != null) - return; - - try { - ProjectUtilities.removeFromBuildSpec(LibCopyBuilder.BUILDER_ID, aProject); - } catch (ResourceException e) { - //this is on a delete...do nothing if already deleted - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - - public void addMapping() { - setExistingMap(); - if (map == null) - map = editModel.addUtilityJARMapping(uri, project); - else - editModel.getUtilityJARMappings().add(map); - addLibCopyBuilder(project); - } - - protected void removeMapping() { - setExistingMap(); - if (map != null) - editModel.getUtilityJARMappings().remove(map); - removeLibCopyBuilder(project); - } - - protected void setExistingMap() { - if (map == null) - map = editModel.getUtilityJARMapping(uri, project); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/EARProjectMap.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/EARProjectMap.java deleted file mode 100644 index 30a249aab..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/EARProjectMap.java +++ /dev/null @@ -1,40 +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.internal.earcreation.modulemap; - - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - - -/** - * @lastgen interface EARProjectMap extends EObject {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public interface EARProjectMap extends EObject { - /** - * @generated This field/method will be replaced during code generation - * @return The list of Mappings references - */ - EList getMappings(); - - /** - * @generated This field/method will be replaced during code generation - * @return The list of UtilityJARMappings references - */ - EList getUtilityJARMappings(); - -} //EARProjectMap diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/EARProjectMapImpl.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/EARProjectMapImpl.java deleted file mode 100644 index 02aea5dec..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/EARProjectMapImpl.java +++ /dev/null @@ -1,171 +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.internal.earcreation.modulemap; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - - - -/** - * @lastgen class EARProjectMapImpl extends EObjectImpl implements EARProjectMap, EObject {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public class EARProjectMapImpl extends EObjectImpl implements EARProjectMap { - /** - * @generated This field/method will be replaced during code generation. - */ - /** - * @generated This field/method will be replaced during code generation. - */ - protected EList mappings = null; - /** - * @generated This field/method will be replaced during code generation. - */ - protected EList utilityJARMappings = null; - - - - /** - * @generated This field/method will be replaced during code generation. - */ - protected EARProjectMapImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return ModulemapPackage.eINSTANCE.getEARProjectMap(); - } - - /** - * @generated This field/method will be replaced during code generation - */ - public EList getMappings() { - if (mappings == null) { - mappings = new EObjectContainmentEList(ModuleMapping.class, this, ModulemapPackage.EAR_PROJECT_MAP__MAPPINGS); - } - return mappings; - } - - /** - * @generated This field/method will be replaced during code generation - */ - public EList getUtilityJARMappings() { - if (utilityJARMappings == null) { - utilityJARMappings = new EObjectContainmentEList(UtilityJARMapping.class, this, ModulemapPackage.EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS); - } - return utilityJARMappings; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (baseClass == null ? featureID : eDerivedStructuralFeatureID(featureID, baseClass)) { - case ModulemapPackage.EAR_PROJECT_MAP__MAPPINGS : - return ((InternalEList) getMappings()).basicRemove(otherEnd, msgs); - case ModulemapPackage.EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS : - return ((InternalEList) getUtilityJARMappings()).basicRemove(otherEnd, msgs); - default : - return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.EAR_PROJECT_MAP__MAPPINGS : - return getMappings(); - case ModulemapPackage.EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS : - return getUtilityJARMappings(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.EAR_PROJECT_MAP__MAPPINGS : - getMappings().clear(); - getMappings().addAll((Collection) newValue); - return; - case ModulemapPackage.EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS : - getUtilityJARMappings().clear(); - getUtilityJARMappings().addAll((Collection) newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.EAR_PROJECT_MAP__MAPPINGS : - getMappings().clear(); - return; - case ModulemapPackage.EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS : - getUtilityJARMappings().clear(); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.EAR_PROJECT_MAP__MAPPINGS : - return mappings != null && !mappings.isEmpty(); - case ModulemapPackage.EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS : - return utilityJARMappings != null && !utilityJARMappings.isEmpty(); - } - return eDynamicIsSet(eFeature); - } - -} //EARProjectMapImpl diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModuleMapping.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModuleMapping.java deleted file mode 100644 index 1dce176e3..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModuleMapping.java +++ /dev/null @@ -1,55 +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.internal.earcreation.modulemap; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.j2ee.application.Module; - - - -/** - * @lastgen interface ModuleMapping extends EObject {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - * </p> - */ -public interface ModuleMapping extends EObject { - /** - * @generated This field/method will be replaced during code generation - * @return The value of the ProjectName attribute - */ - String getProjectName(); - - /** - * @generated This field/method will be replaced during code generation - * @param value - * The new value of the ProjectName attribute - */ - void setProjectName(String value); - - /** - * @generated This field/method will be replaced during code generation - * @return The Module reference - */ - Module getModule(); - - /** - * @generated This field/method will be replaced during code generation - * @param l - * The new value of the Module reference - */ - void setModule(Module value); - -} //ModuleMapping diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModuleMappingImpl.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModuleMappingImpl.java deleted file mode 100644 index 9f8c6b9f9..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModuleMappingImpl.java +++ /dev/null @@ -1,194 +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.internal.earcreation.modulemap; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; - - -/** - * @lastgen class ModuleMappingImpl extends EObjectImpl implements ModuleMapping, EObject {} - * * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public class ModuleMappingImpl extends EObjectImpl implements ModuleMapping { - /** - * The default value of the '{@link #getProjectName() <em>Project Name</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getProjectName() - * @generated - * @ordered - */ - protected static final String PROJECT_NAME_EDEFAULT = null; - - /** - * @generated This field/method will be replaced during code generation. - */ - /** - * @generated This field/method will be replaced during code generation. - */ - protected String projectName = PROJECT_NAME_EDEFAULT; - /** - * @generated This field/method will be replaced during code generation. - */ - protected Module module = null; - - /** - * @generated This field/method will be replaced during code generation. - */ - protected ModuleMappingImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return ModulemapPackage.eINSTANCE.getModuleMapping(); - } - - /** - * @generated This field/method will be replaced during code generation - */ - public String getProjectName() { - return projectName; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void setProjectName(String newProjectName) { - String oldProjectName = projectName; - projectName = newProjectName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModulemapPackage.MODULE_MAPPING__PROJECT_NAME, oldProjectName, projectName)); - } - - /** - * @generated This field/method will be replaced during code generation - */ - public Module getModule() { - if (module != null && module.eIsProxy()) { - Module oldModule = module; - module = (Module) EcoreUtil.resolve(module, this); - if (module != oldModule) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModulemapPackage.MODULE_MAPPING__MODULE, oldModule, module)); - } - } - return module; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Module basicGetModule() { - return module; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void setModule(Module newModule) { - Module oldModule = module; - module = newModule; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModulemapPackage.MODULE_MAPPING__MODULE, oldModule, module)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.MODULE_MAPPING__PROJECT_NAME : - return getProjectName(); - case ModulemapPackage.MODULE_MAPPING__MODULE : - if (resolve) - return getModule(); - return basicGetModule(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.MODULE_MAPPING__PROJECT_NAME : - return PROJECT_NAME_EDEFAULT == null ? projectName != null : !PROJECT_NAME_EDEFAULT.equals(projectName); - case ModulemapPackage.MODULE_MAPPING__MODULE : - return module != null; - } - return eDynamicIsSet(eFeature); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.MODULE_MAPPING__PROJECT_NAME : - setProjectName((String) newValue); - return; - case ModulemapPackage.MODULE_MAPPING__MODULE : - setModule((Module) newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.MODULE_MAPPING__PROJECT_NAME : - setProjectName(PROJECT_NAME_EDEFAULT); - return; - case ModulemapPackage.MODULE_MAPPING__MODULE : - setModule((Module) null); - return; - } - eDynamicUnset(eFeature); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(EARCreationResourceHandler.getString("ModuleMappingImpl_UI_0", new Object[]{projectName})); //$NON-NLS-1$ - return result.toString(); - } - -} //ModuleMappingImpl diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapAdapterFactory.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapAdapterFactory.java deleted file mode 100644 index 4a1a18fac..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapAdapterFactory.java +++ /dev/null @@ -1,130 +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.internal.earcreation.modulemap; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; - - - -/** - * @lastgen class ModulemapAdapterFactory extends AdapterFactoryImpl {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public class ModulemapAdapterFactory extends AdapterFactoryImpl { - /** - * @generated This field/method will be replaced during code generation. - */ - - /** - * @generated This field/method will be replaced during code generation. - */ - protected static ModulemapPackage modelPackage; - - /** - * @generated This field/method will be replaced during code generation. - */ - public ModulemapAdapterFactory() { - if (modelPackage == null) { - modelPackage = ModulemapPackage.eINSTANCE; - } - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject) object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch the delegates to the <code>createXXX</code> methods. <!-- begin-user-doc --> - * <!-- end-user-doc --> - * - * @generated - */ - protected ModulemapSwitch modelSwitch = new ModulemapSwitch() { - public Object caseModuleMapping(ModuleMapping object) { - return createModuleMappingAdapter(); - } - - public Object caseEARProjectMap(EARProjectMap object) { - return createEARProjectMapAdapter(); - } - - public Object caseUtilityJARMapping(UtilityJARMapping object) { - return createUtilityJARMappingAdapter(); - } - - public Object defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * @generated This field/method will be replaced during code generation. - */ - public Adapter createAdapter(Notifier target) { - return (Adapter) modelSwitch.doSwitch((EObject) target); - } - - - /** - * By default create methods return null so that we can easily ignore cases. It's useful to - * ignore a case when inheritance will catch all the cases anyway. - */ - - /** - * @generated This field/method will be replaced during code generation. - */ - public Adapter createEARProjectMapAdapter() { - return null; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public Adapter createModuleMappingAdapter() { - return null; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public Adapter createUtilityJARMappingAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. <!-- begin-user-doc --> This default - * implementation returns null. <!-- end-user-doc --> - * - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //ModulemapAdapterFactory diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapFactory.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapFactory.java deleted file mode 100644 index 92eaa8e8b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapFactory.java +++ /dev/null @@ -1,56 +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.internal.earcreation.modulemap; - -import org.eclipse.emf.ecore.EFactory; - - -/** - * @lastgen interface ModulemapFactory extends EFactory {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public interface ModulemapFactory extends EFactory { - /** - * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - ModulemapFactory eINSTANCE = new org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModulemapFactoryImpl(); - - /** - * @generated This field/method will be replaced during code generation - * @return EARProjectMap value - */ - EARProjectMap createEARProjectMap(); - - /** - * @generated This field/method will be replaced during code generation - * @return ModuleMapping value - */ - ModuleMapping createModuleMapping(); - - /** - * @generated This field/method will be replaced during code generation - * @return UtilityJARMapping value - */ - UtilityJARMapping createUtilityJARMapping(); - - /** - * @generated This field/method will be replaced during code generation. - */ - ModulemapPackage getModulemapPackage(); - -} //ModulemapFactory diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapFactoryImpl.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapFactoryImpl.java deleted file mode 100644 index 1bb612785..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapFactoryImpl.java +++ /dev/null @@ -1,92 +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.internal.earcreation.modulemap; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.impl.EFactoryImpl; - - - -/** - * @lastgen class ModulemapFactoryImpl extends EFactoryImpl implements ModulemapFactory, EFactory {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public class ModulemapFactoryImpl extends EFactoryImpl implements ModulemapFactory { - - /** - * @generated This field/method will be replaced during code generation. - */ - public ModulemapFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case ModulemapPackage.MODULE_MAPPING : - return createModuleMapping(); - case ModulemapPackage.EAR_PROJECT_MAP : - return createEARProjectMap(); - case ModulemapPackage.UTILITY_JAR_MAPPING : - return createUtilityJARMapping(); - } - return null; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EARProjectMap createEARProjectMap() { - EARProjectMapImpl earProjectMap = new EARProjectMapImpl(); - return earProjectMap; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public ModuleMapping createModuleMapping() { - ModuleMappingImpl moduleMapping = new ModuleMappingImpl(); - return moduleMapping; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public UtilityJARMapping createUtilityJARMapping() { - UtilityJARMappingImpl utilityJARMapping = new UtilityJARMappingImpl(); - return utilityJARMapping; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public ModulemapPackage getModulemapPackage() { - return (ModulemapPackage) getEPackage(); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public static ModulemapPackage getPackage() { - return ModulemapPackage.eINSTANCE; - } - -} //ModulemapFactoryImpl diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapInit.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapInit.java deleted file mode 100644 index 5b65b6782..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapInit.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 - **************************************************************************************************/ -package org.eclipse.jst.j2ee.internal.earcreation.modulemap; - - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.earcreation.EAREditModel; -import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil; -import org.eclipse.wst.common.internal.emf.utilities.ResourceDependencyRegister; -/** -* @deprecated -* Use -* <p> -* Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules -* as with the Flexible project changes a .modulemaps file will not exist in an EAR module and -* all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file -*/ - -public class ModulemapInit { - protected static boolean initialized = false; - - public static void init() { - init(true); - } - - public static void init(boolean shouldPreRegisterPackages) { - if (!initialized) { - initialized = true; - invokePrereqInits(shouldPreRegisterPackages); - if (shouldPreRegisterPackages) { - ExtendedEcoreUtil.preRegisterPackage("modulemap.xmi", new EPackage.Descriptor() { //$NON-NLS-1$ - public EPackage getEPackage() { - return ModulemapPackage.eINSTANCE; - } - }); - } - ResourceDependencyRegister.registerDependency(J2EEConstants.APPLICATION_DD_URI_OBJ, EAREditModel.MODULE_MAP_URI_OBJ); - } - } - - public static void invokePrereqInits(boolean shouldPreRegisterPackages) { - //TODO Should remove.... - //com.ibm.ejs.models.base.extensions.init.ExtensionsInit.init(shouldPreRegisterPackages); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapPackage.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapPackage.java deleted file mode 100644 index 5d78b9733..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapPackage.java +++ /dev/null @@ -1,181 +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.internal.earcreation.modulemap; - - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - - -/** - * @lastgen interface ModulemapPackage extends EPackage {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public interface ModulemapPackage extends EPackage { - /** - * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - String eNAME = "modulemap"; //$NON-NLS-1$ - - /** - * @generated This field/method will be replaced during code generation. - */ - - - /** - * @generated This field/method will be replaced during code generation. - */ - int EAR_PROJECT_MAP = 1; - /** - * @generated This field/method will be replaced during code generation. - */ - int MODULE_MAPPING = 0; - /** - * @generated This field/method will be replaced during code generation. - */ - int MODULE_MAPPING__PROJECT_NAME = 0; - /** - * @generated This field/method will be replaced during code generation. - */ - int MODULE_MAPPING__MODULE = 1; - - /** - * The number of structural features of the the '<em>Module Mapping</em>' class. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int MODULE_MAPPING_FEATURE_COUNT = 2; - - /** - * @generated This field/method will be replaced during code generation. - */ - int EAR_PROJECT_MAP__MAPPINGS = 0; - /** - * @generated This field/method will be replaced during code generation. - */ - int EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS = 1; - - /** - * The number of structural features of the the '<em>EAR Project Map</em>' class. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int EAR_PROJECT_MAP_FEATURE_COUNT = 2; - - /** - * @generated This field/method will be replaced during code generation. - */ - int UTILITY_JAR_MAPPING = 2; - /** - * @generated This field/method will be replaced during code generation. - */ - int UTILITY_JAR_MAPPING__PROJECT_NAME = 0; - /** - * @generated This field/method will be replaced during code generation. - */ - int UTILITY_JAR_MAPPING__URI = 1; - - - /** - * The number of structural features of the the '<em>Utility JAR Mapping</em>' class. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int UTILITY_JAR_MAPPING_FEATURE_COUNT = 2; - - - /** - * @generated This field/method will be replaced during code generation. - */ - String eNS_URI = "modulemap.xmi"; //$NON-NLS-1$ - /** - * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - String eNS_PREFIX = "modulemap"; //$NON-NLS-1$ - - /** - * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - ModulemapPackage eINSTANCE = org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModulemapPackageImpl.init(); - - /** - * @generated This field/method will be replaced during code generation - * @return EARProjectMap object - */ - EClass getEARProjectMap(); - - /** - * @generated This field/method will be replaced during code generation. - */ - EReference getEARProjectMap_Mappings(); - - /** - * @generated This field/method will be replaced during code generation. - */ - EReference getEARProjectMap_UtilityJARMappings(); - - /** - * @generated This field/method will be replaced during code generation - * @return ModuleMapping object - */ - EClass getModuleMapping(); - - /** - * @generated This field/method will be replaced during code generation. - */ - EAttribute getModuleMapping_ProjectName(); - - /** - * @generated This field/method will be replaced during code generation. - */ - EReference getModuleMapping_Module(); - - /** - * @generated This field/method will be replaced during code generation - * @return UtilityJARMapping object - */ - EClass getUtilityJARMapping(); - - /** - * @generated This field/method will be replaced during code generation. - */ - EAttribute getUtilityJARMapping_ProjectName(); - - /** - * @generated This field/method will be replaced during code generation. - */ - EAttribute getUtilityJARMapping_Uri(); - - /** - * @generated This field/method will be replaced during code generation. - */ - ModulemapFactory getModulemapFactory(); - -} //ModulemapPackage diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapPackageImpl.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapPackageImpl.java deleted file mode 100644 index 8cd6ad2e3..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapPackageImpl.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.internal.earcreation.modulemap; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.emf.ecore.impl.EcorePackageImpl; -import org.eclipse.jem.java.impl.JavaRefPackageImpl; -import org.eclipse.jst.j2ee.internal.application.ApplicationPackage; -import org.eclipse.jst.j2ee.internal.application.impl.ApplicationPackageImpl; -import org.eclipse.jst.j2ee.internal.common.impl.CommonPackageImpl; - - - -/** - * @lastgen class ModulemapPackageImpl extends EPackageImpl implements ModulemapPackage, EPackage {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public class ModulemapPackageImpl extends EPackageImpl implements ModulemapPackage { - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass moduleMappingEClass = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass earProjectMapEClass = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass utilityJARMappingEClass = null; - - /** - * @generated This field/method will be replaced during code generation. - */ - private ModulemapPackageImpl() { - super(eNS_URI, ModulemapFactory.eINSTANCE); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public static ModulemapPackage init() { - // Initialize simple dependencies - CommonPackageImpl.init(); - JavaRefPackageImpl.init(); - ApplicationPackageImpl.init(); - EcorePackageImpl.init(); - - // Obtain or create and register package and interdependencies - ModulemapPackageImpl theModulemapPackage = (ModulemapPackageImpl) (EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof EPackage ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new ModulemapPackageImpl()); - - // Step 1: create meta-model objects - theModulemapPackage.createPackageContents(); - - // Step 2: complete initialization - theModulemapPackage.initializePackageContents(); - - return theModulemapPackage; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EClass getEARProjectMap() { - return earProjectMapEClass; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EReference getEARProjectMap_Mappings() { - return (EReference) earProjectMapEClass.getEReferences().get(0); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EReference getEARProjectMap_UtilityJARMappings() { - return (EReference) earProjectMapEClass.getEReferences().get(1); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EClass getModuleMapping() { - return moduleMappingEClass; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EAttribute getModuleMapping_ProjectName() { - return (EAttribute) moduleMappingEClass.getEAttributes().get(0); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EReference getModuleMapping_Module() { - return (EReference) moduleMappingEClass.getEReferences().get(0); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EClass getUtilityJARMapping() { - return utilityJARMappingEClass; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EAttribute getUtilityJARMapping_ProjectName() { - return (EAttribute) utilityJARMappingEClass.getEAttributes().get(0); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public EAttribute getUtilityJARMapping_Uri() { - return (EAttribute) utilityJARMappingEClass.getEAttributes().get(1); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public ModulemapFactory getModulemapFactory() { - return (ModulemapFactory) getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is guarded to have no affect on - * any invocation but its first. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void createPackageContents() { - if (isCreated) - return; - isCreated = true; - - // Create classes and their features - moduleMappingEClass = createEClass(MODULE_MAPPING); - createEAttribute(moduleMappingEClass, MODULE_MAPPING__PROJECT_NAME); - createEReference(moduleMappingEClass, MODULE_MAPPING__MODULE); - - earProjectMapEClass = createEClass(EAR_PROJECT_MAP); - createEReference(earProjectMapEClass, EAR_PROJECT_MAP__MAPPINGS); - createEReference(earProjectMapEClass, EAR_PROJECT_MAP__UTILITY_JAR_MAPPINGS); - - utilityJARMappingEClass = createEClass(UTILITY_JAR_MAPPING); - createEAttribute(utilityJARMappingEClass, UTILITY_JAR_MAPPING__PROJECT_NAME); - createEAttribute(utilityJARMappingEClass, UTILITY_JAR_MAPPING__URI); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This method is guarded to have - * no affect on any invocation but its first. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void initializePackageContents() { - if (isInitialized) - return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Obtain other dependent packages - // CommonPackageImpl theCommonPackage = - // (CommonPackageImpl)EPackage.Registry.INSTANCE.getEPackage(CommonPackage.eNS_URI); - // JavaRefPackageImpl theJavaRefPackage = - // (JavaRefPackageImpl)EPackage.Registry.INSTANCE.getEPackage(JavaRefPackage.eNS_URI); - ApplicationPackageImpl theApplicationPackage = (ApplicationPackageImpl) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI); - // EcorePackageImpl theEcorePackage = - // (EcorePackageImpl)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); - - // Add supertypes to classes - - // Initialize classes and features; add operations and parameters - initEClass(moduleMappingEClass, ModuleMapping.class, "ModuleMapping", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$ - initEAttribute(getModuleMapping_ProjectName(), ecorePackage.getEString(), "projectName", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, true, false); //$NON-NLS-1$ - initEReference(getModuleMapping_Module(), theApplicationPackage.getModule(), null, "module", null, 1, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, true, false); //$NON-NLS-1$ - - initEClass(earProjectMapEClass, EARProjectMap.class, "EARProjectMap", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$ - initEReference(getEARProjectMap_Mappings(), this.getModuleMapping(), null, "mappings", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, true, false); //$NON-NLS-1$ - initEReference(getEARProjectMap_UtilityJARMappings(), this.getUtilityJARMapping(), null, "utilityJARMappings", null, 1, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, true, false); //$NON-NLS-1$ - - initEClass(utilityJARMappingEClass, UtilityJARMapping.class, "UtilityJARMapping", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$ - initEAttribute(getUtilityJARMapping_ProjectName(), ecorePackage.getEString(), "projectName", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, true, false); //$NON-NLS-1$ - initEAttribute(getUtilityJARMapping_Uri(), ecorePackage.getEString(), "uri", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, true, false); //$NON-NLS-1$ - - // Create resource - createResource(eNS_URI); - } -} //ModulemapPackageImpl diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapSwitch.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapSwitch.java deleted file mode 100644 index de6864bb3..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapSwitch.java +++ /dev/null @@ -1,107 +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.internal.earcreation.modulemap; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; - - - -/** - * @lastgen class ModulemapSwitch {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public class ModulemapSwitch { - /** - * The cached model package <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected static ModulemapPackage modelPackage; - - /** - * @generated This field/method will be replaced during code generation. - */ - public ModulemapSwitch() { - if (modelPackage == null) { - modelPackage = ModulemapPackage.eINSTANCE; - } - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public Object doSwitch(EObject theEObject) { - EClass theEClass = theEObject.eClass(); - if (theEClass.eContainer() == modelPackage) { - switch (theEClass.getClassifierID()) { - case ModulemapPackage.MODULE_MAPPING : { - ModuleMapping moduleMapping = (ModuleMapping) theEObject; - Object result = caseModuleMapping(moduleMapping); - if (result == null) - result = defaultCase(theEObject); - return result; - } - case ModulemapPackage.EAR_PROJECT_MAP : { - EARProjectMap earProjectMap = (EARProjectMap) theEObject; - Object result = caseEARProjectMap(earProjectMap); - if (result == null) - result = defaultCase(theEObject); - return result; - } - case ModulemapPackage.UTILITY_JAR_MAPPING : { - UtilityJARMapping utilityJARMapping = (UtilityJARMapping) theEObject; - Object result = caseUtilityJARMapping(utilityJARMapping); - if (result == null) - result = defaultCase(theEObject); - return result; - } - default : - return defaultCase(theEObject); - } - } - return defaultCase(theEObject); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public Object caseEARProjectMap(EARProjectMap object) { - return null; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public Object caseModuleMapping(ModuleMapping object) { - return null; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public Object caseUtilityJARMapping(UtilityJARMapping object) { - return null; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public Object defaultCase(EObject object) { - return null; - } - -} //ModulemapSwitch diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/UtilityJARMapping.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/UtilityJARMapping.java deleted file mode 100644 index 2ed2e6da9..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/UtilityJARMapping.java +++ /dev/null @@ -1,53 +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.internal.earcreation.modulemap; - - -import org.eclipse.emf.ecore.EObject; - - -/** - * @lastgen interface UtilityJARMapping extends EObject {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public interface UtilityJARMapping extends EObject { - /** - * @generated This field/method will be replaced during code generation - * @return The value of the ProjectName attribute - */ - String getProjectName(); - - /** - * @generated This field/method will be replaced during code generation - * @param value - * The new value of the ProjectName attribute - */ - void setProjectName(String value); - - /** - * @generated This field/method will be replaced during code generation - * @return The value of the Uri attribute - */ - String getUri(); - - /** - * @generated This field/method will be replaced during code generation - * @param value - * The new value of the Uri attribute - */ - void setUri(String value); - -} //UtilityJARMapping diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/UtilityJARMappingImpl.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/UtilityJARMappingImpl.java deleted file mode 100644 index 6df46a16f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/UtilityJARMappingImpl.java +++ /dev/null @@ -1,183 +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.internal.earcreation.modulemap; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; - - -/** - * @lastgen class UtilityJARMappingImpl extends EObjectImpl implements UtilityJARMapping, EObject {} - * @deprecated - * Use - * <p> - * Need to use the ModuleCore and WorkbenchComponent Api to get to the referenced modules - * as with the Flexible project changes a .modulemaps file will not exist in an EAR module and - * all the info that was captured in .modulemaps file will is now captured in the .wtpmodules file - */ -public class UtilityJARMappingImpl extends EObjectImpl implements UtilityJARMapping { - /** - * The default value of the '{@link #getProjectName() <em>Project Name</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getProjectName() - * @generated - * @ordered - */ - protected static final String PROJECT_NAME_EDEFAULT = null; - - /** - * @generated This field/method will be replaced during code generation. - */ - /** - * @generated This field/method will be replaced during code generation. - */ - protected String projectName = PROJECT_NAME_EDEFAULT; - /** - * The default value of the '{@link #getUri() <em>Uri</em>}' attribute. <!-- begin-user-doc - * --> <!-- end-user-doc --> - * - * @see #getUri() - * @generated - * @ordered - */ - protected static final String URI_EDEFAULT = null; - - /** - * @generated This field/method will be replaced during code generation. - */ - protected String uri = URI_EDEFAULT; - - /** - * @generated This field/method will be replaced during code generation. - */ - protected UtilityJARMappingImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return ModulemapPackage.eINSTANCE.getUtilityJARMapping(); - } - - /** - * @generated This field/method will be replaced during code generation - */ - public String getProjectName() { - return projectName; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void setProjectName(String newProjectName) { - String oldProjectName = projectName; - projectName = newProjectName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModulemapPackage.UTILITY_JAR_MAPPING__PROJECT_NAME, oldProjectName, projectName)); - } - - /** - * @generated This field/method will be replaced during code generation - */ - public String getUri() { - return uri; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void setUri(String newUri) { - String oldUri = uri; - uri = newUri; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModulemapPackage.UTILITY_JAR_MAPPING__URI, oldUri, uri)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.UTILITY_JAR_MAPPING__PROJECT_NAME : - return getProjectName(); - case ModulemapPackage.UTILITY_JAR_MAPPING__URI : - return getUri(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.UTILITY_JAR_MAPPING__PROJECT_NAME : - return PROJECT_NAME_EDEFAULT == null ? projectName != null : !PROJECT_NAME_EDEFAULT.equals(projectName); - case ModulemapPackage.UTILITY_JAR_MAPPING__URI : - return URI_EDEFAULT == null ? uri != null : !URI_EDEFAULT.equals(uri); - } - return eDynamicIsSet(eFeature); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.UTILITY_JAR_MAPPING__PROJECT_NAME : - setProjectName((String) newValue); - return; - case ModulemapPackage.UTILITY_JAR_MAPPING__URI : - setUri((String) newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature.getFeatureID(), eFeature.getContainerClass())) { - case ModulemapPackage.UTILITY_JAR_MAPPING__PROJECT_NAME : - setProjectName(PROJECT_NAME_EDEFAULT); - return; - case ModulemapPackage.UTILITY_JAR_MAPPING__URI : - setUri(URI_EDEFAULT); - return; - } - eDynamicUnset(eFeature); - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(EARCreationResourceHandler.getString("UtilityJARMappingImpl_UI_0", new Object[]{projectName, uri})); //$NON-NLS-1$ - return result.toString(); - } - -} //UtilityJARMappingImpl diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EARArtifactEditOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EARArtifactEditOperation.java deleted file mode 100644 index 18cd25687..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EARArtifactEditOperation.java +++ /dev/null @@ -1,34 +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.internal.modulecore.util; - -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditOperation; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; - -public class EARArtifactEditOperation extends ArtifactEditOperation { - - public EARArtifactEditOperation(EARArtifactEditOperationDataModel operationDataModel) { - super(operationDataModel); - } - - protected ArtifactEdit getArtifactEditForModule(WorkbenchComponent module) { - ComponentHandle handle = ComponentHandle.create(StructureEdit.getContainingProject(module),module.getName()); - return EARArtifactEdit.getEARArtifactEditForWrite(handle); - } - - protected EARArtifactEdit getEJBArtifactEdit() { - return (EARArtifactEdit)getArtifactEdit(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EARArtifactEditOperationDataModel.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EARArtifactEditOperationDataModel.java deleted file mode 100644 index 1f9c9c9a1..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EARArtifactEditOperationDataModel.java +++ /dev/null @@ -1,31 +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.internal.modulecore.util; - -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditOperationDataModel; -import org.eclipse.wst.common.componentcore.resources.ComponentHandle; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; - -public class EARArtifactEditOperationDataModel extends ArtifactEditOperationDataModel { - - public WTPOperation getDefaultOperation() { - return new EARArtifactEditOperation(this); - } - - public EARArtifactEdit getEARArtifactEditForRead() { - ComponentHandle handle = ComponentHandle.create(StructureEdit.getContainingProject(getWorkbenchModule()),getWorkbenchModule().getName()); - - return EARArtifactEdit.getEARArtifactEditForRead(handle); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EarEditAdapterFactory.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EarEditAdapterFactory.java deleted file mode 100644 index d27f95b2b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EarEditAdapterFactory.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 - **************************************************************************************************/ -package org.eclipse.jst.j2ee.internal.modulecore.util; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; - - -/** - * <p> - * Adapts {@see org.eclipse.wst.common.modulecore.ArtifactEditModel}s to - * {@see org.eclipse.jst.j2ee.internal.modulecore.util.EARArtifactEdit} facades. - * </p> - */ -public class EarEditAdapterFactory implements IAdapterFactory { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - - if (adapterType == EARArtifactEdit.ADAPTER_TYPE || adapterType == ArtifactEdit.ADAPTER_TYPE) { - ArtifactEditModel editModel = (ArtifactEditModel) adaptableObject; - if (editModel.getModuleType().equals(EARArtifactEdit.TYPE_ID)) - return new EARArtifactEdit((ArtifactEditModel) adaptableObject); - } - return null; - - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - - return new Class[]{ArtifactEdit.class, EARArtifactEdit.class}; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtension.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtension.java deleted file mode 100644 index cae912f77..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtension.java +++ /dev/null @@ -1,48 +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 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.internal.moduleextension; - -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationDataModel; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationOperation; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEModuleImportDataModel; -import org.eclipse.jst.j2ee.internal.archive.operations.ImportOption; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public interface EarModuleExtension { - String getNatureID(); - - /** - * Return a default instance of the J2EEModuleCreationDataModel. - * - * @return - */ - IDataModel createProjectDataModel(); - - J2EEModuleImportDataModel createImportDataModel(); - - J2EEComponentCreationOperation createProjectCreationOperation(J2EEComponentCreationDataModel dataModel); - - J2EEComponentCreationOperation createProjectCreationOperation(ImportOption option); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtensionImpl.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtensionImpl.java deleted file mode 100644 index 509224cd8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtensionImpl.java +++ /dev/null @@ -1,61 +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 29, 2003 - * - * To change the template for this generated file go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.moduleextension; - -import org.eclipse.core.internal.resources.Project; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationDataModel; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentCreationOperation; -import org.eclipse.jst.j2ee.internal.archive.operations.ImportOption; -import org.eclipse.jst.j2ee.internal.project.J2EENature; - - -public abstract class EarModuleExtensionImpl implements EarModuleExtension { - /** - * - */ - public EarModuleExtensionImpl() { - super(); - // TODO Auto-generated constructor stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.moduleextension.EarModuleExtension#getNature(org.eclipse.core.internal.resources.Project) - */ - public J2EENature getNature(Project proj) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.moduleextension.EarModuleExtension#getNatureID() - */ - public abstract String getNatureID(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.moduleextension.EarModuleExtension#createProjectCreationOperation(com.ibm.etools.archive.ear.operations.ImportOption) - */ - public J2EEComponentCreationOperation createProjectCreationOperation(ImportOption option) { - if (option.getArchiveType() == ImportOption.MODULE) - return createProjectCreationOperation((J2EEComponentCreationDataModel) option.getModel()); - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtensionRegistry.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtensionRegistry.java deleted file mode 100644 index 8ef204c62..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtensionRegistry.java +++ /dev/null @@ -1,72 +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 29, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.moduleextension; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jem.util.RegistryReader; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; - -/** - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class EarModuleExtensionRegistry extends RegistryReader { - - static final String EXTENSION_NAME = "EARModuleExtension"; //$NON-NLS-1$ - static final String ELEMENT_EARMODULE_EXTENSION = "earModuleExtension"; //$NON-NLS-1$ - static final String MODULE_EXTENSION_CLASS = "extensionClass"; //$NON-NLS-1$ - private static EarModuleExtensionRegistry INSTANCE = null; - - public EarModuleExtensionRegistry() { - super(J2EEPlugin.PLUGIN_ID, EXTENSION_NAME); - } - - public static EarModuleExtensionRegistry getInstance() { - if (INSTANCE == null) { - INSTANCE = new EarModuleExtensionRegistry(); - INSTANCE.readRegistry(); - } - return INSTANCE; - } - - /** - * readElement() - parse and deal w/ an extension like: <earModuleExtension extensionClass = - * "com.ibm.etools.web.plugin.WebModuleExtensionImpl"/> - */ - public boolean readElement(IConfigurationElement element) { - if (!element.getName().equals(ELEMENT_EARMODULE_EXTENSION)) - return false; - - EarModuleExtension extension = null; - try { - extension = (EarModuleExtension) element.createExecutableExtension(MODULE_EXTENSION_CLASS); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (extension != null) - addModuleExtension(extension); - return true; - } - - - private static void addModuleExtension(EarModuleExtension ext) { - EarModuleManager.registerModuleExtension(ext); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleManager.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleManager.java deleted file mode 100644 index 0e380f826..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleManager.java +++ /dev/null @@ -1,89 +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 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.internal.moduleextension; - -import java.util.HashMap; - -import org.eclipse.jst.j2ee.internal.project.IConnectorNatureConstants; -import org.eclipse.jst.j2ee.internal.project.IEJBNatureConstants; -import org.eclipse.jst.j2ee.internal.project.IWebNatureConstants; - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class EarModuleManager { - static HashMap moduleExtensions = new HashMap(); - - - /** - * @return - */ - public static HashMap getModuleExtensions() { - return moduleExtensions; - } - - public static EarModuleExtension getModuleExtension(String key) { - //Make sure the registry is loaded - EarModuleExtensionRegistry.getInstance(); - return (EarModuleExtension) moduleExtensions.get(key); - } - - /** - * @return - */ - public static EjbModuleExtension getEJBModuleExtension() { - return (EjbModuleExtension) getModuleExtension(IEJBNatureConstants.NATURE_ID); - } - - /** - * @return - */ - public static JcaModuleExtension getJCAModuleExtension() { - return (JcaModuleExtension) getModuleExtension(IConnectorNatureConstants.NATURE_ID); - } - - /** - * @return - */ - public static WebModuleExtension getWebModuleExtension() { - return (WebModuleExtension) getModuleExtension(IWebNatureConstants.J2EE_NATURE_ID); - } - - public static boolean hasEJBModuleExtension() { - return (EjbModuleExtension) getModuleExtension(IEJBNatureConstants.NATURE_ID) != null; - } - - public static boolean hasJCAModuleExtension() { - return (JcaModuleExtension) getModuleExtension(IConnectorNatureConstants.NATURE_ID) != null; - } - - public static boolean hasWebModuleExtension() { - return (WebModuleExtension) getModuleExtension(IWebNatureConstants.J2EE_NATURE_ID) != null; - } - - public static void registerModuleExtension(EarModuleExtension ext) { - moduleExtensions.put(ext.getNatureID(), ext); - } - - public static void removeModuleExtension(String key) { - moduleExtensions.remove(key); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EjbModuleExtension.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EjbModuleExtension.java deleted file mode 100644 index 5870dfa5f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EjbModuleExtension.java +++ /dev/null @@ -1,49 +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 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.internal.moduleextension; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.internal.earcreation.UpdateModuleReferencesInEARProjectCommand; -import org.eclipse.jst.j2ee.internal.project.J2EENature; -import org.eclipse.wst.common.frameworks.internal.operations.IHeadlessRunnableWithProgress; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public interface EjbModuleExtension extends EarModuleExtension { - - void initializeEjbReferencesToModule(J2EENature nature, UpdateModuleReferencesInEARProjectCommand cmd); - - //J2EEJavaProjectInfo createProjectInfo(); - - //J2EEImportOperationOLD createImportOperation(IProject proj, EJBJarFile ejbJarFile); - - IHeadlessRunnableWithProgress createEJBPostImportOperation(IProject aProj); - - EJBJar getEJBJar(IProject aProject); - - IProject getDefinedEJBClientJARProject(IProject anEJBProject); - - WTPOperation createEJBClientJARProject(IProject anEJBProject); - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/JcaModuleExtension.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/JcaModuleExtension.java deleted file mode 100644 index b0a09a23c..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/JcaModuleExtension.java +++ /dev/null @@ -1,36 +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 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.internal.moduleextension; - -import org.eclipse.jst.j2ee.internal.earcreation.UpdateModuleReferencesInEARProjectCommand; -import org.eclipse.jst.j2ee.internal.project.J2EENature; - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public interface JcaModuleExtension extends EarModuleExtension { - - void initializeEjbReferencesToModule(J2EENature nature, UpdateModuleReferencesInEARProjectCommand cmd); - - //J2EEJavaProjectInfo createProjectInfo(); - - //J2EEImportOperation createImportOperation(IProject proj, RARFile rarFile); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/WebModuleExtension.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/WebModuleExtension.java deleted file mode 100644 index 8c8caddee..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/WebModuleExtension.java +++ /dev/null @@ -1,61 +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 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.internal.moduleextension; - -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.application.WebModule; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.internal.earcreation.UpdateModuleReferencesInEARProjectCommand; -import org.eclipse.jst.j2ee.internal.project.J2EEJavaProjectInfo; -import org.eclipse.jst.j2ee.internal.project.J2EENature; - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public interface WebModuleExtension extends EarModuleExtension { - - static final String WEBSETTINGS_FILE_URI = ".j2ee"; //$NON-NLS-1$ - - void initializeEjbReferencesToModule(J2EENature nature, UpdateModuleReferencesInEARProjectCommand command); - - void addWLPProjects(IProject aProject, Set projectsToBuild); - - J2EEJavaProjectInfo createWebProjectInfo(Archive anArchive); - - void setContextRootForModuleMapping(WebModule m, IProject nestedProject) throws CoreException; - - //J2EEImportOperationOLD createImportOperation(IProject nestedProject, WARFile warFile, - // EARImportConfiguration importConfig); - - String getContentFolder(IProject project, IFile webSettingsFile); - - J2EEJavaProjectInfo createProjectInfo(); - - boolean compareWebContextRoot(Module module, IProject project) throws CoreException; - - boolean hasRuntime(IProject project); - -}
\ No newline at end of file |