diff options
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/earproject')
95 files changed, 0 insertions, 12046 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationDataModelProvider.java deleted file mode 100644 index f21a0e9e6..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationDataModelProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class AddComponentToEnterpriseApplicationDataModelProvider extends CreateReferenceComponentsDataModelProvider implements IAddComponentToEnterpriseApplicationDataModelProperties { - - public AddComponentToEnterpriseApplicationDataModelProvider() { - super(); - } - - public Object getDefaultProperty(String propertyName) { - if (TARGET_COMPONENTS_TO_URI_MAP.equals(propertyName)) { - Map map = new HashMap(); - List components = (List) getProperty(TARGET_COMPONENT_LIST); - for (int i = 0; i < components.size(); i++) { - IVirtualComponent component = (IVirtualComponent) components.get(i); - IProject project = component.getProject(); - String name = component.getName(); - if(name != null) - name = name.replace(' ','_'); - - if (J2EEProjectUtilities.isDynamicWebProject(project)) { - name += IModuleExtensions.DOT_WAR; - } else if (J2EEProjectUtilities.isJCAProject(project)) { - name += IModuleExtensions.DOT_RAR; - } else { - name += IModuleExtensions.DOT_JAR; - } - map.put(component, name); - } - setProperty(propertyName, map); - return map; - } - return super.getDefaultProperty(propertyName); - } - - - public IDataModelOperation getDefaultOperation() { - return new AddComponentToEnterpriseApplicationOp(model); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java deleted file mode 100644 index 9c8a89290..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -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.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -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.application.ApplicationPackage; -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.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.EarFacetRuntimeHandler; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -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.operation.CreateReferenceComponentsOp; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class AddComponentToEnterpriseApplicationOp extends CreateReferenceComponentsOp { - public static final String metaInfFolderDeployPath = "/"; //$NON-NLS-1$ - - public AddComponentToEnterpriseApplicationOp(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if (monitor != null) { - monitor.beginTask("", 3); - } - - try { - J2EEComponentClasspathUpdater.getInstance().pauseUpdates(); - IStatus status = super.execute(submon(monitor, 1), info); - if (!status.isOK()) - return Status.CANCEL_STATUS; - updateEARDD(submon(monitor, 1)); - updateModuleRuntimes(submon(monitor, 1)); - return OK_STATUS; - } finally { - if (monitor != null) { - monitor.done(); - } - J2EEComponentClasspathUpdater.getInstance().resumeUpdates(); - } - } - - protected String getArchiveName(IVirtualComponent comp) { - boolean useArchiveURI = true; - IFacetedProject facetedProject = null; - try { - facetedProject = ProjectFacetsManager.create(comp.getProject()); - } catch (CoreException e) { - useArchiveURI = false; - } - - if (useArchiveURI && facetedProject != null && ProjectFacetsManager.isProjectFacetDefined(IModuleConstants.JST_UTILITY_MODULE)) { - IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_UTILITY_MODULE); - useArchiveURI = projectFacet != null && facetedProject.hasProjectFacet(projectFacet); - } - if (useArchiveURI) { - return super.getArchiveName(comp); - } - return ""; //$NON-NLS-1$ - } - - - /** - * {@link DoNotUseMeThisWillBeDeletedPost15} - * For each module component added to the ear, references are created for every manifest entry. - * - * @param monitor - */ - protected void updateManifestReferences(IProgressMonitor monitor) { - } - - protected void updateEARDD(IProgressMonitor monitor) { - - EARArtifactEdit earEdit = null; - StructureEdit se = null; - try { - IVirtualComponent sourceComp = (IVirtualComponent) model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT); - earEdit = EARArtifactEdit.getEARArtifactEditForWrite(sourceComp.getProject()); - se = StructureEdit.getStructureEditForWrite(sourceComp.getProject()); - if (earEdit != null) { - Application application = earEdit.getApplication(); - List list = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - Map map = (Map) model.getProperty(IAddComponentToEnterpriseApplicationDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP); - if (list != null && list.size() > 0) { - for (int i = 0; i < list.size(); i++) { - StructureEdit compse = null; - IVirtualComponent wc = (IVirtualComponent) list.get(i); - WorkbenchComponent earwc = se.getComponent(); - try { - compse = StructureEdit.getStructureEditForWrite(wc.getProject()); - WorkbenchComponent refwc = compse.getComponent(); - ReferencedComponent ref = se.findReferencedComponent(earwc, refwc); - Module mod = addModule(application, wc, (String) map.get(wc)); - if (ref!=null) - ref.setDependentObject(mod); - } finally { - if (compse != null) { - compse.saveIfNecessary(monitor); - compse.dispose(); - } - } - } - } - } - se.saveIfNecessary(monitor); - earEdit.saveIfNecessary(monitor); - } catch (Exception e) { - Logger.getLogger().logError(e); - } finally { - if (earEdit != null) - earEdit.dispose(); - if (se != null) - se.dispose(); - } - } - - protected Module createNewModule(IVirtualComponent wc) { - if (J2EEProjectUtilities.isDynamicWebProject(wc.getProject())) { - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createWebModule(); - } else if (J2EEProjectUtilities.isEJBProject(wc.getProject())) { - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createEjbModule(); - } else if (J2EEProjectUtilities.isApplicationClientProject(wc.getProject())) { - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createJavaClientModule(); - } else if (J2EEProjectUtilities.isJCAProject(wc.getProject())) { - return ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createConnectorModule(); - } - return null; - } - - protected Module addModule(Application application, IVirtualComponent wc, String name) { - Application dd = application; - Module existingModule = dd.getFirstModule(name); - - if (existingModule == null) { - existingModule = createNewModule(wc); - if (existingModule != null) { - existingModule.setUri(name); - if (existingModule instanceof WebModule) { - Properties props = wc.getMetaProperties(); - String contextroot = ""; //$NON-NLS-1$ - if ((props != null) && (props.containsKey(J2EEConstants.CONTEXTROOT))) - contextroot = props.getProperty(J2EEConstants.CONTEXTROOT); - ((WebModule) existingModule).setContextRoot(contextroot); - } - dd.getModules().add(existingModule); - } - } - return existingModule; - } - - private void updateModuleRuntimes(final IProgressMonitor monitor) { - if (monitor != null) { - monitor.beginTask("", 10); - } - - try { - final IVirtualComponent ear = (IVirtualComponent) this.model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT); - - final IProject earpj = ear.getProject(); - - final List moduleComponents = (List) this.model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - - final Set moduleProjects = new HashSet(); - - for (Iterator itr = moduleComponents.iterator(); itr.hasNext();) { - moduleProjects.add(((IVirtualComponent) itr.next()).getProject()); - } - - if (monitor != null) { - monitor.worked(1); - } - - EarFacetRuntimeHandler.updateModuleProjectRuntime(earpj, moduleProjects, submon(monitor, 9)); - } catch (Exception e) { - Logger.getLogger().logError(e); - } finally { - if (monitor != null) { - monitor.done(); - } - } - } - - private static IProgressMonitor submon(final IProgressMonitor parent, final int ticks) { - return (parent == null ? null : new SubProgressMonitor(parent, ticks)); - } - - 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/AddWebComponentToEARDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddWebComponentToEARDataModelProvider.java deleted file mode 100644 index 867ba9f8f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddWebComponentToEARDataModelProvider.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.util.Set; -import com.ibm.icu.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.datamodel.properties.IAddWebComponentToEnterpriseApplicationDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * - */ -public class AddWebComponentToEARDataModelProvider extends AddComponentToEnterpriseApplicationDataModelProvider implements IAddWebComponentToEnterpriseApplicationDataModelProperties { - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(CONTEXT_ROOT); - return propertyNames; - } - - /** - * - */ - protected String getDefaultURIExtension() { - return "war"; //$NON-NLS-1$ - } - - /** - * - */ - public boolean isWebModuleArchive() { - return true; - } - - /** - * - */ - public boolean propertySet(String propertyName, Object propertyValue) { - boolean notify = super.propertySet(propertyName, propertyValue); - if (notify && propertyName.equals(CONTEXT_ROOT)) - model.notifyPropertyChange(CONTEXT_ROOT, IDataModel.DEFAULT_CHG); - return notify; - } - - /** - * - */ - public Object getDefaultProperty(String propertyName) { - // if (propertyName.equals(CONTEXT_ROOT)) - // return getDefaultContextRoot(); - return super.getDefaultProperty(propertyName); - } - - - /** - * - */ - public IStatus validate(String propertyName) { - if (CONTEXT_ROOT.equals(propertyName)) { - return validateContextRoot(getStringProperty(CONTEXT_ROOT)); - } - return super.validate(propertyName); - } - - /** - * - * @param contextRoot - * @return - */ - public IStatus validateContextRoot(String contextRoot) { - if (contextRoot.equals("") || contextRoot == null) { //$NON-NLS-1$ - return J2EEPlugin.newErrorStatus(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Context_Root_cannot_be_empty_2, new Object[]{contextRoot}), null); - } 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(ProjectSupportResourceHandler.The_character_is_invalid_in_a_context_root, invalidChar); - return J2EEPlugin.newErrorStatus(errorStatus, null); - } - } - } - } else - return J2EEPlugin.newErrorStatus(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Names_cannot_begin_or_end_with_whitespace_5, new Object[]{contextRoot}), null); - return OK_STATUS; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AppClientComponentExportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AppClientComponentExportDataModelProvider.java deleted file mode 100644 index 8b23858d4..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AppClientComponentExportDataModelProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.j2ee.internal.archive.operations.AppClientComponentExportOperation; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - - -public class AppClientComponentExportDataModelProvider extends J2EEComponentExportDataModelProvider { - - public AppClientComponentExportDataModelProvider() { - super(); - } - - public IDataModelOperation getDefaultOperation() { - return new AppClientComponentExportOperation(model); - } - - protected String getModuleExtension() { - return ".jar"; //$NON-NLS-1$ - } - - protected String getWrongComponentTypeString(String projectName) { - return EARCreationResourceHandler.getString(EARCreationResourceHandler.NOT_AN_APP_CLIENT, new Object[]{projectName}); - } - - protected String getProjectType() { - return J2EEProjectUtilities.APPLICATION_CLIENT; - } - /** - * 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. - * @plannedfor 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); -// } -// } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/BinaryProjectHelper.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/BinaryProjectHelper.java deleted file mode 100644 index 3e7245d54..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/BinaryProjectHelper.java +++ /dev/null @@ -1,135 +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.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.emf.workbench.WorkbenchByteArrayOutputStream; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; - -public class BinaryProjectHelper { - - public void importArchiveAsBinary(Archive archive, IProject project, IProgressMonitor monitor) { - try { - - IJavaProject javaProject = JavaCore.create(project); - - IFile savedModuleFile = saveFile(archive, project); - saveEnclosedFile(archive, project, ProjectUtilities.DOT_CLASSPATH); - saveEnclosedFile(archive, project, ProjectUtilities.DOT_PROJECT); - removeImportedClassesFromClasspathIfNecessary(project); - - ensureBinary(javaProject, monitor); - IPath path = savedModuleFile.getFullPath(); - - IClasspathEntry newEntry = JavaCore.newLibraryEntry(path, path, null, true); - - IClasspathEntry[] entries = javaProject.getRawClasspath(); - IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1]; - System.arraycopy(entries, 0, newEntries, 1, entries.length); - newEntries[0] = newEntry; - javaProject.setRawClasspath(newEntries, monitor); - - } catch (FileNotFoundException e) { - Logger.getLogger().log(e); - } catch (IOException e) { - Logger.getLogger().log(e); - } catch (JavaModelException e) { - Logger.getLogger().log(e); - } - } - - /** - * - */ - public static void removeImportedClassesFromClasspathIfNecessary(IProject project) { - IJavaProject javaProj = JavaCore.create(project); - if (javaProj != null) { - IClasspathEntry[] entries = javaProj.readRawClasspath(); - if (entries != null) { - IClasspathEntry entryToRemove = null; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY && entries[i].getPath().toString().endsWith("imported_classes") && !project.getFolder("imported_classes").exists()) { - entryToRemove = entries[i]; - break; - } - } - if (null != entryToRemove) { - IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1]; - for (int i = 0, j = 0; i < newEntries.length && j < entries.length; j++) { - if (entryToRemove != entries[j]) { - newEntries[i] = entries[j]; - i++; - } - } - entries = newEntries; - IPath output = javaProj.readOutputLocation(); - if (output != null) - try { - javaProj.setRawClasspath(entries, output, null); - } catch (JavaModelException e) { - } - } - - } - } - } - - protected IFile saveFile(File aFile, IProject p) throws IOException { - IFile iFile = p.getFile(aFile.getURI()); - WorkbenchByteArrayOutputStream out = new WorkbenchByteArrayOutputStream(iFile); - ArchiveUtil.copy(aFile.getInputStream(), out); - return iFile; - } - - protected void saveEnclosedFile(Archive anArchive, IProject p, String uri) throws IOException { - try { - File aFile = anArchive.getFile(uri); - saveFile(aFile, p); - } catch (FileNotFoundException ignore) { - } - } - - protected void ensureBinary(IJavaProject javaProject, IProgressMonitor monitor) { - - if (javaProject == null) - return; - List newCp = new ArrayList(); - try { - IClasspathEntry[] entries = javaProject.getRawClasspath(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getEntryKind() != IClasspathEntry.CPE_SOURCE) - newCp.add(entries[i]); - } - entries = (IClasspathEntry[]) newCp.toArray(new IClasspathEntry[newCp.size()]); - javaProject.setRawClasspath(entries, monitor); - } catch (JavaModelException ex) { - Logger.getLogger().log(ex); - } - } - -} - 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 6ecbc23ba..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java +++ /dev/null @@ -1,882 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.FileNotFoundException; -import java.io.IOException; -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.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jdt.core.IClasspathEntry; -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.CommonArchiveResourceHandler; -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.exception.OpenFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategy; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.ZipFileLoadStrategyImpl; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.archive.operations.ComponentLoadStrategyImpl; -import org.eclipse.jst.j2ee.internal.archive.operations.EARComponentLoadStrategyImpl; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - - - -public class ClassPathSelection { - protected Archive archive; - protected IProject earProject; - protected IVirtualComponent earComponent; - 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(); - } - - /** - * ClassPathSelection constructor comment. - */ - public ClassPathSelection() { - super(); - } - - protected ClasspathElement createElement(Archive referencingArchive, Archive referencedArchive, String cpEntry) { - ClasspathElement element = new ClasspathElement(referencingArchive); - element.setValid(true); - - String uriString = referencedArchive.getURI(); - URI uri = URI.createURI(uriString); - - boolean hasAbsolutePath = uri.hasAbsolutePath(); - if( hasAbsolutePath ){ - uriString = uri.lastSegment(); - } - - //element.setText(referencedArchive.getURI()); - element.setText(uriString); - element.setTargetArchive(referencedArchive); - element.setEarProject(earProject); - if( earComponent != null ){ - IContainer earConentFolder = earComponent.getRootFolder().getUnderlyingFolder(); - if( earConentFolder.getType() == IResource.FOLDER ){ - element.setEarContentFolder( earConentFolder.getName()); - }else { - element.setEarContentFolder( "" ); - } - } - - 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; - } - - public ClasspathElement createProjectElement(IProject project) { - ClasspathElement element = new ClasspathElement(project); - element.setValid(true); - element.setSelected(true); - element.setText(project.getName()); - element.setProject(project); - addClasspathElement(element,element.getProjectName()); - return element; - } - - public ClasspathElement createProjectElement(IProject project, boolean existingEntry ) { - ClasspathElement element = new ClasspathElement(project); - element.setValid(true); - element.setSelected(existingEntry); - element.setText(project.getName()); - element.setProject(project); - addClasspathElement(element,element.getProjectName()); - return element; - } - - - public ClasspathElement createArchiveElement(URI uri, String name, String cpEntry) { - ClasspathElement element = new ClasspathElement(uri); - element.setValid(false); - element.setRelativeText(name); - if (cpEntry != null) - element.setValuesSelected(cpEntry); - element.setText(name); - element.setEarProject(earProject); - return element; - } - - /** - * @param element - */ - private void setInvalidProject(ClasspathElement element) { - IProject earProj = element.getEarProject(); - //IVirtualComponent[] component = ComponentUtilities.getComponent(earProj.getName()); - IVirtualComponent component = ComponentUtilities.getComponent(earProj.getName()); - EARArtifactEdit edit = null; - try { - edit = EARArtifactEdit.getEARArtifactEditForRead(component); - if (edit != null) { - String moduleName = element.getRelativeText(); - if(moduleName != null) { - IVirtualComponent modComponent = edit.getModule(moduleName); - if(modComponent != null) { - IProject mappedProject = modComponent.getProject(); - element.setProject(mappedProject); - } - } - } - } finally { - if(edit != null) { - edit.dispose(); - edit = null; - } - } - } - - /** - * Insert the method's description here. Creation date: (8/22/2001 1:17:21 PM) - * - * @return java.util.List - */ - public java.util.List getClasspathElements() { - if(classpathElements == null) - classpathElements = new ArrayList(); - return classpathElements; - } - - public java.util.List getSelectedClasspathElements() { - ArrayList list = new ArrayList(); - Iterator it = getClasspathElements().iterator(); - while(it.hasNext()) { - ClasspathElement element = (ClasspathElement)it.next(); - if( element.isSelected() ){ - list.add(element); - } - } - return list; - } - - /** - * 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; - if(classpathElements != 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()]); - } - return null; - } - - /** - * 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 EARComponentLoadStrategyImpl)) - return null; - - return ((EARComponentLoadStrategyImpl) loader).getComponent().getProject(); - } - - public Archive getArchive() { - return archive; - } - - protected IProject getProject(Archive anArchive) { - LoadStrategy loader = anArchive.getLoadStrategy(); - if (loader instanceof ComponentLoadStrategyImpl) - return ((ComponentLoadStrategyImpl) loader).getComponent().getProject(); - return null; - } - - 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); - - String archiveURIString = anArchive.getURI(); - URI archiveURI = URI.createURI(archiveURIString); - boolean hasAbsolutePath = archiveURI.hasAbsolutePath(); - if( hasAbsolutePath ){ - archiveURIString = archiveURI.lastSegment(); - } - if (archiveURIString.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)); - - if( other == null ){ - //making a best guess for the project name - if( element.getProject() == null ){ - int index = cpEntry.indexOf(".jar"); //$NON-NLS-1$ - if( index > 0 ){ - String projectName = cpEntry.substring(0, index); - IProject project = ProjectUtilities.getProject( projectName ); - if( project != null && project.exists() ) - element.setProject( project ); - } - } - } - } - 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()); - } - } - } - - if( earComponent!= null){ - IVirtualReference[] newrefs = earComponent.getReferences(); - for( int i=0; i < newrefs.length; i++){ - IVirtualReference ref = newrefs[i]; - IVirtualComponent referencedComponent = ref.getReferencedComponent(); - boolean isBinary = referencedComponent.isBinary(); - if( isBinary ){ - - - /** - * Warning clean-up 12/05/2005 - */ - //String uri = J2EEProjectUtilities.getResolvedPathForArchiveComponent(referencedComponent.getName()).toString(); - String unresolvedURI = ref.getArchiveName(); - if(unresolvedURI == null){ - try { - unresolvedURI = ModuleURIUtil.getArchiveName(URI.createURI(ModuleURIUtil.getHandleString(referencedComponent))); - } catch (UnresolveableURIException e) { - e.printStackTrace(); - } - } - - if(unresolvedURI != null){ - URI archiveURI = URI.createURI(unresolvedURI); - - boolean alreadyInList = false; - Iterator iter = getClasspathElements().iterator(); - while(iter.hasNext()){ - ClasspathElement tmpelement = (ClasspathElement)iter.next(); - if(unresolvedURI.endsWith(tmpelement.getText())){ - alreadyInList = true; - break; - } - } - - if( !alreadyInList ){ - if( inManifest(cp, archiveURI.lastSegment())){ - element = createArchiveElement(URI.createURI(ModuleURIUtil.getHandleString(referencedComponent)), archiveURI.lastSegment(), archiveURI.lastSegment()); - addClasspathElement(element, unresolvedURI); - }else{ - element = createArchiveElement(URI.createURI(ModuleURIUtil.getHandleString(referencedComponent)), archiveURI.lastSegment(), null); - addClasspathElement(element, unresolvedURI); - } - } - } - } - } - } - } - - boolean inManifest(String[] cp, String archiveName ){ - boolean result = false; - String cpEntry = ""; - for (int i = 0; i < cp.length; i++) { - cpEntry = cp[i]; - if( archiveName.equals(cpEntry)){ - result = true; - } - } - return result; - } - - protected List loadClassPathArchives(){ - /** - * Warning clean-up 12/05/2005 - */ - //LoadStrategy loadStrat = archive.getLoadStrategy(); - - List archives = new ArrayList(); - - if( earComponent!= null){ - IVirtualReference[] newrefs = earComponent.getReferences(); - for( int i=0; i < newrefs.length; i++){ - IVirtualReference ref = newrefs[i]; - IVirtualComponent referencedComponent = ref.getReferencedComponent(); - boolean isBinary = referencedComponent.isBinary(); - - if( isBinary ){ - String uri = J2EEProjectUtilities.getResolvedPathForArchiveComponent(referencedComponent.getName()).toString(); - - try { - ZipFileLoadStrategyImpl strat = createLoadStrategy(uri); - Archive archive = null; - try { - archive = CommonarchiveFactoryImpl.getActiveFactory().primOpenArchive(strat, uri); - } catch (OpenFailureException e) { - // TODO Auto-generated catch block - Logger.getLogger().logError(e); - } - - archives.add(archive); - - } catch (FileNotFoundException e) { - Logger.getLogger().logError(e); - } catch (IOException e) { - Logger.getLogger().logError(e); - } - } - - } - } - return archives; - } - - Archive getClassPathArchive(String uri, List archives){ - for (int i = 0; i < archives.size(); i++) { - Archive anArchive = (Archive) archives.get(i); - - String archiveURIString = anArchive.getURI(); - URI archiveURI = URI.createURI(archiveURIString); - boolean hasAbsolutePath = archiveURI.hasAbsolutePath(); - if( hasAbsolutePath ){ - archiveURIString = archiveURI.lastSegment(); - } - if (archiveURIString.equals(uri)) - return anArchive; - } - return null; - } - - boolean isClassPathArchive(String uri, List archives){ - for (int i = 0; i < archives.size(); i++) { - Archive anArchive = (Archive) archives.get(i); - - String archiveURIString = anArchive.getURI(); - URI archiveURI = URI.createURI(archiveURIString); - /** - * Warning clean-up 12/05/2005 - */ - //boolean hasAbsolutePath = archiveURI.hasAbsolutePath(); - if( archiveURI.lastSegment().equals(uri) ){ - return true; - } - } - return false; - } - - public ZipFileLoadStrategyImpl createLoadStrategy(String uri) throws FileNotFoundException, IOException { - String filename = uri.replace('/', java.io.File.separatorChar); - java.io.File file = new java.io.File(filename); - if (!file.exists()) { - throw new FileNotFoundException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.file_not_found_EXC_, (new Object[]{uri, file.getAbsolutePath()}))); // = "URI Name: {0}; File name: {1}" - } - if (file.isDirectory()) { - throw new FileNotFoundException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.file_not_found_EXC_, (new Object[]{uri, file.getAbsolutePath()}))); // = "URI Name: {0}; File name: {1}" - } - return new org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.ZipFileLoadStrategyImpl(file); - } - - - private void initializeEARProject(EARFile earFile) { - LoadStrategy loadStrat = earFile.getLoadStrategy(); - if (loadStrat instanceof EARComponentLoadStrategyImpl){ - earComponent = ((EARComponentLoadStrategyImpl) loadStrat).getComponent(); - earProject = ((EARComponentLoadStrategyImpl) loadStrat).getComponent().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; - } - - public void addClasspathElement(ClasspathElement element, String uri) { - getClasspathElements().add(element); - getUrisToElements().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 || ejbToClientJARs == null) - return false; - Archive myClientJar = (Archive) ejbToClientJARs.get(archive); - return myClientJar != null && myClientJar == element.getTargetArchive(); - } - - public Map getUrisToElements() { - if(urisToElements == null) - urisToElements = new HashMap(); - return urisToElements; - } - -} 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 5d4bd4a15..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClasspathElement.java +++ /dev/null @@ -1,481 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.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.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.logger.proxy.Logger; -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.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - - -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; - protected URI archiveURI; - protected String earContentFolder; - - public ClasspathElement(Archive anArchive) { - super(); - archive = anArchive; - } - - public ClasspathElement(IProject project) { - super(); - this.project = project; - } - - public ClasspathElement(URI aArchiveURI) { - super(); - archiveURI = aArchiveURI; - } - - protected void computeRelativeText() { - if (archive != null) { - 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 IVirtualComponent getComponent() { - if(project != null){ - return ComponentCore.createComponent(project); - } else if(relativeText != null){ - IVirtualComponent earComponent = ComponentCore.createComponent(earProject); - IVirtualReference[] refs = earComponent.getReferences(); - for (int i = 0; i < refs.length; i++) { - IVirtualReference reference = refs[i]; - if( reference.getReferencedComponent() != null ){ - String name = reference.getReferencedComponent().getName(); - if(name.lastIndexOf('/') != -1){ - name = name.substring(name.lastIndexOf('/')+1); - } - if (name.equals(relativeText)){ - return reference.getReferencedComponent(); - } - } - } - } - return null; - } - - - 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()); - } - - public IClasspathEntry[] newClasspathEntriesForArchive() { - if( !archiveURI.equals("")){ - String resourcePath = ""; - try { - resourcePath = ModuleURIUtil.getArchiveName(archiveURI); - } catch (UnresolveableURIException e) { - Logger.getLogger().logError(e); - } - IPath resPath = new Path(resourcePath); - if (!resPath.isAbsolute()) - resPath = resPath.makeAbsolute(); - java.io.File file = new java.io.File(resourcePath); - if( file.exists() || J2EEPlugin.getWorkspace().getRoot().exists(new Path(resourcePath))){ - return new IClasspathEntry[]{JavaCore.newLibraryEntry( resPath, null, null, true)}; - }else{ - return new IClasspathEntry[]{JavaCore.newVariableEntry( resPath, null, null)}; - } - } - return new IClasspathEntry[0]; - } - - - /** - * 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( archiveURI != null && !archiveURI.equals("") ){ - return newClasspathEntriesForArchive(); - } - 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.getFullPath().append( getEarContentFolder() + IPath.SEPARATOR + earProject.getFile(getText()).getProjectRelativePath()); - 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; - } - - public URI getArchiveURI() { - return archiveURI; - } - - public String getEarContentFolder() { - return earContentFolder; - } - - public void setEarContentFolder(String earContentFolder) { - this.earContentFolder = earContentFolder; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ComputeEARsForContextRootUpdateDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ComputeEARsForContextRootUpdateDataModelProvider.java deleted file mode 100644 index f3313f82c..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ComputeEARsForContextRootUpdateDataModelProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 BEA Systems, Inc - * 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: - * rfrost@bea.com - initial API and impl - *******************************************************************************/ - -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.util.Set; - -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; - -/** - * <code>AbstractDataModelProvider</code> subclass that supports the <code>ComputeEARsForContextRootUpdateOp</code>. - */ -public class ComputeEARsForContextRootUpdateDataModelProvider extends AbstractDataModelProvider implements IUpdateModuleContextRootProperties { - - public Set getPropertyNames() { - final Set propertyNames = super.getPropertyNames(); - propertyNames.add(EARS_TO_UPDATE); - return propertyNames; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ComputeEARsForContextRootUpdateOp.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ComputeEARsForContextRootUpdateOp.java deleted file mode 100644 index 57baa525d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ComputeEARsForContextRootUpdateOp.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 BEA Systems, Inc - * 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: - * rfrost@bea.com - initial API and impl - *******************************************************************************/ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -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.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.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * <code>AbstractDataModelOperation</code> subclass that computes the set of referencing EARs - * in which the context-root for a given module will be updated in the application.xml file. - */ -public class ComputeEARsForContextRootUpdateOp extends AbstractDataModelOperation implements IUpdateModuleContextRootProperties { - - public ComputeEARsForContextRootUpdateOp() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus execute(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { - if (monitor != null) { - monitor.beginTask("", 1); - } - - final IProject project = (IProject)model.getProperty(PROJECT); - final List earsToUpdate = new ArrayList(); - try { - // get the set of all referencing EARs - final IProject[] ears = J2EEProjectUtilities.getReferencingEARProjects(project); - - // for each EAR, check if the current context-root value is equal to the old context-root setting - // if it is, update it to reflect the new value - for (int i = 0; i < ears.length; i++) { - // check if the current value of the context-root for the module - // is equal to the value stored in the associated EAR's - // application.xml - if (currentRootEqualsEARRoot(ears[i], project)) { - earsToUpdate.add(ears[i]); - } - } - // Save the list of EARs to update in a nested IDataModel - IDataModel nestedModel = DataModelFactory.createDataModel(new ComputeEARsForContextRootUpdateDataModelProvider()); - nestedModel.setProperty(EARS_TO_UPDATE, earsToUpdate); - model.addNestedModel(NESTED_MODEL_ID, nestedModel); - - } catch (Exception e) { - Logger.getLogger().logError(e); - } finally { - if (monitor != null) { - monitor.done(); - } - } - return OK_STATUS; - } - - /* - * Determines if the current module context-root is equal to the value in the application.xml. - */ - private boolean currentRootEqualsEARRoot(final IProject earProject, final IProject moduleProject) { - EARArtifactEdit earEdit = null; - try { - earEdit = EARArtifactEdit.getEARArtifactEditForRead(earProject); - if (earEdit == null) { - return false; - } - final Application app = earEdit.getApplication(); - final IVirtualComponent comp = ComponentCore.createComponent(moduleProject); - if (app == null || comp == null) { - return false; - } - final String moduleURI = earEdit.getModuleURI(comp); - final Module module = app.getFirstModule(moduleURI); - if (module != null && module instanceof WebModule) { - final Properties props = comp.getMetaProperties(); - if ((props != null) && (props.containsKey(J2EEConstants.CONTEXTROOT))) { - return ((WebModule) module).getContextRoot().equals(props.getProperty(J2EEConstants.CONTEXTROOT)); - } - } - } finally { - if (earEdit != null) { - earEdit.dispose(); - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // no-op - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // no-op - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CopyArchiveIntoProjectOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CopyArchiveIntoProjectOperation.java deleted file mode 100644 index df1bbaadf..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CopyArchiveIntoProjectOperation.java +++ /dev/null @@ -1,127 +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.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class CopyArchiveIntoProjectOperation extends J2EEUtilityJarImportAssistantOperation { - - public CopyArchiveIntoProjectOperation(File utilityJar) { - super(NLS.bind(EARCreationResourceHandler.CopyArchiveIntoProjectOperation_Copying_archive_into_selected_proje_, utilityJar.getName()), utilityJar); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - MultiStatus status = new MultiStatus(J2EEPlugin.PLUGIN_ID, 0, NLS.bind(EARCreationResourceHandler.CopyArchiveIntoProjectOperation_Copying_archive_into_selected_proje_, getUtilityJar().getName()), null); - - try { - - IFile copiedJarFile = null; - - IProject associatedEARProject = getWorkspaceRoot().getProject(getAssociatedEARProjectName()); - IVirtualComponent earComponent = ComponentCore.createComponent(associatedEARProject); - - IContainer underlyingFolder = earComponent.getRootFolder().getUnderlyingFolder(); - if(underlyingFolder.isAccessible()) { - copiedJarFile = underlyingFolder.getFile(new Path(getUtilityJar().getName())); - } else { - copiedJarFile = associatedEARProject.getFile(getUtilityJar().getName()); - } - if (copiedJarFile.exists()) { - if (isOverwriteIfNecessary()) - copiedJarFile.delete(true, true, new SubProgressMonitor(monitor, 1)); - else { - status.add(J2EEPlugin.createErrorStatus(0, NLS.bind(EARCreationResourceHandler.CopyArchiveIntoProjectOperation_Found_existing_file_0_, copiedJarFile), null)); - return status; - } - } - - FileInputStream fileInputStream = null; - ByteArrayOutputStream bos = null; - ByteArrayInputStream jarFileInputStream = null; - try { - fileInputStream = new FileInputStream(getUtilityJar()); - 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 { - if(fileInputStream != null) - fileInputStream.close(); - } - - jarFileInputStream = new ByteArrayInputStream(bos.toByteArray()); - copiedJarFile.create(jarFileInputStream, 0, new SubProgressMonitor(monitor, 1)); - - addLibraryToClasspath(associatedEARProject, copiedJarFile, monitor); - - createVirtualArchiveComponent(associatedEARProject, getUtilityJar().getName(), copiedJarFile, monitor); - - - } catch (FileNotFoundException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } catch (InvocationTargetException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } catch (InterruptedException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } finally { - if (bos != null) - bos.close(); - if (jarFileInputStream != null) - jarFileInputStream.close(); - } - } catch (IOException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } catch (CoreException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } - return status; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CreateProjectWithExtractedJarOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CreateProjectWithExtractedJarOperation.java deleted file mode 100644 index 930fdfd98..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CreateProjectWithExtractedJarOperation.java +++ /dev/null @@ -1,115 +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.File; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -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.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -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.datamodel.properties.IJavaUtilityJarImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew; - - -public class CreateProjectWithExtractedJarOperation extends J2EEUtilityJarImportAssistantOperation { -// private boolean createBinaryProject = false; - private String newProjectName; - private String projectRoot; - private boolean createAsBinary; - - - public CreateProjectWithExtractedJarOperation(File utilityJar, String overridingProjectRoot) { - super(NLS.bind(EARCreationResourceHandler.CreateProjectWithExtractedJarOperation_Create_project_with_extracted_conte_, utilityJar.getName()), utilityJar); - newProjectName = getUtilityJarProjectName(utilityJar); - projectRoot = findUniqueLocation(overridingProjectRoot, newProjectName); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - MultiStatus status = new MultiStatus(J2EEPlugin.PLUGIN_ID, 0, NLS.bind(EARCreationResourceHandler.CreateProjectWithExtractedJarOperation_Create_project_with_extracted_conte_, getUtilityJar().getName()), null); - Archive archive = null; - try { - archive = CommonarchiveFactory.eINSTANCE.primOpenArchive(getUtilityJar().getAbsolutePath()); - - IDataModel importModel = DataModelFactory.createDataModel(new J2EEUtilityJarImportDataModelProvider()); - - importModel.setProperty(IJavaUtilityJarImportDataModelProperties.FILE, archive); -// importModel.setProperty(IJavaUtilityJarImportDataModelProperties.FILE_NAME, getUtilityJar().getAbsolutePath()); - - if (projectRoot != null && projectRoot.length() > 0) { - importModel.setBooleanProperty(IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION, false); - importModel.setProperty(IProjectCreationPropertiesNew.USER_DEFINED_LOCATION, projectRoot); - } - - // importModel.getJ2eeProjectCreationDataModel().setBooleanProperty(J2EEProjectCreationDataModel.ADD_SERVER_TARGET, true); - if (isOverwriteIfNecessary()) { - // importModel.setBooleanProperty(IJavaUtilityJarImportDataModelProperties.OVERWRITE_HANDLER); - IProject existingProject = getWorkspaceRoot().getProject(newProjectName); - if (existingProject.exists()) { - existingProject.delete(true, true, monitor); - } - } - - importModel.setProperty(IJavaUtilityJarImportDataModelProperties.PROJECT_NAME, newProjectName); - importModel.setProperty(IJavaUtilityJarImportDataModelProperties.EAR_PROJECT_NAME, getAssociatedEARProjectName()); - - status.add(importModel.getDefaultOperation().execute(new SubProgressMonitor(monitor, 1), info)); - - IProject associatedEARProject = getWorkspaceRoot().getProject(getAssociatedEARProjectName()); - IProject utilityJarProject = getWorkspaceRoot().getProject(newProjectName); - linkArchiveToEAR(associatedEARProject, getUtilityJar().getName(), utilityJarProject, new SubProgressMonitor(monitor, 1)); - - } catch (OpenFailureException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } catch (InvocationTargetException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } catch (InterruptedException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } catch (CoreException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } finally { - if(archive != null) - archive.close(); - } - return status; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - public void setNewProjectName(String newProjectName) { - this.newProjectName = newProjectName; - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CreateProjectWithLinkedJarOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CreateProjectWithLinkedJarOperation.java deleted file mode 100644 index 9b3cbb3aa..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/CreateProjectWithLinkedJarOperation.java +++ /dev/null @@ -1,103 +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.File; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.UtilityProjectCreationDataModelProvider; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew; - -public class CreateProjectWithLinkedJarOperation extends J2EEUtilityJarImportAssistantOperation { - - private String linkedPathVariable; - private String projectRoot; - private boolean createAsBinary; - - public CreateProjectWithLinkedJarOperation(File utilityJar, String overridingProjectRoot, String linkedPathVariable) { - super(NLS.bind(EARCreationResourceHandler.CreateProjectWithLinkedJarOperation_Creating_project_with_linked_archiv_, utilityJar.getName()), utilityJar); - this.linkedPathVariable= linkedPathVariable; - projectRoot = findUniqueLocation(overridingProjectRoot, getUtilityJarProjectName(utilityJar)); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - MultiStatus status = new MultiStatus(J2EEPlugin.PLUGIN_ID, 0, NLS.bind(EARCreationResourceHandler.CreateProjectWithLinkedJarOperation_Creating_project_with_linked_archiv_, getUtilityJar().getName()), null); - - try { - IProject project = getWorkspaceRoot().getProject(getUtilityJarProjectName(getUtilityJar())); - - IDataModel createUtilityProject = DataModelFactory.createDataModel(new UtilityProjectCreationDataModelProvider()); - createUtilityProject.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, getUtilityJarProjectName(getUtilityJar())); - - if (projectRoot != null && projectRoot.length() > 0) { - createUtilityProject.setBooleanProperty(IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION, false); - createUtilityProject.setProperty(IProjectCreationPropertiesNew.USER_DEFINED_LOCATION, projectRoot); - } - - createUtilityProject.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, getAssociatedEARProjectName()); - - status.add(createUtilityProject.getDefaultOperation().execute(monitor, info)); - - IProject utilityJarProject = getWorkspaceRoot().getProject(getUtilityJarProjectName(getUtilityJar())); - - /* Remove the default src folder */ - IJavaProject utilityJarJavaProject = JavaCore.create(utilityJarProject); - IPackageFragmentRoot srcFolder = utilityJarJavaProject.getPackageFragmentRoot(utilityJarProject.getFolder("src")); - if(srcFolder.exists()) { - srcFolder.delete(IResource.FORCE, IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH, monitor); - } - status.add(createLinkedArchive(project, getUtilityJar().getName(), getUtilityJar(), linkedPathVariable, monitor)); - - /* Remove the /src mapping */ - IVirtualComponent utilComponent = ComponentCore.createComponent(project); - status.add(removeRootMapping(utilComponent, "/src", monitor)); - - /* Create the /<archive> mapping */ - status.add(createVirtualArchiveComponent(project, getUtilityJar().getName(), project.getFile(getUtilityJar().getName()), monitor)); - - /* Make this project a utility jar project for the EAR */ - IProject associatedEARProject = getWorkspaceRoot().getProject(getAssociatedEARProjectName()); - status.add(linkArchiveToEAR(associatedEARProject, getUtilityJar().getName(), utilityJarProject, new SubProgressMonitor(monitor, 1))); - - } catch (Exception e) { - status.add(J2EEPlugin.createErrorStatus(0, EARCreationResourceHandler.J2EEUtilityJarListImportOperation_UI_2, e)); - } - return status; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - -} 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 5bfb1a189..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/DefaultJ2EEComponentCreationOperation.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.resources.IProject; -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.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.earcreation.IDefaultJ2EEComponentCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.operation.FacetProjectCreationOperation; -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; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -public class DefaultJ2EEComponentCreationOperation 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 DefaultJ2EEComponentCreationOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - if (model.getBooleanProperty(CREATE_EJB)) { - IDataModel projectModel = model.getNestedModel(NESTED_MODEL_EJB); - createEJBComponent(projectModel, monitor); - } - if (model.getBooleanProperty(CREATE_WEB)) { - IDataModel projectModel = model.getNestedModel(NESTED_MODEL_WEB); - createWebJ2EEComponent(projectModel, monitor); - } - if (model.getBooleanProperty(CREATE_CONNECTOR)) { - IDataModel projectModel = model.getNestedModel(NESTED_MODEL_JCA); - createRarJ2EEComponent(projectModel, monitor); - } - if (model.getBooleanProperty(CREATE_APPCLIENT)) { - IDataModel projectModel = model.getNestedModel(NESTED_MODEL_CLIENT); - createAppClientComponent(projectModel, 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); - addDefaultFacets(model); - 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); - addDefaultFacets(model); - 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); - addDefaultFacets(model); - 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); - addDefaultFacets(model); - WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true); - - } - - private void addDefaultFacets(IDataModel model) throws CoreException{ - IRuntime runtime = (IRuntime) model.getProperty(FacetProjectCreationDataModelProvider.FACET_RUNTIME); - String projectName = model.getStringProperty(FacetProjectCreationDataModelProvider.FACET_PROJECT_NAME); - IProject project = ProjectUtilities.getProject( projectName ); - IFacetedProject facetedProject = null; - try { - facetedProject = ProjectFacetsManager.create(project); - } catch (CoreException e) { - - } - - if( facetedProject != null && runtime != null ){ - try { - FacetProjectCreationOperation.addDefaultFactets( facetedProject, runtime ); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - } - } - - 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/EARComponentExportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentExportDataModelProvider.java deleted file mode 100644 index 52037bf23..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentExportDataModelProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.j2ee.internal.archive.operations.EARComponentExportOperation; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class EARComponentExportDataModelProvider extends J2EEArtifactExportDataModelProvider { - - public EARComponentExportDataModelProvider() { - super(); - } - - public IDataModelOperation getDefaultOperation() { - return new EARComponentExportOperation(model); - } - - protected String getModuleExtension() { - return ".ear"; //$NON-NLS-1$ - } - - protected String getWrongComponentTypeString(String projectName) { - return EARCreationResourceHandler.getString(EARCreationResourceHandler.NOT_AN_EAR, new Object[]{projectName}); - } - - protected String getProjectType() { - return J2EEProjectUtilities.ENTERPRISE_APPLICATION; - } - /** - * 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. - * @plannedfor WTP 1.0 - */ -//TODO: can this be done in the new datamodel framework? -// 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); -// } -// } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentImportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentImportDataModelProvider.java deleted file mode 100644 index a85847075..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/EARComponentImportDataModelProvider.java +++ /dev/null @@ -1,736 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Set; - -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.Path; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.WebModule; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentImportDataModelProvider; -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.ModuleFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile; -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.datamodel.properties.IAddWebComponentToEnterpriseApplicationDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IEARComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEModuleImportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJavaUtilityJarImportDataModelProperties; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.archive.operations.EARComponentImportOperation; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -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.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.EARFacetProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProviderNew; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -/** - * 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. - * - * @plannedfor WTP 1.0 - */ -public final class EARComponentImportDataModelProvider extends J2EEArtifactImportDataModelProvider implements IAnnotationsDataModel, IEARComponentImportDataModelProperties { - - /** - * 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$ - - /** - * This is only to force validation for the EAR name against the nested projects; do not set. - */ - public static final String EAR_NAME_VALIDATION = "EARImportDataModel.EAR_NAME_VALIDATION";//$NON-NLS-1$ - - - private IDataModelListener nestedListener = new IDataModelListener() { - public void propertyChanged(DataModelEvent event) { - if (event.getPropertyName().equals(PROJECT_NAME)) { - model.notifyPropertyChange(NESTED_PROJECTS_VALIDATION, IDataModel.DEFAULT_CHG); - } - } - }; - - private Hashtable ejbJarToClientJarModels = new Hashtable(); - - private Hashtable clientJarToEjbJarModels = new Hashtable(); - - private ModuleFile cachedLoadError = null; - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(NESTED_MODULE_ROOT); - propertyNames.add(UTILITY_LIST); - propertyNames.add(MODULE_MODELS_LIST); - propertyNames.add(EJB_CLIENT_LIST); - propertyNames.add(UTILITY_MODELS_LIST); - propertyNames.add(NESTED_PROJECTS_VALIDATION); - propertyNames.add(EAR_NAME_VALIDATION); - propertyNames.add(SELECTED_MODELS_LIST); - propertyNames.add(USE_ANNOTATIONS); - propertyNames.add(ALL_PROJECT_MODELS_LIST); - propertyNames.add(UNHANDLED_PROJECT_MODELS_LIST); - propertyNames.add(HANDLED_PROJECT_MODELS_LIST); - return propertyNames; - } - - public 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 (USE_ANNOTATIONS.equals(propertyName)) { - return Boolean.FALSE; - } else if (ALL_PROJECT_MODELS_LIST.equals(propertyName)) { - return getProjectModels(); - } else if (UNHANDLED_PROJECT_MODELS_LIST.equals(propertyName)) { - return getUnhandledProjectModels(); - } else if (HANDLED_PROJECT_MODELS_LIST.equals(propertyName)) { - return getHandledSelectedModels(); - } - return super.getDefaultProperty(propertyName); - } - - public void propertyChanged(DataModelEvent event) { - super.propertyChanged(event); - if (event.getPropertyName().equals(PROJECT_NAME)) { - changeModuleCreationLocationForNameChange(getProjectModels()); - } else if (event.getPropertyName().equals(IFacetProjectCreationDataModelProperties.FACET_RUNTIME) && event.getDataModel() == model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION)) { - Object propertyValue = event.getProperty(); - IDataModel nestedModel = null; - List projectModels = (List) getProperty(ALL_PROJECT_MODELS_LIST); - for (int i = 0; i < projectModels.size(); i++) { - nestedModel = (IDataModel) projectModels.get(i); - nestedModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, propertyValue); - } - fixupJavaFacets(); - } - } - - public boolean propertySet(String propertyName, Object propertyValue) { - if (ALL_PROJECT_MODELS_LIST.equals(propertyName) || UNHANDLED_PROJECT_MODELS_LIST.equals(propertyName) || HANDLED_PROJECT_MODELS_LIST.equals(propertyName) || EAR_NAME_VALIDATION.equals(propertyName)) { - throw new RuntimeException(propertyName + " is an unsettable property"); //$NON-NLS-1$ - } - boolean doSet = super.propertySet(propertyName, propertyValue); - if (NESTED_MODULE_ROOT.equals(propertyName)) { - updateModuleRoot(); - } else if (FILE_NAME.equals(propertyName)) { - setProperty(MODULE_MODELS_LIST, getModuleModels()); - updateModuleRoot(); - setProperty(UTILITY_LIST, null); - - IDataModel earProjectModel = model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION); - if (getArchiveFile() != null) { - FacetDataModelMap map = (FacetDataModelMap) earProjectModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - IDataModel earFacetDataModel = map.getFacetDataModel(J2EEProjectUtilities.ENTERPRISE_APPLICATION); - - int version = ArchiveUtil.getFastSpecVersion((ModuleFile) getArchiveFile()); - String versionText = J2EEVersionUtil.getJ2EETextVersion(version); - earFacetDataModel.setStringProperty(IFacetDataModelProperties.FACET_VERSION_STR, versionText); - } - - model.notifyPropertyChange(PROJECT_NAME, IDataModel.VALID_VALUES_CHG); - if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3) - setBooleanProperty(USE_ANNOTATIONS, false); - model.notifyPropertyChange(USE_ANNOTATIONS, IDataModel.ENABLE_CHG); - fixupJavaFacets(); - } else if (UTILITY_LIST.equals(propertyName)) { - updateUtilityModels((List) propertyValue); - } else if (USE_ANNOTATIONS.equals(propertyName)) { - List projectModels = (List) getProperty(MODULE_MODELS_LIST); - IDataModel nestedModel = null; - for (int i = 0; i < projectModels.size(); i++) { - nestedModel = (IDataModel) projectModels.get(i); - if (nestedModel.isProperty(USE_ANNOTATIONS)) { - nestedModel.setProperty(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); - IDataModel nestedModel = null; - for (int i = 0; i < nestedModels.size(); i++) { - nestedModel = (IDataModel) nestedModels.get(i); - nestedModel.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, propertyValue); - } - nestedModels = (List) getProperty(UTILITY_MODELS_LIST); - for (int i = 0; i < nestedModels.size(); i++) { - nestedModel = (IDataModel) nestedModels.get(i); - nestedModel.setProperty(IJavaUtilityJarImportDataModelProperties.EAR_PROJECT_NAME, propertyValue); - } - - if (ProjectCreationDataModelProviderNew.validateProjectName(getStringProperty(PROJECT_NAME)).isOK()) { - IProject project = ProjectUtilities.getProject(getStringProperty(PROJECT_NAME)); - if (null != project && project.exists()) { - - IFacetedProject facetedProject = null; - boolean canContinue = true; - try { - facetedProject = ProjectFacetsManager.create(project); - } catch (CoreException e) { - Logger.getLogger().logError(e); - canContinue = false; - } - - if (canContinue) { - IRuntime runtime = facetedProject.getRuntime(); - if (null != runtime) { - setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, runtime); - } - } - } - } - } - return doSet; - } - - 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++) { - IDataModel localModel = (IDataModel) clientList.get(j); - if (localModel.getProperty(IJ2EEComponentImportDataModelProperties.FILE) == 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()) { - utilJars.addAll(getWebLibs((WARFile) file)); - } - } - return utilJars; - } - - public static List getWebLibs(WARFile warFile) { - return ((WARFileImpl) warFile).getLibArchives(); - } - - - protected boolean forceResetOnPreserveMetaData() { - return false; - } - - protected void fixupJavaFacets() { - List subProjects = getSelectedModels(); - IDataModel subDataModel = null; - for (int i = 0; i < subProjects.size(); i++) { - subDataModel = (IDataModel) subProjects.get(i); - subDataModel.validateProperty(FACET_RUNTIME); - } - } - - public IStatus validate(String propertyName) { - if (propertyName.equals(NESTED_PROJECTS_VALIDATION) || propertyName.equals(EAR_NAME_VALIDATION)) { - boolean checkAgainstEARNameOnly = propertyName.equals(EAR_NAME_VALIDATION); - - String earProjectName = getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - List subProjects = getSelectedModels(); - IDataModel 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 = (IDataModel) subProjects.get(i); - tempProjectName = subDataModel.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - // TODO: add manual validation - // IStatus status = - // ProjectCreationDataModel.validateProjectName(tempProjectName); - // if (!status.isOK()) { - // return status; - // } - tempArchive = (Archive) subDataModel.getProperty(FILE); - - if (checkAgainstEARNameOnly) { - if (tempProjectName.equals(earProjectName)) { - return WTPCommonPlugin.createWarningStatus(EARCreationResourceHandler.bind(EARCreationResourceHandler.EARImportDataModel_UI_1, new Object[]{tempProjectName, tempArchive.getURI()})); - } else if (!WTPPlugin.isPlatformCaseSensitive()) { - if (tempProjectName.toLowerCase().equals(earProjectName.toLowerCase())) { - return WTPCommonPlugin.createWarningStatus(EARCreationResourceHandler.bind(EARCreationResourceHandler.EARImportDataModel_UI_1a, new Object[]{earProjectName, tempProjectName, tempArchive.getURI()})); - } - } - } else { - // if (!overwrite && subDataModel.getProject().exists()) { - // return - // WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.getString("EARImportDataModel_UI_0", - // new Object[]{tempProjectName, tempArchive.getURI()})); //$NON-NLS-1$ - // } - tempStatus = subDataModel.validateProperty(IFacetDataModelProperties.FACET_PROJECT_NAME); - if (!tempStatus.isOK()) { - return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.bind(EARCreationResourceHandler.EARImportDataModel_UI_0, new Object[]{tempProjectName, tempArchive.getURI()})); - } - tempStatus = subDataModel.validate(); - if (!tempStatus.isOK()) { - return tempStatus; - } - if (tempProjectName.equals(earProjectName)) { - return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.bind(EARCreationResourceHandler.EARImportDataModel_UI_1, new Object[]{tempProjectName, tempArchive.getURI()})); - } else if (!WTPPlugin.isPlatformCaseSensitive()) { - if (tempProjectName.toLowerCase().equals(earProjectName.toLowerCase())) { - return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.bind(EARCreationResourceHandler.EARImportDataModel_UI_1a, new Object[]{earProjectName, tempProjectName, tempArchive.getURI()})); - } - } - if (projects.containsKey(tempProjectName)) { - return WTPCommonPlugin.createErrorStatus(EARCreationResourceHandler.bind(EARCreationResourceHandler.EARImportDataModel_UI_2, new Object[]{tempProjectName, tempArchive.getURI(), ((Archive) projects.get(tempProjectName)).getURI()})); - } else if (!WTPPlugin.isPlatformCaseSensitive()) { - 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.bind(EARCreationResourceHandler.EARImportDataModel_UI_2a, new Object[]{tempProjectName, currentKey, tempArchive.getURI(), ((Archive) projects.get(currentKey)).getURI()})); - } - } - } - projects.put(tempProjectName, tempArchive); - } - } - } else if (propertyName.equals(FILE_NAME)) { - IStatus status = super.validate(propertyName); - if (!status.isOK()) { - return status; - } else if (cachedLoadError != null) { - return WTPCommonPlugin.createWarningStatus(EARCreationResourceHandler.bind(EARCreationResourceHandler.EARImportDataModel_UI_4, new Object[]{cachedLoadError.getURI()})); - } - return status; - } - // TODO: check context root is not inside current working - // directory...this is invalid - return super.validate(propertyName); - } - - private void updateModuleRoot() { - List projects = getProjectModels(); - String basePath = isPropertySet(NESTED_MODULE_ROOT) ? getStringProperty(NESTED_MODULE_ROOT) : null; - boolean useDefault = basePath == null; - IDataModel localModel = null; - for (int i = 0; null != projects && i < projects.size(); i++) { - localModel = (IDataModel) projects.get(i); - localModel.setProperty(IProjectCreationPropertiesNew.USER_DEFINED_BASE_LOCATION, basePath); - localModel.setBooleanProperty(IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION, useDefault); - } - } - - private void changeModuleCreationLocationForNameChange(List projects) { - IDataModel localModel = null; - for (int i = 0; null != projects && i < projects.size(); i++) { - localModel = (IDataModel) projects.get(i); - if (isPropertySet(NESTED_MODULE_ROOT)) { - IPath newPath = new Path((String) getProperty(NESTED_MODULE_ROOT)); - newPath = newPath.append((String) localModel.getProperty(IJ2EEComponentImportDataModelProperties.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; - IDataModel 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 = (IDataModel) utilityModels.get(j); - if (currentUtilityModel.getProperty(IJavaUtilityJarImportDataModelProperties.FILE) == currentArchive) { - added = true; - } - } - if (!added) { - if (!isPropertySet(listTypeProperty)) { - utilityModels = new ArrayList(); - setProperty(listTypeProperty, utilityModels); - } - IDataModel localModel = DataModelFactory.createDataModel(new J2EEUtilityJarImportDataModelProvider()); - localModel.setProperty(IJavaUtilityJarImportDataModelProperties.FILE, currentArchive); - localModel.setProperty(IJavaUtilityJarImportDataModelProperties.EAR_PROJECT_NAME, getStringProperty(PROJECT_NAME)); - localModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)); - utilityModels.add(localModel); - localModel.addListener(nestedListener); - utilityJarsModified = true; - } - } // Remove extras - for (int i = utilityModels.size() - 1; i >= 0; i--) { - currentUtilityModel = (IDataModel) utilityModels.get(i); - currentArchive = (Archive) currentUtilityModel.getProperty(IJavaUtilityJarImportDataModelProperties.FILE); - 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) { - model.notifyPropertyChange(NESTED_PROJECTS_VALIDATION, IDataModel.VALUE_CHG); - } - } - - private List getModuleModels() { - if (getArchiveFile() == null) - return Collections.EMPTY_LIST; - cachedLoadError = null; - List moduleFiles = getEARFile().getModuleFiles(); - List moduleModels = new ArrayList(); - List clientJarArchives = new ArrayList(); - IDataModel localModel; - String earProjectName = getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - - List defaultModuleNames = new ArrayList(); - defaultModuleNames.add(earProjectName); - List collidingModuleNames = null; - Hashtable ejbJarsWithClients = new Hashtable(); - for (int i = 0; i < moduleFiles.size(); i++) { - localModel = null; - ModuleFile temp = (ModuleFile) moduleFiles.get(i); - try { - if (temp.isApplicationClientFile()) { - localModel = DataModelFactory.createDataModel(new AppClientComponentImportDataModelProvider()); - } else if (temp.isWARFile()) { - WebModuleExtension webExt = EarModuleManager.getWebModuleExtension(); - if (webExt != null) { - localModel = webExt.createImportDataModel(); - WebModule webModule = (WebModule) getEARFile().getModule(temp.getURI(), null); - if (null != webModule && null != webModule.getContextRoot()) { - localModel.setProperty(IAddWebComponentToEnterpriseApplicationDataModelProperties.CONTEXT_ROOT, webModule.getContextRoot()); - } - } - } else if (temp.isEJBJarFile()) { - EjbModuleExtension ejbExt = EarModuleManager.getEJBModuleExtension(); - if (ejbExt != null) { - localModel = 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(localModel, clientArchive); - } catch (Exception e) { - // TODO: handle exception - } - } - } - } else if (temp.isRARFile()) { - JcaModuleExtension rarExt = EarModuleManager.getJCAModuleExtension(); - if (rarExt != null) { - localModel = rarExt.createImportDataModel(); - } - } - if (localModel != null) { - localModel.setProperty(FILE, temp); - localModel.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, earProjectName); - localModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)); - localModel.addListener(this); - localModel.addListener(nestedListener); - moduleModels.add(localModel); - String moduleName = localModel.getStringProperty(IJ2EEFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - if (defaultModuleNames.contains(moduleName)) { - if (collidingModuleNames == null) { - collidingModuleNames = new ArrayList(); - } - collidingModuleNames.add(moduleName); - } else { - defaultModuleNames.add(moduleName); - } - } - } catch (Exception e) { - Logger.getLogger().logError("Error loading nested archive: " + temp.getURI()); //$NON-NLS-1$ - Logger.getLogger().logError(e); - cachedLoadError = temp; - } - } - 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 (((IDataModel) clientModelList.get(i)).getProperty(FILE) == archive) { - clientModel = clientModelList.get(i); - } - } - ejbJarToClientJarModels.put(ejbModel, clientModel); - clientJarToEjbJarModels.put(clientModel, ejbModel); - } - - for (int i = 0; collidingModuleNames != null && i < moduleModels.size(); i++) { - localModel = (IDataModel) moduleModels.get(i); - String moduleName = localModel.getStringProperty(IJ2EEModuleImportDataModelProperties.PROJECT_NAME); - if (collidingModuleNames.contains(moduleName)) { - ModuleFile module = (ModuleFile) localModel.getProperty(IJ2EEModuleImportDataModelProperties.FILE); - 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; - } - localModel.setProperty(IJ2EEModuleImportDataModelProperties.PROJECT_NAME, moduleName + suffix); - } - } - return moduleModels; - } - - protected int getType() { - return XMLResource.APPLICATION_TYPE; - } - - protected Archive openArchive(String uri) throws OpenFailureException { - return CommonarchiveFactory.eINSTANCE.openEARFile(getArchiveOptions(), uri); - } - - private EARFile getEARFile() { - return (EARFile) getArchiveFile(); - } - - public boolean handlesArchive(Archive anArchive) { - 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)); - } - } - IDataModel importDM = null; - for (int i = 0; i < temp.size(); i++) { - importDM = (IDataModel) temp.get(i); - if (importDM.getProperty(FILE) == anArchive) { - return true; - } - } - return false; - } - - private 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; - } - - private 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); - IDataModel localModel = null; - for (int i = 0; i < modelsToCheck.size(); i++) { - localModel = (IDataModel) modelsToCheck.get(i); - // model.extractHandled(newList, addModels); - } - return newList; - } - - private 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); - } - - public boolean isPropertyEnabled(String propertyName) { - if (!super.isPropertyEnabled(propertyName)) { - return false; - } - if (propertyName.equals(USE_ANNOTATIONS)) { - if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3) - return false; - return true; - } - return true; - } - - public void dispose() { - super.dispose(); - List list = getProjectModels(); - for (int i = 0; i < list.size(); i++) { - ((IDataModel) list.get(i)).dispose(); - } - EARFile earFile = getEARFile(); - if (earFile != null) - earFile.close(); - } - - // TODO: Implement with J2EEArtifactImportDataModelProvider - /* - * 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; } } - */ - - protected IDataModel createJ2EEComponentCreationDataModel() { - return DataModelFactory.createDataModel(new EARFacetProjectCreationDataModelProvider()); - } - - public IDataModelOperation getDefaultOperation() { - return new EARComponentImportOperation(model); - } - -}
\ 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 282d15a8a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ExtendedImportFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * @author jsholl - */ -public interface ExtendedImportFactory { - - public Archive openArchive(ArchiveOptions archiveOptions, String uri) throws OpenFailureException; - - public void importModuleFile(IDataModel model, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException; - - public int getSpecVersion(Archive archive); -} 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 fdfc974c6..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, 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 - *******************************************************************************/ -/* - * 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; - } -} 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 04c36f30a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationDataModelProvider.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.util.Set; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.common.jdt.internal.integration.JavaProjectCreationDataModelProvider; -import org.eclipse.jst.common.project.facet.JavaProjectFacetCreationDataModelProvider; -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.componentcore.datamodel.FlexibleProjectCreationDataModelProvider; -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; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see JavaProjectFacetCreationDataModelProvider - */ -public class FlexibleJavaProjectCreationDataModelProvider extends FlexibleProjectCreationDataModelProvider implements IFlexibleJavaProjectCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15{ - - 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 Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(NESTED_MODEL_SERVER_TARGET); - propertyNames.add(ADD_SERVER_TARGET); - propertyNames.add(RUNTIME_TARGET_ID); - return propertyNames; - } - - 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 = model.getNestedModel(NESTED_MODEL_SERVER_TARGET); - projModel.setProperty(IJ2EEProjectServerTargetDataModelProperties.PROJECT_NAME, propertyValue); - } else if (RUNTIME_TARGET_ID.equals(propertyName)) { - IDataModel projModel = 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(RUNTIME_TARGET_ID)) { - IDataModel serverTargetModel = model.getNestedModel(NESTED_MODEL_SERVER_TARGET); - return serverTargetModel.getValidPropertyDescriptors(IJ2EEProjectServerTargetDataModelProperties.RUNTIME_TARGET_ID); - } - return null; - } - - public IStatus validate(String propertyName) { - IStatus status = super.validate(propertyName); - if (!status.isOK()) { - return status; - } else if (propertyName.equals(NESTED_MODEL_SERVER_TARGET)) { - IDataModel stModel = model.getNestedModel(NESTED_MODEL_SERVER_TARGET); - return stModel.validate(); - } - return OK_STATUS; - } -} 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 438c7c91b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/FlexibleJavaProjectCreationOperation.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.internal.plugin.JavaEMFNature; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.common.project.facet.JavaProjectFacetCreationDataModelProvider; -import org.eclipse.jst.j2ee.project.datamodel.properties.IFlexibleJavaProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.FlexibleProjectCreationOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see JavaProjectFacetCreationDataModelProvider - */ -public class FlexibleJavaProjectCreationOperation extends FlexibleProjectCreationOperation implements IFlexibleJavaProjectCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15{ - - 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 = serverModel.getDefaultOperation(); - op.execute(monitor, null); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - IStatus status = super.execute(monitor, info); - try { - createJavaEMFNature(); - addServerTarget(monitor); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } catch (CoreException e) { - Logger.getLogger().log(e); - } catch (InvocationTargetException e) { - Logger.getLogger().log(e); - } catch (InterruptedException e) { - Logger.getLogger().log(e); - } - return status; - } - protected void createJavaEMFNature() throws CoreException { - JavaEMFNature nature = JavaEMFNature.createRuntime(getProject()); - nature.getResourceSet(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IAddComponentToEnterpriseApplicationDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IAddComponentToEnterpriseApplicationDataModelProperties.java deleted file mode 100644 index 66121d392..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IAddComponentToEnterpriseApplicationDataModelProperties.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; - -public interface IAddComponentToEnterpriseApplicationDataModelProperties extends ICreateReferenceComponentsDataModelProperties { - - - -} 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 8b8a47720..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, 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; - -/** - * 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$ - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IModuleExtensions.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IModuleExtensions.java deleted file mode 100644 index a9b8de25a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IModuleExtensions.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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; - -public interface IModuleExtensions { - - public String DOT_WAR = ".war"; //$NON-NLS-1$ - public String DOT_JAR = ".jar"; //$NON-NLS-1$ - public String DOT_RAR = ".rar"; //$NON-NLS-1$ - public String DOT_EAR = ".ear"; //$NON-NLS-1$ - - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IUpdateModuleContextRootProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IUpdateModuleContextRootProperties.java deleted file mode 100644 index 9df847f4b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/IUpdateModuleContextRootProperties.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 BEA Systems, Inc - * 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: - * rfrost@bea.com - initial API and impl - *******************************************************************************/ -package org.eclipse.jst.j2ee.application.internal.operations; - -import org.eclipse.wst.web.internal.operation.IWebProjectPropertiesUpdateDataModelProperties; - -/** - * Holds DataModelOperation properties for updating the context-root of modules in associated EAR application.xml files. - */ -public interface IUpdateModuleContextRootProperties extends IWebProjectPropertiesUpdateDataModelProperties { - /** - * ID for nexted IDataModel - */ - public static final String NESTED_MODEL_ID = "UpdateModuleContextRootModel"; //$NON-NLS-1$ - /** - * Name of property (in nested model) that holds a List of EAR IProjects. - */ - public static final String EARS_TO_UPDATE = "IUpdateModuleContextRootProperties.EARS_TO_UPDATE"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactExportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactExportDataModelProvider.java deleted file mode 100644 index b4852ed15..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactExportDataModelProvider.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -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.core.runtime.Path; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public abstract class J2EEArtifactExportDataModelProvider extends AbstractDataModelProvider implements IJ2EEComponentExportDataModelProperties { - - public HashMap componentMap; - - public J2EEArtifactExportDataModelProvider() { - super(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(PROJECT_NAME); - propertyNames.add(ARCHIVE_DESTINATION); - propertyNames.add(EXPORT_SOURCE_FILES); - propertyNames.add(OVERWRITE_EXISTING); - propertyNames.add(RUN_BUILD); - propertyNames.add(COMPONENT); - return propertyNames; - } - - protected abstract String getProjectType(); - - protected abstract String getWrongComponentTypeString(String projectName); - - protected abstract String getModuleExtension(); - - public 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); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean set = super.propertySet(propertyName, propertyValue); - if (propertyName.equals(PROJECT_NAME)) { - if (getComponentMap().isEmpty()) - intializeComponentMap(); - IVirtualComponent component = (IVirtualComponent) getComponentMap().get(propertyValue); - if (null != component && component.getName().equals(propertyValue)) { - setProperty(COMPONENT, component); - } else { - setProperty(COMPONENT, null); - } - } - return set; - } - - public HashMap getComponentMap() { - if (componentMap == null) - componentMap = new HashMap(); - return componentMap; - } - - public void intializeComponentMap() { - IVirtualComponent[] comps = ComponentUtilities.getAllWorkbenchComponents(); - for (int i = 0; i < comps.length; i++) { - getComponentMap().put(comps[i].getName(), comps[i]); - } - } - - /** - * Populate the resource name combo with projects that are not encrypted. - */ - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - // TODO: populate valid components - if (propertyName.equals(PROJECT_NAME)) { - List componentNames = new ArrayList(); - IVirtualComponent[] wbComps = ComponentUtilities.getAllWorkbenchComponents(); - - List relevantComponents = new ArrayList(); - for (int i = 0; i < wbComps.length; i++) { - if (J2EEProjectUtilities.getJ2EEProjectType(wbComps[i].getProject()).equals(getProjectType())) { - relevantComponents.add(wbComps[i]); - getComponentMap().put(wbComps[i].getName(), wbComps[i]); - } - } - - if (relevantComponents == null || relevantComponents.size() == 0) - return null; - - for (int j = 0; j < relevantComponents.size(); j++) { - componentNames.add(((IVirtualComponent) relevantComponents.get(j)).getName()); - } - String[] names = (String[]) componentNames.toArray(new String[componentNames.size()]); - - return DataModelPropertyDescriptor.createDescriptors(names); - } - return super.getValidPropertyDescriptors(propertyName); - // (ProjectUtilities.getProjectNamesWithoutForwardSlash((String[]) - // projectsWithNature.toArray(new String[projectsWithNature.size()]))); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doValidateProperty(java.lang.String) - */ - public IStatus validate(String propertyName) { - if (PROJECT_NAME.equals(propertyName)) { - String projectName = (String) model.getProperty(PROJECT_NAME); - if (projectName == null || projectName.equals("")) //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.MODULE_EXISTS_ERROR)); - IVirtualComponent component = (IVirtualComponent) componentMap.get(projectName); - if (component == null) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.MODULE_EXISTS_ERROR)); - } - if (!J2EEProjectUtilities.getJ2EEProjectType(component.getProject()).equals(getProjectType())) { - return WTPCommonPlugin.createErrorStatus(getWrongComponentTypeString(projectName)); - } - } - if (ARCHIVE_DESTINATION.equals(propertyName)) { - String archiveLocation = (String) model.getProperty(ARCHIVE_DESTINATION); - if (!model.isPropertySet(ARCHIVE_DESTINATION) || archiveLocation.equals("")) { //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.DESTINATION_INVALID)); //); - } else if (model.isPropertySet(ARCHIVE_DESTINATION) && !validateModuleType(archiveLocation)) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.DESTINATION_ARCHIVE_SHOULD_END_WITH, new Object[]{getModuleExtension()})); //); - } else if (model.isPropertySet(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 OK_STATUS; - } - - 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) == IPath.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 (!model.getBooleanProperty(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; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactImportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactImportDataModelProvider.java deleted file mode 100644 index 6761fea5e..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEArtifactImportDataModelProvider.java +++ /dev/null @@ -1,310 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -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.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.SaveFilter; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.project.J2EECreationResourceHandler; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -public abstract class J2EEArtifactImportDataModelProvider extends AbstractDataModelProvider implements IJ2EEComponentImportDataModelProperties, IDataModelListener { - - private static final String USE_DEFAULT_PROJECT_NAME = "J2EEArtifactImportDataModelProvider.USE_DEFAULT_PROJECT_NAME"; //$NON-NLS-1$ - - public static final String FACET_RUNTIME = "IJ2EEArtifactImportDataModelProperties.FACET_RUNTIME"; //$NON-NLS-1$ - - private IDataModel componentCreationDM; - private OpenFailureException cachedOpenFailureException = null; - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(FILE_NAME); - propertyNames.add(FILE); - propertyNames.add(SAVE_FILTER); - propertyNames.add(OVERWRITE_HANDLER); - propertyNames.add(CLOSE_ARCHIVE_ON_DISPOSE); - propertyNames.add(USE_DEFAULT_PROJECT_NAME); - propertyNames.add(PROJECT_NAME); - propertyNames.add(COMPONENT); - propertyNames.add( FACET_RUNTIME ); - return propertyNames; - } - - public void init() { - super.init(); - componentCreationDM = createJ2EEComponentCreationDataModel(); - componentCreationDM.setBooleanProperty(FacetProjectCreationDataModelProvider.FORCE_VERSION_COMPLIANCE, false); - componentCreationDM.addListener(this); - model.addNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION, componentCreationDM); - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(CLOSE_ARCHIVE_ON_DISPOSE)) { - return Boolean.TRUE; - } else if (propertyName.equals(USE_DEFAULT_PROJECT_NAME)) { - return Boolean.TRUE; - }else if( propertyName.equals(COMPONENT)){ - String projectName = getStringProperty(PROJECT_NAME); - IProject project = ProjectUtilities.getProject(projectName); - return ComponentCore.createComponent(project); - } - return super.getDefaultProperty(propertyName); - } - - private boolean settingFileName = false; - - public boolean propertySet(String propertyName, Object propertyValue) { - if (propertyName.equals(FILE)) { - if (!settingFileName) { - setProperty(FILE_NAME, null); - } - updateDefaultComponentName(); - return true; - } else if (propertyName.equals(SAVE_FILTER) && getArchiveFile() != null) { - getArchiveFile().setSaveFilter(getSaveFilter()); - } else if (FILE_NAME.equals(propertyName)) { - try { - cachedOpenFailureException = null; - handleArchiveSetup((String) propertyValue); - } catch (OpenFailureException oe) { - cachedOpenFailureException = oe; - } - } else if( COMPONENT.equals(propertyName)){ - throw new RuntimeException(propertyName + " should not be set."); //$NON-NLS-1$ - }else if (PROJECT_NAME.equals(propertyName)) { - List nestedModels = new ArrayList(model.getNestedModels()); - IDataModel nestedModel = null; - for (int i = 0; i < nestedModels.size(); i++) { - nestedModel = (IDataModel) nestedModels.get(i); - try { - nestedModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, propertyValue); - } catch (Exception e) { - Logger.getLogger().logError(e); - } - } - } else if( FACET_RUNTIME.equals( propertyName )){ - throw new RuntimeException(propertyName + " should not be set."); //$NON-NLS-1$ - } - return true; - } - - private boolean doingComponentUpdate; - - private void updateDefaultComponentName() { - Archive archive = getArchiveFile(); - if (null != archive && getBooleanProperty(USE_DEFAULT_PROJECT_NAME)) { - try { - doingComponentUpdate = true; - Path path = new Path(archive.getURI()); - String defaultProjectName = path.segment(path.segmentCount() - 1); - if (defaultProjectName.indexOf('.') > 0) { - defaultProjectName = defaultProjectName.substring(0, defaultProjectName.lastIndexOf('.')); - } - setProperty(PROJECT_NAME, defaultProjectName); - } finally { - doingComponentUpdate = false; - } - - } - } - - private boolean handleArchiveSetup(String fileName) throws OpenFailureException { - try { - settingFileName = true; - Archive archive = getArchiveFile(); - if (archive != null) { - archive.close(); - setProperty(FILE, null); - } - String uri = getStringProperty(FILE_NAME); - if (!archiveExistsOnFile()) - return false; - archive = openArchive(uri); - if (null != archive) { - archive.setSaveFilter(getSaveFilter()); - } - setProperty(FILE, archive); - return archive != null; - } finally { - settingFileName = false; - } - - } - - protected abstract Archive openArchive(String uri) throws OpenFailureException; - - private boolean closeModuleFile() { - if (null != getArchiveFile()) { - getArchiveFile().close(); - } - return true; - } - - public IStatus validate(String propertyName) { - if (FILE_NAME.equals(propertyName) && !isPropertySet(FILE)) { - String fileName = getStringProperty(propertyName); - if (fileName == null || fileName.length() == 0) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.ARCHIVE_FILE_NAME_EMPTY_ERROR, new Object[]{ArchiveUtil.getModuleFileTypeName(getType())})); - } else if (cachedOpenFailureException != null) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(cachedOpenFailureException.getMessage())); - } else if (fileName != null && !archiveExistsOnFile()) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.FILE_DOES_NOT_EXIST_ERROR, new Object[]{ArchiveUtil.getModuleFileTypeName(getType())})); - } - } else if (NESTED_MODEL_J2EE_COMPONENT_CREATION.equals(propertyName) ) { - return getDataModel().getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION).validate(true); - } else if(FACET_RUNTIME.equals(propertyName)){ - return validateVersionSupportedByServer(); - } - return OK_STATUS; - } - - protected int getJ2EEVersion() { - return 0; - } - - protected abstract IDataModel createJ2EEComponentCreationDataModel(); - - /* - * @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(); - - 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) { - setProperty(FILE, archiveFile); - } - - protected final Archive getArchiveFile() { - return (Archive) getProperty(FILE); - } - - protected final ArchiveOptions getArchiveOptions() { - ArchiveOptions opts = new ArchiveOptions(); - opts.setIsReadOnly(true); - return opts; - } - - private SaveFilter getSaveFilter() { - return (SaveFilter) getProperty(SAVE_FILTER); - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - return super.getValidPropertyDescriptors(propertyName); - } - - public void propertyChanged(DataModelEvent event) { - if (!doingComponentUpdate && event.getDataModel() == componentCreationDM && event.getPropertyName().equals(PROJECT_NAME) && getBooleanProperty(USE_DEFAULT_PROJECT_NAME)) { - setBooleanProperty(USE_DEFAULT_PROJECT_NAME, false); - } - if( event.getDataModel() == componentCreationDM && event.getPropertyName().equals(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)){ - model.notifyPropertyChange(FACET_RUNTIME, IDataModel.DEFAULT_CHG); - } - } - - /** - * Calling this method will fixup the JST facet version if it is incompatible with the selected runtime - * It should be called when the Server Runtime or the Archive properties are set. - * @return - */ - protected IStatus validateVersionSupportedByServer(){ - if( model.isPropertySet(FILE) && model.isPropertySet(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)){ - IDataModel projectModel = model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION); - FacetDataModelMap map = (FacetDataModelMap) projectModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - Collection projectFacets = (Collection)getProperty(FacetProjectCreationDataModelProvider.REQUIRED_FACETS_COLLECTION); - - IRuntime runtime = (IRuntime) getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME); - if(runtime != null){ - for(Iterator iterator = projectFacets.iterator(); iterator.hasNext();){ - IDataModel facetDataModel = map.getFacetDataModel(((IProjectFacet)iterator.next()).getId()); - IProjectFacetVersion facetVersion = (IProjectFacetVersion)facetDataModel.getProperty(IFacetDataModelProperties.FACET_VERSION); - if(facetVersion.getProjectFacet().getId().equals(IModuleConstants.JST_JAVA)){ - Set set = Collections.singleton(facetVersion.getProjectFacet()); - try { - Set correctSet = runtime.getDefaultFacets(set); - IProjectFacetVersion correctVersion = null; - Iterator correctVersions = correctSet.iterator(); - while(correctVersions.hasNext() && correctVersion == null){ - IProjectFacetVersion version = (IProjectFacetVersion)correctVersions.next(); - if(version.getProjectFacet().getId().equals(IModuleConstants.JST_JAVA)){ - correctVersion = version; - } - } - - if(correctVersion != null){ - if(!facetVersion.equals(correctVersion)){ - facetDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION, correctVersion); - facetVersion = correctVersion; - } - } - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - - if(!runtime.supports(facetVersion)){ - return WTPCommonPlugin.createErrorStatus( J2EECreationResourceHandler.VERSION_NOT_SUPPORTED ); //$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/J2EEComponentCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationDataModelProvider.java deleted file mode 100644 index d4e870b7b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentCreationDataModelProvider.java +++ /dev/null @@ -1,731 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.archive.operations.JavaComponentCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.earcreation.EarComponentCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.project.J2EECreationResourceHandler; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.J2EEFacetInstallDataModelProvider; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -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.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -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.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.ServerUtil; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see J2EEFacetInstallDataModelProvider - */ -public abstract class J2EEComponentCreationDataModelProvider extends JavaComponentCreationDataModelProvider implements IJ2EEComponentCreationDataModelProperties, IAnnotationsDataModel, DoNotUseMeThisWillBeDeletedPost15 { - - private IDataModel earCreationDM = null; - private static String MODULE_NOT_SUPPORTED = "MODULE_NOT_SUPPORTED"; //$NON-NLS-1$ - private static String MODULEVERSION_NOT_SUPPORTED = "VERSION_NOT_SUPPORTED"; //$NON-NLS-1$ - private static String OK = "OK"; //$NON-NLS-1$ - - public void init() { - super.init(); - model.setProperty(COMPONENT_VERSION, getDefaultProperty(COMPONENT_VERSION)); - - IDataModel dm = DataModelFactory.createDataModel(createAddComponentToEAR()); - model.setProperty(NESTED_ADD_COMPONENT_TO_EAR_DM, dm); - propertySet(CLASSPATH_SELECTION, null); - model.setProperty(NESTED_UPDATE_MANIFEST_DM, DataModelFactory.createDataModel(UpdateManifestDataModelProvider.class)); - model.setProperty(USE_ANNOTATIONS, Boolean.FALSE); - } - - public AddComponentToEnterpriseApplicationDataModelProvider createAddComponentToEAR() { - return new AddComponentToEnterpriseApplicationDataModelProvider(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(EAR_COMPONENT_NAME); - propertyNames.add(EAR_COMPONENT_DEPLOY_NAME); - propertyNames.add(ADD_TO_EAR); - propertyNames.add(UI_SHOW_EAR_SECTION); - propertyNames.add(DD_FOLDER); - propertyNames.add(COMPONENT_VERSION); - propertyNames.add(VALID_COMPONENT_VERSIONS_FOR_PROJECT_RUNTIME); - propertyNames.add(NESTED_ADD_COMPONENT_TO_EAR_DM); - propertyNames.add(CLASSPATH_SELECTION); - propertyNames.add(NESTED_EAR_COMPONENT_CREATION_DM); - propertyNames.add(NESTED_UPDATE_MANIFEST_DM); - propertyNames.add(EAR_COMPONENT_PROJECT); - propertyNames.add(USE_ANNOTATIONS); - propertyNames.add(MODULE_URI); - return propertyNames; - } - - 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"; //$NON-NLS-1$ - } else if (propertyName.equals(COMPONENT_VERSION)) { - return getDefaultComponentVersion(); - } else if (propertyName.equals(NESTED_EAR_COMPONENT_CREATION_DM)) - return getDefaultEarCreationDM(); - return super.getDefaultProperty(propertyName); - } - - private Object getDefaultEarCreationDM() { - if (earCreationDM == null) { - earCreationDM = DataModelFactory.createDataModel(new EarComponentCreationDataModelProvider()); - setProperty(NESTED_EAR_COMPONENT_CREATION_DM, earCreationDM); - } - return earCreationDM; - } - - public boolean isPropertyEnabled(String propertyName) { - if (EAR_COMPONENT_NAME.equals(propertyName)) { - return getBooleanProperty(ADD_TO_EAR); - } - return super.isPropertyEnabled(propertyName); - } - - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean status = super.propertySet(propertyName, propertyValue); - if (propertyName.equals(EAR_COMPONENT_NAME)) { - model.setProperty(EAR_COMPONENT_DEPLOY_NAME, propertyValue); - IProject earProj = getEARProject(); - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - earDM.setProperty(IJ2EEComponentCreationDataModelProperties.EAR_COMPONENT_PROJECT, earProj); - model.setProperty(EAR_COMPONENT_PROJECT, earProj); - - } else if (propertyName.equals(COMPONENT_NAME)) { - - if (getBooleanProperty(ADD_TO_EAR)) { - 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)); - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - IProject earProject = getEARProject(); - model.setProperty(EAR_COMPONENT_PROJECT, earProject); - if (earDM != null && earProject != null) - earDM.setProperty(IJ2EEComponentCreationDataModelProperties.EAR_COMPONENT_PROJECT, earProject); - } - } - } else if (propertyName.equals(ADD_TO_EAR)) { - model.notifyPropertyChange(EAR_COMPONENT_NAME, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(NESTED_EAR_COMPONENT_CREATION_DM, IDataModel.DEFAULT_CHG); - IProject earProj = getEARProject(); - model.setProperty(EAR_COMPONENT_PROJECT, earProj); - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - if (earDM != null && earProj != null) { - earDM.setProperty(IJ2EEComponentCreationDataModelProperties.EAR_COMPONENT_PROJECT, earProj); - earDM.setProperty(COMPONENT_VERSION, new Integer(getJ2EEVersion())); - } - - } else if (propertyName.equals(COMPONENT_VERSION)) { - if (getJ2EEVersion() < J2EEVersionConstants.VERSION_1_3) - setProperty(USE_ANNOTATIONS, Boolean.FALSE); - model.notifyPropertyChange(USE_ANNOTATIONS, DataModelEvent.ENABLE_CHG); - model.notifyPropertyChange(EAR_COMPONENT_NAME, DataModelEvent.VALID_VALUES_CHG); - if (getBooleanProperty(ADD_TO_EAR)) { - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - earDM.setProperty(COMPONENT_VERSION, new Integer(getJ2EEVersion())); - } - // this will force to reload all the server types which are valid for this component - // version - model.notifyPropertyChange(RUNTIME_TARGET_ID, DataModelEvent.VALID_VALUES_CHG); - } else if (RUNTIME_TARGET_ID.equals(propertyName)) { - setProperty(ADD_TO_EAR, new Boolean(isEARSupported())); - - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - earDM.setProperty(RUNTIME_TARGET_ID, propertyValue); - } - return status; - } - - protected IProject getEARProject() { - String earProjname = (String) model.getProperty(EAR_COMPONENT_NAME); - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - earDM.setProperty(IComponentCreationDataModelProperties.PROJECT_NAME, earProjname); - - if (earProjname != null && !earProjname.equals("") && validate(EAR_COMPONENT_NAME).isOK()) //$NON-NLS-1$ - return ProjectUtilities.getProject(earProjname); - return null; - } - - - public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName){ - if (propertyName.equals(RUNTIME_TARGET_ID)) { - String propertyValue = (String)getProperty(propertyName); - if( propertyValue != null ){ - IRuntime runtime = getServerTargetByID(propertyValue); - if( runtime != null ) - return new DataModelPropertyDescriptor(propertyValue, runtime.getName()); - } - } - return super.getPropertyDescriptor(propertyName); - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - if (propertyName.equals(COMPONENT_VERSION)) { - return getValidComponentVersionDescriptors(); - } - if (propertyName.equals(EAR_COMPONENT_NAME)) { - int j2eeVersion = getJ2EEVersion(); - return getEARPropertyDescriptor(j2eeVersion); - } else if (propertyName.equals(RUNTIME_TARGET_ID)) { - return validJ2EEServerPropertyDescriptors(); - } - return super.getValidPropertyDescriptors(propertyName); - } - - protected String isvalidJComponentVersionsSupportedByServer() { - String serverID = model.getStringProperty(RUNTIME_TARGET_ID); - IRuntime runtime = getServerTargetByID(serverID); - - if (serverID.equals("") || runtime == null) { //$NON-NLS-1$ - return MODULEVERSION_NOT_SUPPORTED; - } - Integer version = (Integer) model.getProperty(COMPONENT_VERSION); - String j2eeVer = J2EEVersionUtil.convertVersionIntToString(version.intValue()); - return isTypeSupported(runtime.getRuntimeType(), getJ2EEProjectType(), j2eeVer); - } - - protected abstract String getJ2EEProjectType(); - - protected DataModelPropertyDescriptor[] validJ2EEServerPropertyDescriptors() { - - Integer version = (Integer) model.getProperty(COMPONENT_VERSION); - //int j2eeversion = convertModuleVersionToJ2EEVersion(version.intValue()); - String j2eeVersionText = J2EEVersionUtil.convertVersionIntToString(version.intValue()); - - ArrayList validServers = new ArrayList(); - - IDataModel projectdm = model.getNestedModel(NESTED_PROJECT_CREATION_DM); - DataModelPropertyDescriptor[] desc = projectdm.getValidPropertyDescriptors(RUNTIME_TARGET_ID); - for (int i = 0; i < desc.length; i++) { - DataModelPropertyDescriptor descriptor = desc[i]; - String runtimeid = (String) descriptor.getPropertyValue(); - IRuntime runtime = getServerTargetByID(runtimeid); - String ok = isTypeSupported(runtime.getRuntimeType(), getJ2EEProjectType(), j2eeVersionText); - if (ok.equals(OK)) - validServers.add(descriptor); - } - - if (!validServers.isEmpty()) { - int serverTargetListSize = validServers.size(); - DataModelPropertyDescriptor[] result = new DataModelPropertyDescriptor[serverTargetListSize]; - for (int i = 0; i < validServers.size(); i++) { - result[i] = (DataModelPropertyDescriptor) validServers.get(i); - } - return result; - } - return new DataModelPropertyDescriptor[0]; - } - - protected IRuntime getServerTargetByID(String id) { - IRuntime[] targets = ServerUtil.getRuntimes("", ""); //$NON-NLS-1$ //$NON-NLS-2$ - for (int i = 0; i < targets.length; i++) { - IRuntime target = targets[i]; - if (id.equals(target.getId())) - return target; - } - return null; - } - -// private List getValidServerTargets() { -// List validServerTargets = null; -// validServerTargets = ServerTargetHelper.getServerTargets("", ""); //$NON-NLS-1$ //$NON-NLS-2$ -// if (validServerTargets != null && validServerTargets.isEmpty()) -// validServerTargets = null; -// if (validServerTargets == null) -// return Collections.EMPTY_LIST; -// return validServerTargets; -// } - - - protected String isTypeSupported(IRuntimeType type, String moduleID, String j2eeVersion) { - IModuleType[] moduleTypes = type.getModuleTypes(); - - boolean moduleFound = false; - boolean moduleVersionFound = false; - - if (moduleTypes != null) { - int size = moduleTypes.length; - - for (int i = 0; i < size; i++) { - IModuleType moduleType = moduleTypes[i]; - - if (matches(moduleType.getId(), moduleID)) { - moduleFound = true; - String version = moduleType.getVersion(); - if (version.equals(j2eeVersion) || version.equals("*")) { //$NON-NLS-1$ - moduleVersionFound = true; - return OK; - } - if (i < size) - continue; - } - } - } - if (!moduleFound) - return MODULE_NOT_SUPPORTED; - if (!moduleVersionFound) - return MODULEVERSION_NOT_SUPPORTED; - return ""; //$NON-NLS-1$ - } - - - protected static String[] getServerVersions(IRuntimeType type, String moduleID) { - List list = new ArrayList(); - if (type == null) - return null; - IModuleType[] moduleTypes = type.getModuleTypes(); - if (moduleTypes != null) { - int size = moduleTypes.length; - for (int i = 0; i < size; i++) { - IModuleType moduleType = moduleTypes[i]; - if (matches(moduleType.getId(), moduleID)) { - list.add(moduleType.getVersion()); - } - - } - } - String[] versions = null; - if (!list.isEmpty()) { - versions = new String[list.size()]; - list.toArray(versions); - } - return versions; - } - - protected static boolean matches(String serverTypeID, String j2eeModuleID) { - - if (serverTypeID.equals("jst") || serverTypeID.equals("jst.*")) //$NON-NLS-1$ //$NON-NLS-2$ - return j2eeModuleID.equals(J2EEProjectUtilities.DYNAMIC_WEB) || j2eeModuleID.equals(J2EEProjectUtilities.EJB) || j2eeModuleID.equals(J2EEProjectUtilities.ENTERPRISE_APPLICATION) || j2eeModuleID.equals(J2EEProjectUtilities.APPLICATION_CLIENT) || j2eeModuleID.equals(J2EEProjectUtilities.JCA); - - else if (serverTypeID.equals(J2EEProjectUtilities.DYNAMIC_WEB)) - return j2eeModuleID.equals(J2EEProjectUtilities.DYNAMIC_WEB); - - else if (serverTypeID.equals(J2EEProjectUtilities.EJB)) - return j2eeModuleID.equals(J2EEProjectUtilities.EJB); - - else if (serverTypeID.equals(J2EEProjectUtilities.JCA)) - return j2eeModuleID.equals(J2EEProjectUtilities.JCA); - - else if (serverTypeID.equals(J2EEProjectUtilities.APPLICATION_CLIENT)) - return j2eeModuleID.equals(J2EEProjectUtilities.APPLICATION_CLIENT); - - else if (serverTypeID.equals(J2EEProjectUtilities.ENTERPRISE_APPLICATION)) - return j2eeModuleID.equals(J2EEProjectUtilities.ENTERPRISE_APPLICATION) || j2eeModuleID.equals(J2EEProjectUtilities.APPLICATION_CLIENT) || j2eeModuleID.equals(J2EEProjectUtilities.JCA); - - return false; - } - - - - 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) { - if (ModuleCoreNature.isFlexibleProject(flexProject)) { - IVirtualComponent comp = ComponentCore.createComponent(flexProject); - if (J2EEProjectUtilities.isEARProject(comp.getProject())) { - String sVer = J2EEProjectUtilities.getJ2EEProjectVersion(comp.getProject()); - int ver = J2EEVersionUtil.convertVersionStringToInt(sVer); - if (j2eeVersion <= ver) { - DataModelPropertyDescriptor desc = new DataModelPropertyDescriptor(comp.getProject().getName()); - earDescriptorList.add(desc); - } - } - } - } - } finally { - if (mc != null) - mc.dispose(); - } - } - DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[earDescriptorList.size()]; - for (int i = 0; i < descriptors.length; i++) { - DataModelPropertyDescriptor desc = (DataModelPropertyDescriptor) 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.getComponent(); - } - } - } finally { - if (core != null) - core.dispose(); - } - return null; - } - - protected boolean isEARSupported() { - if (this instanceof EarComponentCreationDataModelProvider) - return false; - String serverID = model.getStringProperty(RUNTIME_TARGET_ID); - IRuntime runtime = getServerTargetByID(serverID); - Integer version = (Integer) model.getProperty(COMPONENT_VERSION); - int nj2eeVer = convertModuleVersionToJ2EEVersion(version.intValue()); - String j2eeVer = J2EEVersionUtil.getJ2EETextVersion(nj2eeVer); - - if (runtime != null) { - String msg = isTypeSupported(runtime.getRuntimeType(), J2EEProjectUtilities.ENTERPRISE_APPLICATION, j2eeVer); - if (msg.equals(OK)) { - return true; - } - } - return false; - } - - protected boolean validateComponentAlreadyInEar() { - //IVirtualComponent component = ComponentCore.createComponent(getProject(), getModuleName()); - - IProject earProj = (IProject) model.getProperty(EAR_COMPONENT_PROJECT); - if (earProj != null && earProj.exists()) { - IVirtualComponent earComp = ComponentCore.createComponent(earProj); - if (earComp != null && earComp.exists()) { - IVirtualReference[] refs = earComp.getReferences(); - for (int i = 0; i < refs.length; i++) { - IVirtualReference ref = refs[i]; - IVirtualComponent referencedComp = ref.getReferencedComponent(); - if (referencedComp.getName().equalsIgnoreCase(getModuleName())) - return true; - } - } - } - return false; - } - - 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; - } else if (propertyName.equals(ADD_TO_EAR)) { - boolean val = getBooleanProperty(ADD_TO_EAR); - if (val) { - String serverID = model.getStringProperty(RUNTIME_TARGET_ID); - IRuntime runtime = getServerTargetByID(serverID); - if (serverID.equals("") || runtime == null) { //$NON-NLS-1$ - String msg = EARCreationResourceHandler.SERVER_TARGET_NOT_SUPPORT_EAR; - return WTPCommonPlugin.createErrorStatus(msg); - } - Integer version = (Integer) model.getProperty(COMPONENT_VERSION); - int nj2eeVer = convertModuleVersionToJ2EEVersion(version.intValue()); - String j2eeVer = J2EEVersionUtil.getJ2EETextVersion(nj2eeVer); - String msg = isTypeSupported(runtime.getRuntimeType(), J2EEProjectUtilities.ENTERPRISE_APPLICATION, j2eeVer); - if (!msg.equals(OK)) { - msg = EARCreationResourceHandler.SERVER_TARGET_NOT_SUPPORT_EAR; - return WTPCommonPlugin.createErrorStatus(msg); - } - if (validateComponentAlreadyInEar()) { - msg = J2EECreationResourceHandler.COMPONENT_ALREADYINEAR; - return WTPCommonPlugin.createErrorStatus(msg); - } - } - } else if (propertyName.equals(PROJECT_NAME)) { - if (!isCreatingEarComponent()) { - String projName = getDataModel().getStringProperty(IComponentCreationDataModelProperties.PROJECT_NAME); - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - IProject earProj = (IProject) earDM.getProperty(EAR_COMPONENT_PROJECT); - if (earProj != null) { - String earProjName = earProj.getName(); - if (earProjName.equalsIgnoreCase(projName)) { - String msg = EARCreationResourceHandler.EAR_PROJECTNAME_SAMEAS_MODULE; - return WTPCommonPlugin.createErrorStatus(msg); - } - } - } - } - return super.validate(propertyName); - } - - protected boolean isCreatingEarComponent() { - return false; - } - - private IStatus validateComponentVersionProperty() { - int componentVersion = model.getIntProperty(COMPONENT_VERSION); - String result = isvalidJComponentVersionsSupportedByServer(); - if (result.equals(MODULEVERSION_NOT_SUPPORTED)) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.SPEC_LEVEL_NOT_FOUND)); - } else if (result.equals(MODULE_NOT_SUPPORTED)) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.MODULE_NOT_SUPPORTED)); - } - 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$ //$NON-NLS-2$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_INVALID_CHARS); - 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() { - 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 IDataModel getAddComponentToEARDataModel() { - // return (AddComponentToEnterpriseApplicationDataModel) - // model.getProperty(NESTED_ADD_COMPONENT_TO_EAR_DM); - return (IDataModel) model.getProperty(NESTED_ADD_COMPONENT_TO_EAR_DM); - } - - protected final IDataModel getUpdateManifestDataModel() { - return (IDataModel) 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(); - - -// private DataModelPropertyDescriptor[] validExistingProjectsDescriptors() { -// -// IProject[] workspaceProjects = ProjectUtilities.getAllProjects(); -// List items = new ArrayList(); -// for (int i = 0; i < workspaceProjects.length; i++) { -// IProject project = workspaceProjects[i]; -// try { -// if (project.hasNature(IModuleConstants.MODULE_NATURE_ID)) { -// items.add(project.getName()); -// } -// } catch (CoreException ce) { -// // Ignore -// } -// } -// -// DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[items.size()]; -// for (int i = 0; i < descriptors.length; i++) { -// descriptors[i] = new DataModelPropertyDescriptor(items.get(i)); -// } -// return descriptors; -// -// -// // 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) { -// // IFlexibleProject fProject = ComponentCore.createFlexibleProject(flexProject); -// // if ( fProject.isFlexible()){ -// // IVirtualComponent[] comps = fProject.getComponents(); -// // int earVersion = 0; -// // for( int i=0; i< comps.length; i++ ){ -// // if( comps[i].getComponentTypeId().equals(IModuleConstants.JST_EAR_MODULE)){ -// // String sVer = comps[i].getVersion(); -// // int ver = J2EEVersionUtil.convertVersionStringToInt(sVer); -// // if (j2eeVersion <= ver) { -// // DataModelPropertyDescriptor desc = new -// // DataModelPropertyDescriptor(comps[i].getComponentHandle(), comps[i].getName()); -// // earDescriptorList.add(desc); -// // } -// // } -// // } -// // } -// // } -// // } finally { -// // if (mc != null) -// // mc.dispose(); -// // } -// // } -// // DataModelPropertyDescriptor[] descriptors = new -// // DataModelPropertyDescriptor[earDescriptorList.size()]; -// // for (int i = 0; i < descriptors.length; i++) { -// // DataModelPropertyDescriptor desc = (DataModelPropertyDescriptor)earDescriptorList.get(i); -// // descriptors[i] = new DataModelPropertyDescriptor(desc.getPropertyDescription(), -// // desc.getPropertyDescription()); -// // } -// // return descriptors; -// -// -// } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentExportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentExportDataModelProvider.java deleted file mode 100644 index b302081cc..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentExportDataModelProvider.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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; - -public abstract class J2EEComponentExportDataModelProvider extends J2EEArtifactExportDataModelProvider { - - public J2EEComponentExportDataModelProvider() { - super(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentImportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentImportDataModelProvider.java deleted file mode 100644 index 2a96de9d0..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEComponentImportDataModelProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.util.Set; - -import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEModuleImportDataModelProperties; - -/** - * 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. - * - * @plannedfor WTP 1.0 - */ -public abstract class J2EEComponentImportDataModelProvider extends J2EEArtifactImportDataModelProvider implements IJ2EEModuleImportDataModelProperties { - - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(EXTENDED_IMPORT_FACTORY); - return propertyNames; - } - - protected int getModuleSpecVersion() { - if (!isPropertySet(EXTENDED_IMPORT_FACTORY)) { - return ArchiveUtil.getFastSpecVersion(getModuleFile()); - } - ExtendedImportFactory factory = (ExtendedImportFactory) getProperty(EXTENDED_IMPORT_FACTORY); - return factory.getSpecVersion(getModuleFile()); - } - -// public boolean propertySet(String propertyName, Object propertyValue) { -// boolean set = super.propertySet(propertyName, propertyValue); -// if (propertyName.equals(FILE)) { -// IDataModel moduleDM = model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION); -// if (getModuleFile() != null) { -// moduleDM.setIntProperty(IJ2EEComponentCreationDataModelProperties.COMPONENT_VERSION, getModuleSpecVersion()); -// model.notifyPropertyChange(PROJECT_NAME, IDataModel.VALID_VALUES_CHG); -// } -// } -// return set; -// } - - protected ModuleFile getModuleFile() { - return (ModuleFile) getArchiveFile(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportAssistantOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportAssistantOperation.java deleted file mode 100644 index 6b8889cf8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportAssistantOperation.java +++ /dev/null @@ -1,195 +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.File; -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.AbstractOperation; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IPathVariableManager; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -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.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public abstract class J2EEUtilityJarImportAssistantOperation extends AbstractOperation { - - private File utilityJar; - - private boolean overwriteIfNecessary = false; - private String associatedEARProjectName; - - public J2EEUtilityJarImportAssistantOperation(String label, File utilityJar) { - super(label); - this.utilityJar = utilityJar; - } - - public void setAssociatedEARProjectName(String associatedEARProjectName) { - this.associatedEARProjectName = associatedEARProjectName; - } - - - public void setOverwriteIfNecessary(boolean overwriteProject) { - this.overwriteIfNecessary = overwriteProject; - } - - protected final void createLinkedPathVariable(String linkedPathVariable, File archiveFile) throws CoreException { - IPathVariableManager manager = ResourcesPlugin.getWorkspace().getPathVariableManager(); - IPath linkedPath = new Path(archiveFile.getAbsolutePath()); - manager.setValue(linkedPathVariable, linkedPath); - - } - - protected final String getUtilityJarProjectName(File utilityJar) { - String name = null; - if (utilityJar != null) { - int len = utilityJar.getName().lastIndexOf('.'); - name = utilityJar.getName().substring(0, len); - } - return name; - } - - protected final IStatus linkArchiveToEAR(IProject earProject, String uriMapping, IProject utilityProject, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, ExecutionException { - IDataModel addArchiveProjectToEARDataModel = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider()); - - IVirtualComponent earcomponent = ComponentCore.createComponent(earProject); - IVirtualComponent utilcomponent = ComponentCore.createComponent(utilityProject); - - addArchiveProjectToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earcomponent); - addArchiveProjectToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Collections.singletonList(utilcomponent)); - Map uriMap = new HashMap(); - uriMap.put(utilcomponent, uriMapping); - addArchiveProjectToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap); - return addArchiveProjectToEARDataModel.getDefaultOperation().execute(monitor, null); - } - - protected final IStatus createVirtualArchiveComponent(IProject targetProject, String uriMapping, IFile utilityJarIFile, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, ExecutionException { - IDataModel addArchiveProjectToEARDataModel = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider()); - - IVirtualComponent earcomponent = ComponentCore.createComponent(targetProject); - - IVirtualComponent utilcomponent = ComponentCore.createArchiveComponent(targetProject, VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR + utilityJarIFile.getProjectRelativePath().toString()); - - addArchiveProjectToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earcomponent); - addArchiveProjectToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Collections.singletonList(utilcomponent)); - Map uriMap = new HashMap(); - uriMap.put(utilcomponent, uriMapping); - addArchiveProjectToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap); - return addArchiveProjectToEARDataModel.getDefaultOperation().execute(monitor, null); - } - - - protected final IStatus removeRootMapping(IVirtualComponent sourceComponent, String uriMapping, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, ExecutionException { - - try { - sourceComponent.getRootFolder().removeLink(new Path(uriMapping), 0, monitor); - } catch (CoreException e) { - return J2EEPlugin.createErrorStatus(0, e.getMessage(), e); - } - return Status.OK_STATUS; - } - - protected File getUtilityJar() { - return utilityJar; - } - - protected final IWorkspaceRoot getWorkspaceRoot() { - return ResourcesPlugin.getWorkspace().getRoot(); - } - - - protected final String getAssociatedEARProjectName() { - return associatedEARProjectName; - } - - protected final boolean isOverwriteIfNecessary() { - return overwriteIfNecessary; - } - - protected final void addLibraryToClasspath(IProject associatedEARProject, IFile copiedJarFile, IProgressMonitor monitor) throws CoreException, JavaModelException { - if (associatedEARProject.hasNature(JavaCore.NATURE_ID)) { - - IClasspathEntry entry = JavaCore.newLibraryEntry(copiedJarFile.getFullPath().makeAbsolute(), null, // source - // attachment - null, // source attachment root - new IAccessRule[0], // accessRules - new IClasspathAttribute[0], // extraAttributes - false); // isExported - - IJavaProject earJavaProject = JavaCore.create(associatedEARProject); - IClasspathEntry[] rawClasspath = earJavaProject.getRawClasspath(); - IClasspathEntry[] newClasspath = new IClasspathEntry[rawClasspath.length + 1]; - System.arraycopy(rawClasspath, 0, newClasspath, 0, rawClasspath.length); - newClasspath[rawClasspath.length] = entry; - earJavaProject.setRawClasspath(newClasspath, monitor); - - } - } - - protected final IStatus createLinkedArchive(IProject project, String linkedFileName, File archiveFile, String linkedPathVariable, IProgressMonitor monitor) throws CoreException { - IFile linkedJarFile = null; - IPath pathToArchive = getLinkedPath(archiveFile, linkedPathVariable); - - linkedJarFile = project.getFile(linkedFileName); - if (linkedJarFile.exists()) { - if (isOverwriteIfNecessary()) - linkedJarFile.delete(true, true, new SubProgressMonitor(monitor, 1)); - else - return J2EEPlugin.createErrorStatus(0, NLS.bind(EARCreationResourceHandler.CreateProjectWithLinkedJarOperation_File_already_exists_0_, linkedJarFile.getFullPath()), null); - } - linkedJarFile.createLink(pathToArchive, IResource.ALLOW_MISSING_LOCAL, new SubProgressMonitor(monitor, 1)); - - addLibraryToClasspath(project, linkedJarFile, monitor); - return Status.OK_STATUS; - } - - protected final IPath getLinkedPath(File archiveFile, String linkedPathVariable) throws CoreException { - - if (linkedPathVariable == null || linkedPathVariable.length() == 0) - return new Path(archiveFile.getAbsolutePath()); - else { - createLinkedPathVariable(linkedPathVariable, archiveFile.getParentFile()); - return new Path(linkedPathVariable).append(archiveFile.getName()); - } - } - - protected final String findUniqueLocation(String baseLocation, String proposedProjectName) { - - return baseLocation != null ? (baseLocation + File.separator + proposedProjectName) : null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportDataModelProvider.java deleted file mode 100644 index 3061c2ec2..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportDataModelProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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 java.util.Set; - -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.jst.j2ee.datamodel.properties.IJavaUtilityJarImportDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.UtilityProjectCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public final class J2EEUtilityJarImportDataModelProvider extends J2EEArtifactImportDataModelProvider implements IJavaUtilityJarImportDataModelProperties { - - public static String J2EE_UTILITY_JAR_IMPORT_DMP_ID = "j2eeUtilityJarImportDataModelProvider"; - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(EAR_PROJECT_NAME); - return propertyNames; - } - - protected Archive openArchive(String uri) throws OpenFailureException { - return null; - } - - protected int getType() { - return 0; - } - - public IDataModelOperation getDefaultOperation() { - return new J2EEUtilityJarImportOperationNew(model); - } - - protected IDataModel createJ2EEComponentCreationDataModel() { - return DataModelFactory.createDataModel(new UtilityProjectCreationDataModelProvider()); - } - - public String getID() { - - return J2EE_UTILITY_JAR_IMPORT_DMP_ID; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportOperationNew.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportOperationNew.java deleted file mode 100644 index b384b3c2f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarImportOperationNew.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.j2ee.commonarchivecore.internal.strategy.SaveStrategy; -import org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactImportOperation; -import org.eclipse.jst.j2ee.internal.archive.operations.J2EEJavaComponentSaveStrategyImpl; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class J2EEUtilityJarImportOperationNew extends J2EEArtifactImportOperation { - - public J2EEUtilityJarImportOperationNew(IDataModel dataModel) { - super(dataModel); - } - - protected SaveStrategy createSaveStrategy(IVirtualComponent virtualComponent) { - J2EEJavaComponentSaveStrategyImpl saveStrat = new J2EEJavaComponentSaveStrategyImpl(virtualComponent); - return saveStrat; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportDataModelProvider.java deleted file mode 100644 index b151a5cd1..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportDataModelProvider.java +++ /dev/null @@ -1,348 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -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.jst.j2ee.datamodel.properties.IJ2EEUtilityJarListImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.project.facet.EARFacetUtils; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * @author mdelder - * - */ -public class J2EEUtilityJarListImportDataModelProvider extends AbstractDataModelProvider implements IJ2EEUtilityJarListImportDataModelProperties { - - - - private static final Object[] EMPTY_ARRAY = new Object[0]; - - public J2EEUtilityJarListImportDataModelProvider() { - super(); - } - - public Set getPropertyNames(){ - Set propertyNames = super.getPropertyNames(); - propertyNames.add(EAR_PROJECT_NAME); - propertyNames.add(CREATE_PROJECT); - propertyNames.add(LINK_IMPORT); - propertyNames.add(CREATE_LINKED_PROJECT); - propertyNames.add(COPY); - propertyNames.add(BINARY_IMPORT); - propertyNames.add(UTILITY_JAR_LIST); - propertyNames.add(AVAILABLE_JARS_DIRECTORY); - propertyNames.add(PROJECT_ROOT); - propertyNames.add(OVERRIDE_PROJECT_ROOT); - propertyNames.add(OVERWRITE_IF_NECESSARY); - propertyNames.add(CREATE_LINKED_PATH_VARIABLE); - propertyNames.add(LINKED_PATH_VARIABLE); - return propertyNames; - } - - public boolean propertySet(String propertyName, Object propertyValue) { - - boolean notify = super.propertySet(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 - model.setProperty(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 (J2EEUtilityJarListImportDataModelProvider.CREATE_PROJECT.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_PROJECT)) { - - setBooleanProperty(LINK_IMPORT, false); - setBooleanProperty(CREATE_LINKED_PROJECT, false); - setBooleanProperty(COPY, false); - - model.notifyPropertyChange(BINARY_IMPORT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(OVERRIDE_PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(CREATE_LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - - } else if (J2EEUtilityJarListImportDataModelProvider.LINK_IMPORT.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.LINK_IMPORT)) { - - setBooleanProperty(CREATE_PROJECT, false); - setBooleanProperty(CREATE_LINKED_PROJECT, false); - setBooleanProperty(COPY, false); - - model.notifyPropertyChange(BINARY_IMPORT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(OVERRIDE_PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(CREATE_LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - - } else if (J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PROJECT.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PROJECT)) { - - setBooleanProperty(LINK_IMPORT, false); - setBooleanProperty(CREATE_PROJECT, false); - setBooleanProperty(COPY, false); - - model.notifyPropertyChange(BINARY_IMPORT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(OVERRIDE_PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(CREATE_LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - - } else if (J2EEUtilityJarListImportDataModelProvider.COPY.equals(propertyName) && getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.COPY)) { - - setBooleanProperty(CREATE_PROJECT, false); - setBooleanProperty(LINK_IMPORT, false); - setBooleanProperty(CREATE_LINKED_PROJECT, false); - - model.notifyPropertyChange(BINARY_IMPORT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(OVERRIDE_PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(PROJECT_ROOT, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(CREATE_LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - - - } else if (J2EEUtilityJarListImportDataModelProvider.OVERRIDE_PROJECT_ROOT.equals(propertyName)) { - model.notifyPropertyChange(PROJECT_ROOT, IDataModel.ENABLE_CHG); - } else if (J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PATH_VARIABLE.equals(propertyName)) { - - if (isLinkedPathVariableInvalid()) - setProperty(J2EEUtilityJarListImportDataModelProvider.LINKED_PATH_VARIABLE, "TEAM_SHARED_DIRECTORY"); //$NON-NLS-1$ - - model.notifyPropertyChange(J2EEUtilityJarListImportDataModelProvider.LINKED_PATH_VARIABLE, IDataModel.ENABLE_CHG); - model.notifyPropertyChange(AVAILABLE_JARS_DIRECTORY, IDataModel.ENABLE_CHG); - - } else if (J2EEUtilityJarListImportDataModelProvider.LINKED_PATH_VARIABLE.equals(propertyName)) { - // will only set if necessary - setProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PATH_VARIABLE, Boolean.TRUE); - - if (linkedPathExists()) { - String linkedPathVariable = getStringProperty(J2EEUtilityJarListImportDataModelProvider.LINKED_PATH_VARIABLE); - IPathVariableManager manager = ResourcesPlugin.getWorkspace().getPathVariableManager(); - IPath availableJarsPath = manager.getValue(linkedPathVariable); - setProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PATH_VARIABLE, Boolean.valueOf(availableJarsPath != null)); - - String availableJarsPathString = availableJarsPath.toOSString(); - if (availableJarsPathString != null && availableJarsPathString.length() > 0) - setProperty(J2EEUtilityJarListImportDataModelProvider.AVAILABLE_JARS_DIRECTORY, availableJarsPathString); - } - - model.notifyPropertyChange(AVAILABLE_JARS_DIRECTORY, IDataModel.ENABLE_CHG); - } - return notify; - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#basicIsEnabled(java.lang.String) - */ - public boolean isPropertyEnabled(String propertyName) { - if (J2EEUtilityJarListImportDataModelProvider.BINARY_IMPORT.equals(propertyName)) { - return getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_PROJECT) || getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PROJECT); - } else if (J2EEUtilityJarListImportDataModelProvider.OVERRIDE_PROJECT_ROOT.equals(propertyName)) { - return getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_PROJECT) || getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PROJECT); - } else if (J2EEUtilityJarListImportDataModelProvider.PROJECT_ROOT.equals(propertyName)) { - return (getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_PROJECT) || getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PROJECT)) && getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.OVERRIDE_PROJECT_ROOT); - } else if (J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PATH_VARIABLE.equals(propertyName)) { - return (getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.LINK_IMPORT) || getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PROJECT)); - } else if (J2EEUtilityJarListImportDataModelProvider.LINKED_PATH_VARIABLE.equals(propertyName)) { - return getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PATH_VARIABLE); - } else if (J2EEUtilityJarListImportDataModelProvider.AVAILABLE_JARS_DIRECTORY.equals(propertyName)) { - boolean createPath = getBooleanProperty(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PATH_VARIABLE); - return !createPath || !linkedPathExists(); - } - return super.isPropertyEnabled(propertyName); - } - - private boolean linkedPathExists() { - String linkedPathVariable = getStringProperty(J2EEUtilityJarListImportDataModelProvider.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(J2EEUtilityJarListImportDataModelProvider.CREATE_LINKED_PATH_VARIABLE); - String linkedPathVariable = getStringProperty(J2EEUtilityJarListImportDataModelProvider.LINKED_PATH_VARIABLE); - return (createPath && (linkedPathVariable == null || linkedPathVariable.trim().length() == 0)); - } - - public IDataModelOperation getDefaultOperation() { - return new J2EEUtilityJarListImportOperation(model); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.application.operations.J2EEImportDataModel#getDefaultProperty(java.lang.String) - */ - public 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_NAME.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); - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - if (EAR_PROJECT_NAME.equals(propertyName)) { - return DataModelPropertyDescriptor.createDescriptors(getValidProjectNames()); - } else if (LINKED_PATH_VARIABLE.equals(propertyName)) { - IPathVariableManager manager = ResourcesPlugin.getWorkspace().getPathVariableManager(); - return DataModelPropertyDescriptor.createDescriptors(manager.getPathVariableNames()); - } else - return super.getValidPropertyDescriptors(propertyName); - } - - /** - * Populate the resource name combo with connector projects that are not encrypted. - */ - protected Object[] getValidProjectNames() { - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - List projectsWithNature = new ArrayList(); - - IFacetedProject facetedProject = null; - for (int i = 0; i < projects.length; i++) { - if(projects[i].isAccessible()) { - try { - facetedProject = ProjectFacetsManager.create(projects[i]); - if (facetedProject!=null && facetedProject.hasProjectFacet(EARFacetUtils.EAR_FACET)) { - projectsWithNature.add(projects[i].getFullPath().toString()); - } - } catch (CoreException e) { - J2EEPlugin.logError(0, e.getMessage(), e); - } - } - } - - return ProjectUtilities.getProjectNamesWithoutForwardSlash((String[]) projectsWithNature.toArray(new String[projectsWithNature.size()])); - } - - public IStatus validate(String propertyName) { - if (EAR_PROJECT_NAME.equals(propertyName) /* && isSet(EAR_PROJECT_NAME) */) { - String earProjectName = getStringProperty(EAR_PROJECT_NAME); - if (earProjectName != null && earProjectName.length() > 0) { - IProject earProject = ResourcesPlugin.getWorkspace().getRoot().getProject(earProjectName); - try { - if (!earProject.isAccessible()) - return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.J2EEUtilityJarListImportDataModel_Specify_Valid_Project, null); - return Status.OK_STATUS; - } catch (Exception e) { - return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.J2EEUtilityJarListImportDataModel_Specify_Valid_Project, e); - } - } - return new Status(IStatus.ERROR, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.J2EEUtilityJarListImportDataModel_Specify_Valid_Project, null); - - } else if (UTILITY_JAR_LIST.equals(propertyName) || J2EEUtilityJarListImportDataModelProvider.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.J2EEUtilityJarListImportDataModel_Select_Jar, null); - - /* 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.J2EEUtilityJarListImportDataModel_Specify_Linked_Path, null); - else if (linkedPathExists()) - return new Status(IStatus.INFO, J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.J2EEUtilityJarListImportDataModel_Linked_Path_Exists, null); - } else if (PROJECT_ROOT.equals(propertyName)) { - return validateProjectRoot(); - } - return super.validate(propertyName); - } - - private IStatus validateProjectRoot() { - if (isPropertySet(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.J2EEUtilityJarListImportDataModel_0, null); - } - 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; - // } - - - -} 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 df8e061ee..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/J2EEUtilityJarListImportOperation.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.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEUtilityJarListImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class J2EEUtilityJarListImportOperation extends AbstractDataModelOperation implements IUndoableOperation { - - private static final int ASSISTANT_TICKS = 5; - - public J2EEUtilityJarListImportOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - MultiStatus status = new MultiStatus(J2EEPlugin.PLUGIN_ID, 0, EARCreationResourceHandler.J2EEUtilityJarListImportOperation_UI_Import_Utility_Jars, null); - - Object[] utilityJars = (Object[]) model.getProperty(IJ2EEUtilityJarListImportDataModelProperties.UTILITY_JAR_LIST); - if (utilityJars == null || utilityJars.length == 0) - return J2EEPlugin.createErrorStatus(0, EARCreationResourceHandler.J2EEUtilityJarListImportOperation_There_were_no_utility_jars_selected, null); - - monitor.beginTask(EARCreationResourceHandler.J2EEUtilityJarListImportOperation_UI_Import_Utility_Jars, utilityJars.length * (1 + ASSISTANT_TICKS)); //$NON-NLS-1$ - -// String earProjectName = model.getStringProperty(IJ2EEUtilityJarListImportDataModelProperties.EAR_PROJECT_NAME); -// boolean isBinary = model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.BINARY_IMPORT); - - // if model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.COPY) then - // isLinked = createProject = false; - boolean toLinkImportedJars = shouldLinkImportedJars(); - boolean toCreateProject = shouldCreateProject(); - boolean toOverrideProjectRoot = shouldOverrideProjectRoot(); - boolean toOverwriteIfNecessary = shouldOverwriteIfNecessary(); - - - String projectRoot = null; - if(toOverrideProjectRoot) - projectRoot = model.getStringProperty(IJ2EEUtilityJarListImportDataModelProperties.PROJECT_ROOT); - - monitor.subTask(EARCreationResourceHandler.J2EEUtilityJarListImportOperation_UI_Preparing_to_import); //$NON-NLS-1$ - - String associatedEARProjectName = model.getStringProperty(IJ2EEUtilityJarListImportDataModelProperties.EAR_PROJECT_NAME); - - J2EEUtilityJarImportAssistantOperation assistantOperation = null; - List utilityJarOperations = new ArrayList(); - File utilityJar = null; - String linkedPathVariable = null; - if(model.isPropertySet(IJ2EEUtilityJarListImportDataModelProperties.LINKED_PATH_VARIABLE)) - linkedPathVariable = model.getStringProperty(IJ2EEUtilityJarListImportDataModelProperties.LINKED_PATH_VARIABLE); - for (int i = 0; i < utilityJars.length && !monitor.isCanceled(); i++) { - utilityJar = (File) utilityJars[i]; - if (toCreateProject) { - if (!toLinkImportedJars) { - assistantOperation = new CreateProjectWithExtractedJarOperation(utilityJar, projectRoot); - - } else { - assistantOperation = new CreateProjectWithLinkedJarOperation(utilityJar, projectRoot, linkedPathVariable); - - } - } else { - if (!toLinkImportedJars) { - assistantOperation = new CopyArchiveIntoProjectOperation(utilityJar); - } else - assistantOperation = new LinkArchiveIntoProjectOperation(utilityJar, linkedPathVariable); - } - assistantOperation.setAssociatedEARProjectName(associatedEARProjectName); - assistantOperation.setOverwriteIfNecessary(toOverwriteIfNecessary); - utilityJarOperations.add(assistantOperation); - - monitor.worked(1); - } - - for (Iterator iter = utilityJarOperations.iterator(); iter.hasNext() && !monitor.isCanceled();) { - try { - assistantOperation = (J2EEUtilityJarImportAssistantOperation) iter.next(); - IProgressMonitor submonitor = new SubProgressMonitor(monitor, ASSISTANT_TICKS); - assistantOperation.execute(submonitor, null); - submonitor.done(); - } catch (Exception e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - J2EEPlugin.logError(0, e.getMessage(), e); - } - } - - monitor.done(); - - return status; - } - - private boolean shouldOverwriteIfNecessary() { - return model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.OVERWRITE_IF_NECESSARY); - } - - protected final boolean shouldImportAsBinary() { - return model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.BINARY_IMPORT); - } - - protected final boolean shouldOverrideProjectRoot() { - return model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.OVERRIDE_PROJECT_ROOT); - } - - protected final boolean shouldCreateProject() { - return (model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.CREATE_PROJECT) || model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.CREATE_LINKED_PROJECT)); - } - - protected final boolean shouldLinkImportedJars() { - return (model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.LINK_IMPORT) || model.getBooleanProperty(IJ2EEUtilityJarListImportDataModelProperties.CREATE_LINKED_PROJECT)); - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - - - - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/LinkArchiveIntoProjectOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/LinkArchiveIntoProjectOperation.java deleted file mode 100644 index 1ae71e6ef..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/LinkArchiveIntoProjectOperation.java +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.io.File; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -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.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.osgi.util.NLS; - -public class LinkArchiveIntoProjectOperation extends J2EEUtilityJarImportAssistantOperation { - - - private String linkedPathVariable; - - public LinkArchiveIntoProjectOperation(File utilityJar, String linkedPathVariable) { - super(NLS.bind(EARCreationResourceHandler.LinkArchiveIntoProjectOperation_Linking_archive_into_selected_proje_, utilityJar.getName()), utilityJar); - this.linkedPathVariable = linkedPathVariable; - - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - MultiStatus status = new MultiStatus(J2EEPlugin.PLUGIN_ID, 0, NLS.bind(EARCreationResourceHandler.LinkArchiveIntoProjectOperation_Linking_archive_into_selected_proje_, getUtilityJar().getName()), null); - - IProject project = getWorkspaceRoot().getProject(getAssociatedEARProjectName()); - - try { - IFile linkedJarFile = project.getFile(getUtilityJar().getName()); - if (linkedJarFile.exists()) { - if (isOverwriteIfNecessary()) - linkedJarFile.delete(true, true, new SubProgressMonitor(monitor, 1)); - else { - status.add(J2EEPlugin.createErrorStatus(0, NLS.bind(EARCreationResourceHandler.CreateProjectWithLinkedJarOperation_File_already_exists_0_, linkedJarFile.getFullPath()), null)); - return status; - } - } - status.add(createLinkedArchive(project, getUtilityJar().getName(), getUtilityJar(), linkedPathVariable, monitor)); - - addLibraryToClasspath(project, linkedJarFile, monitor); - - createVirtualArchiveComponent(project, getUtilityJar().getName(), linkedJarFile, monitor); - - } catch (CoreException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - } catch (InvocationTargetException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - } catch (InterruptedException e) { - status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); - } - return status; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.CANCEL_STATUS; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/RemoveComponentFromEnterpriseApplicationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/RemoveComponentFromEnterpriseApplicationDataModelProvider.java deleted file mode 100644 index 137156296..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/RemoveComponentFromEnterpriseApplicationDataModelProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class RemoveComponentFromEnterpriseApplicationDataModelProvider extends RemoveReferenceComponentsDataModelProvider implements IAddComponentToEnterpriseApplicationDataModelProperties { - - public RemoveComponentFromEnterpriseApplicationDataModelProvider() { - super(); - } - - public IDataModelOperation getDefaultOperation() { - return new RemoveComponentFromEnterpriseApplicationOperation(model); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/RemoveComponentFromEnterpriseApplicationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/RemoveComponentFromEnterpriseApplicationOperation.java deleted file mode 100644 index c90763a5a..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/RemoveComponentFromEnterpriseApplicationOperation.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -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.application.Application; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentOperation; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class RemoveComponentFromEnterpriseApplicationOperation extends RemoveReferenceComponentOperation { - - - public RemoveComponentFromEnterpriseApplicationOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - J2EEComponentClasspathUpdater.getInstance().pauseUpdates(); - updateEARDD(monitor); - super.execute(monitor, info); - return OK_STATUS; - } finally { - J2EEComponentClasspathUpdater.getInstance().resumeUpdates(); - } - } - - protected void updateEARDD(IProgressMonitor monitor) { - EARArtifactEdit earEdit = null; - try { - IVirtualComponent comp = (IVirtualComponent) model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT); - if (!comp.getProject().isAccessible()) - return; - J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(comp.getProject()); - earEdit = EARArtifactEdit.getEARArtifactEditForWrite(comp.getProject()); - if (earEdit != null) { - Application application = earEdit.getApplication(); - List list = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - if (list != null && list.size() > 0) { - for (int i = 0; i < list.size(); i++) { - IVirtualComponent wc = (IVirtualComponent) list.get(i); - String moduleURI = getModuleURI(earEdit, wc); - removeModule(application, moduleURI); - IVirtualFile vFile = comp.getRootFolder().getFile(moduleURI); - IFile iFile = vFile.getUnderlyingFile(); - if(iFile.exists()){ - iFile.delete(true, monitor); - } - } - } - } - earEdit.saveIfNecessary(monitor); - } catch (Exception e) { - Logger.getLogger().logError(e); - } finally { - if (earEdit != null) - earEdit.dispose(); - } - } - - protected String getModuleURI(final EARArtifactEdit earEdit, final IVirtualComponent targetComponent) { - return earEdit.getModuleURI(targetComponent); - } - - protected void removeModule(final Application application, final String moduleURI) { - Module module = application.getFirstModule(moduleURI); - application.getModules().remove(module); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModelProperties.java deleted file mode 100644 index 36573c508..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModelProperties.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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; - -public interface UpdateManifestDataModelProperties { - /** - * 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$ - - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModelProvider.java deleted file mode 100644 index 5a7c6116b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestDataModelProvider.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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.Set; -import com.ibm.icu.util.StringTokenizer; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class UpdateManifestDataModelProvider extends AbstractDataModelProvider implements UpdateManifestDataModelProperties { - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(PROJECT_NAME); - propertyNames.add(JAR_LIST); - propertyNames.add(JAR_LIST_TEXT_UI); - propertyNames.add(MERGE); - propertyNames.add(MAIN_CLASS); - propertyNames.add(MANIFEST_FILE); - return propertyNames; - } - - public 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 boolean propertySet(String propertyName, Object propertyValue) { - boolean set = super.propertySet(propertyName, propertyValue); - if (propertyName.equals(JAR_LIST) && isPropertySet(JAR_LIST_TEXT_UI)) - setProperty(JAR_LIST_TEXT_UI, getClasspathAsString()); - return set; - } - - 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; - } - - public IDataModelOperation getDefaultOperation() { - return new UpdateManifestOperation(model); - } -} 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 7c1ff049e..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateManifestOperation.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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 org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -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.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * @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 AbstractDataModelOperation { - - public UpdateManifestOperation(IDataModel dataModel) { - super(dataModel); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable adaptable) throws ExecutionException { - IFile file = (IFile)model.getProperty(UpdateManifestDataModelProperties.MANIFEST_FILE); - - String classPathValue = model.getStringProperty(UpdateManifestDataModelProperties.JAR_LIST_TEXT_UI); - try { - ArchiveManifest mf = J2EEProjectUtilities.readManifest(file); - - if (mf == null) - mf = new ArchiveManifestImpl(); - mf.addVersionIfNecessary(); - if (model.getBooleanProperty(UpdateManifestDataModelProperties.MERGE)) { - mf.mergeClassPath(ArchiveUtil.getTokens(classPathValue)); - } else { - mf.setClassPath(classPathValue); - } - if (model.isPropertySet(UpdateManifestDataModelProperties.MAIN_CLASS)) { - mf.setMainClass(model.getStringProperty(UpdateManifestDataModelProperties.MAIN_CLASS)); - } - - J2EEProjectUtilities.writeManifest(file, mf); - } catch (java.io.IOException ex) { - throw new ExecutionException(ex.getMessage(),ex); - } - return OK_STATUS; - } - - 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/UpdateModuleContextRootInEAROp.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateModuleContextRootInEAROp.java deleted file mode 100644 index cf16b571d..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/UpdateModuleContextRootInEAROp.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 BEA Systems, Inc - * 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: - * rfrost@bea.com - initial API and impl - *******************************************************************************/ -package org.eclipse.jst.j2ee.application.internal.operations; - -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -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.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.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * <code>AbstractDataModelOperation</code> subclass that updates the context-root for a given - * module within the application.xml files of all containing EARs. - */ -public class UpdateModuleContextRootInEAROp extends AbstractDataModelOperation implements IUpdateModuleContextRootProperties { - - public UpdateModuleContextRootInEAROp() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus execute(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { - if(monitor != null) { - monitor.beginTask("", 1); - } - - try { - final String newContextRoot = model.getStringProperty(CONTEXT_ROOT); - final IProject project = (IProject) model.getProperty(PROJECT); - final IDataModel nestedModel = model.getNestedModel(NESTED_MODEL_ID); - if (nestedModel != null) { - List earsToUpdate= (List) nestedModel.getProperty(EARS_TO_UPDATE); - if (newContextRoot != null && earsToUpdate != null && project != null) { - // update each specified EAR - for (int i = 0; i < earsToUpdate.size(); i++) { - updateEARContextRoot((IProject) earsToUpdate.get(i), project, newContextRoot, monitor); - } - } - } - } catch (Exception e) { - Logger.getLogger().logError(e); - } finally { - if (monitor != null) { - monitor.done(); - } - } - return OK_STATUS; - } - - /* - * Updates the context-root element int the application.xml of the specified EAR for the specified - * module project to the new value. - */ - private void updateEARContextRoot(final IProject ear, final IProject project, final String newContextRoot, - final IProgressMonitor monitor) { - EARArtifactEdit earEdit = null; - try { - earEdit = EARArtifactEdit.getEARArtifactEditForWrite(ear); - if (earEdit != null) { - final Application application = earEdit.getApplication(); - final IVirtualComponent comp = ComponentCore.createComponent(project); - if (comp == null) { - return; - } - final String moduleURI = earEdit.getModuleURI(comp); - final Module module = application.getFirstModule(moduleURI); - if (module != null && module instanceof WebModule) { - ((WebModule) module).setContextRoot(newContextRoot); - } - earEdit.saveIfNecessary(monitor); - } - } finally { - if (earEdit != null) { - earEdit.dispose(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // no-op - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // no-op - return null; - } - -} 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 ad7eab8e8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARArtifactEdit.java +++ /dev/null @@ -1,630 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.componentcore.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -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.application.Module; -import org.eclipse.jst.j2ee.application.WebModule; -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.componentcore.EnterpriseArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.archive.operations.EARComponentLoadStrategyImpl; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -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.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.util.IArtifactEditFactory; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -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 implements IArtifactEditFactory { - - public static final Class ADAPTER_TYPE = EARArtifactEdit.class; - - private static final IVirtualReference[] NO_REFERENCES = new IVirtualReference[0]; - - /** - * - */ - public EARArtifactEdit() { - super(); - } - - /** - * @param aHandle - * @param toAccessAsReadOnly - * @throws IllegalArgumentException - */ - public EARArtifactEdit(IProject aProject, boolean toAccessAsReadOnly) throws IllegalArgumentException { - super(aProject, toAccessAsReadOnly); - } - - // This should be revereted to protected when 115924 is fixed - public EARArtifactEdit(IProject aProject, boolean toAccessAsReadOnly, boolean forCreate) throws IllegalArgumentException { - super(aProject, toAccessAsReadOnly, forCreate, J2EEProjectUtilities.ENTERPRISE_APPLICATION); - } - - /** - * <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(IProject aProject) { - EARArtifactEdit artifactEdit = null; - try { - if (isValidEARModule(ComponentCore.createComponent(aProject))) - artifactEdit = new EARArtifactEdit(aProject, true, false); - } catch (Exception 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(IProject aProject) { - EARArtifactEdit artifactEdit = null; - try { - if (isValidEARModule(ComponentCore.createComponent(aProject))) - artifactEdit = new EARArtifactEdit(aProject, false, false); - } catch (Exception 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) { - if (aModule == null) - return null; - return getEARArtifactEditForRead(aModule.getProject()); - } - - - /** - * <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) { - if (aModule == null) - return null; - return getEARArtifactEditForWrite(aModule.getProject()); - } - - /** - * @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; - return J2EEProjectUtilities.isEARProject(aModule.getProject()); - } - - /** - * <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} - */ - - - protected 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(J2EEConstants.APPLICATION_DD_URI_OBJ); - } - - - /** - * <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) { - StructureEdit edit = null; - try { - edit = StructureEdit.getStructureEditForRead(getProject()); - if (edit!=null && edit.getComponent()!=null) { - List referencedComps = edit.getComponent().getReferencedComponents(); - for (int i=0; i<referencedComps.size(); i++) { - ReferencedComponent ref = (ReferencedComponent) referencedComps.get(i); - Object module = ref.getDependentObject(); - if (module!=null && module instanceof Module) { - String existingURI = ((Module)module).getUri(); - if (existingURI!=null && existingURI.equals(currentURI)) - return true; - } - } - } - } finally { - if (edit != null) - edit.dispose(); - } - return false; - } - - /* - * (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 - an array of IVirtualReferences for utility modules in the EAR - */ - public IVirtualReference[] getUtilityModuleReferences() { - - List explicitUtilityReferences = - getComponentReferencesAsList(Collections.singletonList(J2EEProjectUtilities.UTILITY)); - - // fetch other Utility Jars attached to the EAR project - List implicitUtilityReferenceTypes = - Arrays.asList(new String[] { IModuleConstants.JST_APPCLIENT_MODULE, - IModuleConstants.JST_WEB_MODULE, - IModuleConstants.JST_EJB_MODULE }); - - List implicitUtilityReferences = - getComponentReferencesAsList(implicitUtilityReferenceTypes); - - - Application application = getApplication(); - Module module = null; - IVirtualReference reference = null; - for (Iterator referenceItr = implicitUtilityReferences.iterator(); referenceItr.hasNext(); ) { - reference = (IVirtualReference) referenceItr.next(); - module = application.getFirstModule(reference.getArchiveName()); - if(module != null) - referenceItr.remove(); - } - - List allUtilityModuleReferences = new ArrayList(); - allUtilityModuleReferences.addAll(explicitUtilityReferences); - allUtilityModuleReferences.addAll(implicitUtilityReferences); - - if(allUtilityModuleReferences.size() > 0) - return (IVirtualReference[]) allUtilityModuleReferences.toArray(new IVirtualReference[allUtilityModuleReferences.size()]); - return NO_REFERENCES; - - } - - public String getModuleURI(IVirtualComponent moduleComp) { - IVirtualReference [] refs = getComponent().getReferences(); - for(int i=0; i<refs.length; i++){ - if(refs[i].getReferencedComponent().equals(moduleComp)){ - return refs[i].getArchiveName(); - } - } - return null; - } - - private String getJarURI(final ReferencedComponent ref, final IVirtualComponent moduleComp) { - String uri = ref.getArchiveName(); - if( uri == null || uri.length() < 0 ){ - uri = moduleComp.getName()+IJ2EEModuleConstants.JAR_EXT; - }else{ - String prefix = ref.getRuntimePath().makeRelative().toString(); - if(prefix.length() > 0){ - uri = prefix + "/" + uri; //$NON-NLS-1$ - } - } - return uri; - } - - public IVirtualComponent getModuleByManifestURI(final String uri) { - IVirtualComponent earComponent = ComponentCore.createComponent(getProject()); - IVirtualReference [] refs = earComponent.getReferences(); - - for(int i=0;i<refs.length; i++){ - if(refs[i].getArchiveName().equals(uri)){ - return refs[i].getReferencedComponent(); - } - } - return null; - } - - /** - * This method will return the an IVirtualComponent for the given module name. The method take - * either moduleName or moduleName + ".module_extension" (module_extension = ".jar" || ".war" || - * ".rar") which allows users to get a IVirtualComponent for a given entry in an application.xml - * - * @return - a IVirtualComponent for module name - */ - public IVirtualComponent getModule(String moduleName) { - if (moduleName == null) - return null; - if (moduleName.endsWith(IJ2EEModuleConstants.JAR_EXT) || moduleName.endsWith(IJ2EEModuleConstants.WAR_EXT) || moduleName.endsWith(IJ2EEModuleConstants.RAR_EXT)) - moduleName = moduleName.substring(0, (moduleName.length() - IJ2EEModuleConstants.JAR_EXT.length())); - IVirtualReference[] references = getComponentReferences(); - for (int i = 0; i < references.length; i++) { - IVirtualComponent component = references[i].getReferencedComponent(); - if (component.getName().equals(moduleName)) { - return component; - } - } - return null; - } - - /** - * This method will return the list of IVirtualReferences for the J2EE module components - * contained in this EAR application. - * - * @return - an array of IVirtualReferences for J2EE modules in the EAR - */ - public IVirtualReference[] getJ2EEModuleReferences() { - List j2eeTypes = new ArrayList(); - j2eeTypes.add(J2EEProjectUtilities.APPLICATION_CLIENT); - j2eeTypes.add(J2EEProjectUtilities.JCA); - j2eeTypes.add(J2EEProjectUtilities.EJB); - j2eeTypes.add(J2EEProjectUtilities.DYNAMIC_WEB); - return getComponentReferences(j2eeTypes); - } - - /** - * This method will return the list of IVirtualReferences for all of the components contained in - * this EAR application. - * - * @return - an array of IVirtualReferences for components in the EAR - */ - public IVirtualReference[] getComponentReferences() { - return getComponentReferences(Collections.EMPTY_LIST); - } - - /** - * This method will return the IVirtualReference to the component of the given name - * - * @return - IVirtualReference or null if not found - */ - public IVirtualReference getComponentReference(String componentName) { - IVirtualReference[] refs = getComponentReferences(Collections.EMPTY_LIST); - for (int i = 0; i < refs.length; i++) { - IVirtualReference reference = refs[i]; - if (reference.getReferencedComponent().getName().equals(componentName)) - return reference; - - } - return null; - } - - private IVirtualReference[] getComponentReferences(List componentTypes) { - List components = getComponentReferencesAsList(componentTypes); - if(components.size() > 0) - return (IVirtualReference[]) components.toArray(new IVirtualReference[components.size()]); - return NO_REFERENCES; - } - - /** - * - * @param componentTypes - * @return A List of {@link IVirtualReference}s. - */ - private List getComponentReferencesAsList(List componentTypes) { - List components = new ArrayList(); - IVirtualComponent earComponent = getComponent(); - if (earComponent != null && J2EEProjectUtilities.isEARProject(earComponent.getProject())) { - IVirtualReference[] refComponents = earComponent.getReferences(); - for (int i = 0; i < refComponents.length; i++) { - IVirtualComponent module = refComponents[i].getReferencedComponent(); - if (module == null) - continue; - // if component types passed in is null then return all components - if (componentTypes == null || componentTypes.size() == 0) - components.add(refComponents[i]); - else { - if (componentTypes.contains(J2EEProjectUtilities.getJ2EEComponentType(module))) { - components.add(refComponents[i]); - } - } - } - } - return components; - } - - public ArtifactEdit createArtifactEditForRead(IVirtualComponent aComponent) { - - return getEARArtifactEditForRead(aComponent); - } - - public ArtifactEdit createArtifactEditForWrite(IVirtualComponent aComponent) { - - return getEARArtifactEditForWrite(aComponent); - } - - public Archive asArchive(boolean includeSource) throws OpenFailureException { - EARComponentLoadStrategyImpl loader = new EARComponentLoadStrategyImpl(getComponent()); - loader.setExportSource(includeSource); - String uri = ModuleURIUtil.getHandleString(getComponent()); - return CommonarchiveFactory.eINSTANCE.openEARFile(loader, uri); - } - - public static void createDeploymentDescriptor(IProject project, int version) { - EARArtifactEdit earEdit = new EARArtifactEdit(project, false, true); - try { - earEdit.createModelRoot(version); - earEdit.save(null); - } finally { - earEdit.dispose(); - } - } - - /** - * This method will return the context root in this application for the passed in web project. - * - * @param webProject - * @return contextRoot String - */ - public String getWebContextRoot(IProject webProject) { - if (webProject == null || !J2EEProjectUtilities.isDynamicWebProject(webProject)) - return null; - IVirtualComponent webComp = ComponentCore.createComponent(webProject); - String webModuleURI = getModuleURI(webComp); - if (webModuleURI != null) { - WebModule webModule = (WebModule) getApplication().getModule(webModuleURI, null); - if (webModule != null) - return webModule.getContextRoot(); - } - return null; - } - - /** - * This method will set the context root on the application for the passed in contextRoot. This - * must be called in a write artifact edit and be saved for changes to be saved. - * - * @param webProject - * @param aContextRoot - */ - public void setWebContextRoot(IProject webProject, String aContextRoot) { - if (webProject == null || !J2EEProjectUtilities.isDynamicWebProject(webProject)) - return; - IVirtualComponent webComp = ComponentCore.createComponent(webProject); - String webModuleURI = getModuleURI(webComp); - if (webModuleURI != null) { - WebModule webModule = (WebModule) getApplication().getModule(webModuleURI, null); - if (webModule != null) - webModule.setContextRoot(aContextRoot); - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java deleted file mode 100644 index 1bac55444..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.componentcore.util; - -import java.util.ArrayList; -import java.util.Iterator; -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.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; -import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -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.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualFolder; -import org.eclipse.wst.common.componentcore.internal.util.IComponentImplFactory; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -public class EARVirtualComponent extends VirtualComponent implements IComponentImplFactory { - - /** - * @deprecated - * @return - * @see DoNotUseMeThisWillBeDeletedPost15 - */ - protected IVirtualFolder defaultRootFolder; - - public EARVirtualComponent() { - super(); - } - - public EARVirtualComponent(IProject aProject, IPath aRuntimePath) { - super(aProject, aRuntimePath); - defaultRootFolder = new VirtualFolder(aProject, new Path("/")); //$NON-NLS-1$ - } - - public IVirtualComponent createArchiveComponent(IProject aProject, String archiveLocation, IPath aRuntimePath) { - return new J2EEModuleVirtualArchiveComponent(aProject, archiveLocation, aRuntimePath); - } - - public IVirtualComponent createComponent(IProject aProject) { - return new EARVirtualComponent(aProject, new Path("/")); //$NON-NLS-1$ - } - - public IVirtualFolder createFolder(IProject aProject, IPath aRuntimePath) { - return new EARVirtualRootFolder(aProject, aRuntimePath); - } - - private static String getJarURI(final ReferencedComponent ref, final IVirtualComponent moduleComp) { - String uri = ref.getArchiveName(); - if (uri == null || uri.length() < 0) { - if(moduleComp.isBinary()){ - uri = new Path(moduleComp.getName()).lastSegment(); - } else { - uri = moduleComp.getName() + IJ2EEModuleConstants.JAR_EXT; - } - } else { - String prefix = ref.getRuntimePath().makeRelative().toString(); - if (prefix.length() > 0) { - uri = prefix + "/" + uri; //$NON-NLS-1$ - } - } - return uri; - } - - private static List getHardReferences(IVirtualComponent earComponent) { - StructureEdit core = null; - List hardReferences = new ArrayList(); - try { - core = StructureEdit.getStructureEditForRead(earComponent.getProject()); - if (core != null && core.getComponent() != null) { - WorkbenchComponent component = core.getComponent(); - if (component != null) { - List referencedComponents = component.getReferencedComponents(); - for (Iterator iter = referencedComponents.iterator(); iter.hasNext();) { - ReferencedComponent referencedComponent = (ReferencedComponent) iter.next(); - if (referencedComponent == null) - continue; - IVirtualReference vReference = StructureEdit.createVirtualReference(earComponent, referencedComponent); - if (vReference != null) { - IVirtualComponent referencedIVirtualComponent = vReference.getReferencedComponent(); - if (referencedIVirtualComponent != null && referencedIVirtualComponent.exists()) { - String archiveName = null; - if (referencedComponent.getDependentObject() != null) { - archiveName = ((Module) referencedComponent.getDependentObject()).getUri(); - } else { - if (referencedIVirtualComponent.isBinary()) { - archiveName = getJarURI(referencedComponent, referencedIVirtualComponent); - } else { - IProject referencedProject = referencedIVirtualComponent.getProject(); - // If dependent object is not set, assume - // compname is module name + proper - // extension - if (J2EEProjectUtilities.isDynamicWebProject(referencedProject) || J2EEProjectUtilities.isStaticWebProject(referencedProject)) { - archiveName = referencedIVirtualComponent.getName() + IJ2EEModuleConstants.WAR_EXT; - } else if (J2EEProjectUtilities.isJCAProject(referencedProject)) { - archiveName = referencedIVirtualComponent.getName() + IJ2EEModuleConstants.RAR_EXT; - } else if (J2EEProjectUtilities.isUtilityProject(referencedProject)) { - archiveName = getJarURI(referencedComponent, referencedIVirtualComponent); - } else { - archiveName = referencedIVirtualComponent.getName() + IJ2EEModuleConstants.JAR_EXT; - } - } - } - vReference.setArchiveName(archiveName); - hardReferences.add(vReference); - } - } - } - } - } - } finally { - if (core != null) - core.dispose(); - } - return hardReferences; - } - - /** - * Returns the resulting list of referenced components based off the hard references and archives mapping to the root folder. - * - * @param earComponent - * @param hardReferences - * @param membersToIgnore - * @return - */ - private static List getLooseArchiveReferences(EARVirtualComponent earComponent, List hardReferences) { - return getLooseArchiveReferences(earComponent, hardReferences, null, (EARVirtualRootFolder)earComponent.getRootFolder()); - } - - private static List getLooseArchiveReferences(EARVirtualComponent earComponent, List hardReferences, List dynamicReferences, EARVirtualRootFolder folder) { - try { - IVirtualResource[] members = folder.superMembers(); - for (int i = 0; i < members.length; i++) { - if (IVirtualResource.FILE == members[i].getType()) { - if(folder.isDynamicComponent((IVirtualFile)members[i])){ - String archiveName = members[i].getRuntimePath().toString().substring(1); - boolean shouldInclude = true; - for (int j = 0; j < hardReferences.size() && shouldInclude; j++) { - String tempArchiveName = ((IVirtualReference) hardReferences.get(j)).getArchiveName(); - if (null != tempArchiveName && tempArchiveName.equals(archiveName)) { - shouldInclude = false; - } - } - if (shouldInclude) { - IResource iResource = members[i].getUnderlyingResource(); - IVirtualComponent dynamicComponent = ComponentCore.createArchiveComponent(earComponent.getProject(), VirtualArchiveComponent.LIBARCHIVETYPE + iResource.getFullPath().toString()); - IVirtualReference dynamicRef = ComponentCore.createReference(earComponent, dynamicComponent); - dynamicRef.setArchiveName(archiveName); - if (null == dynamicReferences) { - dynamicReferences = new ArrayList(); - } - dynamicReferences.add(dynamicRef); - } - } - } else if(IVirtualResource.FOLDER == members[i].getType()){ - dynamicReferences = getLooseArchiveReferences(earComponent, hardReferences, dynamicReferences, (EARVirtualRootFolder)members[i]); - } - } - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - return dynamicReferences; - } - - public IVirtualReference[] getReferences() { - List hardReferences = getHardReferences(this); - List dynamicReferences = getLooseArchiveReferences(this, hardReferences); - - if (dynamicReferences != null) { - hardReferences.addAll(dynamicReferences); - } - - return (IVirtualReference[]) hardReferences.toArray(new IVirtualReference[hardReferences.size()]); - } - - /** - * @deprecated - * @return - * @see DoNotUseMeThisWillBeDeletedPost15 - */ - public IVirtualFolder getDefaultRootFolder() { - return defaultRootFolder; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualRootFolder.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualRootFolder.java deleted file mode 100644 index 56a7e3a2b..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualRootFolder.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.eclipse.jst.j2ee.componentcore.util; - -import java.util.ArrayList; -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.IPath; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -//TODO this should be renamed to EARVirtualFolder because it is not used only for the root. -public class EARVirtualRootFolder extends VirtualFolder { - - public EARVirtualRootFolder(IProject aComponentProject, IPath aRuntimePath) { - super(aComponentProject, aRuntimePath); - } - - public static String [] EXTENSIONS_TO_IGNORE = new String [] {".jar", ".zip", ".rar", ".war" }; - - public IVirtualResource[] superMembers() throws CoreException { - return superMembers(IResource.NONE); - } - - public IVirtualResource[] superMembers(int memberFlags) throws CoreException { - return super.members(memberFlags); - } - - public boolean isDynamicComponent(IVirtualFile vFile){ - String archiveName = vFile.getName(); - for(int j = 0; j<EXTENSIONS_TO_IGNORE.length; j++){ - if(J2EEComponentClasspathUpdater.endsWithIgnoreCase(archiveName, EXTENSIONS_TO_IGNORE[j])){ - return true; - } - } - return false; - } - - /** - * For now, just rip out files with .jar, .rar, or .war file extensions, because these are - * the only files automatically added dyamically - */ - public IVirtualResource[] members(int memberFlags) throws CoreException { - IVirtualResource[] members = superMembers(memberFlags); - List virtualResources = new ArrayList(); - boolean shouldAdd = true; - for (int i = 0; i < members.length; i++) { - shouldAdd = true; - if (IVirtualResource.FILE == members[i].getType()) { - if(isDynamicComponent((IVirtualFile)members[i])){ - shouldAdd = false; - } - } - if (shouldAdd) { - virtualResources.add(members[i]); - } - } - return (IVirtualResource[]) virtualResources - .toArray(new IVirtualResource[virtualResources.size()]); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/package.xml b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/package.xml deleted file mode 100644 index aec496d4e..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/package.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../../../" /> - <title>EJBArtifactEdit api overview</title> - </head> - - <body> - <abstract> - This package includes the EARArtifactEdit api. This api is used to work with the emf model - of a flexible EAR module. It contains api to read and serialize out the emf model for enterprise applications. - </abstract> - - <a href="#top">top</a> - </body> -</html> -
\ 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 f9ef5e227..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/DefaultJ2EEComponentCreationDataModelProvider.java +++ /dev/null @@ -1,423 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 java.util.Set; - -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.applicationclient.internal.creation.AppClientFacetProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -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.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -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.WTPPlugin; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -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$ - - private IDataModel ejbModel; - private IDataModel ejbFacetModel; - private IDataModel webModel; - private IDataModel webFacetModel; - private IDataModel jcaModel; - private IDataModel jcaFacetModel; - private IDataModel clientModel; - private IDataModel clientFacetModel; - - public DefaultJ2EEComponentCreationDataModelProvider() { - super(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(PROJECT_NAME); - propertyNames.add(EAR_COMPONENT_NAME); - propertyNames.add(APPCLIENT_COMPONENT_NAME); - propertyNames.add(WEB_COMPONENT_NAME); - propertyNames.add(EJB_COMPONENT_NAME); - propertyNames.add(CONNECTOR_COMPONENT_NAME); - propertyNames.add(J2EE_VERSION); - propertyNames.add(CREATE_EJB); - propertyNames.add(CREATE_WEB); - propertyNames.add(CREATE_APPCLIENT); - propertyNames.add(CREATE_CONNECTOR); - propertyNames.add(MODULE_NAME_COLLISIONS_VALIDATION); - propertyNames.add(ENABLED); - propertyNames.add(NESTED_MODEL_CLIENT); - propertyNames.add(NESTED_MODEL_EJB); - propertyNames.add(NESTED_MODEL_JCA); - propertyNames.add(NESTED_MODEL_WEB); - propertyNames.add(FACET_RUNTIME); - return propertyNames; - } - - - public IDataModelOperation getDefaultOperation() { - return new DefaultJ2EEComponentCreationOperation(model); - } - - public void init() { - initNestedCreationModels(); - super.init(); - } - - protected void initNestedCreationModels() { - clientModel = DataModelFactory.createDataModel(new AppClientFacetProjectCreationDataModelProvider()); - model.addNestedModel(NESTED_MODEL_CLIENT, clientModel); - clientFacetModel = ((FacetDataModelMap)clientModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP)).getFacetDataModel(J2EEProjectUtilities.APPLICATION_CLIENT); - clientFacetModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, false); - - EjbModuleExtension ejbExt = EarModuleManager.getEJBModuleExtension(); - if (ejbExt != null) { - ejbModel = ejbExt.createProjectDataModel(); - if (ejbModel != null){ - model.addNestedModel(NESTED_MODEL_EJB, ejbModel); - ejbFacetModel = ((FacetDataModelMap)ejbModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP)).getFacetDataModel(J2EEProjectUtilities.EJB); - ejbFacetModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, false); - } - } - WebModuleExtension webExt = EarModuleManager.getWebModuleExtension(); - if (webExt != null) { - webModel = webExt.createProjectDataModel(); - if (webModel != null){ - model.addNestedModel(NESTED_MODEL_WEB, webModel); - webFacetModel = ((FacetDataModelMap)webModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP)).getFacetDataModel(J2EEProjectUtilities.DYNAMIC_WEB); - webFacetModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, false); - } - } - JcaModuleExtension rarExt = EarModuleManager.getJCAModuleExtension(); - if (rarExt != null) { - jcaModel = rarExt.createProjectDataModel(); - if (jcaModel != null){ - model.addNestedModel(NESTED_MODEL_JCA, jcaModel); - jcaFacetModel = ((FacetDataModelMap)jcaModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP)).getFacetDataModel(J2EEProjectUtilities.JCA); - jcaFacetModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, false); - } - } - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.startsWith(CREATE_BASE)) - return getDefaultCreateValue(propertyName); - if (propertyName.equals(ENABLED)) - return Boolean.TRUE; - return super.getDefaultProperty(propertyName); - } - - - 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; - } - - 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; - } - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean notify = super.propertySet(propertyName, propertyValue); - if (propertyName.equals(J2EE_VERSION)) { - updatedJ2EEVersion((Integer) propertyValue); - return true; - }else if (propertyName.startsWith(CREATE_BASE)){ - notifyEnablement(convertPropertyNameToInt(propertyName)); - }else if (propertyName.equals(EAR_COMPONENT_NAME)) { - setDefaultComponentNames((String) propertyValue); - }else if(webModel != null && propertyName.equals(WEB_COMPONENT_NAME)){ - webModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, propertyValue); - }else if(clientModel != null && propertyName.equals(APPCLIENT_COMPONENT_NAME)){ - clientModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, propertyValue); - }else if(ejbModel != null && propertyName.equals(EJB_COMPONENT_NAME)){ - ejbModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, propertyValue); - }else if(jcaModel != null && propertyName.equals(CONNECTOR_COMPONENT_NAME)){ - jcaModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, propertyValue); - } - else if(FACET_RUNTIME.equals(propertyName)){ - if(webModel != null){ - webModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, propertyValue); - } - if(clientModel != null){ - clientModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, propertyValue); - } - if(ejbModel != null){ - ejbModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, propertyValue); - } - if(jcaModel != null){ - jcaModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, propertyValue); - } - } - 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(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - projectName = WTPPlugin.isPlatformCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase(); - list.add(projectName); - errorNoSelection = false; - } - if (getBooleanProperty(CREATE_EJB)) { - actualProjectName = ejbModel.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - projectName = WTPPlugin.isPlatformCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase(); - if (!list.contains(projectName)) { - list.add(projectName); - } else { - errorCollision = true; - } - errorNoSelection = false; - } - if (!errorCollision && getBooleanProperty(CREATE_WEB)) { - actualProjectName = webModel.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - projectName = WTPPlugin.isPlatformCaseSensitive() ? actualProjectName : actualProjectName.toLowerCase(); - if (!list.contains(projectName)) { - list.add(projectName); - } else { - errorCollision = true; - } - errorNoSelection = false; - } - if (!errorCollision && getBooleanProperty(CREATE_CONNECTOR)) { - actualProjectName = jcaModel.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - projectName = WTPPlugin.isPlatformCaseSensitive() ? 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.NoModulesSelected, null); - } - } - - return OK_STATUS; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModel#doValidateProperty(java.lang.String) - */ - public IStatus validate(String propertyName) { - - if (getBooleanProperty(CREATE_APPCLIENT) && propertyName.equals(APPCLIENT_COMPONENT_NAME)) { - return clientModel.validateProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - } - - if (getBooleanProperty(CREATE_WEB) && propertyName.equals(WEB_COMPONENT_NAME)) { - return webModel.validateProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - } - - if (getBooleanProperty(CREATE_EJB) && propertyName.equals(EJB_COMPONENT_NAME)) { - return ejbModel.validateProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - } - - if (getBooleanProperty(CREATE_CONNECTOR) && propertyName.equals(CONNECTOR_COMPONENT_NAME)) { - return jcaModel.validateProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_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); -// 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(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, compName); - } - } - - 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); - } - - private void setNestedJ2EEVersion(Object j2eeVersion) { - int j2eeVer = ((Integer) j2eeVersion).intValue(); - if (ejbFacetModel != null) { - String facetVersionString = J2EEVersionUtil.convertVersionIntToString(J2EEVersionUtil.convertJ2EEVersionIDToEJBVersionID(j2eeVer)); - IProjectFacetVersion facetVersion = ProjectFacetsManager.getProjectFacet(ejbFacetModel.getStringProperty(IFacetDataModelProperties.FACET_ID)).getVersion(facetVersionString); - ejbFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, facetVersion); - } - if (webFacetModel != null) { - String facetVersionString = J2EEVersionUtil.convertVersionIntToString(J2EEVersionUtil.convertJ2EEVersionIDToWebVersionID(j2eeVer)); - IProjectFacetVersion facetVersion = ProjectFacetsManager.getProjectFacet(webFacetModel.getStringProperty(IFacetDataModelProperties.FACET_ID)).getVersion(facetVersionString); - webFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, facetVersion); - } - if (jcaFacetModel != null) { - String facetVersionString = J2EEVersionUtil.convertVersionIntToString(J2EEVersionUtil.convertJ2EEVersionIDToConnectorVersionID(j2eeVer)); - IProjectFacetVersion facetVersion = ProjectFacetsManager.getProjectFacet(jcaFacetModel.getStringProperty(IFacetDataModelProperties.FACET_ID)).getVersion(facetVersionString); - jcaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, facetVersion); - } - if (clientFacetModel != null){ - String facetVersionString = J2EEVersionUtil.convertVersionIntToString(j2eeVer); - IProjectFacetVersion facetVersion = ProjectFacetsManager.getProjectFacet(clientFacetModel.getStringProperty(IFacetDataModelProperties.FACET_ID)).getVersion(facetVersionString); - clientFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, facetVersion); - } - } - - 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; - } - - public boolean isPropertyEnabled(String propertyName) { - if (propertyName.equals(CREATE_CONNECTOR)) { - int version = getIntProperty(J2EE_VERSION); - return version > J2EEVersionConstants.J2EE_1_2_ID; - } - if( propertyName.equals(CONNECTOR_COMPONENT_NAME)){ - return getBooleanProperty(CREATE_CONNECTOR); - } - 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/EARCreationResourceHandler.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARCreationResourceHandler.java deleted file mode 100644 index 79e50f08f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EARCreationResourceHandler.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 org.eclipse.osgi.util.NLS; - -public class EARCreationResourceHandler extends NLS { - - private static final String BUNDLE_NAME = "earcreation";//$NON-NLS-1$ - - private EARCreationResourceHandler() { - // Do not instantiate - } - - public static String Error_occured_getting_appl_ERROR_; - public static String Error_occured_getting_appl1_ERROR_; - public static String Creating__UI_; - public static String Creating_EAR_Project_UI_; - public static String The_project_already_exist_ERROR_; - public static String EARProjectCreationOperatio_ERROR_; - public static String ABS_PATH_CHANGED_UI_; - public static String UNSAVED_CHANGES_WARN_; - public static String PROJECT_MAP_PROBLEMS_ERROR_; - public static String MODULE_PROJECTS_CLOSED_WARN_; - public static String Add_Module_Command_Label_UI_; - public static String Remove_Module_Command_Label_UI_; - - public static String Set_project_UI_; - public static String Add_Utility_JAR_UI; - public static String REM_UTIL_JAR_UI; - public static String PROJ_DESC_UPDATE_ERROR_UI_; - public static String Not_an_ear_project_UI_; - public static String EAR_PROJECT_MUST_BE_OPEN_UI_; - public static String Updating_absolute_paths_UI_; - public static String DuplicateModuleNames; - public static String NoModulesSelected; - - public static String KEY_1; - public static String KEY_2; - public static String KEY_3; - public static String KEY_4; - public static String KEY_5; - public static String KEY_6; - public static String KEY_7; - public static String KEY_8; - public static String KEY_9; - public static String KEY_10; - public static String KEY_11; - public static String KEY_12; - public static String KEY_13; - public static String KEY_14; - public static String KEY_15; - public static String KEY_16; - - public static String J2EEUtilityJarListImportOperation_UI_Import_Utility_Jars; - public static String J2EEUtilityJarListImportOperation_UI_Preparing_to_import; - public static String J2EEUtilityJarListImportOperation_UI_2; - public static String J2EEUtilityJarListImportDataModel_0; - public static String J2EEUtilityJarListImportDataModel_Specify_Valid_Project; - public static String J2EEUtilityJarListImportDataModel_Select_Jar; - public static String J2EEUtilityJarListImportDataModel_Specify_Linked_Path; - public static String J2EEUtilityJarListImportOperation_There_were_no_utility_jars_selected; - public static String J2EEUtilityJarListImportDataModel_Linked_Path_Exists; - - - public static String CreateProjectWithExtractedJarOperation_Create_project_with_extracted_conte_; - public static String CopyArchiveIntoProjectOperation_Copying_archive_into_selected_proje_; - public static String CopyArchiveIntoProjectOperation_Found_existing_file_0_; - public static String CreateProjectWithLinkedJarOperation_Creating_project_with_linked_archiv_; - public static String CreateProjectWithLinkedJarOperation_Cannot_link_utility_jar_into_a_clos_; - public static String CreateProjectWithLinkedJarOperation_File_already_exists_0_; - public static String LinkArchiveIntoProjectOperation_Linking_archive_into_selected_proje_; - - public static String EARImportDataModel_UI_0; - public static String EARImportDataModel_UI_1; - public static String EARImportDataModel_UI_1a; - public static String EARImportDataModel_UI_2; - public static String EARImportDataModel_UI_2a; - public static String EARImportDataModel_UI_3; - public static String EARImportDataModel_UI_4; - public static String ModuleMappingImpl_UI_0; - public static String UtilityJARMappingImpl_UI_0; - public static String importWrongType; - public static String importWrongVersion; - public static String EAR_PROJECTNAME_SAMEAS_MODULE; - - static { - NLS.initializeMessages(BUNDLE_NAME, EARCreationResourceHandler.class); - } - - public static String getString(String key, Object[] args) { - return NLS.bind(key, args); - } - - public static final String ADD_MODULE_MODULE_TYPE = KEY_1; - public static final String ADD_MODULE_MODULE_EXISTS = KEY_2; - public static final String ADD_MODULE_MODULE_CLOSED = KEY_3; - public static final String ADD_MODULE_MODULE_NULL = KEY_4; - public static final String ADD_PROJECT_URI_EXISTS = KEY_5; - public static final String ADD_PROJECT_NOT_JAVA = KEY_6; - public static final String ADD_PROJECT_UTIL_URI = KEY_7; - public static final String ADD_PROJECT_UTIL_MAPPED = KEY_8; - public static final String ADD_PROJECT_NOT_EAR = KEY_9; - public static final String ADD_PROJECT_URI_EMPTY = KEY_10; - public static final String NOT_AN_APP_CLIENT = KEY_11; - public static final String NOT_AN_EAR = KEY_12; - public static final String NOT_AN_EJB = KEY_13; - public static final String NOT_A_RAR = KEY_14; - public static final String NOT_A_WAR = KEY_15; - public static final String SERVER_TARGET_NOT_SUPPORT_EAR = KEY_16; -} 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 04fd5dcab..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarComponentCreationDataModelProvider.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -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.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.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.EARFacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -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; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see EARFacetProjectCreationDataModelProvider - */ -public class EarComponentCreationDataModelProvider extends J2EEComponentCreationDataModelProvider implements IEarComponentCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15 { - - public IDataModelOperation getDefaultOperation() { - //return new EARComponentCreationOperation(model); - return new EarComponentCreationFacetOperation(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 Set getPropertyNames(){ - Set propertyNames = super.getPropertyNames(); - propertyNames.add(J2EE_PROJECTS_LIST); - propertyNames.add(JAVA_PROJECT_LIST); - return propertyNames; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(DD_FOLDER)) { - return IPath.SEPARATOR + "META_INF"; //$NON-NLS-1$ - } else if (propertyName.equals(UI_SHOW_EAR_SECTION)) { - return Boolean.FALSE; - } else if (propertyName.equals(J2EE_PROJECTS_LIST)) { - return Collections.EMPTY_LIST; - }else if (propertyName.equals(JAVA_PROJECT_LIST)){ - return Collections.EMPTY_LIST; - } else if(propertyName.equals(NESTED_EAR_COMPONENT_CREATION_DM)){ - return model; - } - 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.VERSION_1_2: - description = J2EEVersionConstants.VERSION_1_2_TEXT; - break; - case J2EEVersionConstants.VERSION_1_3: - description = J2EEVersionConstants.VERSION_1_3_TEXT; - break; - case J2EEVersionConstants.VERSION_1_4: - default: - description = J2EEVersionConstants.VERSION_1_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 - IStatus stat = super.validate(propertyName); - if( stat.isOK()){ - 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.SERVER_TARGET_NOT_SUPPORT_EAR; - return WTPCommonPlugin.createErrorStatus(msg); - } - } - } - } - } - }else if(propertyName.equals(J2EE_PROJECTS_LIST)){ - return validateTargetComponentVersion((List)model.getProperty(J2EE_PROJECTS_LIST)); - } - return super.validate(propertyName); - } - - private IStatus validateTargetComponentVersion(List list) { - - Integer version = (Integer) model.getProperty(COMPONENT_VERSION); - int earVersion = version.intValue(); - for (Iterator iter = list.iterator(); iter.hasNext();) { - IProject handle = (IProject)iter.next(); - //IVirtualComponent comp = (IVirtualComponent) iter.next(); - IVirtualComponent comp = ComponentCore.createComponent(handle.getProject()); - int compVersion = J2EEVersionUtil.convertVersionStringToInt(comp); - if (earVersion < compVersion) { - String errorStatus = "The Module specification level of "+handle.getName()+", is incompatible with the containing EAR version"; //$NON-NLS-1$ - return J2EEPlugin.newErrorStatus(errorStatus, null); - } - - } - return OK_STATUS; - } - - - 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)); - } else if(propertyName.equals(NESTED_EAR_COMPONENT_CREATION_DM)){ - throw new RuntimeException(); - } - return returnValue; - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName){ - return super.getValidPropertyDescriptors(propertyName); - } - - protected boolean isCreatingEarComponent() { - return true; - } - - protected IProject getEARProject(){ - String earProjname = (String) model.getProperty(COMPONENT_NAME); - - IDataModel earDM = (IDataModel) model.getProperty(NESTED_EAR_COMPONENT_CREATION_DM); - earDM.setProperty(IEarComponentCreationDataModelProperties.PROJECT_NAME, earProjname); - - if( earProjname != null && !earProjname.equals("") && validate(COMPONENT_NAME).isOK()) - return ProjectUtilities.getProject(earProjname); - else - return null; - - } - - protected String getJ2EEProjectType() { - return J2EEProjectUtilities.ENTERPRISE_APPLICATION; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarComponentCreationFacetOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarComponentCreationFacetOperation.java deleted file mode 100644 index c2990d517..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarComponentCreationFacetOperation.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -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.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.datamodel.properties.IJavaComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.EARFacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IComponentCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; -import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager; -import org.eclipse.wst.server.core.ServerCore; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see EARFacetProjectCreationDataModelProvider - */ -public class EarComponentCreationFacetOperation extends AbstractDataModelOperation implements IFacetProjectCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15 { - - public EarComponentCreationFacetOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - String runtime = model.getStringProperty(IJavaComponentCreationDataModelProperties.RUNTIME_TARGET_ID); - IRuntime facetRuntime = null; - try { - runtime = ServerCore.findRuntime(runtime).getName(); - facetRuntime = RuntimeManager.getRuntime(runtime); - } catch (Exception e) { - // proceed with facetRuntime = null - } - dm.setProperty(FACET_RUNTIME, facetRuntime); - String projectName = model.getStringProperty(IComponentCreationDataModelProperties.PROJECT_NAME); - dm.setProperty(FACET_PROJECT_NAME, projectName); - - IDataModel newDM = setupEarInstallAction(); - FacetDataModelMap map = (FacetDataModelMap) dm.getProperty(FACET_DM_MAP); - map.add(newDM); - - IStatus stat = dm.getDefaultOperation().execute(monitor, info); - if (stat.isOK()) - addModulesToEAR(monitor); - - return stat; - } - - protected IDataModel setupEarInstallAction() { - String versionStr = model.getPropertyDescriptor(IJ2EEComponentCreationDataModelProperties.COMPONENT_VERSION).getPropertyDescription(); - IDataModel earFacetInstallDataModel = DataModelFactory.createDataModel(new EarFacetInstallDataModelProvider()); - earFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, model.getStringProperty(IComponentCreationDataModelProperties.PROJECT_NAME)); - earFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, versionStr); - return earFacetInstallDataModel; - } - - protected void setRuntime(IFacetedProject facetProj) throws CoreException { - String runtimeID = model.getStringProperty(IJavaComponentCreationDataModelProperties.RUNTIME_TARGET_ID); - String runtimeName = ServerCore.findRuntime(runtimeID).getName(); - try { - IRuntime runtime = RuntimeManager.getRuntime(runtimeName); - facetProj.setRuntime(runtime, null); - } catch (IllegalArgumentException e) { - Logger.getLogger().logError(e); - } - } - - private IStatus addModulesToEAR(IProgressMonitor monitor) { - IStatus stat = OK_STATUS; - try { - IDataModel dm = (IDataModel) model.getProperty(IJ2EEComponentCreationDataModelProperties.NESTED_ADD_COMPONENT_TO_EAR_DM); - String projectName = model.getStringProperty(IComponentCreationDataModelProperties.PROJECT_NAME); - IProject project = ProjectUtilities.getProject(projectName); - IVirtualComponent component = ComponentCore.createComponent(project); - - - dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, component); - - List moduleProjectsList = (List) model.getProperty(IEarComponentCreationDataModelProperties.J2EE_PROJECTS_LIST); - if (moduleProjectsList != null && !moduleProjectsList.isEmpty()) { - List moduleComponentsList = new ArrayList(moduleProjectsList.size()); - for (int i = 0; i < moduleProjectsList.size(); i++) { - moduleComponentsList.add(ComponentCore.createComponent((IProject) moduleProjectsList.get(i))); - } - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, moduleComponentsList); - stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - if (stat != OK_STATUS) - return stat; - dm.getDefaultOperation().execute(monitor, null); - } - } catch (Exception e) { - Logger.getLogger().log(e); - } - return stat; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarFacetInstallDataModelProvider.java deleted file mode 100644 index 7114446e7..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarFacetInstallDataModelProvider.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.J2EEFacetInstallDataModelProvider; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; - -public class EarFacetInstallDataModelProvider extends J2EEFacetInstallDataModelProvider implements IEarFacetInstallDataModelProperties { - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(CONTENT_DIR); - names.add(J2EE_PROJECTS_LIST); - names.add(JAVA_PROJECT_LIST); - return names; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(FACET_ID)) { - return J2EEProjectUtilities.ENTERPRISE_APPLICATION; - } else if (propertyName.equals(CONTENT_DIR)) { - return ProductManager.getProperty(IProductConstants.APPLICATION_CONTENT_FOLDER); - } else if (propertyName.equals(J2EE_PROJECTS_LIST) || propertyName.equals(JAVA_PROJECT_LIST)) { - return Collections.EMPTY_LIST; - } - return super.getDefaultProperty(propertyName); - } - - public IStatus validate(String name) { - if (name.equals(J2EE_PROJECTS_LIST)) { - return validateTargetComponentVersion((List) model.getProperty(J2EE_PROJECTS_LIST)); - } - return super.validate(name); - } - - private IStatus validateTargetComponentVersion(List list) { - int earVersion = getJ2EEVersion(); - for (Iterator iter = list.iterator(); iter.hasNext();) { - IProject handle = (IProject) iter.next(); - IVirtualComponent comp = ComponentCore.createComponent(handle.getProject()); - if (comp == null) return OK_STATUS; //Not a faceted project, so version not relevant - int compVersion = J2EEVersionUtil.convertVersionStringToInt(comp); - if (earVersion < compVersion) { - String errorStatus = "The Module specification level of " + handle.getName() + ", is incompatible with the containing EAR version"; //$NON-NLS-1$ - return J2EEPlugin.newErrorStatus(errorStatus, null); - } - } - return OK_STATUS; - } - - protected int convertFacetVersionToJ2EEVersion(IProjectFacetVersion version) { - return J2EEVersionUtil.convertVersionStringToInt(version.getVersionString()); - } -} 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 5fc021a25..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IDefaultJ2EEComponentCreationDataModelProperties.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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$ - - public static final String FACET_RUNTIME = "DefaultJ2EEComponentCreationDataModel.FACET_RUNTIME";//$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IEarFacetInstallDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IEarFacetInstallDataModelProperties.java deleted file mode 100644 index b95eb21bc..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/IEarFacetInstallDataModelProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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 org.eclipse.jst.j2ee.project.facet.EARFacetProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetInstallDataModelProperties; - - -public interface IEarFacetInstallDataModelProperties extends IJ2EEFacetInstallDataModelProperties { - - /** - * This field should not be used. It is not part of the API and may be modified in the future. - */ - public static Class _provider_class = EARFacetProjectCreationDataModelProvider.class; - - //TODO what is this??? - public static final String CONTENT_DIR = "IEarFacetInstallDataModelProperties.CONTENT_DIR";//$NON-NLS-1$ - - public static final String J2EE_PROJECTS_LIST = "IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST"; //$NON-NLS-1$ - public static final String JAVA_PROJECT_LIST = "IEarFacetInstallDataModelProperties.JAVA_PROJECT_LIST"; //$NON-NLS-1$ -} 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 fd059de77..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/ILooseConfigConstants.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.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; - -} 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 49d57deec..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, 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.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 .component 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 ed53a879c..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, 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.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 .component 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 cee99ee07..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, 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.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 .component 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 333f8d9b7..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, 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.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 .component 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 ae34dbb68..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, 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.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 .component 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 33a1f779e..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, 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.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 .component 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 1f132f364..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, 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.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 .component 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 31f97e7f4..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/modulemap/ModulemapInit.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.modulemap; - - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil; - -//import com.ibm.etools.j2ee.internal.project.EAREditModel; -/** -* @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 .component 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; - } - public EFactory getEFactory() { - return ModulemapFactory.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); - } -} 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 638f73a11..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, 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.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 .component 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 c593480ce..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, 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.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.internal.impl.JavaRefPackageImpl; -import org.eclipse.jst.j2ee.application.ApplicationPackage; -import org.eclipse.jst.j2ee.application.internal.impl.ApplicationPackageImpl; -import org.eclipse.jst.j2ee.common.internal.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 .component 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 ff5df4d72..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, 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.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 .component 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 e52356154..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, 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.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 .component 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 d935451e0..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, 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.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 .component 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/EarEditAdapterFactory.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EarEditAdapterFactory.java deleted file mode 100644 index 889db8005..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/modulecore/util/EarEditAdapterFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.core.runtime.IAdapterFactory; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -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 (J2EEProjectUtilities.isEARProject(editModel.getProject())) - 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}; - } -} 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 71c0defc1..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtension.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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.archive.operations.ImportOption; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public interface EarModuleExtension { - - /** - * Return a default instance of the J2EEModuleCreationDataModel. - * - * @return - */ - IDataModel createProjectDataModel(); - - IDataModel createImportDataModel(); - - IDataModelOperation createProjectCreationOperation(IDataModel dataModel); - - IDataModelOperation createProjectCreationOperation(ImportOption option); -} 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 d67120d17..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleExtensionImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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.jst.j2ee.internal.archive.operations.ImportOption; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - - -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#createProjectCreationOperation(com.ibm.etools.archive.ear.operations.ImportOption) - */ - public IDataModelOperation createProjectCreationOperation(ImportOption option) { - if (option.getArchiveType() == ImportOption.MODULE) - return option.getModel().getDefaultOperation(); - return null; - } - - public IDataModelOperation createProjectCreationOperation(IDataModel dataModel) { - return dataModel.getDefaultOperation(); - } - -} 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 3a9ed1419..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, 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 - *******************************************************************************/ -/* - * 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); - } - -} 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 14d2cfb6f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EarModuleManager.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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.J2EEProjectUtilities; - - -/** - * @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(J2EEProjectUtilities.EJB); - } - - /** - * @return - */ - public static JcaModuleExtension getJCAModuleExtension() { - return (JcaModuleExtension) getModuleExtension(J2EEProjectUtilities.JCA); - } - - /** - * @return - */ - public static WebModuleExtension getWebModuleExtension() { - return (WebModuleExtension) getModuleExtension(J2EEProjectUtilities.DYNAMIC_WEB); - } - - public static boolean hasEJBModuleExtension() { - return (EjbModuleExtension) getModuleExtension(J2EEProjectUtilities.EJB) != null; - } - - public static boolean hasJCAModuleExtension() { - return (JcaModuleExtension) getModuleExtension(J2EEProjectUtilities.JCA) != null; - } - - public static boolean hasWebModuleExtension() { - return getModuleExtension(J2EEProjectUtilities.DYNAMIC_WEB) != null; - } - - public static void registerModuleExtension(EarModuleExtension ext) { - if (ext instanceof WebModuleExtension) - moduleExtensions.put(J2EEProjectUtilities.DYNAMIC_WEB, ext); - else if (ext instanceof EjbModuleExtension) - moduleExtensions.put(J2EEProjectUtilities.EJB, ext); - else if (ext instanceof JcaModuleExtension) - moduleExtensions.put(J2EEProjectUtilities.JCA, ext); - else - moduleExtensions.put(J2EEProjectUtilities.ENTERPRISE_APPLICATION, ext); - } - - public static void removeModuleExtension(String key) { - moduleExtensions.remove(key); - } -} 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 2ff3645dd..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/EjbModuleExtension.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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.wst.common.frameworks.datamodel.IDataModelOperation; - - - -/** - * @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); - - EJBJar getEJBJar(IProject aProject); - - IProject getDefinedEJBClientJARProject(IProject anEJBProject); - - IDataModelOperation createEJBClientJARProject( - final String clientProjectName, - final String srcFolderName, - final String ejbProjectName, - final String earProjectName, - final org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime); - - IDataModelOperation createEJBClientJARProject(IProject ejbProject); - -} 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 92ca9ca7f..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, 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 - *******************************************************************************/ -/* - * 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); -} 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 cf9a5d031..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/moduleextension/WebModuleExtension.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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 - *******************************************************************************/ -/* - * 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.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); - - - 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); - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EARFacetProjectCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EARFacetProjectCreationDataModelProvider.java deleted file mode 100644 index d0c396e6f..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EARFacetProjectCreationDataModelProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.project.facet; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.jst.j2ee.internal.earcreation.EarFacetInstallDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class EARFacetProjectCreationDataModelProvider extends FacetProjectCreationDataModelProvider { - - public EARFacetProjectCreationDataModelProvider() { - super(); - } - - public void init() { - super.init(); - FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP); - IDataModel earFacet = DataModelFactory.createDataModel(new EarFacetInstallDataModelProvider()); - map.add(earFacet); - - Collection requiredFacets = new ArrayList(); - requiredFacets.add(ProjectFacetsManager.getProjectFacet(earFacet.getStringProperty(IFacetDataModelProperties.FACET_ID))); - setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EARFacetUtils.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EARFacetUtils.java deleted file mode 100644 index 45d7c67e2..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EARFacetUtils.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.project.facet; - -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class EARFacetUtils { - - public static final IProjectFacet EAR_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EAR_MODULE); - public static final IProjectFacetVersion EAR_12 = EAR_FACET.getVersion("1.2"); //$NON-NLS-1$ - public static final IProjectFacetVersion EAR_13 = EAR_FACET.getVersion("1.3"); //$NON-NLS-1$ - public static final IProjectFacetVersion EAR_14 = EAR_FACET.getVersion("1.4"); //$NON-NLS-1$ - - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetInstallDelegate.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetInstallDelegate.java deleted file mode 100644 index 46c617a03..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetInstallDelegate.java +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.common.project.facet.WtpUtils; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.earcreation.IEarFacetInstallDataModelProperties; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.FacetDataModelProvider; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public final class EarFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - IDataModel model = (IDataModel) cfg; - - if (monitor != null) { - monitor.worked(1); - } - // Add WTP natures. - - WtpUtils.addNaturestoEAR(project); - - final IVirtualComponent c = ComponentCore.createComponent(project); - c.create(0, null); - - final IVirtualFolder earroot = c.getRootFolder(); - earroot.createLink(new Path("/" + model.getStringProperty(IEarFacetInstallDataModelProperties.CONTENT_DIR)), 0, null); //$NON-NLS-1$ - - if (!project.getFile(J2EEConstants.APPLICATION_DD_URI).exists()) { - String ver = fv.getVersionString(); - int nVer = J2EEVersionUtil.convertVersionStringToInt(ver); - EARArtifactEdit.createDeploymentDescriptor(project, nVer); - } - - try { - ((IDataModelOperation) model.getProperty(FacetDataModelProvider.NOTIFICATION_OPERATION)).execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - } - - finally { - if (monitor != null) { - monitor.done(); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetPostInstallDelegate.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetPostInstallDelegate.java deleted file mode 100644 index fee5cac65..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetPostInstallDelegate.java +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider; -import org.eclipse.jst.j2ee.internal.earcreation.IEarFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public final class EarFacetPostInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - IDataModel model = (IDataModel) cfg; - - if (monitor != null) { - monitor.worked(1); - } - - final IVirtualComponent c = ComponentCore.createComponent(project); - - Set dependentProjects = new HashSet(); - dependentProjects.addAll((List) model.getProperty(IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST)); - dependentProjects.addAll((List) model.getProperty(IEarFacetInstallDataModelProperties.JAVA_PROJECT_LIST)); - if (!dependentProjects.isEmpty()) { - List dependentComponents = new ArrayList(dependentProjects.size()); - for (Iterator iterator = dependentProjects.iterator(); iterator.hasNext();) { - IProject depProject = (IProject) iterator.next(); - IVirtualComponent depComp = ComponentCore.createComponent(depProject); - if (depComp == null) { - JavaProjectMigrationOperation utilOp = J2EEProjectUtilities.createFlexJavaProjectForProjectOperation(depProject); - utilOp.execute(null, null); - depComp = ComponentCore.createComponent(depProject); - } - - dependentComponents.add(depComp); - } - - final IDataModel dataModel = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider()); - dataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, c); - List modList = (List) dataModel.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modList.addAll(dependentComponents); - dataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modList); - try { - dataModel.getDefaultOperation().execute(null, null); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - } - - } - - finally { - if (monitor != null) { - monitor.done(); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetRuntimeHandler.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetRuntimeHandler.java deleted file mode 100644 index 4dd10c7b8..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetRuntimeHandler.java +++ /dev/null @@ -1,214 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class EarFacetRuntimeHandler -{ - /** - * Private constructor. This class is not meant to be instantiated. - */ - - private EarFacetRuntimeHandler() {} - - public static void updateModuleProjectRuntime( final IProject earProject, - final IProject moduleProject, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", 1 ); - } - - try - { - final IFacetedProject earFacetedProject - = ProjectFacetsManager.create( earProject ); - - final IRuntime earRuntime = earFacetedProject.getRuntime(); - - final IFacetedProject moduleFacetedProject - = ProjectFacetsManager.create( moduleProject ); - - if( moduleFacetedProject != null && - ! equals( earRuntime, moduleFacetedProject.getRuntime() ) ) - { - boolean supports = true; - - if( earRuntime != null ) - { - for( Iterator itr = moduleFacetedProject.getProjectFacets().iterator(); - itr.hasNext(); ) - { - final IProjectFacetVersion fver - = (IProjectFacetVersion) itr.next(); - - if( ! earRuntime.supports( fver ) ) - { - supports = false; - break; - } - } - } - - if( supports ) - { - moduleFacetedProject.setRuntime( earRuntime, submon( monitor, 1 ) ); - } - } - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - - public static void updateModuleProjectRuntime( final IProject earProject, - final Set moduleProjects, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", moduleProjects.size() ); - } - - try - { - for( Iterator itr = moduleProjects.iterator(); itr.hasNext(); ) - { - final IProject moduleProject = (IProject) itr.next(); - - updateModuleProjectRuntime( earProject, moduleProject, - submon( monitor, 1 ) ); - } - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - - public static final class RuntimeChangedDelegate - - implements IDelegate - - { - public void execute( final IProject project, - final IProjectFacetVersion fv, - final Object cfg, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", 10 ); //$NON-NLS-1$ - } - - try - { - // Compile the list of projects referenced by this ear project. - - final Set moduleProjects = new HashSet(); - - final IVirtualComponent earvc - = ComponentCore.createComponent( project ); - - final IVirtualReference[] vrefs = earvc.getReferences(); - - for( int i = 0; i < vrefs.length; i++ ) - { - final IVirtualReference vref = vrefs[ i ]; - final IVirtualComponent vc = vref.getReferencedComponent(); - - moduleProjects.add( vc.getProject() ); - } - - if( monitor != null ) - { - monitor.worked( 1 ); - } - - // Attempt to change the runtime for each of the referenced projects. - - updateModuleProjectRuntime( project, moduleProjects, - submon( monitor, 9 ) ); - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - } - - private static IProgressMonitor submon( final IProgressMonitor parent, - final int ticks ) - { - return ( parent == null ? null : new SubProgressMonitor( parent, ticks ) ); - } - - private static boolean equals( final Object obj1, - final Object obj2 ) - { - if( obj1 == obj2 ) - { - return true; - } - else if( obj1 == null || obj2 == null ) - { - return false; - } - else - { - return obj1.equals( obj2 ); - } - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetValidator.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetValidator.java deleted file mode 100644 index 386297246..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetValidator.java +++ /dev/null @@ -1,138 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectValidator; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class EarFacetValidator - - implements IFacetedProjectValidator - -{ - private static final String MARKER_ID - = J2EEPlugin.PLUGIN_ID + ".differentRuntimesDetected"; - - public void validate( final IFacetedProject fproj ) - - throws CoreException - - { - final IVirtualComponent vc - = ComponentCore.createComponent( fproj.getProject() ); - - if( vc == null ) - { - return; - } - - if( fproj.hasProjectFacet( EARFacetUtils.EAR_FACET ) ) - { - fproj.getProject().deleteMarkers( MARKER_ID, false, - IResource.DEPTH_ZERO ); - - final IVirtualReference[] refs = vc.getReferences(); - - for( int i = 0; i < refs.length; i++ ) - { - final IVirtualReference ref = refs[ i ]; - final IVirtualComponent refvc = ref.getReferencedComponent(); - - if( refvc != null && !refvc.isBinary()) - { - final IProject refpj = refvc.getProject(); - validate( fproj, ProjectFacetsManager.create( refpj ) ); - } - } - } - else - { - final IVirtualComponent[] referencing - = vc.getReferencingComponents(); - - for( int i = 0; i < referencing.length; i++ ) - { - final IVirtualComponent refvc = referencing[ i ]; - - final IFacetedProject reffpj - = ProjectFacetsManager.create( refvc.getProject() ); - - if( reffpj.hasProjectFacet( EARFacetUtils.EAR_FACET ) ) - { - validate( reffpj ); - } - } - } - } - - private void validate( final IFacetedProject ear, - final IFacetedProject module ) - - throws CoreException - - { - final IRuntime earRuntime = ear.getRuntime(); - final IRuntime moduleRuntime = module.getRuntime(); - - if( earRuntime == null && moduleRuntime != null ) - { - // Should this also be a warning? - } - else if( earRuntime != null && moduleRuntime == null ) - { - // Should this also be a warning? - } - else if( earRuntime != null && moduleRuntime != null && - ! earRuntime.equals( moduleRuntime ) ) - { - final String msg - = NLS.bind( Resources.targettingDifferentRuntimes, - module.getProject().getName() ); - - final IMarker m = ear.createWarningMarker( MARKER_ID, msg ); - - m.setAttribute( "moduleProject", module.getProject().getName() ); - m.setAttribute( "runtime1", ear.getRuntime().getName() ); - m.setAttribute( "runtime2", module.getRuntime().getName() ); - } - } - - private static final class Resources - - extends NLS - - { - public static String targettingDifferentRuntimes; - - static - { - initializeMessages( EarFacetValidator.class.getName(), - Resources.class ); - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetValidator.properties b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetValidator.properties deleted file mode 100644 index 17d4bab76..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetValidator.properties +++ /dev/null @@ -1 +0,0 @@ -targettingDifferentRuntimes = Referenced module project {0} is targetting a different runtime. diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetVersionChangeDelegate.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetVersionChangeDelegate.java deleted file mode 100644 index e121e6b05..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/EarFacetVersionChangeDelegate.java +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -/** - * Warning clean-up 12/05/2005 - */ -//import org.eclipse.wst.common.componentcore.ComponentCore; -//import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class EarFacetVersionChangeDelegate - - implements IDelegate - -{ - public void execute( final IProject project, - final IProjectFacetVersion fv, - final Object cfg, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", 1 ); - } - - try - { - /** - * Warning clean-up 12/05/2005 - */ - //final IVirtualComponent c = ComponentCore.createComponent(project); - -// final StructureEdit edit -// = StructureEdit.getStructureEditForWrite( project ); -// -// try -// { -// final ComponentType oldctype -// = StructureEdit.getComponentType( c ); -// -// final ComponentType newctype -// = ComponentcoreFactory.eINSTANCE.createComponentType(); -// -// newctype.setComponentTypeId( oldctype.getComponentTypeId() ); -// newctype.setVersion( fv.getVersionString() ); -// newctype.getProperties().addAll( oldctype.getProperties() ); -// -// StructureEdit.setComponentType( c, newctype ); -// -// edit.saveIfNecessary( null ); -// } -// finally -// { -// edit.dispose(); -// } - - if( monitor != null ) - { - monitor.worked( 1 ); - } - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IJavaProjectMigrationDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IJavaProjectMigrationDataModelProperties.java deleted file mode 100644 index 0eab85c35..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IJavaProjectMigrationDataModelProperties.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.project.facet; - - -public interface IJavaProjectMigrationDataModelProperties { - - /** - * Required - */ - public static final String PROJECT_NAME = "IJavaProjectMigrationDataModelProperties.PROJECT_NAME"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IJavaUtilityProjectCreationDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IJavaUtilityProjectCreationDataModelProperties.java deleted file mode 100644 index 9f9093527..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IJavaUtilityProjectCreationDataModelProperties.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.project.facet; - -public interface IJavaUtilityProjectCreationDataModelProperties { - - public static final String PROJECT_NAME = "IJavaUtilityProjectCreationDataModelProperties.PROJECT_NAME"; //$NON-NLS-1$ - -// public static final String PROJECT_LOCATION = "IJavaUtilityProjectCreationDataModelProperties.PROJECT_LOCATION"; //$NON-NLS-1$ - - public static final String EAR_PROJECT_NAME = "IJavaUtilityProjectCreationDataModelProperties.EAR_PROJECT_NAME"; //$NON-NLS-1$ - - public static final String RUNTIME = "IJavaUtilityProjectCreationDataModelProperties.RUNTIME"; //$NON-NLS-1$ - - public static final String SOURCE_FOLDER = "IJavaUtilityProjectCreationDataModelProperties.SOURCE_FOLDER"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IUtilityFacetInstallDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IUtilityFacetInstallDataModelProperties.java deleted file mode 100644 index 34162f167..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/IUtilityFacetInstallDataModelProperties.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.project.facet; - -public interface IUtilityFacetInstallDataModelProperties extends IJ2EEModuleFacetInstallDataModelProperties { - - /** - * This field should not be used. It is not part of the API and may be modified in the future. - */ - public static Class _provider_class = UtilityFacetInstallDataModelProvider.class; -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaProjectMigrationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaProjectMigrationDataModelProvider.java deleted file mode 100644 index 54b310108..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaProjectMigrationDataModelProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.project.facet; - -import java.util.Set; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -/** - * This dataModel is a common super class used for creation of WTP 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. - * - * @plannedfor WTP 1.0 - */ -public class JavaProjectMigrationDataModelProvider extends AbstractDataModelProvider implements IJavaProjectMigrationDataModelProperties { - - public void init() { - super.init(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(PROJECT_NAME); - return propertyNames; - } - - public void propertyChanged(DataModelEvent event) { - if (event.getFlag() == DataModelEvent.VALUE_CHG) { - event.getDataModel(); - } - } - - public boolean propertySet(String propertyName, Object propertyValue) { - return true; - } - - public Object getDefaultProperty(String propertyName) { - return super.getDefaultProperty(propertyName); - } - - public IStatus validate(String propertyName) { - - return OK_STATUS; - } - - public IDataModelOperation getDefaultOperation() { - return new JavaProjectMigrationOperation(model); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaProjectMigrationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaProjectMigrationOperation.java deleted file mode 100644 index 7725a02e6..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaProjectMigrationOperation.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.project.facet; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jst.common.project.facet.JavaFacetInstallDataModelProvider; -import org.eclipse.jst.common.project.facet.JavaFacetUtils; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - - -public class JavaProjectMigrationOperation extends AbstractDataModelOperation implements IJavaProjectMigrationDataModelProperties { - - - - public JavaProjectMigrationOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) { - - - - IDataModel jdm = DataModelFactory.createDataModel(new JavaFacetInstallDataModelProvider()); - - jdm.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, model.getStringProperty(PROJECT_NAME)); - - jdm.setProperty(IFacetDataModelProperties.FACET_VERSION, getJavaFacetVersion() ); - - IDataModel udm = DataModelFactory.createDataModel(new UtilityFacetInstallDataModelProvider()); - try { - udm.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, model.getStringProperty(PROJECT_NAME)); - udm.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, "1.0"); //$NON-NLS-1$ - udm.setProperty(IJ2EEModuleFacetInstallDataModelProperties.MODULE_URI, - model.getStringProperty(PROJECT_NAME) + ".jar"); //$NON-NLS-1$ - } catch (Exception e) { - Logger.getLogger().logError(e); - } - - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, model.getStringProperty(PROJECT_NAME)); - - FacetDataModelMap map = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - map.add(jdm); - map.add(udm); - - try { - dm.getDefaultOperation().execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - return OK_STATUS; - } - - private IProjectFacetVersion getJavaFacetVersion(){ - - IProject project = J2EEProjectUtilities.getProject( model.getStringProperty(PROJECT_NAME) ); - IJavaProject jProj = JemProjectUtilities.getJavaProject( project ); - String jdtVersion = jProj.getOption(JavaCore.COMPILER_COMPLIANCE, true ); - - if (jdtVersion.startsWith("1.3")) { //$NON-NLS-1$ - return JavaFacetUtils.JAVA_13; - } else if (jdtVersion.startsWith("1.4")) { //$NON-NLS-1$ - return JavaFacetUtils.JAVA_14; - }else if (jdtVersion.startsWith("1.5")) { //$NON-NLS-1$ - return JavaFacetUtils.JAVA_50; - } - return JavaFacetUtils.JAVA_60; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityComponentCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityComponentCreationDataModelProvider.java deleted file mode 100644 index ae7079ec4..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityComponentCreationDataModelProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.project.facet; - - -import java.util.Set; - -import org.eclipse.jst.j2ee.datamodel.properties.IUtilityJavaComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.archive.operations.JavaComponentCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see UtilityProjectCreationDataModelProvider - */ -public class JavaUtilityComponentCreationDataModelProvider - extends JavaComponentCreationDataModelProvider implements IUtilityJavaComponentCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15{ - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(EAR_PROJECT_NAME); - return propertyNames; - } - - public IDataModelOperation getDefaultOperation() { - return new JavaUtilityComponentCreationFacetOperation(model); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityComponentCreationFacetOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityComponentCreationFacetOperation.java deleted file mode 100644 index d00d6f746..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityComponentCreationFacetOperation.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.project.facet; - -import org.eclipse.core.commands.ExecutionException; -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.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see UtilityProjectCreationDataModelProvider - */ -public class JavaUtilityComponentCreationFacetOperation extends J2EEComponentCreationFacetOperation implements DoNotUseMeThisWillBeDeletedPost15{ - - public JavaUtilityComponentCreationFacetOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - IStatus result = OK_STATUS; - try { - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, (String) model.getProperty(JavaUtilityComponentCreationDataModelProvider.PROJECT_NAME)); - - FacetDataModelMap map = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - map.add(setupJavaInstallAction()); - - IDataModel newModel = setupUtilityInstallAction(model); - map.add( newModel ); - - setRuntime(newModel, dm); // Setting runtime property - setAddToEARFromWizard(newModel); - result = dm.getDefaultOperation().execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - return result; - } - - protected IDataModel setupUtilityInstallAction(IDataModel aDM) { - IDataModel dm = DataModelFactory.createDataModel(new UtilityFacetInstallDataModelProvider()); - try { - dm.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, model.getStringProperty(JavaUtilityComponentCreationDataModelProvider.PROJECT_NAME)); - dm.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, "1.0"); //$NON-NLS-1$ - dm.setProperty(IUtilityFacetInstallDataModelProperties.RUNTIME_TARGET_ID, model.getProperty(JavaUtilityComponentCreationDataModelProvider.RUNTIME_TARGET_ID)); - dm.setProperty(IUtilityFacetInstallDataModelProperties.CONFIG_FOLDER, - model.getProperty(JavaUtilityComponentCreationDataModelProvider.JAVASOURCE_FOLDER)); - dm.setStringProperty(IUtilityFacetInstallDataModelProperties.EAR_PROJECT_NAME,model.getStringProperty(JavaUtilityComponentCreationDataModelProvider.EAR_PROJECT_NAME)); - - } catch (Exception e) { - Logger.getLogger().logError(e); - } - - return dm; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityProjectCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityProjectCreationDataModelProvider.java deleted file mode 100644 index ba73143ba..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityProjectCreationDataModelProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.project.facet; - - -import java.util.Set; - -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - - - -public class JavaUtilityProjectCreationDataModelProvider - extends AbstractDataModelProvider implements IJavaUtilityProjectCreationDataModelProperties{ - - public JavaUtilityProjectCreationDataModelProvider() { - super(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(PROJECT_NAME); - //propertyNames.add(PROJECT_LOCATION); - propertyNames.add(EAR_PROJECT_NAME); - propertyNames.add(RUNTIME); - propertyNames.add(SOURCE_FOLDER); - return propertyNames; - } - - - public IDataModelOperation getDefaultOperation() { - return new JavaUtilityProjectCreationOperation(model); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityProjectCreationOperation.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityProjectCreationOperation.java deleted file mode 100644 index a7baf7597..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/JavaUtilityProjectCreationOperation.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.project.facet; - - - -import org.eclipse.core.commands.ExecutionException; -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.common.project.facet.JavaFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.componentcore.internal.operation.FacetProjectCreationOperation; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -public class JavaUtilityProjectCreationOperation extends AbstractDataModelOperation implements IJavaUtilityProjectCreationDataModelProperties{ - - - - public JavaUtilityProjectCreationOperation(IDataModel model) { - super(model); - } - - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - IStatus stat = OK_STATUS; - - String projectName = model.getStringProperty( IJavaUtilityProjectCreationDataModelProperties.PROJECT_NAME ); - String earProjectName = model.getStringProperty( IJavaUtilityProjectCreationDataModelProperties.EAR_PROJECT_NAME );; - String javaSourceFolder = model.getStringProperty( IJavaUtilityProjectCreationDataModelProperties.SOURCE_FOLDER ); - - org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime = (IRuntime) model.getProperty(IJavaUtilityProjectCreationDataModelProperties.RUNTIME); - - IDataModel dm = DataModelFactory.createDataModel(new UtilityProjectCreationDataModelProvider()); - - - //IDataModel pdm = dm.getNestedModel( IFacetProjectCreationDataModelProperties.NESTED_PROJECT_DM ); - //pdm.setStringProperty( IProjectCreationPropertiesNew.PROJECT_LOCATION, model.getStringProperty( IJavaUtilityProjectCreationDataModelProperties.PROJECT_LOCATION ) ); - - FacetDataModelMap map = (FacetDataModelMap) dm.getProperty(UtilityProjectCreationDataModelProvider.FACET_DM_MAP); - - IDataModel javadm = map.getFacetDataModel( IModuleConstants.JST_JAVA ); - IDataModel utildm = map.getFacetDataModel( J2EEProjectUtilities.UTILITY ); - - - javadm.setProperty( JavaFacetInstallDataModelProvider.FACET_PROJECT_NAME, - projectName); - - - javadm.setProperty( JavaFacetInstallDataModelProvider.SOURCE_FOLDER_NAME, - javaSourceFolder); - - - utildm.setProperty( IUtilityFacetInstallDataModelProperties.EAR_PROJECT_NAME, earProjectName); - - utildm.setProperty( IUtilityFacetInstallDataModelProperties.FACET_RUNTIME, runtime ); - dm.setProperty(UtilityProjectCreationDataModelProvider.FACET_RUNTIME, runtime); - - FacetProjectCreationOperation op = new FacetProjectCreationOperation(dm); - try { - stat = op.execute( monitor, null ); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - return stat; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetInstallDataModelProvider.java deleted file mode 100644 index e13df8267..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetInstallDataModelProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.project.facet; - -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public class UtilityFacetInstallDataModelProvider extends J2EEModuleFacetInstallDataModelProvider implements IUtilityFacetInstallDataModelProperties { - - public Object getDefaultProperty(String propertyName) { - if (FACET_ID.equals(propertyName)) { - return J2EEProjectUtilities.UTILITY; - } - return super.getDefaultProperty(propertyName); - } - - protected int convertFacetVersionToJ2EEVersion(IProjectFacetVersion version) { - return 0; - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetInstallDelegate.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetInstallDelegate.java deleted file mode 100644 index 00a68edc3..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetInstallDelegate.java +++ /dev/null @@ -1,123 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -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.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.common.project.facet.WtpUtils; -import org.eclipse.jst.common.project.facet.core.ClasspathHelper; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.FacetDataModelProvider; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public final class UtilityFacetInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - - final IDataModel model = (IDataModel) cfg; - - // Add WTP natures. - - WtpUtils.addNatures(project); - - // Setup the flexible project structure. - - final IVirtualComponent c = ComponentCore.createComponent(project); - - c.create(0, null); - - final IVirtualFolder jsrc = c.getRootFolder(); - final IJavaProject jproj = JavaCore.create(project); - - final IClasspathEntry[] cp = jproj.getRawClasspath(); - - for (int i = 0; i < cp.length; i++) { - final IClasspathEntry cpe = cp[i]; - - if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) { - IPath path = cpe.getPath().removeFirstSegments(1); - if (path.isEmpty()) { - path = new Path("/"); //$NON-NLS-1$ - } - jsrc.createLink(path, 0, null); - } - } - - final IWorkspace ws = ResourcesPlugin.getWorkspace(); - - final IVirtualFolder root = c.getRootFolder(); - - IContainer container = null; - - if (root.getProjectRelativePath().segmentCount() == 0) { - container = project; - } else { - container = project.getFolder(root.getProjectRelativePath()); - } - - try { - if (container != null) - createManifest(project, container, monitor); - } catch (InvocationTargetException e) { - Logger.getLogger().logError(e); - } catch (InterruptedException e) { - Logger.getLogger().logError(e); - } - - - ClasspathHelper.removeClasspathEntries(project, fv); - - if (!ClasspathHelper.addClasspathEntries(project, fv)) { - // TODO: Support the no runtime case. - // ClasspathHelper.addClasspathEntries( project, fv, <something> ); - } - - try { - ((IDataModelOperation) model.getProperty(FacetDataModelProvider.NOTIFICATION_OPERATION)).execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - if (monitor != null) { - monitor.worked(1); - } - } catch (Exception e) { - Logger.getLogger().logError(e); - } finally { - if (monitor != null) { - monitor.done(); - } - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetPostInstallDelegate.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetPostInstallDelegate.java deleted file mode 100644 index aec49dde7..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetPostInstallDelegate.java +++ /dev/null @@ -1,79 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -public final class UtilityFacetPostInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - - final IDataModel model = (IDataModel) cfg; - - - // Associate with an EAR, if necessary. - if (model.getBooleanProperty(IUtilityFacetInstallDataModelProperties.ADD_TO_EAR)) { - final String earProjectName = model.getStringProperty(IUtilityFacetInstallDataModelProperties.EAR_PROJECT_NAME); - if (earProjectName != null && earProjectName != "") { //$NON-NLS-1$ -// IProject earProject = ProjectUtilities.getProject(earProjectName); -// if (earProject.exists()) { -// IVirtualComponent earComp = ComponentCore.createComponent(earProject); -// -// IDataModel dataModel = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider()); -// dataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earComp); -// List modList = (List) dataModel.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); -// modList.add(c); -// dataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modList); -// try { -// dataModel.getDefaultOperation().execute(null, null); -// } catch (ExecutionException e) { -// Logger.getLogger().logError(e); -// } -// } - - - final String moduleURI = model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.MODULE_URI); - - //final String moduleURI = project.getName() + ".jar"; - - installAndAddModuletoEAR( J2EEVersionConstants.VERSION_1_4_TEXT, - earProjectName, - (IRuntime) model.getProperty(IJ2EEFacetInstallDataModelProperties.FACET_RUNTIME), - project, - moduleURI, - monitor ); - } - } - - - } catch (Exception e) { - Logger.getLogger().logError(e); - } finally { - if (monitor != null) { - monitor.done(); - } - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetUnInstallDelegate.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetUnInstallDelegate.java deleted file mode 100644 index a5f3eadca..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityFacetUnInstallDelegate.java +++ /dev/null @@ -1,72 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.project.facet; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.common.project.facet.WtpUtils; -import org.eclipse.jst.common.project.facet.core.ClasspathHelper; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public final class UtilityFacetUnInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try{ - //remove .component file - IFile file = project.getFile( StructureEdit.MODULE_META_FILE_NAME ); - file.delete( true, monitor ); - - //remove manifest file - final IVirtualComponent c = ComponentCore.createComponent(project); - final IVirtualFolder root = c.getRootFolder(); - IContainer container = null; - - if (root.getProjectRelativePath().segmentCount() == 0) { - container = project; - } else { - container = project.getFolder(root.getProjectRelativePath()); - } - - IFile manifestFile = container.getFile(new Path(J2EEConstants.MANIFEST_URI)); - manifestFile.delete( true, monitor ); - - IFolder manifestFolder = container.getFolder( new Path(J2EEConstants.META_INF) ); - manifestFolder.delete( true, monitor ); - - //remove module core nature - WtpUtils.removeNatures( project ); - - //remove server class path container - ClasspathHelper.removeClasspathEntries( project, fv ); - - }finally { - if (monitor != null) { - monitor.done(); - } - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityProjectCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityProjectCreationDataModelProvider.java deleted file mode 100644 index 7750bb9dc..000000000 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/project/facet/UtilityProjectCreationDataModelProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.project.facet; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties; -import org.eclipse.jst.common.project.facet.JavaFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.project.facet.ProductManager; - -public class UtilityProjectCreationDataModelProvider extends J2EEFacetProjectCreationDataModelProvider { - - public UtilityProjectCreationDataModelProvider() { - super(); - } - - public void init() { - super.init(); - FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP); - IDataModel javaFacet = DataModelFactory.createDataModel(new JavaFacetInstallDataModelProvider()); - // If applicable, keep project structure optimized by making output directory the same as the content root - if (ProductManager.shouldUseSingleRootStructure()) - javaFacet.setProperty(IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME, javaFacet.getStringProperty(IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME)); - map.add(javaFacet); - IDataModel utilFacet = DataModelFactory.createDataModel(new UtilityFacetInstallDataModelProvider()); - map.add(utilFacet); - utilFacet.addListener(new IDataModelListener() { - public void propertyChanged(DataModelEvent event) { - if (IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME.equals(event.getPropertyName())) { - if (isPropertySet(EAR_PROJECT_NAME)) - setProperty(EAR_PROJECT_NAME, (String)event.getProperty()); - else - model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.DEFAULT_CHG); - }else if (IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR.equals(event.getPropertyName())) { - setProperty(ADD_TO_EAR, event.getProperty()); - } - } - }); - - Collection requiredFacets = new ArrayList(); - requiredFacets.add(ProjectFacetsManager.getProjectFacet(javaFacet.getStringProperty(IFacetDataModelProperties.FACET_ID))); - requiredFacets.add(ProjectFacetsManager.getProjectFacet(utilFacet.getStringProperty(IFacetDataModelProperties.FACET_ID))); - setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - if( propertyName.equals( MODULE_URI )){ - FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP); - IDataModel utilFacet = map.getFacetDataModel( J2EEProjectUtilities.UTILITY ); - utilFacet.setProperty( IJ2EEModuleFacetInstallDataModelProperties.MODULE_URI, propertyValue ); - } - return super.propertySet(propertyName, propertyValue); - } -}
\ No newline at end of file |