Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.common.frameworks/src/org')
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java77
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathFoldersParticipant.java81
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibReferencesParticipant.java216
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibRefsProviderParticipant.java64
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddMappedOutputFoldersParticipant.java158
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerReferenceResolver.java68
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerVirtualComponent.java172
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyComponent.java22
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyProvider.java32
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyReceiver.java54
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ISingleRootStatus.java55
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IgnoreJavaInSourceFolderParticipant.java83
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ReplaceManifestExportParticipant.java124
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java203
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootStatus.java48
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootUtil.java445
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/AbstractJavaComponentDiscerner.java37
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifest.java124
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifestImpl.java357
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/IJavaComponentDiscerner.java86
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/JavaModuleComponentUtility.java87
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ManifestUtilities.java437
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestDataModelProperties.java46
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestDataModelProvider.java100
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestOperation.java78
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorations.java75
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorationsManager.java375
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathUtil.java113
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java562
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainerInitializer.java85
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModel.java237
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModelFactory.java74
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectValidationHandler.java56
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WTPWorkingCopyManager.java545
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManager.java49
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManagerFactory.java57
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyProvider.java60
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/IJavaProjectLite.java75
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaCoreLite.java211
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaLiteUtilities.java192
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaProjectLite.java186
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/IJavaFacetInstallDataModelProperties.java20
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java139
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java90
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java34
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/WtpUtils.java69
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/DataModelToJavaFacetInstallConfigAdapter.java48
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/JavaFacetInstallConfigToDataModelAdapter.java50
48 files changed, 0 insertions, 6656 deletions
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java
deleted file mode 100644
index d2890b13a..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.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.common.frameworks;
-
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.common.frameworks.internal.WTPPlugin;
-import org.eclipse.core.runtime.Platform;
-import java.lang.Throwable;
-import org.eclipse.core.runtime.CoreException;
-
-public final class CommonFrameworksPlugin
-
- extends WTPPlugin
-
-{
- public static final String PLUGIN_ID = "org.eclipse.jst.common.frameworks"; //$NON-NLS-1$
- public static final String DEFAULT_SOURCE_FOLDER = "defaultSource"; //$NON-NLS-1$
- public static final String OUTPUT_FOLDER = "outputFolder"; //$NON-NLS-1$
-
- private static CommonFrameworksPlugin inst;
-
- /**
- * Get the plugin singleton.
- */
-
- public static CommonFrameworksPlugin getDefault()
- {
- return inst;
- }
-
- public CommonFrameworksPlugin() {
- super();
- if (inst == null)
- inst = this;
- }
- @Override
- public String getPluginID()
- {
- return PLUGIN_ID;
- }
-
- public static void log( final Exception e )
- {
- final ILog log = CommonFrameworksPlugin.getDefault().getLog();
- final String msg = "Encountered an unexpected exception."; //$NON-NLS-1$
-
- log.log( new Status( IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e ) );
- }
-
- public static IStatus createStatus(int severity, String message, Throwable exception) {
- return new Status(severity, PLUGIN_ID, message, exception);
- }
-
- public static IStatus createStatus(int severity, String message) {
- return createStatus(severity, message, null);
- }
-
- public static void logError(Throwable exception) {
- Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception));
- }
-
- public static void logError(CoreException exception) {
- Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() );
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathFoldersParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathFoldersParticipant.java
deleted file mode 100644
index 632231380..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathFoldersParticipant.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * Add classpath folder references. This is necessary because
- * these classpath folder references are not exactly stored as
- * IVirtualReference objects persisted in the component.xml, but rather
- * pulled in from another model.
- *
- * @author rob.stryker@jboss.com
- *
- */
-public class AddClasspathFoldersParticipant extends AbstractFlattenParticipant {
- private List<IFlatResource> list;
-
- @Override
- public boolean shouldIgnoreReference(IVirtualComponent rootComponent,
- IVirtualReference referenced, FlatComponentTaskModel dataModel) {
- if( (rootComponent instanceof IClasspathDependencyProvider) &&
- (referenced.getReferencedComponent() instanceof IClasspathDependencyComponent) &&
- ((IClasspathDependencyComponent)referenced.getReferencedComponent()).isClassFolder())
- return true;
- return false;
- }
-
-
- @Override
- public void finalize(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- this.list = resources;
- if( !(component instanceof IClasspathDependencyProvider ))
- return;
- // Add all Java output folders that have publish/export attributes
- try {
- addClassFolderDependencies((IClasspathDependencyProvider)component);
- } catch( CoreException ce ) {
- // Ignore
- }
- }
-
- private void addClassFolderDependencies(final IClasspathDependencyProvider component) throws CoreException {
- if (!component.isBinary()) {
- final IVirtualReference[] cpRefs = component.getJavaClasspathReferences();
- for (int i = 0; i < cpRefs.length; i++) {
- final IVirtualReference cpRef = cpRefs[i];
- final IPath runtimePath = cpRef.getRuntimePath();
- final IVirtualComponent comp = cpRef.getReferencedComponent();
- if (comp instanceof IClasspathDependencyComponent) {
- final IClasspathDependencyComponent cpComp = (IClasspathDependencyComponent) comp;
- if (cpComp.isClassFolder() && cpComp.getClassFolder() != null) {
- IPath targetPath = null;
- targetPath = runtimePath.makeRelative();
- final IContainer container = cpComp.getClassFolder();
- new VirtualComponentFlattenUtility(list, null).addContainer(container, targetPath);
- }
- }
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibReferencesParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibReferencesParticipant.java
deleted file mode 100644
index a91077f6e..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibReferencesParticipant.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * Copy the classpath LIB references from a child with
- * a ../ runtime path into a receiving parent.
- *
- * @author rob
- *
- */
-public class AddClasspathLibReferencesParticipant extends AbstractFlattenParticipant {
- private List<IFlatResource> list;
-
-
- @Override
- public boolean shouldIgnoreReference(IVirtualComponent rootComponent,
- IVirtualReference referenced, FlatComponentTaskModel dataModel) {
- if (referenced.getRuntimePath().toString().startsWith(IClasspathDependencyReceiver.RUNTIME_MAPPING_INTO_CONTAINER))
- return true;
- return false;
- }
-
-
- @Override
- public void finalize(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- this.list = resources;
- if( !(component instanceof IClasspathDependencyReceiver ))
- return;
- if( ((IClasspathDependencyReceiver)component).canReceiveClasspathDependencies())
- addReferencedComponentClasspathDependencies((IClasspathDependencyReceiver)component);
- }
-
- private void addReferencedComponentClasspathDependencies(final IClasspathDependencyReceiver component) {
- final IVirtualReference[] refs = component.getReferences();
- for (int i = 0; i < refs.length; i++) {
- final IVirtualReference reference = refs[i];
- final IPath runtimePath = reference.getRuntimePath();
- final IVirtualComponent referencedComponent = reference.getReferencedComponent();
-
- // if the reference cannot export dependencies, skip
- if( !(referencedComponent instanceof IClasspathDependencyProvider) )
- continue;
-
- if (!referencedComponent.isBinary() && referencedComponent instanceof IClasspathDependencyProvider) {
- final IVirtualReference[] cpRefs = ((IClasspathDependencyProvider) referencedComponent).getJavaClasspathReferences();
- for (int j = 0; j < cpRefs.length; j++) {
- final IVirtualReference cpRef = cpRefs[j];
- IPath cpRefRuntimePath = cpRef.getRuntimePath();
-
- if (cpRef.getReferencedComponent() instanceof IClasspathDependencyComponent) {
- // want to avoid adding dups
- IClasspathDependencyComponent cpComp = (IClasspathDependencyComponent) cpRef.getReferencedComponent();
- // don't want to process class folder refs here
- if (cpComp.isClassFolder())
- continue;
-
- //if path isn't ../, it shouldn't be added here [bug 247090]
- if (!cpRefRuntimePath.toString().startsWith(IClasspathDependencyReceiver.RUNTIME_MAPPING_INTO_CONTAINER))
- continue;
-
- // TODO: verify this cpRefRuntimePath is acceptable?
- //if( !runtimePath.equals(component.getClasspathFolderPath(cpComp))) continue;
-
- cpRefRuntimePath = runtimePath.append(cpRefRuntimePath.removeFirstSegments(1));
- new VirtualComponentFlattenUtility(list, null).addFile(cpComp, cpRefRuntimePath, cpComp);
- }
- }
- }
- }
- }
-
-
- private List<IVirtualReference> getReferencedProjectComponentClasspathDependencies(final IClasspathDependencyReceiver component, FlatComponentTaskModel dataModel) {
- final IVirtualReference[] refs = component.getReferences();
- List<IVirtualReference> validReferences = new ArrayList<IVirtualReference>();
-
- for (int i = 0; i < refs.length; i++) {
- final IVirtualReference reference = refs[i];
- final IVirtualComponent referencedComponent = reference.getReferencedComponent();
-
- // if the reference cannot export dependencies, skip
- if( !(referencedComponent instanceof IClasspathDependencyProvider) )
- continue;
-
- if (!referencedComponent.isBinary() && referencedComponent instanceof IClasspathDependencyProvider) {
- final IVirtualReference[] cpRefs = ((IClasspathDependencyProvider) referencedComponent).getJavaClasspathReferences();
- for (int j = 0; j < cpRefs.length; j++) {
- final IVirtualReference cpRef = cpRefs[j];
- IPath cpRefRuntimePath = cpRef.getRuntimePath();
-
- // TODO: Create a new interface like IClasspathDependencyComponent but for project references
- if (!(cpRef.getReferencedComponent() instanceof IClasspathDependencyComponent)) {
-
- //if path isn't ../, it shouldn't be added here [bug 247090]
- if (!cpRefRuntimePath.toString().startsWith(IClasspathDependencyReceiver.RUNTIME_MAPPING_INTO_CONTAINER))
- continue;
-
- validReferences.add(new ClasspathLibVirtualReference(cpRef));
-
- }
- }
- }
- }
- return validReferences;
-
- }
-
- @Override
- public List<IVirtualReference> getChildModules(IVirtualComponent component, FlatComponentTaskModel dataModel){
- List<IVirtualReference> result = null;
- if( !(component instanceof IClasspathDependencyReceiver ))
- return null;
- // Gather project classpath dependencies from child references
- if( ((IClasspathDependencyReceiver)component).canReceiveClasspathDependencies())
- result = getReferencedProjectComponentClasspathDependencies((IClasspathDependencyReceiver)component, dataModel);
- return result;
- }
-
-
- // Inner class used as a wrapper for VirtualReferences, delegating most of the methods to the wrapped object, except
- // the getRuntimePath() method. This is needed so a reference to a virtual component can be added correctly to the receiving parent
- private static class ClasspathLibVirtualReference implements IVirtualReference{
- private IVirtualReference ref;
- ClasspathLibVirtualReference(IVirtualReference ref){
- this.ref = ref;
- }
-
- public void create(int updateFlags, IProgressMonitor aMonitor) {
- ref.create(updateFlags, aMonitor);
- }
-
- public boolean exists() {
- return ref.exists();
- }
-
- public String getArchiveName() {
- return ref.getArchiveName();
- }
-
- public int getDependencyType() {
- return ref.getDependencyType();
- }
-
- public IVirtualComponent getEnclosingComponent() {
- return ref.getEnclosingComponent();
- }
-
- public IVirtualComponent getReferencedComponent() {
- return ref.getReferencedComponent();
- }
-
- public IPath getRuntimePath() {
- // remove the ../ portion of the path
- return ref.getRuntimePath().removeFirstSegments(1);
- }
-
- public boolean isDerived() {
- return ref.isDerived();
- }
-
- public void setArchiveName(String archiveName) {
- ref.setArchiveName(archiveName);
-
- }
-
- public void setDependencyType(int aDependencyType) {
- ref.setDependencyType(aDependencyType);
-
- }
-
- public void setReferencedComponent(
- IVirtualComponent referencedComponent, EObject dependentObject) {
- ref.setReferencedComponent(referencedComponent, dependentObject);
-
- }
-
- public void setRuntimePath(IPath aRuntimePath) {
- ref.setRuntimePath(aRuntimePath);
- }
- }
-
-// private boolean canExportClasspathComponentDependencies(IVirtualComponent component) {
-// final IProject project = component.getProject();
-// // check for valid project type
-// if (JavaEEProjectUtilities.isEJBProject(project)
-// || JavaEEProjectUtilities.isDynamicWebProject(project)
-// || JavaEEProjectUtilities.isJCAProject(project)
-// || JavaEEProjectUtilities.isUtilityProject(project)) {
-// return true;
-// }
-// return false;
-// }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibRefsProviderParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibRefsProviderParticipant.java
deleted file mode 100644
index 867946ff4..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddClasspathLibRefsProviderParticipant.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.common.internal.modulecore;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * Collect the classpath LIB references from a dependency provider
- * and add to the members list.
- *
- */
-public class AddClasspathLibRefsProviderParticipant extends AbstractFlattenParticipant {
- private List<IFlatResource> list;
-
-
- @Override
- public void finalize(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- this.list = resources;
-
- if (!(component instanceof IClasspathDependencyProvider))
- return;
-
- addReferencedComponentClasspathDependencies((IClasspathDependencyProvider)component);
- }
-
- private void addReferencedComponentClasspathDependencies(final IClasspathDependencyProvider component) {
- final IVirtualReference[] cpRefs = component.getJavaClasspathReferences();
- for (int j = 0; j < cpRefs.length; j++) {
- final IVirtualReference cpRef = cpRefs[j];
- IPath cpRefRuntimePath = cpRef.getRuntimePath();
-
- if (cpRef.getReferencedComponent() instanceof IClasspathDependencyComponent) {
- // want to avoid adding dups
- IClasspathDependencyComponent cpComp = (IClasspathDependencyComponent) cpRef.getReferencedComponent();
- // don't want to process class folder refs here
- if (cpComp.isClassFolder())
- continue;
-
- if (cpRefRuntimePath.toString().startsWith(IClasspathDependencyReceiver.RUNTIME_MAPPING_INTO_CONTAINER))
- continue;
-
- new VirtualComponentFlattenUtility(list, null).addFile(cpComp, cpRefRuntimePath, cpComp);
- }
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddMappedOutputFoldersParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddMappedOutputFoldersParticipant.java
deleted file mode 100644
index bb614adb7..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/AddMappedOutputFoldersParticipant.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-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.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.internal.core.JavaProject;
-import org.eclipse.jst.common.jdt.internal.javalite.IJavaProjectLite;
-import org.eclipse.jst.common.jdt.internal.javalite.JavaCoreLite;
-import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities;
-import org.eclipse.wst.common.componentcore.internal.ComponentResource;
-import org.eclipse.wst.common.componentcore.internal.StructureEdit;
-import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.FilterResourceParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility;
-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility.ShouldIncludeUtilityCallback;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-
-public class AddMappedOutputFoldersParticipant extends AbstractFlattenParticipant implements ShouldIncludeUtilityCallback {
- private List<IFlatResource> list;
- private String[] filteredSuffixes = new String[]{};
-
- public AddMappedOutputFoldersParticipant() {
- // intentionally blank
- }
-
- public AddMappedOutputFoldersParticipant(String[] filtered) {
- this.filteredSuffixes = filtered;
- }
-
- public boolean shouldAddComponentFile(IVirtualComponent component, IFlatFile file) {
- IFlattenParticipant[] delegates = getDelegateParticipants();
- for( int i = 0; i < delegates.length; i++ ) {
- if(!delegates[i].shouldAddExportableFile(null, component, null, file))
- return false;
- }
- return true;
- }
-
- public IFlattenParticipant[] getDelegateParticipants() {
- return new IFlattenParticipant[] {
- FilterResourceParticipant.createSuffixFilterParticipant(filteredSuffixes)
- };
- }
-
- @Override
- public void finalize(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- this.list = resources;
- list.getClass();
- if( !isApprovedComponent(component))
- return;
-
- HashMap<IContainer, IPath> mapped = getMappedJavaOutputContainers(component.getProject());
- Iterator<IContainer> i = mapped.keySet().iterator();
- while(i.hasNext()) {
- IContainer next = i.next();
- try {
- new VirtualComponentFlattenUtility(list, this).addContainer(next, mapped.get(next));
- } catch( CoreException ce) {}
- }
- }
-
- protected boolean isApprovedComponent(IVirtualComponent vc) {
- // TODO
- return true;
- }
-
- public final static HashMap<IContainer, IPath> getMappedJavaOutputContainers(IProject project) {
- ComponentResourceProxy[] proxies = findAllMappingProxies(project);
- IJavaProjectLite javaProjectLite = JavaCoreLite.create(project);
-
- HashMap<IContainer, IPath> map = new HashMap<IContainer, IPath>();
- IFile classpathFile = project.getFile(JavaProject.CLASSPATH_FILENAME);
- if( javaProjectLite.exists() && classpathFile.exists()) {
- IClasspathEntry[] entries = javaProjectLite.readRawClasspath();
- for (IClasspathEntry entry : entries) {
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- IPath cpePath = entry.getPath();
- for( int i = 0; i < proxies.length; i++ ) {
- if( cpePath.equals(new Path(project.getName()).append(proxies[i].source).makeAbsolute())) {
- IContainer outputContainer = JavaLiteUtilities.getJavaOutputContainer(javaProjectLite, entry);
- if (!map.containsKey(outputContainer)) {
- map.put(outputContainer, proxies[i].runtimePath);
- }
- }
- // TODO
- }
- }
- }
- }
- return map;
- }
-
- /*
- * This code below is also duplicated in common.ui in the generic page
- * to handle module assembly
- */
-
- public static ComponentResourceProxy[] findAllMappingProxies(IProject project) {
- ComponentResource[] allMappings = findAllMappings(project);
- ComponentResourceProxy[] proxies = new ComponentResourceProxy[allMappings.length];
- for( int i = 0; i < allMappings.length; i++ ) {
- proxies[i] = new ComponentResourceProxy(
- allMappings[i].getSourcePath(),
- allMappings[i].getRuntimePath());
- }
- return proxies;
- }
-
- protected static ComponentResource[] findAllMappings(IProject project) {
- StructureEdit structureEdit = null;
- try {
- structureEdit = StructureEdit.getStructureEditForRead(project);
- WorkbenchComponent component = structureEdit.getComponent();
- Object[] arr = component.getResources().toArray();
- ComponentResource[] result = new ComponentResource[arr.length];
- for( int i = 0; i < arr.length; i++ )
- result[i] = (ComponentResource)arr[i];
- return result;
- } catch(Exception e) {
- } finally {
- if( structureEdit != null )
- structureEdit.dispose();
- }
- return new ComponentResource[]{};
- }
-
- public static class ComponentResourceProxy {
- public IPath source, runtimePath;
- public ComponentResourceProxy(IPath source, IPath runtimePath) {
- this.source = source;
- this.runtimePath = runtimePath;
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerReferenceResolver.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerReferenceResolver.java
deleted file mode 100644
index c942e136a..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerReferenceResolver.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage;
-import org.eclipse.wst.common.componentcore.internal.DependencyType;
-import org.eclipse.wst.common.componentcore.internal.ReferencedComponent;
-import org.eclipse.wst.common.componentcore.internal.impl.PlatformURLModuleConnection;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualReference;
-import org.eclipse.wst.common.componentcore.resolvers.IReferenceResolver;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-public class ClasspathContainerReferenceResolver implements IReferenceResolver {
- public static final String PROTOCOL = PlatformURLModuleConnection.MODULE_PROTOCOL
- +IPath.SEPARATOR + ClasspathContainerVirtualComponent.CLASSPATH_CON + IPath.SEPARATOR;
- public boolean canResolve(IVirtualComponent context,
- ReferencedComponent referencedComponent) {
- URI uri = referencedComponent.getHandle();
- if( uri.segmentCount() > 2 && uri.segment(0).equals(ClasspathContainerVirtualComponent.CLASSPATH)
- && uri.segment(1).equals(ClasspathContainerVirtualComponent.CON))
- return true;
- return false;
- }
-
- public IVirtualReference resolve(IVirtualComponent context,
- ReferencedComponent referencedComponent) {
- URI uri = referencedComponent.getHandle();
- if( uri.segmentCount() > 2 && uri.segment(0).equals(ClasspathContainerVirtualComponent.CLASSPATH)
- && uri.segment(1).equals(ClasspathContainerVirtualComponent.CON)) {
- String path = uri.toString().substring(PROTOCOL.length());
- IVirtualReference ref = new VirtualReference(context,
- new ClasspathContainerVirtualComponent(context.getProject(), context, path));
- ref.setArchiveName(referencedComponent.getArchiveName());
- ref.setRuntimePath(referencedComponent.getRuntimePath());
- ref.setDependencyType(referencedComponent.getDependencyType().getValue());
- return ref;
- }
- return null;
- }
-
- public boolean canResolve(IVirtualReference reference) {
- if( reference.getReferencedComponent() instanceof ClasspathContainerVirtualComponent )
- return true;
- return false;
- }
-
- public ReferencedComponent resolve(IVirtualReference reference) {
- ClasspathContainerVirtualComponent vc = (ClasspathContainerVirtualComponent)reference.getReferencedComponent();
- ReferencedComponent rc = ComponentcorePackage.eINSTANCE.getComponentcoreFactory().createReferencedComponent();
- rc.setArchiveName(reference.getArchiveName());
- rc.setRuntimePath(reference.getRuntimePath());
- rc.setHandle(URI.createURI(PROTOCOL + vc.getClasspathContainerPath()));
- rc.setDependencyType(DependencyType.CONSUMES_LITERAL);
- return rc;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerVirtualComponent.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerVirtualComponent.java
deleted file mode 100644
index 93b5ca59e..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ClasspathContainerVirtualComponent.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IContainer;
-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.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.common.componentcore.internal.resources.AbstractResourceListVirtualComponent;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualFile;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualFolder;
-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.IVirtualResource;
-
-public class ClasspathContainerVirtualComponent extends
- AbstractResourceListVirtualComponent {
- public static final String CLASSPATH = "classpath"; //$NON-NLS-1$
- public static final String CON = "con"; //$NON-NLS-1$
- public static final String CLASSPATH_CON = CLASSPATH + Path.SEPARATOR + CON;
- private String containerPath;
- private IClasspathEntry[] containerEntries;
- private IClasspathContainer container;
- private boolean initialized = false;
- private Object initLock = new Object();
- public ClasspathContainerVirtualComponent(IProject p,
- IVirtualComponent referencingComponent, String containerPath) {
- super(p, referencingComponent);
- this.containerPath = containerPath;
- }
-
- private void init() {
- synchronized (initLock) {
- if (initialized) {
- return;
- }
- }
- try {
- IClasspathContainer localContainer = JavaCore.getClasspathContainer(new Path(containerPath), JavaCore.create(project));
- IClasspathEntry[] localcontainerEntries = null;
- if (localContainer != null) {
- localcontainerEntries = localContainer.getClasspathEntries();
- } else {
- localcontainerEntries = new IClasspathEntry[] {};
- }
- synchronized (initLock) {
- if(initialized){
- return;
- }
- container = localContainer;
- containerEntries = localcontainerEntries;
- }
- } catch (JavaModelException jme) {
- // eat it
- } finally {
- synchronized (initLock) {
- initialized = true;
- }
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if(this == o){
- return true;
- }
-
- if(!super.equals(o)){
- return false;
- }
- ClasspathContainerVirtualComponent other = (ClasspathContainerVirtualComponent) o;
- return containerPath == null ? other.containerPath == null : containerPath.equals(other.containerPath);
- }
-
- @Override
- public int hashCode() {
- return super.hashCode() + (containerPath == null ? 0 : containerPath.hashCode());
- }
-
- public String getContainerPath() {
- return containerPath;
- }
-
- @Override
- public String getId() {
- return CLASSPATH_CON + Path.SEPARATOR + containerPath;
- }
-
- @Override
- protected String getFirstIdSegment() {
- // Do not call
- return null;
- }
-
- public IClasspathContainer getClasspathContainer(){
- init();
- return container;
- }
-
- private IClasspathEntry[] getEntries() {
- init();
- return containerEntries;
- }
-
- public String getClasspathContainerPath() {
- return containerPath;
- }
-
- @Override
- public IVirtualFolder getRootFolder() {
- IVirtualFolder folder = new VirtualFolder(project, new Path("/")) { //$NON-NLS-1$
- @Override
- public IVirtualResource[] members(int memberFlags) throws CoreException {
- IClasspathEntry[] entries = getEntries();
- ArrayList<IVirtualFile> jars = new ArrayList<IVirtualFile>();
- for(IClasspathEntry entry: entries) {
- if( entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- File f = entry.getPath().toFile();
- jars.add(new AbsoluteVirtualFile(getProject(), new Path("/"), f)); //$NON-NLS-1$
- }
- }
- return jars.toArray(new IVirtualFile[jars.size()]);
- }
- };
- return folder;
- }
-
- protected class AbsoluteVirtualFile extends VirtualFile {
- private File file;
- public AbsoluteVirtualFile(IProject aComponentProject,
- IPath aRuntimePath, File absoluteFile) {
- super(aComponentProject, aRuntimePath, null);
- this.file = absoluteFile;
- }
- @Override
- public Object getAdapter(Class adapter) {
- if( File.class.equals(adapter))
- return file;
- return null;
- }
- }
-
- @Override
- protected IContainer[] getUnderlyingContainers() {
- // do not implement, overriding key method members(int)
- return new IContainer[]{};
- }
-
- @Override
- protected IResource[] getLooseResources() {
- // do not implement, overriding key method members(int)
- return new IResource[]{};
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyComponent.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyComponent.java
deleted file mode 100644
index f4b044eaf..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyComponent.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-public interface IClasspathDependencyComponent extends IVirtualComponent {
- public boolean isClassFolder();
- public IContainer getClassFolder();
- public IVirtualReference[] getReferences();
- public String[] getManifestClasspath();
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyProvider.java
deleted file mode 100644
index 37fcd4494..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyProvider.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * This class is meant to mark a virtual component as
- * a type of virtual component which can provide
- * classpath dependencies to be included in a parent component
- *
- * @author rob.stryker@redhat.com
- *
- */
-public interface IClasspathDependencyProvider extends IVirtualComponent {
- /**
- * Return a list of references which should be exported into a
- * parent module's appropriate folder for classpath entities.
- *
- * @return
- */
- public IVirtualReference[] getJavaClasspathReferences();
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyReceiver.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyReceiver.java
deleted file mode 100644
index eb267251c..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IClasspathDependencyReceiver.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-
-/**
- * This class is meant to mark a virtual component as
- * a type of virtual component which can receive and handle
- * classpath dependencies from child references
- *
- * @author rob.stryker@redhat.com
- *
- */
-public interface IClasspathDependencyReceiver extends IVirtualComponent {
- /**
- * Runtime path used to indicate that the resolved contributions from a classpath entry should be
- * mapped into the exported/deployed structure of the parent module at the same location that the target module
- * is mapped.
- */
- public static final String RUNTIME_MAPPING_INTO_CONTAINER = "../"; //$NON-NLS-1$
-
- /**
- * IPath value of RUNTIME_MAPPING_INTO_CONTAINER.
- */
- public static final IPath RUNTIME_MAPPING_INTO_CONTAINER_PATH = new Path(RUNTIME_MAPPING_INTO_CONTAINER);
-
-
- /**
- * Returns whether this virtual component can accept
- * classpath references from children.
- *
- * @return
- */
- public boolean canReceiveClasspathDependencies();
-
- /**
- * Return the preferred folder to place child classpath
- * dependencies, or null if they can go wherever the reference directs
- *
- * @return
- */
- public IPath getClasspathFolderPath(IClasspathDependencyComponent component);
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ISingleRootStatus.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ISingleRootStatus.java
deleted file mode 100644
index aeb87a421..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ISingleRootStatus.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.common.internal.modulecore;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-
-public interface ISingleRootStatus extends IStatus {
-
- // Information [0-32]
- public static final int SINGLE_ROOT_CONTAINER_FOUND = 1;
- public static final int SINGLE_ROOT_FORCED = 2;
- //DO NOT ADD ANY OTHER CONSTANTS TO THE INFORMATION SECTION
-
- // Warnings [33-127]
- public static final int SOURCE_PATH_NOT_FOUND = 33;
-
- // Errors [128-512]
- public static final int NO_COMPONENT_FOUND = 129;
- public static final int EXPLICITLY_DISABLED = 130;
- public static final int CONSUMABLE_REFERENCES_FOUND = 131;
- public static final int LINKED_RESOURCES_FOUND = 132;
- public static final int NO_RESOURCE_MAPS_FOUND = 133;
- public static final int JAVA_OUTPUT_NOT_A_CONTENT_ROOT = 134;
- public static final int JAVA_OUTPUT_GREATER_THAN_1 = 135;
- public static final int RUNTIME_PATH_NOT_ROOT = 136;
- public static final int SOURCE_NOT_JAVA_CONTAINER = 137;
- public static final int BINARY_COMPONENT_FOUND = 138;
-
- // callback-contributed errors: 512 and up
-
- /**
- * Returns the path with which the status is associated.
- *
- * @return the path with which the status is associated.
- */
- public IPath getPath();
-
- /**
- * Will return the IContainer that is used as the "single-root".
- * If a "single-root" structure is not found this method will return null.
- *
- * @return the "single-root" container
- */
- public IContainer getSingleRoot();
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IgnoreJavaInSourceFolderParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IgnoreJavaInSourceFolderParticipant.java
deleted file mode 100644
index bb8ee418a..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/IgnoreJavaInSourceFolderParticipant.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jst.common.jdt.internal.javalite.IJavaProjectLite;
-import org.eclipse.jst.common.jdt.internal.javalite.JavaCoreLite;
-import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities;
-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-
-public class IgnoreJavaInSourceFolderParticipant extends AbstractFlattenParticipant {
- IJavaProjectLite liteProj = null;
- List<IPath> containers = new ArrayList<IPath>();
-
- @Override
- public void initialize(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- if( hasJava(component) ) {
- liteProj = JavaCoreLite.create(component.getProject());
- if( liteProj != null && JavaLiteUtilities.getJavaOutputContainers(liteProj).size() > 0) {
- List<IContainer> temp = JavaLiteUtilities.getJavaSourceContainers(liteProj);
- Iterator<IContainer> i = temp.iterator();
- while(i.hasNext()) {
- containers.add(i.next().getFullPath());
- }
- }
- }
- }
-
- @Override
- public boolean shouldAddExportableFile(IVirtualComponent rootComponent,
- IVirtualComponent currentComponent,
- FlatComponentTaskModel dataModel, IFlatFile file) {
- if( rootComponent == currentComponent ) {
- if( hasJava(rootComponent) ) {
- /*
- * Only ignore when given an ear, war, etc, and not
- * one of it's consumed children, which may be a fileset,
- * or some other unknown type of contributor
- */
- IFile t = (IFile)file.getAdapter(IFile.class);
- if( t != null ) {
- Iterator<IPath> i = containers.iterator();
- while(i.hasNext()) {
- if( i.next().isPrefixOf(t.getFullPath()) && t.getName().endsWith(".java")) { //$NON-NLS-1$
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- protected boolean hasJava(IVirtualComponent component) {
- try {
- return component.getProject().isNatureEnabled("org.eclipse.jdt.core.javanature"); //$NON-NLS-1$
- } catch( CoreException ce) {
- // ignore
- }
- return false;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ReplaceManifestExportParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ReplaceManifestExportParticipant.java
deleted file mode 100644
index 257f19729..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/ReplaceManifestExportParticipant.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import java.io.File;
-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.jst.common.frameworks.CommonFrameworksPlugin;
-import org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities;
-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatFile;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * This class is solely responsible for replacing manifest.mf files
- * which require updating before being exported
- *
- * @author rob
- *
- */
-public class ReplaceManifestExportParticipant extends AbstractFlattenParticipant {
- //protected static final IPath MANIFEST_PATH = new Path(J2EEConstants.MANIFEST_URI);
- private IPath manifestPath;
-
- public ReplaceManifestExportParticipant(IPath manifestPath) {
- this.manifestPath = manifestPath;
- }
-
- @Override
- public void finalize(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- forceUpdate(component, dataModel, resources);
- }
-
- public void forceUpdate(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- List<String> javaClasspathURIs = getClasspathURIs(component);
- if( !javaClasspathURIs.isEmpty()) {
- // find the old manifest
- IFlatFolder parent = (IFlatFolder)VirtualComponentFlattenUtility.getExistingModuleResource(resources, manifestPath.removeLastSegments(1));
- if( parent != null ) {
- IFlatResource[] children = parent.members();
- IFile original = null;
- int originalIndex = 0;
- for( int i = 0; i < children.length; i++) {
- if( children[i].getName().equals(manifestPath.lastSegment())) {
- original = (IFile)children[i].getAdapter(IFile.class);
- originalIndex = i;
- File newManifest = getNewManifest(component.getProject(), original, javaClasspathURIs);
- FlatFile newManifestExportable = new FlatFile(newManifest, newManifest.getName(), manifestPath.removeLastSegments(1));
- children[originalIndex] = newManifestExportable;
- parent.setMembers(children);
- return;
- }
- }
- }
- }
- }
-
- /**
- * Return whichever File is the new one, even if it's the same as the old one
- * @return
- */
- public File getNewManifest(IProject project, IFile originalManifest, List<String> javaClasspathURIs) {
- final IPath workingLocation = project.getWorkingLocation(CommonFrameworksPlugin.PLUGIN_ID);
- // create path to temp MANIFEST.MF
- final IPath tempManifestPath = workingLocation.append(manifestPath);
- final File tempFile = tempManifestPath.toFile();
- if (!tempFile.exists()) {
- // create parent dirs for temp MANIFEST.MF
- final File parent = tempFile.getParentFile();
- if (!parent.exists()) {
- if (!parent.mkdirs()) {
- return originalManifest != null ? originalManifest.getLocation().toFile() : null;
- }
- }
- }
- try {
- ManifestUtilities.updateManifestClasspath(originalManifest, javaClasspathURIs, tempFile);
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
- }
- return tempFile.exists() ? tempFile :
- originalManifest != null ? originalManifest.getLocation().toFile() : null;
- }
-
- public static List<String> getClasspathURIs(IVirtualComponent component) {
- ArrayList<String> uris = new ArrayList<String>();
- uris = new ArrayList<String>();
- if (component instanceof IClasspathDependencyProvider) {
- final IClasspathDependencyProvider j2eeComp = (IClasspathDependencyProvider) component;
- final IVirtualReference[] refs = j2eeComp.getJavaClasspathReferences();
- if (refs != null) {
- for (int i = 0; i < refs.length; i++) {
- if (refs[i].getRuntimePath().toString().startsWith(IClasspathDependencyReceiver.RUNTIME_MAPPING_INTO_CONTAINER)) {
- uris.add(refs[i].getRuntimePath().removeFirstSegments(1).append(refs[i].getArchiveName()).toString());
- }
- }
- }
- }
- return uris;
- }
-
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java
deleted file mode 100644
index 0e9059d68..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-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.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.common.internal.modulecore.SingleRootUtil.SingleRootCallback;
-import org.eclipse.wst.common.componentcore.internal.DependencyType;
-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.ChildModuleReference;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatFolder;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
-import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility;
-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * Single root optimization.
- * @author rob
- */
-public class SingleRootExportParticipant extends AbstractFlattenParticipant {
- private SingleRootParticipantCallback callbackHandler;
- private IVirtualComponent rootComponent;
- private FlatComponentTaskModel dataModel;
- private IFlattenParticipant[] delegates;
- private List<IChildModuleReference> children;
-
- public interface SingleRootParticipantCallback extends SingleRootCallback {
- public IFlattenParticipant[] getDelegateParticipants();
- }
-
- public SingleRootExportParticipant() {
- super();
- callbackHandler = null;
- }
- public SingleRootExportParticipant(SingleRootParticipantCallback handler) {
- this();
- callbackHandler = handler;
- }
-
- @Override
- public void initialize(IVirtualComponent component,
- FlatComponentTaskModel dataModel, List<IFlatResource> resources) {
- this.rootComponent = component;
- this.dataModel = dataModel;
- }
-
-
- private void initializeDelegates() {
- if (callbackHandler != null) {
- delegates = callbackHandler.getDelegateParticipants();
- }
- else {
- delegates = new IFlattenParticipant[] {};
- }
- }
-
- @Override
- public boolean canOptimize(IVirtualComponent component,
- FlatComponentTaskModel dataModel) {
- return new SingleRootUtil(component, callbackHandler).isSingleRoot();
- }
-
- @Override
- public void optimize(IVirtualComponent component, FlatComponentTaskModel dataModel,
- List<IFlatResource> resources, List<IChildModuleReference> childModules) {
- try {
- resources.clear(); // We want complete control
- childModules.clear();
- children = childModules;
- initializeDelegates();
-
- IContainer container = new SingleRootUtil(component, callbackHandler).getSingleRoot();
- IFlatResource[] mr = getMembers(resources, container, new Path("")); //$NON-NLS-1$
- int size = mr.length;
- for (int j = 0; j < size; j++) {
- resources.add(mr[j]);
- }
-
- addChildModules(component);
-
- // run finalizers
- for (int i = 0; i < delegates.length; i++) {
- delegates[i].finalize(component, dataModel, resources);
- }
- } catch( CoreException ce ) {
- // TODO
- }
- }
-
- protected IFlatResource[] getMembers(List<IFlatResource> members,
- IContainer cont, IPath path) throws CoreException {
- IResource[] res = cont.members();
- int size2 = res.length;
- List list = new ArrayList(size2);
- for (int j = 0; j < size2; j++) {
- if (res[j] instanceof IContainer) {
- IContainer cc = (IContainer) res[j];
- // Retrieve already existing module folder if applicable
- IFlatFolder mf = (FlatFolder) VirtualComponentFlattenUtility.getExistingModuleResource(members,path.append(new Path(cc.getName()).makeRelative()));
- if (mf == null) {
- mf = new FlatFolder(cc, cc.getName(), path);
- IFlatFolder parent = (FlatFolder) VirtualComponentFlattenUtility.getExistingModuleResource(members, path);
- if (path.isEmpty() || path.equals(new Path("/"))) //$NON-NLS-1$
- members.add(mf);
- else {
- if (parent == null)
- parent = VirtualComponentFlattenUtility.ensureParentExists(members, path, cc);
- VirtualComponentFlattenUtility.addMembersToModuleFolder(parent, new IFlatResource[] {mf});
- }
- }
- IFlatResource[] mr = getMembers(members, cc, path.append(cc.getName()));
- VirtualComponentFlattenUtility.addMembersToModuleFolder(mf, mr);
- } else {
- IFile f = (IFile) res[j];
- IFlatFile mf = VirtualComponentFlattenUtility.createModuleFile(f, path);
- if (shouldAddComponentFile(rootComponent, mf))
- list.add(mf);
- }
- }
- FlatResource[] mr = new FlatResource[list.size()];
- list.toArray(mr);
- return mr;
- }
-
- protected void addChildModules(IVirtualComponent vc) throws CoreException {
- Map<String, Object> options = new HashMap<String, Object>();
- options.put(IVirtualComponent.REQUESTED_REFERENCE_TYPE, IVirtualComponent.FLATTENABLE_REFERENCES);
- IVirtualReference[] allReferences = vc.getReferences(options);
- for (int i = 0; i < allReferences.length; i++) {
- IVirtualReference reference = allReferences[i];
- if (reference.getDependencyType() == DependencyType.USES ) {
- if (shouldIgnoreReference(vc, reference))
- continue;
-
- if (isChildModule(vc, reference)) {
- ChildModuleReference cm = new ChildModuleReference(reference, new Path("")); //$NON-NLS-1$
- List<IChildModuleReference> duplicates = new ArrayList();
- for (IChildModuleReference tmp : children) {
- if (tmp.getRelativeURI().equals(cm.getRelativeURI()))
- duplicates.add(tmp);
- }
- children.removeAll(duplicates);
- children.add(cm);
- }
- }
- }
- }
-
- protected boolean isChildModule(IVirtualComponent component, IVirtualReference referencedComponent) {
- for (int i = 0; i < delegates.length; i++) {
- if (delegates[i].isChildModule(component, referencedComponent, dataModel))
- return true;
- }
- return false;
- }
-
- protected boolean shouldIgnoreReference(IVirtualComponent component, IVirtualReference referencedComponent) {
- for (int i = 0; i < delegates.length; i++ ) {
- if (delegates[i].shouldIgnoreReference(component, referencedComponent, dataModel))
- return true;
- }
- return false;
- }
-
-
- public boolean shouldAddComponentFile(IVirtualComponent component, IFlatFile file) {
- for (int i = 0; i < delegates.length; i++) {
- if (delegates[i].isChildModule(component, dataModel, file)) {
- ChildModuleReference child = new ChildModuleReference(component.getProject(), file);
- children.add(child);
- return false;
- } else if (!delegates[i].shouldAddExportableFile(component, component, dataModel, file))
- return false;
- }
- return true;
- }
-
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootStatus.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootStatus.java
deleted file mode 100644
index b78535ff8..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootStatus.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.common.internal.modulecore;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-
-public class SingleRootStatus extends Status implements ISingleRootStatus {
-
- IPath path;
- IContainer container;
-
- public SingleRootStatus(int type, int code, IPath resourcePath, IContainer containerPath, String message, Throwable exception) {
- super(type, CommonFrameworksPlugin.PLUGIN_ID, code, message, exception);
- path = resourcePath;
- container = containerPath;
- }
-
- public SingleRootStatus(int code, IPath resourcePath, IContainer containerPath) {
- this(getSeverity(code), code, resourcePath, containerPath, null, null);
- }
-
- public IPath getPath() {
- return path;
- }
-
- public IContainer getSingleRoot() {
- return container;
- }
-
- protected static int getSeverity(int code) {
- if( code < 33 ) return IStatus.INFO;
- if( code < 128 ) return IStatus.WARNING;
- return IStatus.ERROR;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootUtil.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootUtil.java
deleted file mode 100644
index 0a5f43847..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootUtil.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.common.internal.modulecore;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities;
-import org.eclipse.wst.common.componentcore.internal.ComponentResource;
-import org.eclipse.wst.common.componentcore.internal.Property;
-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;
-
-public class SingleRootUtil {
- public interface SingleRootCallback {
- public boolean canValidate(IVirtualComponent vc);
- public void validate(SingleRootUtil util, IVirtualComponent vc, IProject project, List resourceMaps);
- }
-
- /**
- * Used to return immediately after the first error code is found.
- */
- public static final int INCLUDE_FIRST_ERROR = 0x08;
- /**
- * Used to capture all status codes (error, warning, info)
- */
- public static final int INCLUDE_ALL = 0x07;
- /**
- * Used to capture all error and warning status codes only.
- */
- public static final int INCLUDE_ERRORS_AND_WARNINGS = 0x06;
- /**
- * Used to capture all error status codes only.
- */
- public static final int INCLUDE_ERRORS = 0x04;
-
- private static final int WARNINGS = 0x02;
- private static final int INFO = 0x01;
- private static final int CANCEL = 0x0;
- private static final int GET_SINGLE_ROOT_CONTAINER = 0x09;
- private static String USE_SINGLE_ROOT_PROPERTY = "useSingleRoot"; //$NON-NLS-1$
- private IVirtualComponent aComponent;
- private SingleRootCallback callback;
- private List<IContainer> cachedSourceContainers;
- private IContainer[] cachedOutputContainers;
- private MultiStatus wrapperStatus;
- private int VALIDATE_FLAG;
-
- public SingleRootUtil(IVirtualComponent component) {
- this(component, null);
- }
-
- public SingleRootUtil(IVirtualComponent component, SingleRootCallback callback) {
- this.aComponent = component;
- this.callback = callback;
- }
-
-
- /**
- * Returns true if this module has a simple structure based on a
- * single-root folder, and false otherwise.
- *
- * In a single-root structure, all files that are contained within the root folder
- * are part of the module, and are already in the correct module structure. No
- * module resources exist outside of this single folder.
- *
- * @return true if this module has a single-root structure, and
- * false otherwise
- */
- public boolean isSingleRoot() {
- return validateSingleRoot(INCLUDE_FIRST_ERROR).getSeverity() != IStatus.ERROR;
- }
-
- /**
- * Will attempt to return the IContainer that counts as the "single-root".
- * If this module does not qualify as a "single-root" module, this
- * method will return null. Otherwise it will return an IContainer
- * that may be used as the single-root container.
- *
- * @return IContainer representing single-root container
- */
- public IContainer getSingleRoot() {
- IStatus status = validateSingleRoot(GET_SINGLE_ROOT_CONTAINER);
- if (status.getSeverity() == IStatus.INFO) {
- IStatus[] children = ((MultiStatus) status).getChildren();
- ISingleRootStatus rootStatus = (ISingleRootStatus) children[0];
- return rootStatus.getSingleRoot();
- }
- return null;
- }
-
- /**
- * Validates whether the component module has a single-root structure.
- * An IStatus with a severity of OK is returned for a valid single-root
- * structure. A MultiStatus containing children of type ISingleRootStatus
- * is returned if any status codes were captured during the validation.
- * A MultiStatus with a severity of INFO or WARNING is returned for a valid
- * single-root structure containing status codes with no severities of ERROR.
- * A MultiStatus with a severity of ERROR means the component does not have a
- * valid single-root structure.
- *
- * @param flag - indicates the status codes (by severity) to capture during
- * the validation. The INLCUDE_ALL flag will also capture the
- * single-root container if a single-root structure was found.
- * Valid flags are:
- * INCLUDE_ALL
- * INCLUDE_ERRORS_AND_WARNINGS
- * INCLUDE_ERRORS
- * INCLUDE_FIRST_ERROR
- *
- * @return IStatus
- */
- public IStatus validateSingleRoot(int flag) {
- VALIDATE_FLAG = flag;
- wrapperStatus = null;
- StructureEdit edit = null;
- try {
- edit = StructureEdit.getStructureEditForRead(getProject());
- if (edit == null || edit.getComponent() == null) {
- reportStatus(ISingleRootStatus.NO_COMPONENT_FOUND);
- return getStatus();
- }
-
- if (aComponent.isBinary()) {
- reportStatus(ISingleRootStatus.BINARY_COMPONENT_FOUND);
- return getStatus();
- }
-
- // 229650 - check to see if the property 'useSingleRoot' is defined.
- Boolean useSingleRoot = getUseSingleRootProperty(edit);
- if (useSingleRoot != null) {
- //check if it was set to false
- if (!useSingleRoot.booleanValue()) {
- reportStatus(ISingleRootStatus.EXPLICITLY_DISABLED);
- }
- else {
- reportStatus(ISingleRootStatus.SINGLE_ROOT_FORCED, aComponent.getRootFolder().getUnderlyingFolder());
- }
- return getStatus();
- }
-
- // if there are any consumed references, this is not single-root
- if (hasConsumableReferences(aComponent)) {
- reportStatus(ISingleRootStatus.CONSUMABLE_REFERENCES_FOUND);
- if (VALIDATE_FLAG == CANCEL)
- return getStatus();
- }
-
- // if there are any linked resources then this is not a single-root module
- if (rootFoldersHaveLinkedContent()) {
- reportStatus(ISingleRootStatus.LINKED_RESOURCES_FOUND);
- if (VALIDATE_FLAG == CANCEL)
- return getStatus();
- }
-
- List resourceMaps = edit.getComponent().getResources();
-
- // If the list is empty, return false
- if (resourceMaps.size() < 1) {
- reportStatus(ISingleRootStatus.NO_RESOURCE_MAPS_FOUND);
- return getStatus();
- }
-
- if (callback != null && callback.canValidate(aComponent)) {
- callback.validate(this, aComponent, getProject(), resourceMaps);
- }
- if (VALIDATE_FLAG != CANCEL) {
- validateProject(resourceMaps);
- }
- return getStatus();
- } finally {
- cachedOutputContainers = null;
- cachedSourceContainers = null;
- if (edit != null)
- edit.dispose();
- }
- }
-
- protected Boolean getUseSingleRootProperty(StructureEdit edit) {
- WorkbenchComponent wbComp = edit.getComponent();
- final List componentProperties = wbComp.getProperties();
- if (componentProperties != null) {
- final Iterator componentPropertiesIterator = componentProperties.iterator();
- while (componentPropertiesIterator.hasNext()) {
- Property wbProperty = (Property) componentPropertiesIterator.next();
- if (USE_SINGLE_ROOT_PROPERTY.equals(wbProperty.getName())) {
- return Boolean.valueOf(wbProperty.getValue());
- }
- }
- }
- return null;
- }
-
- protected boolean hasConsumableReferences(IVirtualComponent vc) {
- IVirtualReference[] refComponents = vc.getReferences();
- for (int i = 0; i < refComponents.length; i++) {
- IVirtualReference reference = refComponents[i];
- if (reference != null && reference.getDependencyType()==IVirtualReference.DEPENDENCY_TYPE_CONSUMES) {
- return true;
- }
- }
- return false;
- }
-
- private void validateProject(List resourceMaps) {
- // Ensure there are only source folder component resource mappings to the root content folder
- if (isRootResourceMapping(resourceMaps)) {
- IContainer[] javaOutputFolders = getJavaOutputFolders();
- // Verify only one java outputfolder
- if (javaOutputFolders.length == 1) {
- // By the time we get here we know: for any folders defined as source in the
- // .component file that they are also java source folders.
- if (!isSourceContainer(javaOutputFolders[0])) {
- // The single output folder is NOT a source folder so this is single-rooted. Since the
- // output folder (something like classes or bin) is not a source folder, JDT copies all files
- // (including non Java files) to this folder, so every resource needed at runtime is located
- // in a single directory.
- reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, javaOutputFolders[0]);
- return;
- }
- // Verify the java output folder is the same as one of the content roots
- IPath javaOutputPath = getJavaOutputFolders()[0].getProjectRelativePath();
- IContainer[] rootFolders = aComponent.getRootFolder().getUnderlyingFolders();
- for (int i=0; i < rootFolders.length; i++) {
- IPath compRootPath = rootFolders[i].getProjectRelativePath();
- if (javaOutputPath.equals(compRootPath)) {
- reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, aComponent.getRootFolder().getUnderlyingFolder());
- return;
- }
- }
- reportStatus(ISingleRootStatus.JAVA_OUTPUT_NOT_A_CONTENT_ROOT);
- }
- else {
- reportStatus(ISingleRootStatus.JAVA_OUTPUT_GREATER_THAN_1);
- }
- }
- }
-
- public IContainer[] getJavaOutputFolders() {
- if (cachedOutputContainers == null)
- cachedOutputContainers = getJavaOutputFolders(aComponent);
- return cachedOutputContainers;
- }
-
- public static IContainer[] getJavaOutputFolders(IVirtualComponent component) {
- if (component == null)
- return new IContainer[0];
-
- List<IContainer> l = JavaLiteUtilities.getJavaOutputContainers(component);
- return l.toArray(new IContainer[l.size()]);
- }
-
- /**
- * Checks if the path argument is to a source container for the project.
- *
- * @param a workspace relative full path
- * @return is path a source container?
- */
- public boolean isSourceContainer(IContainer sourceContainer) {
- if (cachedSourceContainers == null) {
- cachedSourceContainers = getSourceContainers(aComponent);
- }
- return cachedSourceContainers.contains(sourceContainer);
- }
-
- public static List<IContainer> getSourceContainers(IVirtualComponent component) {
- if (component == null)
- Collections.emptyList();
- return JavaLiteUtilities.getJavaSourceContainers(component);
- }
-
- /*
- * This method returns true if the root folders of this component have any linked resources (folder or file);
- * Otherwise false is returned.
- */
- private boolean rootFoldersHaveLinkedContent() {
- if (this.aComponent != null) {
- final IContainer[] rootFolders = this.aComponent.getRootFolder().getUnderlyingFolders();
- for (int i = 0; i < rootFolders.length; i++) {
- try {
- boolean hasLinkedContent = this.hasLinkedContent(rootFolders[i]);
- if (hasLinkedContent) {
- return true;
- }
- }
- catch (CoreException coreEx) {
- CommonFrameworksPlugin.logError(coreEx);
- }
- }
- }
- return false;
- }
-
- /*
- * If the resource to check is a file then this method will return true if the file is linked. If the resource to
- * check is a folder then this method will return true if it, any of its sub directories, or any file contained
- * with-in this directory of any of it's sub directories are linked. Otherwise false is returned.
- */
- private boolean hasLinkedContent(final IResource resourceToCheck) throws CoreException {
- if ((resourceToCheck != null) && resourceToCheck.isAccessible()) {
- // skip non-accessible files
- if (resourceToCheck.isLinked()) {
- return true;
- }
- switch (resourceToCheck.getType()) {
- case IResource.FOLDER:
- // recursively check sub directory contents
- final IResource[] subDirContents = ((IFolder) resourceToCheck).members();
- for (int i = 0; i < subDirContents.length; i++) {
- if (hasLinkedContent(subDirContents[i])) {
- return true;
- }
- }
- break;
- case IResource.FILE:
- return resourceToCheck.isLinked();
- default:
- // skip as we only care about files and folders
- break;
- }
- }
- return false;
- }
-
- /**
- * Ensure that any component resource mappings are for source folders and
- * that they map to the root content folder
- *
- * @param resourceMaps
- * @return boolean
- */
- private boolean isRootResourceMapping(List resourceMaps) {
- for (int i=0; i < resourceMaps.size(); i++) {
- ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i);
- // Verify it maps to "/" for the content root
- if (!isRootMapping(resourceMap)) {
- reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT, resourceMap.getRuntimePath());
- if (VALIDATE_FLAG == CANCEL) return false;
- }
-
- // verify it is also a src container
- IPath sourcePath = resourceMap.getSourcePath();
- IResource sourceResource = getProject().findMember(sourcePath);
- if (sourceResource != null && sourceResource.exists()) {
- if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) {
- reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath);
- }
- }
- else {
- reportStatus(ISingleRootStatus.SOURCE_PATH_NOT_FOUND, sourcePath);
- }
- if (VALIDATE_FLAG == CANCEL) return false;
- }
- return true;
- }
-
- public boolean isRootMapping(ComponentResource map) {
- // Verify it maps to "/" for the content root
- if (map.getRuntimePath().equals(Path.ROOT))
- return true;
- return false;
- }
-
- public IProject getProject() {
- return aComponent.getProject();
- }
-
- public void reportStatus(int code) {
- reportStatus(code, null, null);
- }
-
- public void reportStatus(int code, IContainer container) {
- reportStatus(code, null, container);
- }
-
- public void reportStatus(int code, IPath path) {
- reportStatus(code, path, null);
- }
-
- public void reportStatus(int code, IPath path, IContainer container) {
- ISingleRootStatus status = new SingleRootStatus(code, path, container);
- if (status.getSeverity() == IStatus.ERROR) {
- if ((VALIDATE_FLAG & INCLUDE_FIRST_ERROR) != 0) {
- VALIDATE_FLAG = CANCEL;
- addStatus(status);
- }
- else if ((VALIDATE_FLAG & INCLUDE_ERRORS) != 0) {
- addStatus(status);
- }
- }
- else if (status.getSeverity() == IStatus.WARNING && (VALIDATE_FLAG & WARNINGS) != 0) {
- addStatus(status);
- }
- else if (status.getSeverity() == IStatus.INFO && (VALIDATE_FLAG & INFO) != 0) {
- VALIDATE_FLAG = CANCEL;
- addStatus(status);
- }
- }
-
- public int getValidateFlag() {
- return VALIDATE_FLAG;
- }
-
- public void setValidateFlag(int validateFlag) {
- VALIDATE_FLAG = validateFlag;
- }
-
- public IStatus getStatus() {
- if (wrapperStatus != null) {
- return wrapperStatus;
- }
- return Status.OK_STATUS;
- }
-
- private void addStatus(ISingleRootStatus status) {
- if (wrapperStatus == null) {
- wrapperStatus = new MultiStatus(CommonFrameworksPlugin.PLUGIN_ID, 0, new IStatus[] { status }, null, null);
- } else {
- wrapperStatus.add(status);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/AbstractJavaComponentDiscerner.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/AbstractJavaComponentDiscerner.java
deleted file mode 100644
index 2a93e0f33..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/AbstractJavaComponentDiscerner.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore.util;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-public class AbstractJavaComponentDiscerner implements IJavaComponentDiscerner {
-
- public IProject[] findParentProjects(IProject child) {
- return new IProject[]{};
- }
-
- public IVirtualReference[] findPossibleManifestEntries(
- IProject parentProject, IProject childProject) {
- return new IVirtualReference[]{};
- }
-
- public IVirtualReference[] findPossibleManifestEntries(
- IProject parentProject, IProject childProject,
- IVirtualReference[] currentEntries) {
- return new IVirtualReference[]{};
- }
-
- public IVirtualReference[] findCurrentManifestEntries(
- IProject parentProject, IProject childProject) {
- return new IVirtualReference[]{};
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifest.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifest.java
deleted file mode 100644
index db2dd0e86..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.common.internal.modulecore.util;
-
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-import java.util.jar.Attributes;
-
-/**
- * Contains the API of
- *
- * @link java.util.jar.Manifest, along with added helpers
- */
-public interface ArchiveManifest {
- /**
- * Creates a new manifest entry (attributes) for the given name
- */
- public void addEntry(String entryName);
-
- public void addEntry(String entryName, Attributes attr);
-
- /**
- * Adds the key/value pair to the attributes for the given entry name; if the entry does not
- * exist, creates a new attributes
- */
- public void addEntryAttribute(String entryName, String key, String value);
-
- /**
- * Defaults the version to "1.0" if not already set
- */
- public void addVersionIfNecessary();
-
- public void appendClassPath(String extension);
-
- /**
- * @see java.util.jar.Manifest#clear
- */
- public void clear();
-
- /**
- * @see java.util.jar.Manifest#getAttributes
- */
- public Attributes getAttributes(String name);
-
- public String getClassPath();
-
- public String[] getClassPathTokenized();
-
- /**
- * @see java.util.jar.Manifest#getEntries
- */
- public Map getEntries();
-
- public String getEntryAttribute(String entryName, String key);
-
- /**
- * @see java.util.jar.Manifest#getAttributes
- */
- public Attributes getMainAttributes();
-
- public String getMainClass();
-
- /**
- * Return the value iff the entry exists in a case-sensitive manner; manifest version is
- * required for the manifest to save correctly
- */
- public String getManifestVersion();
-
- /**
- * Return the value iff the entry exists in a case-sensitive manner; implementation version is
- * optional in the manifest
- * */
- public String getImplementationVersion();
-
- /**
- * Add all the entries not already contained in the class path of this manifest
- */
- public void mergeClassPath(String[] classPathEntries);
-
- /**
- * @see java.util.jar.Manifest#read
- */
- public void read(InputStream is) throws IOException;
-
- public void removeEntry(String entryName);
-
- public void removeEntryAttribute(String entryName, Object key);
-
- public void setClassPath(String aSpaceDelimitedPath);
-
- public void setMainClass(String className);
-
- public void setManifestVersion(java.lang.String version);
-
- public void setImplemenationVersion(java.lang.String version);
-
- /**
- * @see java.util.jar.Manifest#write
- */
- public void write(OutputStream out) throws IOException;
-
- /**
- * Writes the Manifest to the specified OutputStream, splitting each classpath entry on a line
- * by itself.
- *
- * @param out
- * the output stream
- * @exception IOException
- * if an I/O error has occurred
- */
- public void writeSplittingClasspath(OutputStream out) throws IOException;
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifestImpl.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifestImpl.java
deleted file mode 100644
index 166b6de82..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ArchiveManifestImpl.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 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.common.internal.modulecore.util;
-
-
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.jar.Attributes;
-
-import com.ibm.icu.util.StringTokenizer;
-
-
-/**
- * Helper class for manifest files
- */
-public class ArchiveManifestImpl extends java.util.jar.Manifest implements ArchiveManifest {
- /**
- * ArchiveManifest constructor comment.
- */
- public ArchiveManifestImpl() {
- super();
- }
-
- /**
- * ArchiveManifest constructor comment.
- *
- * @param is
- * java.io.InputStream
- * @throws java.io.IOException
- * The exception description.
- */
- public ArchiveManifestImpl(java.io.InputStream is) throws java.io.IOException {
- try {
- read(is);
- } catch(Exception e){
- IOException ioe = new IOException(e.toString());
- ioe.initCause(e);
- throw ioe;
- }
- }
-
- /**
- * ArchiveManifest constructor comment.
- *
- * @param man
- * java.util.jar.Manifest
- */
- public ArchiveManifestImpl(java.util.jar.Manifest man) {
- super(man);
- }
-
- /**
- * Creates a new manifest entry (attributes) for the given name
- */
- public void addEntry(String entryName) {
- Attributes attr = new Attributes();
- addEntry(entryName, attr);
- }
-
- public void addEntry(String entryName, Attributes attr) {
- getEntries().put(entryName, attr);
- }
-
- /**
- * Adds the key/value pair to the attributes for the given entry name; if the entry does not
- * exist, creates a new attributes
- */
- public void addEntryAttribute(String entryName, String key, String value) {
- Attributes attr = getAttributes(entryName);
- if (attr == null)
- addEntry(entryName);
- attr = getAttributes(entryName);
- attr.putValue(key, value);
- }
-
- public void addVersionIfNecessary() {
- //This is a hack because of the fact that the manifest does not serialize correctly if
- //The version is not set. In addition to saves, the serialization is used for copy
- if (getManifestVersion() == null || getManifestVersion().equals(""))//$NON-NLS-1$
- setManifestVersion("1.0");//$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest
- */
- public void appendClassPath(java.lang.String extension) {
- String classPath = getClassPath();
- if (classPath != null)
- setClassPath(classPath + " " + extension);//$NON-NLS-1$
- else
- setClassPath(extension);
- }
-
- /**
- * @see org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest
- */
- public java.lang.String getClassPath() {
- return ManifestUtilities.getValueIgnoreKeyCase(Attributes.Name.CLASS_PATH.toString(), getMainAttributes());
- }
-
- /**
- * @see org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest
- */
- public java.lang.String[] getClassPathTokenized() {
- String classPath = getClassPath();
- if (classPath == null)
- return new String[0];
- return ManifestUtilities.getTokens(classPath);
- }
-
- public String getEntryAttribute(String entryName, String key) {
- Attributes attr = getAttributes(entryName);
- if (attr == null)
- return null;
- return attr.getValue(key);
- }
-
- public String getMainClass() {
- return ManifestUtilities.getValueIgnoreKeyCase(Attributes.Name.MAIN_CLASS.toString(), getMainAttributes());
- }
-
- public String getManifestVersion() {
- return getMainAttributes().getValue(Attributes.Name.MANIFEST_VERSION);
- }
-
- /**
- * @see org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest
- */
- public void mergeClassPath(java.lang.String[] classPathEntries) {
- StringBuffer sb = new StringBuffer();
- java.util.List existing = java.util.Arrays.asList(getClassPathTokenized());
- String cp = getClassPath();
- if (cp != null)
- sb.append(cp);
- boolean empty = cp == null || "".equals(cp); //$NON-NLS-1$
- for (int i = 0; i < classPathEntries.length; i++) {
- if (!existing.contains(classPathEntries[i])) {
- if (!empty)
- sb.append(" "); //$NON-NLS-1$
- else
- empty = false;
- sb.append(classPathEntries[i]);
- }
- }
- setClassPath(sb.toString());
- }
-
- public void removeEntry(String entryName) {
- getEntries().remove(entryName);
- }
-
- public void removeEntryAttribute(String entryName, Object key) {
- Attributes attr = getAttributes(entryName);
- if (attr != null)
- attr.remove(key);
- }
-
- /**
- * @see org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest
- */
- public void setClassPath(java.lang.String aSpaceDelimitedPath) {
- Attributes attributes = getMainAttributes();
- if (aSpaceDelimitedPath == null)
- attributes.remove(Attributes.Name.CLASS_PATH);
- else
- attributes.putValue(Attributes.Name.CLASS_PATH.toString(), aSpaceDelimitedPath);
- }
-
- /**
- * @see org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest
- */
- public void setMainClass(java.lang.String className) {
- Attributes attributes = getMainAttributes();
- if (className == null)
- attributes.remove(Attributes.Name.MAIN_CLASS);
- else
- attributes.putValue(Attributes.Name.MAIN_CLASS.toString(), className);
- }
-
- /**
- * @see org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest
- */
- public void setManifestVersion(java.lang.String version) {
- Attributes attributes = getMainAttributes();
- attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), version);
- }
-
- /**
- * Writes the Manifest to the specified OutputStream, splitting each classpath entry on a line
- * by itself.
- *
- * @param out
- * the output stream
- * @exception IOException
- * if an I/O error has occurred
- */
- public void writeSplittingClasspath(OutputStream out) throws IOException {
- DataOutputStream dos = new DataOutputStream(out);
- // Write out the main attributes for the manifest
- writeMainSplittingClasspath(getMainAttributes(), dos);
- // Now write out the pre-entry attributes
- Iterator it = getEntries().entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry e = (Map.Entry) it.next();
- StringBuffer buffer = new StringBuffer("Name: "); //$NON-NLS-1$
- buffer.append((String) e.getKey());
- buffer.append("\r\n"); //$NON-NLS-1$
- localMake72Safe(buffer);
- dos.writeBytes(buffer.toString());
- write((Attributes) e.getValue(), dos);
- }
- dos.flush();
- }
-
- /*
- * Writes the current attributes to the specified data output stream. XXX Need to handle UTF8
- * values and break up lines longer than 72 bytes
- *
- * @see Attributes#write
- */
- protected void write(Attributes attributes, DataOutputStream os) throws IOException {
- Iterator it = attributes.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry e = (Map.Entry) it.next();
- StringBuffer buffer = new StringBuffer(((Attributes.Name) e.getKey()).toString());
- buffer.append(": "); //$NON-NLS-1$
- buffer.append(toUtf8((String) e.getValue()));
- buffer.append("\r\n"); //$NON-NLS-1$
- localMake72Safe(buffer);
- os.writeBytes(buffer.toString());
- }
- os.writeBytes("\r\n"); //$NON-NLS-1$
- }
-
- /*
- * Writes the current attributes to the specified data output stream, make sure to write out the
- * MANIFEST_VERSION or SIGNATURE_VERSION attributes first.
- *
- * @see Attributes#writeMain
- */
- protected void writeMainSplittingClasspath(Attributes attributes, DataOutputStream out) throws IOException {
- // write out the *-Version header first, if it exists
- String vername = Attributes.Name.MANIFEST_VERSION.toString();
- String version = toUtf8(attributes.getValue(vername));
- if (version == null) {
- vername = Attributes.Name.SIGNATURE_VERSION.toString();
- version = toUtf8(attributes.getValue(vername));
- }
-
- if (version != null) {
- out.writeBytes(vername + ": " + version + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // write out all attributes except for the version
- // we wrote out earlier
- Iterator it = attributes.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry e = (Map.Entry) it.next();
- String name = ((Attributes.Name) e.getKey()).toString();
- if ((version != null) && !(name.equalsIgnoreCase(vername))) {
- if (name.equalsIgnoreCase(Attributes.Name.CLASS_PATH.toString())) {
- writeSplit(out, name, toUtf8((String) e.getValue()));
- continue;
- }
- StringBuffer buffer = new StringBuffer(name);
- buffer.append(": "); //$NON-NLS-1$
- buffer.append(toUtf8((String) e.getValue()));
- buffer.append("\r\n"); //$NON-NLS-1$
- localMake72Safe(buffer);
- out.writeBytes(buffer.toString());
- }
- }
- out.writeBytes("\r\n"); //$NON-NLS-1$
- }
-
- protected void writeSplit(DataOutputStream out, String name, String value) throws IOException {
- StringTokenizer tok = new StringTokenizer(value);
- int inc = 0;
- while (tok.hasMoreTokens()) {
- StringBuffer buffer = null;
- if (inc == 0) {
- buffer = new StringBuffer(name);
- buffer.append(": "); //$NON-NLS-1$
- } else {
- buffer = new StringBuffer();
- buffer.append(' ');
- }
- buffer.append(tok.nextToken());
- if (tok.countTokens() > 0)
- buffer.append(" \r\n"); //$NON-NLS-1$
- else
- buffer.append("\r\n"); //$NON-NLS-1$
- localMake72Safe(buffer);
- out.writeBytes(buffer.toString());
- inc++;
- }
- }
-
- /**
- * Adds line breaks to enforce a maximum 72 bytes per line.
- */
- protected static void localMake72Safe(StringBuffer line) {
- int length = line.length();
- if (length > 72) {
- int index = 70;
- // bug 233801 - we are splitting every 72 bytes, but adding two bytes to the end of,
- // and one space at the beginning of every line after the first
- while (index - 1 < length) {
- if (line.charAt(index) == ' ')
- {
- index--;
- }
- line.insert(index, "\r\n "); //$NON-NLS-1$
- index += 72;
- length += 3;
- }
- }
- return;
- }
-
- public String getImplementationVersion() {
- return getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION);
- }
-
- public void setImplemenationVersion(String version) {
- Attributes attributes = getMainAttributes();
- attributes.putValue(Attributes.Name.IMPLEMENTATION_VERSION.toString(), version);
- }
-
- /**
- * Encodes a double-byte string into UTF8 form. Every character in the
- * returned string represents one byte of the UTF8 encoding.
- */
-
- private String toUtf8( final String str ) throws IOException
- {
- if( str == null )
- {
- return null;
- }
- final byte[] utf8 = str.getBytes( "UTF-8" ); //$NON-NLS-1$
- return new String( utf8, 0, 0, utf8.length );
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/IJavaComponentDiscerner.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/IJavaComponentDiscerner.java
deleted file mode 100644
index 55f6c029c..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/IJavaComponentDiscerner.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore.util;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * This is internal. Please don't use it unless you're prepared
- * for it to change drastically at any random time.
- *
- * This interface represents a utility to help discover the heirarchy
- * of java-related components, and assist in manifest management.
- */
-public interface IJavaComponentDiscerner {
- /**
- * Return a list of parent projects, projects which already *do* have
- * a project reference to this child project
- * @param child
- * @return
- */
- public IProject[] findParentProjects(IProject child);
-
- /**
- * All returned manifest entries should have a runtime path and archiveName
- * which, when combined, will be suitable for export to a child's
- * manifest file. If a reference is in a folder that does not
- * require it to be present in the manifest.mf classpath, it
- * should *NOT* be returned here.
- *
- * All references should have a getRuntimePath() + getArchiveName() that
- * resolves to the value that should be in the manifest.mf classpath section.
- *
- * Any reference *already* in the manifest should *not* be returned here
- *
- * @param parentProject
- * @param childProject
- * @return
- */
- public IVirtualReference[] findPossibleManifestEntries(IProject parentProject, IProject childProject);
-
- /**
- * All returned manifest entries should have a runtime path and archiveName
- * which, when combined, will be suitable for export to a child's
- * manifest file. If a reference is in a folder that does not
- * require it to be present in the manifest.mf classpath, it
- * should *NOT* be returned here.
- *
- * All references should have a getRuntimePath() + getArchiveName() that
- * resolves to the value that should be in the manifest.mf classpath section.
- *
- * Any reference equivilant to the ones in currentEntries should not be returned
- *
- * @param parentProject
- * @param childProject
- * @return
- */
- public IVirtualReference[] findPossibleManifestEntries(IProject parentProject, IProject childProject, IVirtualReference[] currentEntries);
-
-
- /**
- * All returned manifest entries should have a runtime path and archiveName
- * which, when combined, will be suitable for export to a child's
- * manifest file. If a reference is in a folder that does not
- * require it to be present in the manifest.mf classpath, it
- * should *NOT* be returned here.
- *
- * All references should have a getRuntimePath() + getArchiveName() that
- * resolves to the value that should be in the manifest.mf classpath section.
- *
- * Any reference *not* in the manifest should *not* be returned here
- *
- * @param parentProject
- * @param childProject
- * @return
- */
- public IVirtualReference[] findCurrentManifestEntries(IProject parentProject, IProject childProject);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/JavaModuleComponentUtility.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/JavaModuleComponentUtility.java
deleted file mode 100644
index 48d956740..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/JavaModuleComponentUtility.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat 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:
- * Red Hat - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.internal.modulecore.util;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * A Utility class to help find current and possible manifest entries
- */
-public class JavaModuleComponentUtility {
-
- private static IJavaComponentDiscerner[] discerners;
- protected static IJavaComponentDiscerner[] getDiscerners() {
- if( discerners == null ) {
- discerners = loadDiscerners();
- }
- return discerners == null ? new IJavaComponentDiscerner[]{} : discerners;
- }
-
- private static IJavaComponentDiscerner[] loadDiscerners() {
- ArrayList<IJavaComponentDiscerner> list = new ArrayList<IJavaComponentDiscerner>();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(
- CommonFrameworksPlugin.PLUGIN_ID, "JavaComponentDiscerner"); //$NON-NLS-1$
- for( int i = 0; i < cf.length; i++ ) {
- try {
- list.add((IJavaComponentDiscerner)cf[i].createExecutableExtension("class")); //$NON-NLS-1$
- } catch( CoreException ce ) {
- // TODO log
- }
- }
- return list.toArray(new IJavaComponentDiscerner[list.size()]);
- }
-
- public static IProject[] findParentProjects(IProject child) {
- IJavaComponentDiscerner[] extensions = getDiscerners();
- ArrayList<IProject> list = new ArrayList<IProject>();
- for( int i = 0; i < extensions.length; i++ ) {
- list.addAll(Arrays.asList(extensions[i].findParentProjects(child)));
- }
- return list.toArray(new IProject[list.size()]);
- }
-
- public static IVirtualReference[] findPossibleManifestEntries(IProject parentProject, IProject childProject) {
- IJavaComponentDiscerner[] extensions = getDiscerners();
- ArrayList<IVirtualReference> list = new ArrayList<IVirtualReference>();
- for( int i = 0; i < extensions.length; i++ ) {
- list.addAll(Arrays.asList(extensions[i].findPossibleManifestEntries(parentProject, childProject)));
- }
- return list.toArray(new IVirtualReference[list.size()]);
- }
-
- public static IVirtualReference[] findPossibleManifestEntries(IProject parentProject, IProject childProject, IVirtualReference[] current) {
- IJavaComponentDiscerner[] extensions = getDiscerners();
- ArrayList<IVirtualReference> list = new ArrayList<IVirtualReference>();
- for( int i = 0; i < extensions.length; i++ ) {
- list.addAll(Arrays.asList(extensions[i].findPossibleManifestEntries(parentProject, childProject, current)));
- }
- return list.toArray(new IVirtualReference[list.size()]);
- }
-
- public static IVirtualReference[] findCurrentManifestEntries(IProject parentProject, IProject childProject) {
- IJavaComponentDiscerner[] extensions = getDiscerners();
- ArrayList<IVirtualReference> list = new ArrayList<IVirtualReference>();
- for( int i = 0; i < extensions.length; i++ ) {
- list.addAll(Arrays.asList(extensions[i].findCurrentManifestEntries(parentProject, childProject)));
- }
- return list.toArray(new IVirtualReference[list.size()]);
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ManifestUtilities.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ManifestUtilities.java
deleted file mode 100644
index 6c98551ed..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/ManifestUtilities.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation, Red Hat, 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.common.internal.modulecore.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jem.util.emf.workbench.WorkbenchByteArrayOutputStream;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
-
-import com.ibm.icu.util.StringTokenizer;
-
-public class ManifestUtilities {
- public static final String MANIFEST_HEADER = "Manifest-Version: 1.0\r\nClass-Path: \r\n\r\n"; //$NON-NLS-1$
- public static void createManifestFile(IFile file) throws CoreException, IOException {
- try {
- WorkbenchByteArrayOutputStream out = new WorkbenchByteArrayOutputStream(file);
- out.write(MANIFEST_HEADER.getBytes());
- out.close();
- } catch (IOException ioe) {
- throw ioe;
- }
- }
-
- public static String[] getTokens(String aString) {
- return getTokens(aString, null);
- }
-
- public static String[] getTokens(String aString, String delimiter) {
- StringTokenizer tok = (delimiter == null) ? new StringTokenizer(aString) : new StringTokenizer(aString, delimiter);
- int size = tok.countTokens();
- String[] tokens = new String[size];
- for (int i = 0; i < size && tok.hasMoreTokens(); i++) {
- tokens[i] = tok.nextToken();
- }
- return tokens;
- }
-
- /**
- * getValueIgnoreKeyCase method comment.
- */
- public static java.lang.String getValueIgnoreKeyCase(java.lang.String key, java.util.jar.Attributes attr) {
- Iterator keysAndValues = attr.entrySet().iterator();
- while (keysAndValues.hasNext()) {
- Map.Entry entry = (Map.Entry) keysAndValues.next();
- String entryKey = entry.getKey().toString();
- if (entryKey.equalsIgnoreCase(key))
- return entry.getValue() == null ? null : entry.getValue().toString();
- }
- return null;
- }
-
- public static ArchiveManifest getManifest(IVirtualComponent component, IPath manifestPath) {
- if( !component.isBinary() )
- return getNonBinaryComponentManifest(component, manifestPath);
- return getBinaryComponentManifest(component, manifestPath);
- }
-
- public static ArchiveManifest getBinaryComponentManifest(IVirtualComponent component, IPath manifestPath) {
- java.io.File file = (File)component.getAdapter(File.class);
- if( file != null && file.exists()) {
- ArchiveManifest manifest = readBinaryManifest(file, manifestPath);
- return manifest;
- }
- return null;
- }
-
- public static ArchiveManifest getManifest(IFile f) {
- File f2 = f.getLocation().toFile();
- return getManifest(f2);
- }
-
- public static ArchiveManifest getManifest(File f) {
- if( f != null && f.exists()) {
- InputStream in;
- try {
- in = new FileInputStream(f);
- ArchiveManifest manifest = new ArchiveManifestImpl(in);
- return manifest;
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
- }
- }
- return null;
- }
-
- public static void writeManifest(IFile aFile, ArchiveManifest manifest) throws java.io.IOException {
- OutputStream out = new WorkbenchByteArrayOutputStream(aFile);
- manifest.writeSplittingClasspath(out);
- out.close();
- }
-
-
- public static ArchiveManifest getNonBinaryComponentManifest(IVirtualComponent component, IPath manifestPath) {
- try {
- if(!component.isBinary()){
- IVirtualFile vManifest = component.getRootFolder().getFile(manifestPath);
- if (vManifest.exists()) {
- IFile manifestFile = vManifest.getUnderlyingFile();
- InputStream in = null;
- try {
- in = manifestFile.getContents();
- ArchiveManifest manifest = new ArchiveManifestImpl(in);
- return manifest;
- } finally {
- if (in != null) {
- in.close();
- in = null;
- }
- }
- }
- }
- } catch( IOException ioe ) {
- } catch(CoreException ce) {
- }
- return null;
- }
-
-
- public static String[] getManifestClasspath(IVirtualComponent component, IPath manifestPath) {
- ArchiveManifest mf = getManifest(component, manifestPath);
- if( mf != null )
- return mf.getClassPathTokenized();
- return new String[]{};
- }
-
- public static ArchiveManifest readBinaryManifest(File file, IPath manifestPath) {
- ArchiveManifest manifest = null;
- ZipFile zipFile = null;
- if( file != null ) {
- try {
- zipFile = ManifestUtilities.newZipFile(file);
- ZipEntry entry = zipFile.getEntry(manifestPath.toString());
- if( entry != null ) {
- InputStream entryStream = getInputstreamForZipEntry(zipFile, manifestPath.toString());
- manifest = new ArchiveManifestImpl(entryStream);
- zipFile.close();
- }
- } catch( IOException ioe) {
- if( zipFile != null ) {
- try {
- zipFile.close();
- } catch( IOException ioe2) {}
- }
- }
- }
- return manifest;
- }
-
- public static InputStream getInputstreamForZipEntry(ZipFile zipFile, String uri) throws IOException {
- try {
- ZipEntry entry = zipFile.getEntry(uri);
- if (entry == null) {
- // this is a hack, but zip files are sensitive to the difference
- // between '/' and '\\'
- // so the hack is to try all combinations to see if any exist
- char[] chars = uri.toCharArray();
- int[] slashIndices = new int[chars.length];
- int slashCount = 0;
- for (int i = 0; i < uri.length(); i++) {
- if (chars[i] == '/' || chars[i] == '\\') {
- slashIndices[slashCount] = i;
- slashCount++;
- }
- }
- int slashPow = (int) Math.pow(2, slashCount);
- boolean foundIt = false;
- for (int i = 0; i < slashPow && !foundIt; i++) {
- for (int j = 0; j < slashCount; j++) {
- if ((i >> j & 1) == 1) {
- chars[slashIndices[j]] = '/';
- } else {
- chars[slashIndices[j]] = '\\';
- }
- }
- entry = zipFile.getEntry(new String(chars));
- if (entry != null) {
- foundIt = true;
- }
- }
- if (entry == null) {
- Exception del = new FileNotFoundException(uri);
- throw new IOException(del.toString());
- }
- }
- return new java.io.BufferedInputStream(zipFile.getInputStream(entry));
- } catch (IllegalStateException zipClosed) {
- throw new IOException(zipClosed.toString());
- }
- }
-
- public static String[] getNonBinaryComponentManifestClasspath(IVirtualComponent component, IPath manifestPath)
- throws IOException, CoreException {
- String[] manifestClasspath = null;
- if(!component.isBinary()){
- IVirtualFile vManifest = component.getRootFolder().getFile(manifestPath);
- if (vManifest.exists()) {
- IFile manifestFile = vManifest.getUnderlyingFile();
- InputStream in = null;
- try {
- in = manifestFile.getContents();
- ArchiveManifest manifest = new ArchiveManifestImpl(in);
- manifestClasspath = manifest.getClassPathTokenized();
- } finally {
- if (in != null) {
- in.close();
- in = null;
- }
- }
- }
- }
- return manifestClasspath;
- }
-
- public static ZipFile newZipFile(String fileName)throws ZipException, IOException {
- return ManifestUtilities.newZipFile(new File(fileName), ZipFile.OPEN_READ);
- }
- public static ZipFile newZipFile(File aFile)throws ZipException, IOException {
- return ManifestUtilities.newZipFile(aFile, ZipFile.OPEN_READ);
- }
-
- /**
- * Utility to create ZipFiles which avoid memory leaks
- * because closing them fails to close open inputstreams.
- * There is a SUN bug open for this: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6735255
- * but it looks like the "fix" will be to change the Javadoc :-(
- * @param aFile mode
- * @return
- * @throws ZipException
- * @throws IOException
- */
- public static ZipFile newZipFile(File aFile, int mode) throws ZipException, IOException {
- return new ZipFile(aFile, mode){
- Collection <InputStream> openStreams = null;
-
- @Override
- public InputStream getInputStream(ZipEntry entry) throws IOException {
- InputStream in = super.getInputStream(entry);
- if(in != null){
- if(openStreams == null){
- openStreams = new ArrayList<InputStream>();
- }
- openStreams.add(in);
- }
- return in;
- }
-
- @Override
- public void close() throws IOException {
- closeOpenStreams();
- super.close();
- }
-
- private void closeOpenStreams() {
- if(openStreams != null){
- for (Iterator iterator = openStreams.iterator(); iterator.hasNext();) {
- InputStream in = (InputStream) iterator.next();
- try {
- in.close();
- } catch (IOException e) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning(e);
- }
- iterator.remove();
- }
- }
- }
- };
- }
-
- public static ArchiveManifest readManifest(IFile aFile) {
- InputStream in = null;
- try {
- if (aFile == null || !aFile.exists())
- return null;
- in = aFile.getContents();
- return new ArchiveManifestImpl(in);
- } catch (Exception ex) {
- // TODO J2EEPlugin.logError(ex);
- return null;
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException weTried) {
- }
- }
- }
- }
-
- private static ConcurrentHashMap<String, String> manifestClasspaths = new ConcurrentHashMap<String, String>();
-
- /**
- * Generates new MANIFEST.MF with a dynamically updated classpath that is written to the specified
- * output stream.
- * @param manifestFile The current MANIFEST.MF file.
- * @param dynamicURIs Is List of URIs to dynamically add to the manifest classpath.
- * @param outputStream Stream to which the modified entry should be written.
- * @throws IOException
- * @throws FileNotFoundException
- */
- public static void updateManifestClasspath(final IFile manifestFile, final List dynamicURIs, final OutputStream outputStream) throws IOException, FileNotFoundException {
- updateManifestClasspathImpl(manifestFile, dynamicURIs, null, outputStream);
- }
-
- /**
- * Generates new MANIFEST.MF with a dynamically updated classpath that is written to the specified
- * output stream.
- * @param manifestFile The current MANIFEST.MF file.
- * @param dynamicURIs Is List of URIs to dynamically add to the manifest classpath.
- * @param outputFile File to which the modified entry should be written.
- * @throws IOException
- * @throws FileNotFoundException
- */
- public static void updateManifestClasspath(final IFile manifestFile, final List dynamicURIs, final File outputFile) throws IOException, FileNotFoundException {
- updateManifestClasspathImpl(manifestFile, dynamicURIs, outputFile, null);
- }
-
- /**
- * Generates new MANIFEST.MF with a dynamically updated classpath that is written to the specified
- * file or output stream, with the stream taking precedence.
- * @param manifestFile The current MANIFEST.MF file.
- * @param dynamicURIs Is List of URIs to dynamically add to the manifest classpath.
- * @param outputFile File to which the modified entry should be written.
- * @param OutputStream stream Stream to which the modified entry should be written. If not null,
- * the stream will be written and the outputFile ignored.
- * @throws IOException
- * @throws FileNotFoundException
- */
- private static void updateManifestClasspathImpl(final IFile manifestFile, final List dynamicURIs, final File outputFile, final OutputStream stream) throws IOException, FileNotFoundException {
-
- OutputStream outputStream = stream;
- try {
- InputStream in = null;
- ArchiveManifest manifest = null;
- try {
- in = manifestFile.getContents();
- manifest = new ArchiveManifestImpl(in);
- } catch (CoreException ce) {
- throw new IOException(ce.getLocalizedMessage());
- } finally {
- if (in != null) {
- try {
- in.close();
- in = null;
- } catch (IOException e) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning(e);
- }
- }
- }
- final String[] manifestClasspath = manifest.getClassPathTokenized();
- final List updatedCP = new ArrayList();
- for (int i = 0; i < manifestClasspath.length; i++) {
- updatedCP.add(manifestClasspath[i]);
- }
- // update manifest classpath to include dynamic entries
- for (int j = 0; j < dynamicURIs.size(); j++) {
- final String containerURI = (String) dynamicURIs.get(j);
- // need to check existing entries to ensure it doesn't are exist on the classpath
- boolean exists = false;
- for (int i = 0; i < manifestClasspath.length; i++) {
- if (manifestClasspath[i].equals(containerURI)) {
- exists = true;
- break;
- }
- }
- if (!exists) {
- updatedCP.add(containerURI);
- }
- }
- final StringBuffer cpBuffer = new StringBuffer();
- boolean first = true;
- for (int j = 0; j < updatedCP.size(); j++) {
- if (!first) {
- cpBuffer.append(" "); //$NON-NLS-1$
- } else {
- first = false;
- }
- cpBuffer.append((String) updatedCP.get(j));
- }
- String cp = cpBuffer.toString();
- // If we have an output stream, always write to the stream
- if (outputStream != null) {
- manifest.setClassPath(cp);
- manifest.write(outputStream);
- outputStream.flush();
- }
- // Else, without an output stream, conditionally update the specified file
- else {
- // To avoid making the internally generated manifest file appear to projects
- // as a perpetually modified resource, check if the file needs to change.
- // This checking helps with the usefulness of "delta" deployment with
- // utility projects.
- String manifestPath = manifestFile.getFullPath().toString();
- String priorClasspath = manifestClasspaths.get(manifestPath);
- if (priorClasspath == null || !priorClasspath.equals(cp) || !outputFile.exists()) {
- manifestClasspaths.put(manifestPath, cp);
- manifest.setClassPath(cp);
- outputStream = new FileOutputStream(outputFile);
- manifest.write(outputStream);
- outputStream.flush();
- }
- }
- } finally {
- if (outputStream != null) {
- outputStream.close();
- }
- }
- }
-
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestDataModelProperties.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestDataModelProperties.java
deleted file mode 100644
index a62e843bc..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/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.common.internal.modulecore.util;
-
-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.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestDataModelProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestDataModelProvider.java
deleted file mode 100644
index 7ac871477..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestDataModelProvider.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Nov 13, 2003
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package org.eclipse.jst.common.internal.modulecore.util;
-
-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&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class UpdateManifestDataModelProvider extends AbstractDataModelProvider implements UpdateManifestDataModelProperties {
-
- @Override
- 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;
- }
-
- @Override
- 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);
- }
-
- @Override
- 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;
- }
-
- @Override
- public IDataModelOperation getDefaultOperation() {
- return new UpdateManifestOperation(model);
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestOperation.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestOperation.java
deleted file mode 100644
index ad255e4e5..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/util/UpdateManifestOperation.java
+++ /dev/null
@@ -1,78 +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&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package org.eclipse.jst.common.internal.modulecore.util;
-
-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.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&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class UpdateManifestOperation extends AbstractDataModelOperation {
-
- public UpdateManifestOperation(IDataModel dataModel) {
- super(dataModel);
- }
-
- @Override
- 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 {
- if(file != null && file.exists()) {
- ArchiveManifest mf = ManifestUtilities.readManifest(file);
-
- if (mf == null)
- mf = new ArchiveManifestImpl();
- mf.addVersionIfNecessary();
- if (model.getBooleanProperty(UpdateManifestDataModelProperties.MERGE)) {
- mf.mergeClassPath(ManifestUtilities.getTokens(classPathValue));
- } else {
- mf.setClassPath(classPathValue);
- }
- if (model.isPropertySet(UpdateManifestDataModelProperties.MAIN_CLASS)) {
- mf.setMainClass(model.getStringProperty(UpdateManifestDataModelProperties.MAIN_CLASS));
- }
-
- ManifestUtilities.writeManifest(file, mf);
- }
- } catch (java.io.IOException ex) {
- throw new ExecutionException(ex.getMessage(),ex);
- }
- return OK_STATUS;
- }
-
- @Override
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return null;
- }
-
- @Override
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- return null;
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorations.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorations.java
deleted file mode 100644
index 4e4cb5f5d..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorations.java
+++ /dev/null
@@ -1,75 +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.common.jdt.internal.classpath;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.JavaCore;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public final class ClasspathDecorations
-{
- private IPath sourceAttachmentPath;
- private IPath sourceAttachmentRootPath;
- private ArrayList extraAttributes = new ArrayList();
-
- public IPath getSourceAttachmentPath()
- {
- return this.sourceAttachmentPath;
- }
-
- public void setSourceAttachmentPath( final IPath sourceAttachmentPath )
- {
- this.sourceAttachmentPath = sourceAttachmentPath;
- }
-
- public IPath getSourceAttachmentRootPath()
- {
- return this.sourceAttachmentRootPath;
- }
-
- public void setSourceAttachmentRootPath( final IPath sourceAttachmentRootPath )
- {
- this.sourceAttachmentRootPath = sourceAttachmentRootPath;
- }
-
- public IClasspathAttribute[] getExtraAttributes()
- {
- final IClasspathAttribute[] array
- = new IClasspathAttribute[ this.extraAttributes.size() ];
-
- return (IClasspathAttribute[]) this.extraAttributes.toArray( array );
- }
-
- public void setExtraAttributes( final IClasspathAttribute[] attrs )
- {
- for( int i = 0; i < attrs.length; i++ )
- {
- this.extraAttributes.add( attrs[ i ] );
- }
- }
-
- public void addExtraAttribute( final String name,
- final String value )
- {
- final IClasspathAttribute attr
- = JavaCore.newClasspathAttribute( name, value );
-
- this.extraAttributes.add( attr );
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorationsManager.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorationsManager.java
deleted file mode 100644
index ece1d1899..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorationsManager.java
+++ /dev/null
@@ -1,375 +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.common.jdt.internal.classpath;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public final class ClasspathDecorationsManager
-{
- private final File f;
- private final HashMap decorations;
-
- public ClasspathDecorationsManager( final String plugin )
- {
- final IWorkspace ws = ResourcesPlugin.getWorkspace();
- final File wsdir = ws.getRoot().getLocation().toFile();
- final File wsmdroot = new File( wsdir, ".metadata/.plugins" ); //$NON-NLS-1$
- final File pmdroot = new File( wsmdroot, plugin );
-
- this.f = new File( pmdroot, "classpath.decorations.xml" ); //$NON-NLS-1$
- this.decorations = read();
- }
-
- public ClasspathDecorations getDecorations( final String key,
- final String entry )
- {
- final HashMap submap = (HashMap) this.decorations.get( key );
-
- if( submap == null )
- {
- return null;
- }
-
- return (ClasspathDecorations) submap.get( entry );
- }
-
- public void setDecorations( final String key,
- final String entry,
- final ClasspathDecorations dec )
- {
- HashMap submap = (HashMap) this.decorations.get( key );
-
- if( submap == null )
- {
- submap = new HashMap();
- this.decorations.put( key, submap );
- }
-
- submap.put( entry, dec );
- }
-
- public void clearAllDecorations( final String key )
- {
- this.decorations.remove( key );
- }
-
- public void save()
- {
- final File folder = this.f.getParentFile();
-
- if( ! folder.exists() && ! folder.mkdirs() )
- {
- return;
- }
-
- PrintWriter w = null;
-
- try
- {
- w = new PrintWriter( new BufferedWriter( new OutputStreamWriter( new FileOutputStream( this.f ), "UTF-8" ) ) ); //$NON-NLS-1$
-
- w.println( "<classpath>" ); //$NON-NLS-1$
-
- for( Iterator itr1 = decorations.entrySet().iterator();
- itr1.hasNext(); )
- {
- final Map.Entry entry1 = (Map.Entry) itr1.next();
- final Map submap = (Map) entry1.getValue();
-
- w.print( " <container id=\"" ); //$NON-NLS-1$
- w.print( (String) entry1.getKey() );
- w.println( "\">" ); //$NON-NLS-1$
-
- for( Iterator itr2 = submap.entrySet().iterator();
- itr2.hasNext(); )
- {
- final Map.Entry entry2 = (Map.Entry) itr2.next();
-
- final ClasspathDecorations dec
- = (ClasspathDecorations) entry2.getValue();
-
- w.print( " <entry id=\"" ); //$NON-NLS-1$
- w.print( (String) entry2.getKey() );
- w.println( "\">" ); //$NON-NLS-1$
-
- if( dec.getSourceAttachmentPath() != null )
- {
- w.print( " <source-attachment-path>" ); //$NON-NLS-1$
- w.print( dec.getSourceAttachmentPath().toString() );
- w.println( "</source-attachment-path>" ); //$NON-NLS-1$
- }
-
- if( dec.getSourceAttachmentRootPath() != null )
- {
- w.print( " <source-attachment-root-path>" ); //$NON-NLS-1$
- w.print( dec.getSourceAttachmentRootPath().toString() );
- w.println( "</source-attachment-root-path>" ); //$NON-NLS-1$
- }
-
- final IClasspathAttribute[] attrs
- = dec.getExtraAttributes();
-
- for( int i = 0; i < attrs.length; i++ )
- {
- final IClasspathAttribute attr = attrs[ i ];
-
- w.print( " <attribute name=\"" ); //$NON-NLS-1$
- w.print( attr.getName() );
- w.print( "\">" ); //$NON-NLS-1$
- w.print( attr.getValue() );
- w.println( "</attribute>" ); //$NON-NLS-1$
- }
-
- w.println( " </entry>" ); //$NON-NLS-1$
- }
-
- w.println( " </container>" ); //$NON-NLS-1$
- }
-
- w.println( "</classpath>" ); //$NON-NLS-1$
- }
- catch( IOException e )
- {
- CommonFrameworksPlugin.log( e );
- }
- finally
- {
- if(null != w){
- w.close();
- }
- }
- }
-
- private HashMap read()
- {
- final HashMap map = new HashMap();
- if( ! this.f.exists() ) return map;
-
- BufferedReader in = null;
- Element root = null;
-
- try
- {
- final DocumentBuilderFactory factory
- = DocumentBuilderFactory.newInstance();
-
- final DocumentBuilder docbuilder = factory.newDocumentBuilder();
-
- in = new BufferedReader(new InputStreamReader( new FileInputStream( f.getPath()),"UTF-8")); //$NON-NLS-1$
- root = docbuilder.parse( new InputSource(in)).getDocumentElement();
- }
- catch( Exception e )
- {
- CommonFrameworksPlugin.log( e );
- return map;
- }
- finally
- {
- if( in != null )
- {
- try
- {
- in.close();
- }
- catch( IOException e ) {}
- }
- }
-
- for( Iterator itr1 = elements( root, "container" ); itr1.hasNext(); ) //$NON-NLS-1$
- {
- final Element e1 = (Element) itr1.next();
- final String cid = e1.getAttribute( "id" ); //$NON-NLS-1$
-
- final HashMap submap = new HashMap();
- map.put( cid, submap );
-
- for( Iterator itr2 = elements( e1, "entry" ); itr2.hasNext(); ) //$NON-NLS-1$
- {
- final Element e2 = (Element) itr2.next();
- final String eid = e2.getAttribute( "id" ); //$NON-NLS-1$
- final ClasspathDecorations dec = new ClasspathDecorations();
-
- submap.put( eid, dec );
-
- for( Iterator itr3 = elements( e2 ); itr3.hasNext(); )
- {
- final Element e3 = (Element) itr3.next();
- final String n = e3.getNodeName();
-
- if( n.equals( "source-attachment-path" ) ) //$NON-NLS-1$
- {
- dec.setSourceAttachmentPath( new Path( text( e3 ) ) );
- }
- else if( n.equals( "source-attachment-root-path" ) ) //$NON-NLS-1$
- {
- dec.setSourceAttachmentRootPath( new Path( text( e3 ) ) );
- }
- else if( n.equals( "attribute" ) ) //$NON-NLS-1$
- {
- final String name = e3.getAttribute( "name" ); //$NON-NLS-1$
- dec.addExtraAttribute( name, text( e3 ) );
- }
- }
- }
- }
-
- return map;
- }
-
- private static String text( final Element el )
- {
- final NodeList nodes = el.getChildNodes();
-
- String str = null;
- StringBuffer buf = null;
-
- for( int i = 0, n = nodes.getLength(); i < n; i++ )
- {
- final Node node = nodes.item( i );
-
- if( node.getNodeType() == Node.TEXT_NODE )
- {
- final String val = node.getNodeValue();
-
- if( buf != null )
- {
- buf.append( val );
- }
- else if( str != null )
- {
- buf = new StringBuffer();
- buf.append( str );
- buf.append( val );
-
- str = null;
- }
- else
- {
- str = val;
- }
- }
- }
-
- if( buf != null )
- {
- return buf.toString();
- }
- return str;
- }
-
- private static Iterator elements( final Element el,
- final String name )
- {
- return new ElementsIterator( el, name );
- }
-
- private static Iterator elements( final Element el )
- {
- return new ElementsIterator( el, null );
- }
-
- private static final class ElementsIterator
-
- implements Iterator
-
- {
- private final NodeList nodes;
- private final int length;
- private final String name;
- private int position;
- private Element element;
-
- public ElementsIterator( final Element parent,
- final String name )
- {
- this.nodes = parent.getChildNodes();
- this.length = nodes.getLength();
- this.position = -1;
- this.name = name;
-
- advance();
- }
-
- private void advance()
- {
- this.element = null;
- this.position++;
-
- for( ; this.position < this.length && this.element == null;
- this.position++ )
- {
- final Node node = this.nodes.item( this.position );
-
- if( node.getNodeType() == Node.ELEMENT_NODE &&
- ( this.name == null ||
- node.getNodeName().equals( this.name ) ) )
- {
- this.element = (Element) node;
- }
- }
- }
-
- public boolean hasNext()
- {
- return ( this.element != null );
- }
-
- public Object next()
- {
- final Element el = this.element;
-
- if( el == null )
- {
- throw new NoSuchElementException();
- }
-
- advance();
-
- return el;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathUtil.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathUtil.java
deleted file mode 100644
index c4161f49b..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathUtil.java
+++ /dev/null
@@ -1,113 +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.common.jdt.internal.classpath;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathContainer;
-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.logger.proxy.Logger;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public final class ClasspathUtil
-{
- private ClasspathUtil() {}
-
- public static Set getResolvedClasspath( final IJavaProject jproj,
- final IPath entryToIgnore )
- {
- return getResolvedClasspath( jproj, Collections.singleton( entryToIgnore ) );
- }
-
- public static Set getResolvedClasspath( final IJavaProject jproj,
- final Set entriesToIgnore )
- {
- final Set resolved = new HashSet();
-
- try
- {
- final IClasspathEntry[] entries = jproj.getRawClasspath();
-
- for( int i = 0; i < entries.length; i++ )
- {
- IClasspathEntry entry = entries[ i ];
-
- if( entriesToIgnore.contains( entry.getPath() ) )
- {
- continue;
- }
-
- switch( entry.getEntryKind() )
- {
- case IClasspathEntry.CPE_LIBRARY:
- case IClasspathEntry.CPE_PROJECT:
- {
- resolved.add( entry.getPath() );
- break;
- }
- case IClasspathEntry.CPE_VARIABLE:
- {
- entry = JavaCore.getResolvedClasspathEntry( entry );
-
- if( entry != null )
- {
- resolved.add( entry.getPath() );
- }
-
- break;
- }
- case IClasspathEntry.CPE_CONTAINER:
- {
- final IClasspathContainer container;
-
- try
- {
- container = JavaCore.getClasspathContainer( entry.getPath(), jproj );
- }
- catch( JavaModelException e )
- {
- Logger.getLogger().logError( e );
- continue;
- }
-
- if( container != null )
- {
- final IClasspathEntry[] containerEntries
- = container.getClasspathEntries();
-
- for( int j = 0; j < containerEntries.length; j++ )
- {
- resolved.add( containerEntries[ j ].getPath() );
- }
- }
- }
- }
- }
- }
- catch( JavaModelException e )
- {
- Logger.getLogger().logError( e );
- }
-
- return resolved;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java
deleted file mode 100644
index fadb62021..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java
+++ /dev/null
@@ -1,562 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2005, 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.common.jdt.internal.classpath;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-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.jdt.core.IAccessRule;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-import org.eclipse.jst.common.internal.modulecore.IClasspathDependencyComponent;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public abstract class FlexibleProjectContainer
-
- implements IClasspathContainer
-
-{
- protected static final class PathType
- {
- public static final PathType
- LIB_DIRECTORY = new PathType(),
- CLASSES_DIRECTORY = new PathType();
- }
-
- private static ClasspathDecorationsManager decorations;
-
- static
- {
- // Register the resource listener that will listen for changes to
- // resources relevant to flexible project containers across the
- // workspace and refresh them as necessary.
-
- Listener.register();
-
- // Read the decorations from the workspace metadata.
-
- final String plugin = CommonFrameworksPlugin.PLUGIN_ID;
- decorations = new ClasspathDecorationsManager( plugin );
- }
-
- private static final String SEPARATOR = "!"; //$NON-NLS-1$
-
- public static String getDecorationManagerKey(IProject project, String container){
- return project.getName() + SEPARATOR + container;
- }
-
- protected final IPath path;
- protected final IJavaProject owner;
- protected final IProject project;
- private final IPath[] paths;
- private final PathType[] pathTypes;
- protected final List entries;
- private final IClasspathEntry[] cpentries;
- private static final Set containerTypes = new HashSet();
-
- public FlexibleProjectContainer( final IPath path,
- final IJavaProject owner,
- final IProject project,
- final IPath[] paths,
- final PathType[] types )
- {
- this.path = path;
- this.owner = owner;
- this.project = project;
- this.paths = paths;
- this.pathTypes = types;
-
- if( ! isFlexibleProject( this.project ) )
- {
- // Silently noop if the referenced project is not a flexible
- // project. Should I be doing something else here?
-
- this.entries = Collections.EMPTY_LIST;
- this.cpentries = new IClasspathEntry[ 0 ];
-
- return;
- }
-
- addFlexibleProjectContainerType( path.segment( 0 ) );
-
- this.entries = computeClasspathEntries();
- this.cpentries = new IClasspathEntry[ this.entries.size() ];
-
- for( int i = 0, n = this.entries.size(); i < n; i++ )
- {
- IPath entryPath = (IPath) this.entries.get( i );
- IResource resource =ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
- if(null != resource && resource.getType() == IResource.PROJECT)
- this.cpentries[ i ] = JavaCore.newProjectEntry(entryPath, false);
- else
- this.cpentries[ i ] = newLibraryEntry( entryPath );
- }
- }
-
- public int getKind()
- {
- return K_APPLICATION;
- }
-
- public IPath getPath()
- {
- return this.path;
- }
-
- public IClasspathEntry[] getClasspathEntries()
- {
- return this.cpentries;
- }
-
- public boolean isOutOfDate( final IResourceDelta delta )
- {
- if( delta == null )
- {
- return false;
- }
- return isOutOfDate();
- }
-
- public boolean isOutOfDate() {
- final List currentEntries = computeClasspathEntries();
- return ! this.entries.equals( currentEntries );
- }
-
- public abstract void refresh();
-
- /**
- * If forceUpdate is <code>false</code> then a refresh is made only if
- * {@link #isOutOfDate()} returns <code>true</code>. If forceUpdate is
- * <code>true</code> then a refresh is immediately made without checking
- * {@link #isOutOfDate()}.
- *
- * @param forceUpdate
- */
- public void refresh(boolean forceUpdate){
- if(forceUpdate || isOutOfDate()){
- refresh();
- }
- }
-
- static ClasspathDecorationsManager getDecorationsManager()
- {
- return decorations;
- }
-
- protected IVirtualReference [] computeReferences(IVirtualComponent vc){
- return vc.getReferences();
- }
-
- protected List computeClasspathEntries()
- {
- final List entries = new ArrayList();
-
- final IVirtualComponent vc
- = ComponentCore.createComponent( this.project );
-
- if( vc == null )
- {
- return entries;
- }
-
- IVirtualReference[] refs = computeReferences(vc);
- IVirtualComponent comp = null;
- Set jarsHandled = new HashSet();
- String jarName = null;
- for (int i = 0; i < refs.length; i++) {
- comp = refs[i].getReferencedComponent();
- if (!refs[i].getRuntimePath().equals(paths[0].makeAbsolute()))
- continue;
- jarName = refs[i].getArchiveName();
- if(null != jarName){
- jarsHandled.add(jarName);
- }
- IPath newPath = null;
- if (comp.isBinary()) {
- if( comp instanceof IClasspathDependencyComponent )
- continue;
- newPath = (IPath)comp.getAdapter(IPath.class);
- } else
- newPath = comp.getProject().getFullPath();
-
- if( newPath != null && !entries.contains(newPath))
- entries.add( newPath );
- }
-
- for( int i = 0; i < this.paths.length; i++ )
- {
- final IVirtualFolder rootFolder = vc.getRootFolder();
- final IVirtualFolder vf = rootFolder.getFolder( paths[ i ] );
-
- if( this.pathTypes[ i ] == PathType.LIB_DIRECTORY )
- {
- final IVirtualResource[] contents;
-
- try
- {
- contents = members( vf );
- }
- catch( CoreException e )
- {
- CommonFrameworksPlugin.log( e );
- continue;
- }
-
- for( int j = 0; j < contents.length; j++ )
- {
- final IResource r = contents[ j ].getUnderlyingResource();
- final IPath p = r.getLocation();
-
- if(!jarsHandled.contains(p.lastSegment()) && isJarFile( r ) )
- {
- jarsHandled.add(p.lastSegment());
- entries.add( p );
- }
- }
- }
- else
- {
- final IContainer[] uf = vf.getUnderlyingFolders();
-
- for( int j = 0; j < uf.length; j++ )
- {
- final IPath p = uf[ j ].getFullPath();
-
- if( ! jarsHandled.contains( p.lastSegment() ) &&
- ! isSourceOrOutputDirectory( p ) )
- {
- jarsHandled.add(p.lastSegment());
- entries.add( p );
- }
- }
- }
- }
-
- return entries;
- }
-
- // TODO: This method was created to provide a safe last-minute workaround
- // for the issue described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=162974.
- // This code needs to be revisited in a future release to find a more
- // permanent solution.
-
- protected IVirtualResource[] members( final IVirtualFolder vf )
-
- throws CoreException
-
- {
- return vf.members();
- }
-
- private IClasspathEntry newLibraryEntry( final IPath p )
- {
- IPath srcpath = null;
- IPath srcrootpath = null;
- IClasspathAttribute[] attrs = {};
- IAccessRule[] access = {};
-
- final ClasspathDecorations dec
- = decorations.getDecorations( getDecorationManagerKey(project, getPath().toString()), p.toString() );
-
- if( dec != null )
- {
- srcpath = dec.getSourceAttachmentPath();
- srcrootpath = dec.getSourceAttachmentRootPath();
- attrs = dec.getExtraAttributes();
- }
-
- return JavaCore.newLibraryEntry( p, srcpath, srcrootpath, access, attrs,
- false );
-
- }
-
- private boolean isSourceOrOutputDirectory( final IPath aPath )
- {
- if( isJavaProject( this.project ) )
- {
- try
- {
- final IJavaProject jproject = JavaCore.create( this.project );
- final IClasspathEntry[] cp = jproject.getRawClasspath();
-
- for( int i = 0; i < cp.length; i++ )
- {
- final IClasspathEntry cpe = cp[ i ];
-
- if( cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE )
- {
- final IPath src = cpe.getPath();
- final IPath output = cpe.getOutputLocation();
-
- if( src.equals( aPath ) ||
- output != null && output.equals( aPath ) )
- {
- return true;
- }
- }
- }
-
- if( jproject.getOutputLocation().equals( aPath ) )
- {
- return true;
- }
- }
- catch( JavaModelException e )
- {
- CommonFrameworksPlugin.log( e );
- }
- }
-
- return false;
- }
-
- private static boolean isJavaProject( final IProject pj )
- {
- try
- {
- return pj.getNature( JavaCore.NATURE_ID ) != null;
- }
- catch( CoreException e )
- {
- return false;
- }
- }
-
- private static boolean isFlexibleProject( final IProject pj )
- {
- try
- {
- return pj.getNature( IModuleConstants.MODULE_NATURE_ID ) != null;
- }
- catch( CoreException e )
- {
- return false;
- }
- }
-
- private static boolean isJarFile( final IResource f )
- {
- if( f.getType() == IResource.FILE )
- {
- final String fname = f.getName();
-
- if( fname.endsWith( ".jar" ) || fname.endsWith( ".zip" ) ) //$NON-NLS-1$ //$NON-NLS-2$
- {
- return true;
- }
- }
-
- return false;
- }
-
- private static boolean isMetadataFile( final IResource f )
- {
- if( f.getType() == IResource.FILE )
- {
- final String fname = f.getName();
-
- if( fname.equals( ".component" ) || //$NON-NLS-1$
- fname.equals( "org.eclipse.wst.common.component" ) || //$NON-NLS-1$
- fname.equals( ".classpath")) //$NON-NLS-1$
- {
- return true;
- }
- }
-
- return false;
- }
-
- private static boolean isFlexibleProjectContainer( final IPath path )
- {
- synchronized( containerTypes )
- {
- return containerTypes.contains( path.segment( 0 ) );
- }
- }
-
- private static void addFlexibleProjectContainerType( final String type )
- {
- synchronized( containerTypes )
- {
- containerTypes.add( type );
- }
- }
-
- private static final class Listener
-
- implements IResourceChangeListener
-
- {
- public static void register()
- {
- final Listener listener = new Listener();
- final IWorkspace ws = ResourcesPlugin.getWorkspace();
- ws.addResourceChangeListener( listener, IResourceChangeEvent.PRE_BUILD );
- }
-
- public void resourceChanged( final IResourceChangeEvent event )
- {
- // Screen the delta before going any further.
-
- if( ! isInterestingEvent( event ) )
- {
- return;
- }
-
- // Locate all of the flexible project containers.
-
- final ArrayList containers = new ArrayList();
-
- final IProject[] projects
- = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-
- for( int i = 0; i < projects.length; i++ )
- {
- final IProject project = projects[ i ];
-
- try
- {
- if( isJavaProject( project ) )
- {
- final IJavaProject jproj = JavaCore.create( project );
- final IClasspathEntry[] cpes = jproj.getRawClasspath();
-
- for( int j = 0; j < cpes.length; j++ )
- {
- final IClasspathEntry cpe = cpes[ j ];
- final IPath path = cpe.getPath();
-
- if( cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
- isFlexibleProjectContainer( path ) )
- {
- final IClasspathContainer cont
- = JavaCore.getClasspathContainer( path, jproj );
-
- containers.add( cont );
- }
- }
- }
- }
- catch( JavaModelException e )
- {
- CommonFrameworksPlugin.log( e );
- }
- }
-
- // Refresh the containers that are out of date.
-
- final IResourceDelta delta = event.getDelta();
-
- for( int i = 0, n = containers.size(); i < n; i++ )
- {
- final FlexibleProjectContainer c
- = (FlexibleProjectContainer) containers.get( i );
-
- if( c.isOutOfDate( delta ) )
- {
- c.refresh();
- }
- }
- }
-
- private static boolean isInterestingEvent( final IResourceChangeEvent event )
- {
- final boolean[] result = new boolean[ 1 ];
-
- final IResourceDeltaVisitor visitor = new IResourceDeltaVisitor()
- {
- public boolean visit( final IResourceDelta delta )
- {
- final IResource r = delta.getResource();
-
- switch( r.getType() )
- {
- case IResource.ROOT:
- {
- return true;
- }
- case IResource.PROJECT:
- {
- return ModuleCoreNature.isFlexibleProject( (IProject) r );
- }
- case IResource.FOLDER:
- {
- final int kind = delta.getKind();
-
- if( kind == IResourceDelta.ADDED ||
- kind == IResourceDelta.REMOVED )
- {
- result[ 0 ] = true;
- return false;
- }
- return true;
- }
- case IResource.FILE:
- {
- if( isJarFile( r ) || isMetadataFile( r ) )
- {
- result[ 0 ] = true;
- }
-
- return false;
- }
- default:
- {
- return false;
- }
- }
- }
- };
-
- try
- {
- event.getDelta().accept( visitor, false );
- }
- catch( CoreException e )
- {
- CommonFrameworksPlugin.log( e );
- }
-
- return result[ 0 ];
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainerInitializer.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainerInitializer.java
deleted file mode 100644
index 16eb12aa2..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainerInitializer.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2005, 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.common.jdt.internal.classpath;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.ClasspathContainerInitializer;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public abstract class FlexibleProjectContainerInitializer
-
- extends ClasspathContainerInitializer
-
-{
- private static final ClasspathDecorationsManager decorations
- = FlexibleProjectContainer.getDecorationsManager();
-
- @Override
- public boolean canUpdateClasspathContainer( final IPath containerPath,
- final IJavaProject project)
- {
- return true;
- }
-
- @Override
- public void requestClasspathContainerUpdate( final IPath containerPath,
- final IJavaProject project,
- final IClasspathContainer sg )
-
- throws CoreException
-
- {
- final String key = FlexibleProjectContainer.getDecorationManagerKey(project.getProject(), containerPath.toString());
-
- final IClasspathEntry[] entries = sg.getClasspathEntries();
-
- decorations.clearAllDecorations( key );
-
- for( int i = 0; i < entries.length; i++ )
- {
- final IClasspathEntry entry = entries[ i ];
-
- final IPath srcpath = entry.getSourceAttachmentPath();
- final IPath srcrootpath = entry.getSourceAttachmentRootPath();
- final IClasspathAttribute[] attrs = entry.getExtraAttributes();
-
- if( srcpath != null || attrs.length > 0 )
- {
- final String eid = entry.getPath().toString();
- final ClasspathDecorations dec = new ClasspathDecorations();
-
- dec.setSourceAttachmentPath( srcpath );
- dec.setSourceAttachmentRootPath( srcrootpath );
- dec.setExtraAttributes( attrs );
-
- decorations.setDecorations( key, eid, dec );
- }
- }
-
- decorations.save();
-
- final IClasspathContainer container
- = JavaCore.getClasspathContainer( containerPath, project );
-
- ( (FlexibleProjectContainer) container ).refresh();
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModel.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModel.java
deleted file mode 100644
index 21ee651a5..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModel.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.common.jdt.internal.integration;
-
-import java.util.Set;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel;
-import org.eclipse.wst.common.frameworks.internal.SaveFailedException;
-import org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResource;
-import org.eclipse.wst.common.internal.emf.resource.ReferencedResource;
-import org.eclipse.wst.common.internal.emf.resource.TranslatorResource;
-import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext;
-
-public class JavaArtifactEditModel extends ArtifactEditModel implements WorkingCopyProvider {
-
- private WorkingCopyManager workingCopyManager = null;
-
- public JavaArtifactEditModel(String anEditModelId, EMFWorkbenchContext context, boolean toMakeReadOnly,
- boolean toAccessUnknownResourcesAsReadOnly, URI moduleURI, URI rootURI, String rootContentType) {
- super(anEditModelId, context, toMakeReadOnly, toAccessUnknownResourcesAsReadOnly, moduleURI, rootURI, rootContentType);
- }
-
- public JavaArtifactEditModel(String editModelID, EMFWorkbenchContext context, boolean toMakeReadOnly, URI moduleURI, URI rootURI,
- String rootContentType) {
- super(editModelID, context, toMakeReadOnly, moduleURI, rootURI, rootContentType);
- }
-
- /**
- * @param anEditModelId
- * @param aContext
- * @param toMakeReadOnly
- * @param toAccessUnknownResourcesAsReadOnly
- * @param aModuleURI
- */
- public JavaArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, boolean toAccessUnknownResourcesAsReadOnly, URI aModuleURI) {
- super(anEditModelId, aContext, toMakeReadOnly,
- toAccessUnknownResourcesAsReadOnly, aModuleURI);
- }
-
- /**
- * @param anEditModelId
- * @param aContext
- * @param toMakeReadOnly
- * @param aModuleURI
- */
- public JavaArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, URI aModuleURI) {
- super(anEditModelId, aContext, toMakeReadOnly, aModuleURI);
- }
-
- /**
- * This will delete
- *
- * @cu from the workbench and fix the internal references for this working copy manager.
- */
- public void delete(org.eclipse.jdt.core.ICompilationUnit cu, org.eclipse.core.runtime.IProgressMonitor monitor) {
- getWorkingCopyManager().delete(cu, monitor);
- }
-
- /**
- * This method should only be called by the J2EENature.
- */
- @Override
- protected void doDispose() {
- super.doDispose();
- resetWorkingCopyManager();
- }
-
- @Override
- public Set getAffectedFiles() {
- java.util.Set affected = super.getAffectedFiles();
- if (getWorkingCopyManager() != null)
- affected.addAll(getWorkingCopyManager().getAffectedFiles());
-
- return affected;
- }
-
- /**
- * Returns the working copy remembered for the compilation unit encoded in the given editor
- * input. Does not connect the edit model to the working copy.
- *
- * @param input
- * ICompilationUnit
- * @return the working copy of the compilation unit, or <code>null</code> if the input does
- * not encode an editor input, or if there is no remembered working copy for this
- * compilation unit
- */
- public org.eclipse.jdt.core.ICompilationUnit getExistingWorkingCopy(org.eclipse.jdt.core.ICompilationUnit cu) throws org.eclipse.core.runtime.CoreException {
- return getWorkingCopyManager().getExistingWorkingCopy(cu);
- }
-
- /**
- * Returns the working copy remembered for the compilation unit.
- *
- * @param input
- * ICompilationUnit
- * @return the working copy of the compilation unit, or <code>null</code> if there is no
- * remembered working copy for this compilation unit
- */
- public org.eclipse.jdt.core.ICompilationUnit getWorkingCopy(ICompilationUnit cu, boolean forNewCU) throws CoreException {
- return getWorkingCopyManager().getWorkingCopy(cu, forNewCU);
- }
-
- /**
- * Save the new compilation units only.
- */
- @Override
- protected void handleSaveIfNecessaryDidNotSave(IProgressMonitor monitor) {
- getWorkingCopyManager().saveOnlyNewCompilationUnits(monitor);
- }
-
- /**
- * @see org.eclipse.jst.j2ee.internal.internal.workbench.J2EEEditModel#isDirty()
- */
- @Override
- public boolean isDirty() {
- boolean dirtyBool = super.isDirty();
- if (!dirtyBool && getWorkingCopyManager() != null)
- dirtyBool = getWorkingCopyManager().hasWorkingCopies();
- return dirtyBool;
- }
-
- /**
- * This will force all of the referenced Resources to be saved.
- */
- @Override
- public void primSave(IProgressMonitor monitor) {
- saveCompilationUnits(monitor);
- if (monitor == null || !monitor.isCanceled())
- super.primSave(monitor);
- }
- @Override
- protected void runSaveOperation(IWorkspaceRunnable runnable, IProgressMonitor monitor) throws SaveFailedException {
- try {
- ResourcesPlugin.getWorkspace().run(runnable, null,IWorkspace.AVOID_UPDATE,monitor);
- } catch (CoreException e) {
- throw new SaveFailedException(e);
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (4/11/2001 4:14:26 PM)
- *
- * @return java.util.Set
- */
- @Override
- public void processResource(Resource aResource) {
- if (aResource != null && !getResources().contains(aResource)) {
- if (aResource instanceof ReferencedResource) {
- access((ReferencedResource) aResource);
- //We need a better way to pass this through the save options instead.
- //We also need to make this dynamic based on the project target
- ((ReferencedResource) aResource).setFormat(CompatibilityXMIResource.FORMAT_MOF5);
- } else if (!isReadOnly())
- aResource.setTrackingModification(true);
- addResource(aResource);
- }
- }
-
- /**
- * Release each of the referenced resources.
- */
- @Override
- protected void release(Resource aResource) {
-
- removeResource(aResource);
- if (aResource != null) {
- boolean isRefRes = aResource instanceof ReferencedResource;
- if (isRefRes)
- release((ReferencedResource) aResource);
- else if (!isReadOnly())
- aResource.setTrackingModification(false);
- if (!isDisposing())
- resetWorkingCopyManager();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jst.j2ee.internal.internal.workbench.J2EEEditModel#resourceIsLoadedChanged(org.eclipse.emf.ecore.resource.Resource,
- * boolean, boolean)
- */
- @Override
- protected void resourceIsLoadedChanged(Resource aResource, boolean oldValue, boolean newValue) {
- if (!isReverting && !disposing && !isReadOnly() && oldValue && !newValue && aResource instanceof TranslatorResource)
- resetWorkingCopyManager();
- super.resourceIsLoadedChanged(aResource, oldValue, newValue);
- }
-
- @Override
- protected void reverted(ReferencedResource revertedResource) {
- if (getWorkingCopyManager() != null)
- getWorkingCopyManager().revert();
- revertAllResources();
- }
-
- /**
- * This will save all of the referenced CompilationUnits to be saved.
- */
- public void saveCompilationUnits(IProgressMonitor monitor) {
- getWorkingCopyManager().saveCompilationUnits(monitor);
- }
-
- public WorkingCopyManager getWorkingCopyManager() {
- if (workingCopyManager == null)
- workingCopyManager = WorkingCopyManagerFactory.newRegisteredInstance();
- return workingCopyManager;
- }
-
- /**
- * Reset the working copy manager because the ejb-jar.xml was removed without disposing.
- */
- protected void resetWorkingCopyManager() {
- if (workingCopyManager != null) {
- workingCopyManager.dispose();
- workingCopyManager = null;
- }
- }
-
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModelFactory.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModelFactory.java
deleted file mode 100644
index 27640f5a2..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModelFactory.java
+++ /dev/null
@@ -1,74 +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.common.jdt.internal.integration;
-
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext;
-import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel;
-import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory;
-
-/**
- * <p>
- * The following class is experimental until fully documented.
- * </p>
- */
-public class JavaArtifactEditModelFactory extends EditModelFactory {
-
- public static final String MODULE_EDIT_MODEL_ID = "org.eclipse.jst.modulecore.editModel"; //$NON-NLS-1$
-
- public static final String PARAM_MODULE_URI = "MODULE_URI"; //$NON-NLS-1$
-
- public static final String PARAM_ROOT_URI = "ROOT_URI"; //$NON-NLS-1$
-
- public static final String PARAM_ROOT_CONTENT_TYPE = "ROOT_CONTENT_TYPE"; //$NON-NLS-1$
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#createEditModelForRead(java.lang.String, org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext, java.util.Map)
- */
- @Override
- public EditModel createEditModelForRead(String editModelID, EMFWorkbenchContext context, Map params) {
- URI moduleURI = (URI) ((params != null) ? params.get(PARAM_MODULE_URI) : null);
- URI rootURI = (URI) ((params != null) ? params.get(PARAM_ROOT_URI) : null);
- String rootContentType = (String) ((params != null) ? params.get(PARAM_ROOT_CONTENT_TYPE) : null);
- if(moduleURI == null)
- throw new IllegalStateException("A Module URI must be provided"); //$NON-NLS-1$
-
- return new JavaArtifactEditModel(editModelID, context, true, moduleURI,rootURI,rootContentType);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#createEditModelForWrite(java.lang.String, org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext, java.util.Map)
- */
- @Override
- public EditModel createEditModelForWrite(String editModelID, EMFWorkbenchContext context, Map params) {
- URI moduleURI = (URI) ((params != null) ? params.get(PARAM_MODULE_URI) : null);
- URI rootURI = (URI) ((params != null) ? params.get(PARAM_ROOT_URI) : null);
- String rootContentType = (String) ((params != null) ? params.get(PARAM_ROOT_CONTENT_TYPE) : null);
- if(moduleURI == null)
- throw new IllegalStateException("A Module URI must be provided"); //$NON-NLS-1$
- return new JavaArtifactEditModel(editModelID, context, false,false, moduleURI,rootURI,rootContentType);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#getCacheID(java.lang.String, java.util.Map)
- */
- @Override
- public String getCacheID(String editModelID, Map params) {
- URI moduleURI = (URI)params.get(PARAM_MODULE_URI);
- if(moduleURI != null)
- return editModelID+":"+moduleURI.toString(); //$NON-NLS-1$
- return editModelID+":NOURI"; //$NON-NLS-1$
- }
-
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectValidationHandler.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectValidationHandler.java
deleted file mode 100644
index ece991275..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectValidationHandler.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.common.jdt.internal.integration;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.wst.validation.internal.IValidationSelectionHandler;
-
-
-/**
- * Java Project validation
- */
-public class JavaProjectValidationHandler implements IValidationSelectionHandler {
-
- private String validationType = null;
-
- /**
- * Default constructor
- */
- public JavaProjectValidationHandler() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.frameworks.internal.IValidationSelectionHandler#getBaseValidationType(java.lang.Object)
- */
- public IResource getBaseValidationType(Object selection) {
- if (selection instanceof IJavaProject)
- return ((IJavaProject)selection).getProject();
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.frameworks.internal.IValidationSelectionHandler#getValidationTypeString()
- */
- public String getValidationTypeString() {
- return validationType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.frameworks.internal.IValidationSelectionHandler#setValidationTypeString(java.lang.String)
- */
- public void setValidationTypeString(String validationType) {
- this.validationType = validationType;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WTPWorkingCopyManager.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WTPWorkingCopyManager.java
deleted file mode 100644
index c43d15d42..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WTPWorkingCopyManager.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.common.jdt.internal.integration;
-
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-import org.eclipse.wst.common.frameworks.internal.ISaveHandler;
-import org.eclipse.wst.common.frameworks.internal.SaveFailedException;
-import org.eclipse.wst.common.frameworks.internal.SaveHandlerHeadless;
-import org.eclipse.wst.common.frameworks.internal.SaveHandlerRegister;
-import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-/**
- * Insert the type's description here. Creation date: (4/27/2001 4:14:30 PM)
- *
- * @author: Administrator
- */
-public class WTPWorkingCopyManager implements WorkingCopyManager {
-
- //New CUs that will need to be deleted upon dispose
- private List originalNewCompilationUnits;
- //New CUs that were created that need saved immediately (after each gen)
- private List needsSavingCompilationUnits;
- //A complete list of new CUs that is only cleared on save and dispose
- private List newCompilationUnits;
- private HashMap deletedCompilationUnits;
- protected static final Class IRESOURCE_CLASS = IResource.class;
-
- /**
- * WTPWorkingCopyManager constructor comment.
- */
- public WTPWorkingCopyManager() {
- super();
- }
-
- protected void addDeletedCompilationUnit(ICompilationUnit cu) {
- getNeedsSavingCompilationUnits().remove(cu);
- if (!getOriginalNewCompilationUnits().contains(cu) && !getDeletedCompilationUnits().containsKey(cu))
- primAddDeletedCompilationUnit(cu);
- getOriginalNewCompilationUnits().remove(cu);
- }
-
- protected void addNewCompilationUnit(ICompilationUnit cu, ICompilationUnit workingCopy) {
- getNewCompilationUnits().add(cu);
- getNeedsSavingCompilationUnits().add(workingCopy);
- if (!getDeletedCompilationUnits().containsKey(cu))
- getOriginalNewCompilationUnits().add(cu);
- }
-
- /**
- * This will save all of the new CompilationUnits to be saved.
- */
- protected void commitWorkingCopy(ICompilationUnit wc, IProgressMonitor monitor) {
- try {
- try {
- wc.commitWorkingCopy(false, monitor);
- } catch (JavaModelException e) {
- if (isFailedWriteFileFailure(e) && shouldSaveReadOnly(wc))
- wc.commitWorkingCopy(false, monitor);
- else
- throw e;
- }
- } catch (JavaModelException e) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e);
- throw new SaveFailedException(e);
- } finally {
- try {
- wc.discardWorkingCopy();
- } catch (JavaModelException e1) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e1);
- throw new SaveFailedException(e1);
- }
- }
- }
-
- /**
- * This will delete
- *
- * @cu from the workbench and fix the internal references for this working copy manager.
- */
- public void delete(final ICompilationUnit cu, final IProgressMonitor monitor) {
- ICompilationUnit localCU = cu;
- if (localCU.isWorkingCopy())
- localCU = localCU.getPrimary();
- addDeletedCompilationUnit(localCU);
- try {
- localCU.delete(false, monitor);
- } catch (JavaModelException e) {
- if (e.getStatus().getCode() != org.eclipse.jdt.core.IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST)
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e);
- }
- }
-
- protected void discardOriginalNewCompilationUnits() {
- if (getOriginalNewCompilationUnits().isEmpty())
- return;
- List cus = getOriginalNewCompilationUnits();
- ICompilationUnit cu;
- ICompilationUnit wc = null;
- for (int i = 0; i < cus.size(); i++) {
- cu = (ICompilationUnit) cus.get(i);
- if (cu.isWorkingCopy()) {
- wc = cu;
- cu = wc.getPrimary();
- }
- primDelete(cu);
- if (wc != null)
- try {
- wc.discardWorkingCopy();
- } catch (JavaModelException e) {
- Logger.getLogger().logError(e);
- }
- }
- }
-
- public void dispose() {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor aMonitor) {
- primDispose();
- }
- };
- try {
- if (!WTPCommonPlugin.getWorkspace().isTreeLocked()) {
- WTPCommonPlugin.getWorkspace().run(runnable,null, IWorkspace.AVOID_UPDATE,null);
- } else {
- runnable.run(null);
- }
- } catch (CoreException e) {
- CommonFrameworksPlugin.logError(e);
- }
- }
-
- public void revert() {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor aMonitor) {
- primRevert();
- }
- };
- runOperation(runnable, null, true);
- }
-
- public Set getAffectedFiles() {
- return Collections.EMPTY_SET;
- }
-
- /**
- * Insert the method's description here. Creation date: (7/11/2001 6:43:37 PM)
- *
- * @return java.util.HashMap
- */
- protected HashMap getDeletedCompilationUnits() {
- if (deletedCompilationUnits == null)
- deletedCompilationUnits = new HashMap();
- return deletedCompilationUnits;
- }
-
- /**
- * Returns the working copy remembered for the compilation unit encoded in the given editor
- * input. Does not connect the edit model to the working copy.
- *
- * @param input
- * ICompilationUnit
- * @return the working copy of the compilation unit, or <code>null</code> if the input does
- * not encode an editor input, or if there is no remembered working copy for this
- * compilation unit
- */
- public org.eclipse.jdt.core.ICompilationUnit getExistingWorkingCopy(ICompilationUnit cu) throws CoreException {
- ICompilationUnit newCU = getNewCompilationUnitWorkingCopy(cu);
- if (newCU != null)
- return newCU;
- return null;
- }
-
- /**
- * Insert the method's description here. Creation date: (7/19/2001 11:00:19 AM)
- *
- * @return java.util.List
- */
- protected java.util.List getNeedsSavingCompilationUnits() {
- if (needsSavingCompilationUnits == null)
- needsSavingCompilationUnits = new ArrayList();
- return needsSavingCompilationUnits;
- }
-
- /**
- * Insert the method's description here. Creation date: (4/26/2001 3:49:05 PM)
- *
- * @return java.util.List
- */
- protected java.util.List getNewCompilationUnits() {
- if (newCompilationUnits == null)
- newCompilationUnits = new ArrayList();
- return newCompilationUnits;
- }
-
- /**
- * It is possible that we have already created this CompilationUnit and its working copy. If
- * this is the case, return our new working copy and do not create a new one.
- */
- protected ICompilationUnit getNewCompilationUnitWorkingCopy(ICompilationUnit cu) {
- if (hasNewCompilationUnit(cu)) {
- List list = getNeedsSavingCompilationUnits();
- ICompilationUnit copy;
- for (int i = 0; i < list.size(); i++) {
- copy = (ICompilationUnit) list.get(i);
- if (cu.equals(copy.getPrimary()))
- return copy;
- }
- }
- return null;
- }
-
- /**
- * Insert the method's description here. Creation date: (4/26/2001 3:49:05 PM)
- *
- * @return java.util.List
- */
- protected java.util.List getOriginalNewCompilationUnits() {
- if (originalNewCompilationUnits == null)
- originalNewCompilationUnits = new ArrayList();
- return originalNewCompilationUnits;
- }
-
- /**
- * Return the IPackageFragment for the given ICompilationUnit.
- */
- protected IPackageFragment getPackageFragment(ICompilationUnit cu) {
- if (cu == null)
- return null;
- IJavaElement parent = cu;
- int elementType = cu.getElementType();
- while (parent != null && elementType != IJavaElement.PACKAGE_FRAGMENT) {
- parent = parent.getParent();
- if (parent != null)
- elementType = parent.getElementType();
- else
- elementType = -1;
- }
- return (IPackageFragment) parent;
- }
-
- protected ISaveHandler getSaveHandler() {
- return SaveHandlerRegister.getSaveHandler();
- }
-
- /**
- * Returns the working copy remembered for the compilation unit.
- *
- * @param input
- * ICompilationUnit
- * @return the working copy of the compilation unit, or <code>null</code> if there is no
- * remembered working copy for this compilation unit
- */
- public ICompilationUnit getWorkingCopy(ICompilationUnit cu, boolean forNewCU) throws org.eclipse.core.runtime.CoreException {
- if (cu == null || cu.isWorkingCopy())
- return cu;
- ICompilationUnit newCU = getNewCompilationUnitWorkingCopy(cu);
- if (newCU != null)
- return newCU;
- ICompilationUnit workingCopy = cu.getWorkingCopy(null);
- addNewCompilationUnit(cu, workingCopy);
- return workingCopy;
- }
-
- /**
- * Has a new compilation unit already been created.
- */
- protected boolean hasNewCompilationUnit(ICompilationUnit cu) {
- return getNewCompilationUnits().contains(cu);
- }
-
- protected boolean isFailedWriteFileFailure(Exception ex) {
- return SaveHandlerHeadless.isFailedWriteFileFailure(ex);
- }
-
- protected void primAddDeletedCompilationUnit(ICompilationUnit cu) {
- if (cu == null)
- return;
- Object[] info = new Object[2];
- info[0] = getPackageFragment(cu);
- try {
- info[1] = cu.getSource();
- } catch (JavaModelException e) {
- info[1] = null;
- }
- getDeletedCompilationUnits().put(cu, info);
- }
-
- // This is an internal delete call.
- protected void primDelete(ICompilationUnit cu) {
- try {
- if (cu.exists())
- cu.delete(true, new org.eclipse.core.runtime.NullProgressMonitor());
- } catch (JavaModelException e) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e);
- //What to do here?
- }
- }
-
- protected void primDispose() {
- discardOriginalNewCompilationUnits();
- reviveDeletedCompilationUnits();
- newCompilationUnits = null;
- needsSavingCompilationUnits = null;
- originalNewCompilationUnits = null;
- deletedCompilationUnits = null;
- }
-
- protected void primRevert() {
- discardOriginalNewCompilationUnits();
- reviveDeletedCompilationUnits();
- newCompilationUnits = null;
- needsSavingCompilationUnits = null;
- originalNewCompilationUnits = null;
- deletedCompilationUnits = null;
- }
-
- /**
- * Returns the working copy remembered for the compilation unit encoded in the given editor
- * input.
- *
- * @param input
- * ICompilationUnit
- * @return the working copy of the compilation unit, or <code>null</code> if the input does
- * not encode an editor input, or if there is no remembered working copy for this
- * compilation unit
- */
- protected ICompilationUnit primGetWorkingCopy(ICompilationUnit cu) throws CoreException {
- return null;
- }
-
- /**
- * This will save all of the referenced CompilationUnits to be saved.
- */
- protected void primSaveCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) {
- saveNewCompilationUnits(monitor);
- getDeletedCompilationUnits().clear();
- }
-
- /**
- * This will save all of the new CompilationUnits to be saved.
- */
- protected void primSaveOnlyNewCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) {
- List cus = getNeedsSavingCompilationUnits();
- ICompilationUnit wc;
- for (int i = 0; i < cus.size(); i++) {
- wc = (ICompilationUnit) cus.get(i);
- commitWorkingCopy(wc, monitor);
- }
- cus.clear();
- }
-
- protected void removeDeletedCompilationUnit(ICompilationUnit cu) {
- if (getDeletedCompilationUnits().remove(cu) != null) {
- if (cu.isWorkingCopy()) {
- ICompilationUnit original, nextCU, testCU;
- original = cu.getPrimary();
- Set cus = getDeletedCompilationUnits().keySet();
- Iterator it = cus.iterator();
- while (it.hasNext()) {
- nextCU = (ICompilationUnit) it.next();
- testCU = nextCU.isWorkingCopy() ? (ICompilationUnit) nextCU.getPrimary() : nextCU;
- if (testCU.equals(original)) {
- cus.remove(nextCU);
- return;
- }
- }
- }
- }
- }
-
- protected void reviveDeletedCompilationUnit(ICompilationUnit cu, Object[] info, IProgressMonitor pm) {
- if(cu.getJavaProject().isOpen()) {
- if (info[0] != null && info[1] != null) {
- String typeName = cu.getElementName();
- IPackageFragment pack = (IPackageFragment) info[0];
- String source = (String) info[1];
- try {
- ICompilationUnit existingCU = pack.getCompilationUnit(typeName);
- if (existingCU.exists() && getNewCompilationUnits().contains(existingCU))
- existingCU.delete(false, pm);
- pack.createCompilationUnit(typeName, source, false, pm);
- } catch (JavaModelException e) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e);
- }
- }
- }
- }
-
- protected void reviveDeletedCompilationUnits() {
- if (getDeletedCompilationUnits().isEmpty())
- return;
-
- IProgressMonitor pm = new org.eclipse.core.runtime.NullProgressMonitor();
- Iterator it = getDeletedCompilationUnits().entrySet().iterator();
- Map.Entry entry;
- ICompilationUnit cu;
- Object[] info;
- while (it.hasNext()) {
- entry = (Map.Entry) it.next();
- cu = (ICompilationUnit) entry.getKey();
- info = (Object[]) entry.getValue();
- reviveDeletedCompilationUnit(cu, info, pm);
- }
-
- }
-
- protected void runOperation(IWorkspaceRunnable aRunnable, IProgressMonitor monitor, boolean validate) {
- primRunOperation(aRunnable, monitor);
-
- // TODO Break the validator depedency
- // if (validate)
- // primRunOperation(aRunnable, monitor);
- // else {
- // IProject proj = getValidationProject();
- //
- // ValidatorManager mgr = ValidatorManager.getManager();
- // boolean disableValidators = proj != null;
- // boolean wasSuspended = false;
- // if (disableValidators) {
- // wasSuspended = mgr.isSuspended(proj);
- // if (!wasSuspended)
- // mgr.suspendValidation(proj, true);
- // }
- // try {
- // primRunOperation(aRunnable, monitor);
- // } finally {
- // if (disableValidators && !wasSuspended)
- // mgr.suspendValidation(proj, false);
- // }
- // }
- }
-
- protected void primRunOperation(IWorkspaceRunnable aRunnable, IProgressMonitor monitor) {
-
- if (aRunnable != null) {
- //if (workspace.isTreeLocked())
- //Logger.getLogger().logTrace(ResourceHandler.getString("Cannot_run_J2EEUIWorkingCo_ERROR_"));
- // //$NON-NLS-1$ = "Cannot run J2EEUIWorkingCopyManager operation because the Workspace
- // tree is locked."
- //else {
- if (!WTPCommonPlugin.getWorkspace().isTreeLocked()) {
- try {
- WTPCommonPlugin.getWorkspace().run(aRunnable, monitor);
- } catch (CoreException e) {
- throw new SaveFailedException(e);
- }
- }
- }
- }
-
- /**
- * This will save all of the referenced CompilationUnits to be saved.
- */
- public void saveCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) {
- getSaveHandler().access();
- try {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor aMonitor) {
- primSaveCompilationUnits(aMonitor);
- }
- };
- runOperation(runnable, monitor, true);
- } catch (SaveFailedException ex) {
- getSaveHandler().handleSaveFailed(ex, monitor);
- } finally {
- getSaveHandler().release();
- }
- }
-
- /**
- * This will save all of the referenced CompilationUnits to be saved.
- */
- protected void saveNewCompilationUnits(IProgressMonitor monitor) {
- primSaveOnlyNewCompilationUnits(monitor);
- getOriginalNewCompilationUnits().clear();
- getNewCompilationUnits().clear();
- }
-
- /**
- * This will save all of the new CompilationUnits to be saved.
- */
- public void saveOnlyNewCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) {
- getSaveHandler().access();
- try {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor aMonitor) {
- primSaveOnlyNewCompilationUnits(aMonitor);
- }
- };
- runOperation(runnable, monitor, false);
- } catch (SaveFailedException ex) {
- getSaveHandler().handleSaveFailed(ex, monitor);
- } finally {
- getSaveHandler().release();
- }
- }
-
- protected boolean shouldSaveReadOnly(ICompilationUnit wc) {
- IResource resource = null;
-
- resource = (IResource) wc.getPrimary().getAdapter(IRESOURCE_CLASS);
-
- if (resource == null || resource.getType() != IResource.FILE || !resource.getResourceAttributes().isReadOnly())
- return false;
-
- return getSaveHandler().shouldContinueAndMakeFileEditable((IFile) resource);
- }
-
- /**
- * @see com.ibm.etools.j2ee.workbench.IJ2EEWorkingCopyManager#hasWorkingCopies()
- */
- public boolean hasWorkingCopies() {
- return (deletedCompilationUnits != null && !deletedCompilationUnits.isEmpty()) || (needsSavingCompilationUnits != null && !needsSavingCompilationUnits.isEmpty()) || (newCompilationUnits != null && !newCompilationUnits.isEmpty());
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManager.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManager.java
deleted file mode 100644
index 35ccc89fb..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManager.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.common.jdt.internal.integration;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-/**
- * @author Administrator
- *
- *
- */
-public interface WorkingCopyManager extends WorkingCopyProvider {
-
- void dispose();
-
- java.util.Set getAffectedFiles();
-
- /**
- * This will save all of the referenced CompilationUnits to be saved.
- */
- void saveCompilationUnits(IProgressMonitor monitor);
-
- /**
- * This will save all of the new CompilationUnits to be saved.
- */
- void saveOnlyNewCompilationUnits(IProgressMonitor monitor);
-
- /**
- * Method hasWorkingCopies.
- *
- * @return boolean
- */
- boolean hasWorkingCopies();
-
- /**
- * Revert all working copies.
- */
- void revert();
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManagerFactory.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManagerFactory.java
deleted file mode 100644
index 9153f9e99..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManagerFactory.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.common.jdt.internal.integration;
-
-import org.eclipse.jem.util.UIContextDetermination;
-
-
-/**
- * @author mdelder
- *
- *
- */
-public class WorkingCopyManagerFactory {
-
- // protected static Class workingCopyManagerClass;
-
- public static WorkingCopyManager newRegisteredInstance() {
- return (WorkingCopyManager) UIContextDetermination.createInstance("workingCopyManager"); //$NON-NLS-1$
- }
-
- // public static IWorkingCopyManager createWorkingCopyManager() {
- // if (getWorkingCopyManagerClass() != null)
- // try {
- // return (IWorkingCopyManager) getWorkingCopyManagerClass().newInstance();
- // } catch (InstantiationException e1) {
- // } catch (IllegalAccessException e2) {
- // }
- // return null;
- // }
- //
- // /**
- // * Insert the method's description here.
- // * Creation date: (4/26/2001 7:53:15 AM)
- // * @return java.lang.Class
- // */
- // public static java.lang.Class getWorkingCopyManagerClass() {
- // return workingCopyManagerClass;
- // }
- //
- // /**
- // * Insert the method's description here.
- // * Creation date: (4/26/2001 7:53:15 AM)
- // * @param newWorkingCopyManagerClass java.lang.Class
- // */
- // public static void setWorkingCopyManagerClass(java.lang.Class newWorkingCopyManagerClass) {
- // workingCopyManagerClass = newWorkingCopyManagerClass;
- // }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyProvider.java
deleted file mode 100644
index 2696f5c54..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyProvider.java
+++ /dev/null
@@ -1,60 +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.common.jdt.internal.integration;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.ICompilationUnit;
-
-
-/**
- * The user of the Java code generation framework must supply an implementation of this interface.
- * The framework will obtain compilation working copies from this interface. The supplier of the
- * implementation is responsible for committing the working copies when appropriate for the user's
- * edit model.
- */
-public interface WorkingCopyProvider {
-
- /**
- * This will delete compilation unit from the workbench and fix the internal references for this
- * working copy manager.
- *
- * @param cu
- * the compilation unit to delete
- * @param monitor
- * the progress monitor to use for the delete
- */
- void delete(ICompilationUnit cu, IProgressMonitor monitor);
-
- /**
- * Returns the working copy remembered for the compilation unit. That is, the manager already
- * has a working copy for this unit, it does not create a new working copy. Does not connect the
- * edit model to the working copy.
- *
- * @param input
- * the compilation unit
- * @return the working copy of the compilation unit, or <code>null</code> it there is no
- * remembered working copy for this compilation unit
- */
- ICompilationUnit getExistingWorkingCopy(ICompilationUnit cu) throws CoreException;
-
- /**
- * Returns the working copy remembered for the compilation unit or creates a new working copy
- * for the compilation unit and returns it. If a working copy is passed in, it is returned.
- *
- * @param input
- * the compilation unit
- * @return the working copy of the compilation unit
- * @exception CoreException
- * if the working copy can not be created
- */
- ICompilationUnit getWorkingCopy(ICompilationUnit cu, boolean forNewCU) throws CoreException;
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/IJavaProjectLite.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/IJavaProjectLite.java
deleted file mode 100644
index ced0aec1e..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/IJavaProjectLite.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.common.jdt.internal.javalite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-/**
- * <p>
- * Represents a scaled down version of an {@link IJavaProject}. This subset of
- * methods is guaranteed to not force a load of the underlying
- * {@link IJavaModel}. This enables safe access to a limited set of
- * {@link IJavaProject} API for multi-threaded clients to call during times of
- * extreme concurrency, e.g. workbench startup.
- * </p>
- * <p>
- * An instance of one of these handles can be created via
- * <code>JavaCoreLite.create(project)</code>.
- * </p>
- *
- * @see JavaCore#create(org.eclipse.core.resources.IProject)
- * @see IJavaProject
- * @see IClasspathEntry
- */
-public interface IJavaProjectLite {
- /**
- * @see IJavaProject#readRawClasspath()
- *
- * @return
- */
- IClasspathEntry[] readRawClasspath();
-
- /**
- * @see IJavaProject#readOutputLocation()
- *
- * @return
- */
- IPath readOutputLocation();
-
- /**
- * @see IJavaProject#getProject()
- *
- * @return
- */
- IProject getProject();
-
- /**
- * @see IJavaProject#exists()
- */
- boolean exists();
-
- /**
- * @see IJavaProject#isOpen()
- * @return
- */
- boolean isOpen();
-
- /**
- * @see IJavaProject#hasBuildState()
- * @return
- */
- public boolean hasBuildState();
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaCoreLite.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaCoreLite.java
deleted file mode 100644
index b79aa6bc3..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaCoreLite.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.common.jdt.internal.javalite;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.ClasspathContainerInitializer;
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.IAccessRule;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IElementChangedListener;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.core.JavaModelManager;
-
-public final class JavaCoreLite {
-
- public static String NATURE_ID = JavaCore.NATURE_ID;
-
- private static Object lock = new Object();
-
- private static JavaCoreLite INSTANCE = null;
-
- private class JavaCoreLiteListener implements IElementChangedListener, IResourceChangeListener {
- public void elementChanged(ElementChangedEvent event) {
- IJavaElementDelta delta = event.getDelta();
- IJavaElementDelta[] children = delta.getAffectedChildren();
- for (int i = 0; i < children.length; i++) {
- processDelta(children[i]);
- }
- }
-
- private void processDelta(IJavaElementDelta delta) {
- int flags = delta.getFlags();
- if ((flags & IJavaElementDelta.F_CLOSED) != 0) {
- IJavaElement element = delta.getElement();
- IJavaProject javaProject = (IJavaProject) element;
- IProject project = javaProject.getProject();
- synchronized (lock) {
- initializedJavaProjects.remove(project);
- javaProjectLiteCache.remove(project);
- }
- } else if ((flags & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0) {
- IJavaElement element = delta.getElement();
- if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
- IJavaProject javaProject = (IJavaProject) element;
- IProject project = javaProject.getProject();
- synchronized (lock) {
- if (!initializedJavaProjects.contains(project) && javaProjectLiteCache.containsKey(project)) {
- JavaProjectLite javaProjectLite = javaProjectLiteCache.get(project);
- javaProjectLite.flushClasspath();
- }
- }
- }
- } else if ((flags & IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED) != 0) {
- IJavaElement element = delta.getElement();
- if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
- IJavaProject javaProject = (IJavaProject) element;
- IProject project = javaProject.getProject();
- synchronized (lock) {
- if (!initializedJavaProjects.contains(project)) {
- initializedJavaProjects.add(project);
- if (javaProjectLiteCache.containsKey(project)) {
- JavaProjectLite javaProjectLite = javaProjectLiteCache.get(project);
- javaProjectLite.markJavaProjectInitialized();
- }
- }
- }
- }
- }
- }
-
- public void resourceChanged(IResourceChangeEvent event) {
- switch (event.getType()) {
- case IResourceChangeEvent.PRE_CLOSE:
- case IResourceChangeEvent.PRE_DELETE:
- IResource resource = event.getResource();
- if (resource.getType() == IResource.PROJECT) {
- IProject project = (IProject) resource;
- synchronized (lock) {
- initializedJavaProjects.remove(project);
- javaProjectLiteCache.remove(project);
- }
- }
- }
- }
- }
-
- private Set<IProject> initializedJavaProjects = new HashSet<IProject>();
- private Map<IProject, JavaProjectLite> javaProjectLiteCache = new HashMap<IProject, JavaProjectLite>();
- private JavaCoreLiteListener listener = null;
-
- private static JavaCoreLite getInstance() {
- synchronized (lock) {
- if (INSTANCE == null) {
- INSTANCE = new JavaCoreLite();
- }
- }
- return INSTANCE;
- }
-
- private JavaCoreLite() {
- listener = new JavaCoreLiteListener();
- JavaCore.addElementChangedListener(listener);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE);
- }
-
- private IJavaProjectLite createImpl(IProject project) {
- synchronized (lock) {
- if (javaProjectLiteCache.containsKey(project)) {
- return javaProjectLiteCache.get(project);
- }
- }
-
- IJavaProject javaProject = JavaCore.create(project);
- if (javaProject != null) {
- boolean javaProjectInitialized = false;
- synchronized (lock) {
- javaProjectInitialized = initializedJavaProjects.contains(project);
- }
- if (!javaProjectInitialized) {
- if (isInitialized(javaProject)) {
- synchronized (lock) {
- initializedJavaProjects.add(project);
- }
- javaProjectInitialized = true;
- }
- }
- JavaProjectLite javaProjectLite = new JavaProjectLite(javaProject, javaProjectInitialized);
- synchronized (lock) {
- javaProjectLiteCache.put(project, javaProjectLite);
- }
- return javaProjectLite;
- }
- return null;
- }
-
- static boolean isInitialized(IJavaProject javaProject) {
- if (javaProject.isOpen()) {
- JavaModelManager.PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(javaProject.getProject(), false);
- if (projectInfo != null) {
- if (projectInfo.getResolvedClasspath() != null) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static final IJavaProjectLite create(IProject project) {
- if (project == null) {
- throw new NullPointerException();
- }
- return getInstance().createImpl(project);
- }
-
- public static final IJavaProjectLite create(IJavaProject javaProject) {
- if (javaProject == null) {
- throw new NullPointerException();
- }
- return create(javaProject.getProject());
- }
-
- public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID) {
- return JavaCore.getClasspathContainerInitializer(containerID);
- }
-
- public static IClasspathEntry newProjectEntry(IPath path) {
- return JavaCore.newProjectEntry(path);
- }
-
- public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
- return JavaCore.newProjectEntry(path, isExported);
- }
-
- public static IClasspathEntry newProjectEntry(IPath path, IAccessRule[] accessRules, boolean combineAccessRules, IClasspathAttribute[] extraAttributes, boolean isExported) {
- return JavaCore.newProjectEntry(path, accessRules, combineAccessRules, extraAttributes, isExported);
- }
-
- public static IClasspathEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath) {
- return JavaCore.newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath);
- }
-
- public static IClasspathEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, boolean isExported) {
- return JavaCore.newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, isExported);
- }
-
- public static IClasspathEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IAccessRule[] accessRules, IClasspathAttribute[] extraAttributes, boolean isExported) {
- return JavaCore.newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, accessRules, extraAttributes, isExported);
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaLiteUtilities.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaLiteUtilities.java
deleted file mode 100644
index f61edbcee..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaLiteUtilities.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.common.jdt.internal.javalite;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-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.jdt.core.IClasspathEntry;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
-
-public final class JavaLiteUtilities {
-
- /**
- * Returns the Java source (i.e. where the .java files are) IContainers for
- * the specified IJavaProjectLite
- *
- * @param javaProjectLite
- * @return
- */
- public final static List<IContainer> getJavaSourceContainers(final IJavaProjectLite javaProjectLite) {
- IClasspathEntry[] entries = javaProjectLite.readRawClasspath();
- List<IContainer> containers = new ArrayList<IContainer>();
- for (IClasspathEntry entry : entries) {
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().segmentCount() > 0) {
- IContainer container = null;
- if( entry.getPath().segmentCount() == 1 )
- container = ResourcesPlugin.getWorkspace().getRoot().getProject(entry.getPath().segment(0));
- else
- container = ResourcesPlugin.getWorkspace().getRoot().getFolder(entry.getPath());
- if( !containers.contains(container))
- containers.add(container);
- }
- }
- return containers;
- }
-
- /**
- * Returns the Java source (i.e. where the compiled .class files are) IContainers for
- * the specified IJavaProjectLite
- *
- * @param javaProjectLite
- * @return
- */
- public final static List<IContainer> getJavaOutputContainers(final IJavaProjectLite javaProjectLite) {
- List<IContainer> containers = new ArrayList<IContainer>();
- IContainer defaultOutputContainer = getDefaultJavaOutputContainer(javaProjectLite);
- containers.add(defaultOutputContainer);
- IClasspathEntry[] entries = javaProjectLite.readRawClasspath();
- for (IClasspathEntry entry : entries) {
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- IContainer outputContainer = getJavaOutputContainer(javaProjectLite, entry);
- if (!containers.contains(outputContainer)) {
- containers.add(outputContainer);
- }
- }
- }
- return containers;
- }
-
- private static enum JavaContainerType {
- SOURCE, OUTPUT
- }
-
- /**
- * Returns all Java output (i.e. where the compiled .class files are)
- * IContainers whose source is explicitly mapped by the specified component,
- * or if the output container itself is explicitly mapped.
- *
- * @param virtualComponent
- * @return
- */
- public static List<IContainer> getJavaOutputContainers(IVirtualComponent virtualComponent) {
- return getJavaContainers(virtualComponent, JavaContainerType.OUTPUT);
- }
-
- /**
- * Returns all Java source (i.e. where the .java files are) IContainers
- * explicitly mapped by the specified component.
- *
- * @param virtualComponent
- * @return
- */
- public static List<IContainer> getJavaSourceContainers(IVirtualComponent virtualComponent) {
- return getJavaContainers(virtualComponent, JavaContainerType.SOURCE);
- }
-
- private static List<IContainer> getJavaContainers(IVirtualComponent virtualComponent, JavaContainerType javaContainerType) {
- if (virtualComponent.isBinary()) {
- return Collections.emptyList();
- }
- IProject project = virtualComponent.getProject();
- try {
- if (!project.hasNature(JavaCoreLite.NATURE_ID)) {
- return Collections.emptyList();
- }
- } catch (CoreException e) {
- CommonFrameworksPlugin.logError(e);
- return Collections.emptyList();
- }
-
- IJavaProjectLite javaProjectLite = JavaCoreLite.create(project);
- List<IContainer> containers = new ArrayList<IContainer>();
- if (javaContainerType == JavaContainerType.OUTPUT) {
- IContainer defaultOutputContainer = getDefaultJavaOutputContainer(javaProjectLite);
- IVirtualResource[] virtualResources = ComponentCore.createResources(defaultOutputContainer);
- for (IVirtualResource virtualResource : virtualResources) {
- if (virtualResource.getComponent().equals(virtualComponent)) {
- containers.add(defaultOutputContainer);
- break;
- }
- }
- }
- IClasspathEntry[] entries = javaProjectLite.readRawClasspath();
- for (IClasspathEntry entry : entries) {
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- IPath sourcePath = entry.getPath().removeFirstSegments(1); // remove the project from the path
- IContainer sourceContainer = sourcePath.segmentCount() == 0 ? project : project.getFolder(sourcePath);
- if (sourceContainer != null) {
- IVirtualResource[] virtualResources = ComponentCore.createResources(sourceContainer);
- for (IVirtualResource virtualResource : virtualResources) {
- if (virtualResource.getComponent().equals(virtualComponent)) {
- switch (javaContainerType) {
- case SOURCE:
- if (!containers.contains(sourceContainer)) {
- containers.add(sourceContainer);
- }
- break;
- case OUTPUT:
- IContainer outputContainer = getJavaOutputContainer(javaProjectLite, entry);
- if (!containers.contains(outputContainer)) {
- containers.add(outputContainer);
- }
- break;
- }
- }
- }
- }
- }
- }
- return containers;
- }
-
- /**
- * Returns the default Java output IContainer (i.e. where the compiled
- * .class files go)
- *
- * @param javaProjectLite
- * @return
- */
- public static IContainer getDefaultJavaOutputContainer(IJavaProjectLite javaProjectLite) {
- IProject project = javaProjectLite.getProject();
- IPath defaultOutputPath = javaProjectLite.readOutputLocation();
- if (defaultOutputPath.segmentCount() == 1) {
- return project;
- }
- return project.getFolder(defaultOutputPath.removeFirstSegments(1));
- }
-
- /**
- * Returns the Java output (i.e. where the compiled .class files go)
- * IContainer for the specified IClasspathEntry
- *
- * @param javaProjectLite
- * @param entry
- * @return
- */
- public static IContainer getJavaOutputContainer(IJavaProjectLite javaProjectLite, IClasspathEntry entry) {
- IProject project = javaProjectLite.getProject();
- IPath outputPath = entry.getOutputLocation();
- if (outputPath != null) {
- return project.getFolder(outputPath.removeFirstSegments(1));
- }
- return getDefaultJavaOutputContainer(javaProjectLite);
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaProjectLite.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaProjectLite.java
deleted file mode 100644
index f8141e523..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/javalite/JavaProjectLite.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.common.jdt.internal.javalite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
-
-/**
- * @see IJavaProjectLite
- */
-public final class JavaProjectLite implements IJavaProjectLite {
- private final IJavaProject _javaProject;
-
- private Object lock = new Object();
- private boolean _javaProjectInitialized = false;
- private boolean _rawClasspathRead = false;
- private IClasspathEntry[] _rawClasspath;
- private boolean _rawOutputLocationRead = false;
- private IPath _rawOutputLocation;
- private long _dotClasspathModificationStamp = IFile.NULL_STAMP;
-
- JavaProjectLite(IJavaProject javaProject, boolean javaProjectInitialized) {
- this._javaProject = javaProject;
- this._javaProjectInitialized = javaProjectInitialized;
- }
-
- void markJavaProjectInitialized() {
- synchronized (lock) {
- if (!_javaProjectInitialized) {
- _javaProjectInitialized = true;
- flushClasspath();
- }
- }
- }
-
- private boolean isJavaProjectInitialized() {
- synchronized (lock) {
- return _javaProjectInitialized;
- }
- }
-
- void flushClasspath() {
- synchronized (lock) {
- _rawClasspathRead = false;
- _rawClasspath = null;
- _rawOutputLocationRead = false;
- _rawOutputLocation = null;
- _dotClasspathModificationStamp = IFile.NULL_STAMP;
- }
- }
-
- private void verifyDotClasspathModificationStamp() {
- long modificationStamp = IFile.NULL_STAMP;
- synchronized (lock) {
- modificationStamp = _dotClasspathModificationStamp;
- }
- if (modificationStamp == IFile.NULL_STAMP) {
- flushClasspath();
- return;
- }
- IFile dotClasspath = _javaProject.getProject().getFile(".classpath"); //$NON-NLS-1$
- if (!dotClasspath.exists()) {
- flushClasspath();
- return;
- }
- if (modificationStamp != dotClasspath.getModificationStamp()) {
- flushClasspath();
- return;
- }
- }
-
- private void updateDotClasspathModificationStamp() {
- IFile dotClasspath = _javaProject.getProject().getFile(".classpath"); //$NON-NLS-1$
- long modificationStamp = dotClasspath.getModificationStamp();
- synchronized (lock) {
- _dotClasspathModificationStamp = modificationStamp;
- }
- }
-
- public final IClasspathEntry[] readRawClasspath() {
- if (!isJavaProjectInitialized()) {
- if (JavaCoreLite.isInitialized(_javaProject)) {
- markJavaProjectInitialized();
- }
- }
-
- if (isJavaProjectInitialized()) {
- try {
- return _javaProject.getRawClasspath();
- } catch (JavaModelException e) {
- CommonFrameworksPlugin.log(e);
- }
- }
-
- verifyDotClasspathModificationStamp();
-
- boolean dataRead = false;
- synchronized (lock) {
- dataRead = _rawClasspathRead;
- }
- if (!dataRead) {
- updateDotClasspathModificationStamp();
- IClasspathEntry[] rawClasspath = _javaProject.readRawClasspath();
- synchronized (lock) {
- _rawClasspathRead = true;
- _rawClasspath = rawClasspath;
- }
- }
- return _rawClasspath;
- }
-
- public final IPath readOutputLocation() {
- if (!isJavaProjectInitialized()) {
- if (JavaCoreLite.isInitialized(_javaProject)) {
- markJavaProjectInitialized();
- }
- }
-
- if (isJavaProjectInitialized()) {
- try {
- return _javaProject.getOutputLocation();
- } catch (JavaModelException e) {
- CommonFrameworksPlugin.log(e);
- }
- }
-
- verifyDotClasspathModificationStamp();
-
- boolean dataRead = false;
- synchronized (lock) {
- dataRead = _rawOutputLocationRead;
- }
- if (!dataRead) {
- updateDotClasspathModificationStamp();
- IPath rawOutputLocation = _javaProject.readOutputLocation();
- if (rawOutputLocation == null) {
- // borrowed from JavaProject.getDefaultOutputLocation()
- rawOutputLocation = _javaProject.getProject().getFullPath().append("bin"); //$NON-NLS-1$
- }
- synchronized (lock) {
- _rawOutputLocationRead = true;
- _rawOutputLocation = rawOutputLocation;
- }
- }
- return _rawOutputLocation;
- }
-
- /**
- * @see IJavaProjectLite#getProject()
- */
- public final IProject getProject() {
- return _javaProject.getProject();
- }
-
- public final boolean exists() {
- return _javaProject.exists();
- }
-
- /**
- * @see IJavaProjectLite#isOpen()
- */
- public final boolean isOpen() {
- return _javaProject.isOpen();
- }
-
- /**
- * @see IJavaProjectLite#hasBuildState()
- */
- public final boolean hasBuildState() {
- return _javaProject.hasBuildState();
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/IJavaFacetInstallDataModelProperties.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/IJavaFacetInstallDataModelProperties.java
deleted file mode 100644
index 10daa48c6..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/IJavaFacetInstallDataModelProperties.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 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.common.project.facet;
-
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties;
-
-public interface IJavaFacetInstallDataModelProperties extends IDataModelProperties {
-
- public static final String SOURCE_FOLDER_NAME = "IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME"; //$NON-NLS-1$
- public static final String DEFAULT_OUTPUT_FOLDER_NAME = "IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME"; //$NON-NLS-1$
- public static final String JAVA_FACET_INSTALL_CONFIG = "IJavaFacetInstallDataModelProperties.JAVA_FACET_INSTALL_CONFIG"; //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java
deleted file mode 100644
index 31791b25e..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 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.common.project.facet;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.common.project.facet.core.JavaFacet;
-import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig;
-import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.ChangeEvent;
-import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.util.IEventListener;
-
-public class JavaFacetInstallDataModelProvider extends FacetInstallDataModelProvider implements IJavaFacetInstallDataModelProperties {
-
- private final JavaFacetInstallConfig installConfig;
-
- public JavaFacetInstallDataModelProvider()
- {
- this( new JavaFacetInstallConfig() );
- }
-
- public JavaFacetInstallDataModelProvider( final JavaFacetInstallConfig installConfig )
- {
- this.installConfig = installConfig;
- }
-
- @Override
- public Set getPropertyNames()
- {
- Set propertyNames = super.getPropertyNames();
- propertyNames.add(JAVA_FACET_INSTALL_CONFIG);
- propertyNames.add(SOURCE_FOLDER_NAME);
- propertyNames.add(DEFAULT_OUTPUT_FOLDER_NAME);
- return propertyNames;
- }
-
- @Override
- public void init()
- {
- super.init();
-
- final IDataModel dm = getDataModel();
-
- dm.setProperty( FACET_ID, JavaFacet.ID );
- dm.setProperty( JAVA_FACET_INSTALL_CONFIG, this.installConfig );
-
- String sourceFolderName = null;
-
- if( ! this.installConfig.getSourceFolders().isEmpty() )
- {
- sourceFolderName = this.installConfig.getSourceFolders().get( 0 ).toPortableString();
- }
-
- dm.setProperty( SOURCE_FOLDER_NAME, sourceFolderName );
-
- String defaultOutputFolderName = null;
-
- if( this.installConfig.getDefaultOutputFolder() != null )
- {
- defaultOutputFolderName = this.installConfig.getDefaultOutputFolder().toPortableString();
- }
-
- dm.setProperty( DEFAULT_OUTPUT_FOLDER_NAME, defaultOutputFolderName );
-
- final IEventListener<JavaFacetInstallConfig.ChangeEvent> listener
- = new IEventListener<JavaFacetInstallConfig.ChangeEvent>()
- {
- public void handleEvent( final ChangeEvent event )
- {
- if( event.getType() == JavaFacetInstallConfig.ChangeEvent.Type.SOURCE_FOLDERS_CHANGED )
- {
- String val = null;
-
- if( installConfig.getSourceFolders().size() > 0 )
- {
- val = installConfig.getSourceFolders().get( 0 ).toPortableString();
- }
-
- dm.setProperty( SOURCE_FOLDER_NAME, val );
- }
- else if( event.getType() == JavaFacetInstallConfig.ChangeEvent.Type.DEFAULT_OUTPUT_FOLDER_CHANGED )
- {
- final String val = installConfig.getDefaultOutputFolder().toPortableString();
- dm.setProperty( DEFAULT_OUTPUT_FOLDER_NAME, val );
- }
- }
- };
-
- this.installConfig.addListener( listener );
- }
-
- @Override
- public boolean propertySet( final String propertyName,
- final Object propertyValue )
- {
- if( propertyName.equals( SOURCE_FOLDER_NAME ) )
- {
- final List<IPath> sourceFolders;
-
- if( propertyValue == null )
- {
- sourceFolders = Collections.emptyList();
- }
- else
- {
- sourceFolders = Collections.<IPath>singletonList( new Path( (String) propertyValue ) );
- }
-
- this.installConfig.setSourceFolders( sourceFolders );
-
- return true;
- }
- else if( propertyName.equals( DEFAULT_OUTPUT_FOLDER_NAME ) )
- {
- this.installConfig.setDefaultOutputFolder( new Path( (String) propertyValue ) );
- return true;
- }
- else if( propertyName.equals( JAVA_FACET_INSTALL_CONFIG ) )
- {
- return false;
- }
-
- return super.propertySet( propertyName, propertyValue );
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java
deleted file mode 100644
index e2312ab3e..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2005, 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.common.project.facet;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jst.common.project.facet.core.JavaFacet;
-import org.eclipse.jst.common.project.facet.core.internal.JavaFacetUtil;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-
-/**
- * This class is deprecated. JavaFacet class should be used instead.
- *
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-@Deprecated
-
-public final class JavaFacetUtils
-{
- public static final IProjectFacet JAVA_FACET = JavaFacet.FACET;
- public static final IProjectFacetVersion JAVA_13 = JavaFacet.VERSION_1_3;
- public static final IProjectFacetVersion JAVA_14 = JavaFacet.VERSION_1_4;
- public static final IProjectFacetVersion JAVA_50 = JavaFacet.VERSION_1_5;
- public static final IProjectFacetVersion JAVA_60 = JavaFacet.VERSION_1_6;
-
- public static String getCompilerLevel()
- {
- return JavaFacetUtil.getCompilerLevel();
- }
-
- public static String getCompilerLevel( final IProject project )
- {
- return JavaFacetUtil.getCompilerLevel( project );
- }
-
- public static void setCompilerLevel( final IProject project,
- final IProjectFacetVersion fv )
-
- throws CoreException
-
- {
- JavaFacetUtil.setCompilerLevel( project, fv );
- }
-
- public static void setCompilerLevel( final IProject project,
- final String level )
-
- throws CoreException
-
- {
- JavaFacetUtil.setCompilerLevel( project, level );
- }
-
- public static void scheduleFullBuild( final IProject project )
- {
- JavaFacetUtil.scheduleFullBuild( project );
- }
-
- public static void resetClasspath( final IProject project,
- final IProjectFacetVersion oldver,
- final IProjectFacetVersion newver )
-
- throws CoreException
-
- {
- JavaFacetUtil.resetClasspath( project, oldver, newver );
- }
-
- public static IProjectFacetVersion compilerLevelToFacet( final String ver )
- {
- return JavaFacet.FACET.getVersion( ver );
- }
-
- public static String facetToCompilerLevel( final IProjectFacetVersion fv )
- {
- return fv.getVersionString();
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java
deleted file mode 100644
index 88ad59710..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.common.project.facet;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.jst.common.project.facet.core.JavaFacet;
-import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider;
-
-public class JavaProjectFacetCreationDataModelProvider extends FacetProjectCreationDataModelProvider {
-
- public JavaProjectFacetCreationDataModelProvider() {
- super();
- }
-
- @Override
- public void init() {
- super.init();
-
- Collection requiredFacets = new ArrayList();
- requiredFacets.add(JavaFacet.FACET);
- setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/WtpUtils.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/WtpUtils.java
deleted file mode 100644
index b82d7d2dd..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/WtpUtils.java
+++ /dev/null
@@ -1,69 +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.common.project.facet;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public final class WtpUtils
-{
- private WtpUtils() {}
-
- private static final String WTP_NATURE
- = "org.eclipse.wst.common.modulecore.ModuleCoreNature"; //$NON-NLS-1$
-
- private static final String JEM_NATURE
- = "org.eclipse.jem.workbench.JavaEMFNature"; //$NON-NLS-1$
-
- private static final String[] NATURES = {WTP_NATURE, JEM_NATURE};
-
- public static void addNatures( final IProject project )
-
- throws CoreException
-
- {
- for (int i = 0; i < NATURES.length; i++) {
- if (!project.hasNature(NATURES[i])) {
- ProjectUtilities.addNatureToProject(project, NATURES[i]);
- }
- }
- }
-
- public static void addNaturestoEAR( final IProject project )
-
- throws CoreException
-
- {
- final IProjectDescription desc = project.getDescription();
- final String[] current = desc.getNatureIds();
- final String[] replacement = new String[ current.length + 1 ];
- System.arraycopy( current, 0, replacement, 0, current.length );
- replacement[ current.length ] = WTP_NATURE;
- desc.setNatureIds( replacement );
- project.setDescription( desc, null );
- }
-
- public static void removeNatures( final IProject project )
-
- throws CoreException
-
- {
- ProjectUtilities.removeNatureFromProject( project, WTP_NATURE );
- ProjectUtilities.removeNatureFromProject( project, JEM_NATURE );
- }
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/DataModelToJavaFacetInstallConfigAdapter.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/DataModelToJavaFacetInstallConfigAdapter.java
deleted file mode 100644
index aaee1bdc2..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/DataModelToJavaFacetInstallConfigAdapter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2008 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
- ******************************************************************************/
-
-package org.eclipse.jst.common.project.facet.internal;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
-import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public final class DataModelToJavaFacetInstallConfigAdapter
-
- implements IAdapterFactory
-
-{
- private static final Class[] ADAPTER_TYPES = { JavaFacetInstallConfig.class };
-
- public Object getAdapter( final Object adaptable,
- final Class adapterType )
- {
- if( adapterType == JavaFacetInstallConfig.class )
- {
- final IDataModel dm = (IDataModel) adaptable;
-
- return dm.getProperty( IJavaFacetInstallDataModelProperties.JAVA_FACET_INSTALL_CONFIG );
- }
-
- return null;
- }
-
- public Class[] getAdapterList()
- {
- return ADAPTER_TYPES;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/JavaFacetInstallConfigToDataModelAdapter.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/JavaFacetInstallConfigToDataModelAdapter.java
deleted file mode 100644
index f42c4c5c5..000000000
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/internal/JavaFacetInstallConfigToDataModelAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2008 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
- ******************************************************************************/
-
-package org.eclipse.jst.common.project.facet.internal;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.jst.common.project.facet.JavaFacetInstallDataModelProvider;
-import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public final class JavaFacetInstallConfigToDataModelAdapter
-
- implements IAdapterFactory
-
-{
- private static final Class[] ADAPTER_TYPES = { IDataModel.class };
-
- public Object getAdapter( final Object adaptable,
- final Class adapterType )
- {
- if( adapterType == IDataModel.class )
- {
- final JavaFacetInstallDataModelProvider provider
- = new JavaFacetInstallDataModelProvider( (JavaFacetInstallConfig) adaptable );
-
- return DataModelFactory.createDataModel( provider );
- }
-
- return null;
- }
-
- public Class[] getAdapterList()
- {
- return ADAPTER_TYPES;
- }
-
-}

Back to the top