diff options
Diffstat (limited to 'plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst')
122 files changed, 0 insertions, 21388 deletions
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ArtifactEdit.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ArtifactEdit.java deleted file mode 100644 index 77cca5740..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ArtifactEdit.java +++ /dev/null @@ -1,743 +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.wst.common.componentcore; - -import java.util.EventObject; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler; -import org.eclipse.jem.util.UIContextDetermination; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.BinaryComponentHelper; -import org.eclipse.wst.common.componentcore.internal.impl.ArtifactEditModelFactory; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.internal.operations.IOperationHandler; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelListener; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.IValidateEditContext; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * Provides a Facade pattern for accessing Module Content Metamodels for Web Tools Platform flexible - * modules. - * <p> - * ArtifactEdit hides the management of accessing edit models ({@see ArtifactEditModel}) - * correctly. Each project may have multiple ({@see ArtifactEditModel})s depending on the number - * of modules contained by the project. Clients should use ArtifactEdit or an appropriate subclass - * when working with the content models of WTP modules. - * </p> - * - * <p> - * Each ArtifactEdit facade is designed to manage the EditModel lifecycle for clients. However, - * while each ArtifactEdit is designed to be passed around as needed, clients must enforce the - * ArtifactEdit lifecycle. The most common method of acquiring a ArtifactEdit instance facade is to - * use {@see #getArtifactEditForRead(WorkbenchComponent)} or - * {@see #getArtifactEditForWrite(WorkbenchComponent)}. - * </p> - * <p> - * When clients have concluded their use of the instance, <b>clients must call {@see #dispose()} - * </b>. - * </p> - * <p> - * This class is experimental until fully documented. - * </p> - * - * @see ModuleCoreNature - * @see ArtifactEditModel - * @plannedfor 1.0 - */ -public class ArtifactEdit implements IEditModelHandler, IAdaptable{ - - public static final Class ADAPTER_TYPE = ArtifactEdit.class; - private final ArtifactEditModel artifactEditModel; - private boolean isReadOnly; - private boolean isArtifactEditModelSelfManaged; - - private boolean isBinary; - private BinaryComponentHelper binaryComponentHelper; - private final IProject project; - - /** - * - */ - protected ArtifactEdit() { - super(); - artifactEditModel = null; - project = null; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will not be used for editing. Invocations of any save*() API on an instance returned from - * this method will throw exceptions. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * <p>Note: This method is for internal use only. Clients should not call this method.</p> - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may only be used to read the underlying content - * model - */ - public static ArtifactEdit getArtifactEditForRead(IVirtualComponent aModule) { - if(aModule.isBinary()){ - return new ArtifactEdit(aModule); - } - if (isValidEditableModule(aModule)) { - IProject project = aModule.getProject(); - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(project); - return new ArtifactEdit(nature, aModule, true); - } - return null; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will be used for editing. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * <p>Note: This method is for internal use only. Clients should not call this method.</p> - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may be used to modify and persist changes to the - * underlying content model - */ - public static ArtifactEdit getArtifactEditForWrite(IVirtualComponent aModule) { - if (!aModule.isBinary() && isValidEditableModule(aModule)) { - IProject project = aModule.getProject(); - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(project); - return new ArtifactEdit(nature, aModule, false); - } - return null; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will not be used for editing. Invocations of any save*() API on an instance returned from - * this method will throw exceptions. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may only be used to read the underlying content - * model - */ - public static ArtifactEdit getArtifactEditForRead(IProject aProject) { - ArtifactEdit artifactEdit = null; - try { - artifactEdit = new ArtifactEdit(aProject, true); - } catch (IllegalArgumentException iae) { - artifactEdit = null; - } - return artifactEdit; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will be used for editing. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may be used to modify and persist changes to the - * underlying content model - */ - public static ArtifactEdit getArtifactEditForWrite(IProject aProject) { - ArtifactEdit artifactEdit = null; - try { - artifactEdit = new ArtifactEdit(aProject, false); - } catch (IllegalArgumentException iae) { - artifactEdit = null; - } - return artifactEdit; - } - - /** - * <p>Note: This method is for internal use only. Clients should not call this method.</p> - * @param module - * A {@see WorkbenchComponent} - * @return True if the supplied module has a moduleTypeId which has a defined - * {@see IEditModelFactory} and is contained by an accessible project - */ - public static boolean isValidEditableModule(IVirtualComponent aModule) { - if (aModule == null) - return false; - if (ModuleURIUtil.fullyQualifyURI(aModule.getProject()) == null) - return false; - /* and the containing project must be resolveable and accessible */ - IProject project = aModule.getProject(); - if (project == null || !project.isAccessible()) - return false; - return true; - } - - - /** - * <p> - * Creates an instance facade for the given {@see ArtifactEditModel}. - * </p> - * - * @param anArtifactEditModel - */ - public ArtifactEdit(ArtifactEditModel anArtifactEditModel) { - artifactEditModel = anArtifactEditModel; - isReadOnly = artifactEditModel.isReadOnly(); - isArtifactEditModelSelfManaged = false; - - project = anArtifactEditModel.getProject(); - } - - - protected ArtifactEdit(IVirtualComponent aBinaryModule){ - if(!aBinaryModule.isBinary()){ - throw new RuntimeException("This constructor is only for binary components."); - } - binaryComponentHelper = initBinaryComponentHelper(aBinaryModule); - artifactEditModel = null; - isReadOnly = true; - isBinary = true; - isArtifactEditModelSelfManaged = true; - project = null; - - } - - protected BinaryComponentHelper initBinaryComponentHelper(IVirtualComponent binaryModule) { - return null; - } - - /** - * <p> - * Creates an instance facade for the given {@see WorkbenchComponent}. - * </p> - * <p>Note: This method is for internal use only. Clients should not call this method.</p> - * @param aNature - * A non-null {@see ModuleCoreNature} for an accessible project - * @param aModule - * A non-null {@see WorkbenchComponent} pointing to a module from the given - * {@see ModuleCoreNature} - */ - protected ArtifactEdit(ModuleCoreNature aNature, IVirtualComponent aModule, boolean toAccessAsReadOnly) { - - isReadOnly = toAccessAsReadOnly; - isArtifactEditModelSelfManaged = true; - project = aNature.getProject(); - IProject aProject = aModule.getProject(); - URI componentURI = ModuleURIUtil.fullyQualifyURI(aProject); - Map editModelParams = null; - if (getContentTypeDescriber() != null) { - editModelParams = new HashMap(); - editModelParams.put(ArtifactEditModelFactory.PARAM_ROOT_URI, getRootURI()); - editModelParams.put(ArtifactEditModelFactory.PARAM_ROOT_CONTENT_TYPE, getContentTypeDescriber()); - } - if (toAccessAsReadOnly) - artifactEditModel = aNature.getArtifactEditModelForRead(componentURI, this, null, editModelParams); - else - artifactEditModel = aNature.getArtifactEditModelForWrite(componentURI, this, null, editModelParams); - } - - /** - * <p> - * Creates an instance facade for the given {@see WorkbenchComponent}. - * </p> - * - * @param aNature - * A non-null {@see ModuleCoreNature} for an accessible project - * @param aModule - * A non-null {@see WorkbenchComponent} pointing to a module from the given - * {@see ModuleCoreNature} - */ - public ArtifactEdit(IProject aProject, boolean toAccessAsReadOnly) throws IllegalArgumentException { - this(aProject,toAccessAsReadOnly,false,null); - } - - /** - * <p> - * Creates an instance facade for the given {@see WorkbenchComponent}. - * </p> - * - * @param aProject - * @param toAccessAsReadOnly - * @param forCreate - * @param projectType - * @throws IllegalArgumentException - */ - protected ArtifactEdit(IProject aProject, boolean toAccessAsReadOnly, boolean forCreate, String projectType) throws IllegalArgumentException { - - this(aProject,toAccessAsReadOnly,forCreate,projectType,null); - } - - protected void verifyOperationSupported() { - if(!validArtifactEdit){ - throw new RuntimeException("Invalid Artifact Edit access (model version not supported)"); - } - } - - private boolean validArtifactEdit = true; - - public boolean isValid() { - return validArtifactEdit; - } - - protected void markInvalid(){ - Logger.global.log(Level.WARNING, "Invalid Artifact Edit access (model version not supported)"); - validArtifactEdit = false; - } - - - /** - * <p> - * Creates an instance facade for the given {@see WorkbenchComponent}. - * </p> - * - * @param aProject - * @param toAccessAsReadOnly - * @param forCreate - * @param projectType - Used to pass specific editModel edit (Used to lookup factory) - * @param editModelParams - Properties that can be used to create cacheKey on editModelFactory - * @throws IllegalArgumentException - */ - protected ArtifactEdit(IProject aProject, boolean toAccessAsReadOnly, boolean forCreate, String projectType, Map editModelParams) throws IllegalArgumentException { - - if (aProject == null || !aProject.isAccessible()) - throw new IllegalArgumentException("Invalid project: " + aProject); - - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(aProject); - - if (nature == null) - throw new IllegalArgumentException("Project does not have ModuleCoreNature: " + aProject); - if (!validProjectVersion(aProject)){ - markInvalid(); - } - IVirtualComponent component = ComponentCore.createComponent(aProject); - if (component == null) - throw new IllegalArgumentException("Invalid component handle: " + aProject); - if (!forCreate && !isValidEditableModule(component)) - throw new IllegalArgumentException("Invalid component handle: " + aProject); - project = aProject; - URI componentURI = ModuleURIUtil.fullyQualifyURI(aProject); - if (getContentTypeDescriber() != null) { - if (editModelParams == null) - editModelParams = new HashMap(); - editModelParams.put(ArtifactEditModelFactory.PARAM_ROOT_URI, getRootURI()); - editModelParams.put(ArtifactEditModelFactory.PARAM_ROOT_CONTENT_TYPE, getContentTypeDescriber()); - } - if (toAccessAsReadOnly) - artifactEditModel = nature.getArtifactEditModelForRead(componentURI, this, projectType, editModelParams); - else - artifactEditModel = nature.getArtifactEditModelForWrite(componentURI, this, projectType, editModelParams); - - - isReadOnly = toAccessAsReadOnly; - isArtifactEditModelSelfManaged = true; - } - - public boolean isProjectOfType(IProject project, String typeID) { - IFacetedProject facetedProject = null; - try { - facetedProject = ProjectFacetsManager.create(project); - } catch (CoreException e) { - return false; - } - if (facetedProject != null && ProjectFacetsManager.isProjectFacetDefined(typeID)) { - IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(typeID); - return projectFacet != null && facetedProject.hasProjectFacet(projectFacet); - } - return false; - } - /** - * Used to optionally define an associated content type for XML file creation - * @return - */ - protected String getContentTypeDescriber() { - - if (isProjectOfType(project, IModuleConstants.JST_EJB_MODULE)) - return "org.eclipse.jst.j2ee.ejbDD"; - if (isProjectOfType(project, IModuleConstants.JST_WEB_MODULE)) - return "org.eclipse.jst.j2ee.webDD"; - if (isProjectOfType(project, IModuleConstants.JST_EAR_MODULE)) - return "org.eclipse.jst.j2ee.earDD"; - if (isProjectOfType(project, IModuleConstants.JST_APPCLIENT_MODULE)) - return "org.eclipse.jst.j2ee.appclientDD"; - return null; - } - - /** - * Used to optionally define an root URI for the project - * @return - */ - protected URI getRootURI() { - - if (isProjectOfType(project, IModuleConstants.JST_EJB_MODULE)) - return URI.createURI("META-INF/ejb-jar.xml"); - if (isProjectOfType(project, IModuleConstants.JST_WEB_MODULE)) - return URI.createURI("WEB-INF/web.xml"); - if (isProjectOfType(project, IModuleConstants.JST_EAR_MODULE)) - return URI.createURI("META-INF/application.xml"); - if (isProjectOfType(project, IModuleConstants.JST_APPCLIENT_MODULE)) - return URI.createURI("META-INF/application-client.xml"); - return null; - } - - protected boolean validProjectVersion(IProject project2) { - return true; - } - - /** - * <p> - * Force a save of the underlying model. The following method should be used with care. Unless - * required, use {@see #saveIfNecessary(IProgressMonitor)} instead. - * </p> - * - * @see org.eclipse.wst.common.componentcore.IEditModelHandler#save() - * @throws IllegalStateException - * If the ModuleCore object was created as read-only - */ - public void save(IProgressMonitor aMonitor) { - if (isReadOnly()) - throwAttemptedReadOnlyModification(); - else if (validateEdit().isOK()) - artifactEditModel.save(aMonitor, this); - } - - /** - * <p> - * Save the underlying model only if no other clients are currently using the model. If the - * model is not shared, it will be saved. If it is shared, the save will be deferred. - * </p> - * - * @see org.eclipse.wst.common.componentcore.IEditModelHandler#saveIfNecessary() - * @throws IllegalStateException - * If the ModuleCore object was created as read-only - */ - public void saveIfNecessary(IProgressMonitor aMonitor) { - if (isReadOnly()) - throwAttemptedReadOnlyModification(); - else if (validateEdit().isOK()) - artifactEditModel.saveIfNecessary(aMonitor, this); - } - - /** - * Validate edit for resource state - */ - public IStatus validateEdit() { - IValidateEditContext validator = (IValidateEditContext) UIContextDetermination.createInstance(IValidateEditContext.CLASS_KEY); - return validator.validateState(getArtifactEditModel()); - } - - /** - * Save only if necessary. If typically a save would not occur because this edit model is - * shared, the user will be prompted using the @operationHandler. - * If the prompt returns true (the user wants to save) and the model is not shared, - * the entire edit model will be saved. You may pass in a boolean <code>wasDirty</code> to - * indicate whether this edit model was dirty prior to making any changes and - * calling this method. {@link EditModel#isDirty()} - */ - public void saveIfNecessaryWithPrompt(IProgressMonitor monitor, IOperationHandler operationHandler, boolean wasDirty) { - - if (shouldSave(operationHandler, wasDirty)) - saveIfNecessary(monitor); - else - handleSaveIfNecessaryDidNotSave(monitor); - } - - /** - * Default is to do nothing. This method is called if a saveIfNecessary or - * saveIfNecessaryWithPrompt determines not to save. This provides subclasses with an - * opportunity to do some other action. - */ - private void handleSaveIfNecessaryDidNotSave(IProgressMonitor monitor) { - // do nothing - } - - /** - * Should the resources be saved. - */ - private boolean shouldSave(IOperationHandler operationHandler, boolean wasDirty) { - return !wasDirty ? shouldSave() : shouldSave(operationHandler); - } - - /** - * Prompt for a save. - */ - private boolean promptToSave(IOperationHandler operationHandler) { - if (operationHandler == null) - return false; - return operationHandler.canContinue(EMFWorkbenchResourceHandler.getString("The_following_resources_ne_UI_"), getArtifactEditModel().getResourceURIs(true)); //$NON-NLS-1$ = "The following resources need to be saved but are currently shared, do you want to save now?" - } - - /** - * Should the resources be saved. - */ - private boolean shouldSave(IOperationHandler operationHandler) { - return shouldSave() || promptToSave(operationHandler); - } - - /** - * Should the resources be saved. - */ - private boolean shouldSave() { - return !isReadOnly() && isArtifactEditModelSelfManaged; - } - - /** - * <p> - * Clients must call the following method when they have finished using the model, even if the - * ArtifactEdit instance facade was created as read-only. - * </p> - * - * @see org.eclipse.wst.common.componentcore.IEditModelHandler#dispose() - */ - public void dispose() { - if(isBinary()){ - binaryComponentHelper.dispose(); - } else if (isArtifactEditModelSelfManaged && artifactEditModel != null) - artifactEditModel.releaseAccess(this); - } - - /** - * <p> - * Returns the root object for read or write access (depending on how the current ArtifactEdit - * was loaded). - * </p> - * - * @return The root object of the underlying model - */ - public EObject getContentModelRoot() { - if(isBinary()) - return binaryComponentHelper.getPrimaryRootObject(); - if (artifactEditModel!=null) - return artifactEditModel.getPrimaryRootObject(); - return null; - } - - /** - * <p> - * Add a listener to track lifecylce events from the underlying EditModel. - * </p> - * - * @param listener - * A non-null EditModelListener - */ - public void addListener(EditModelListener listener) { - if(isBinary()){ - - } else { - if (artifactEditModel!=null && listener!=null) - artifactEditModel.addListener(listener); - } - } - - /** - * <p> - * Remove the supplied listener - * </p> - * - * @param listener - * A non-null EditModelListener - * - */ - public void removeListener(EditModelListener listener) { - if(isBinary()){ - } else if (artifactEditModel!=null && !artifactEditModel.isDisposed()) { - artifactEditModel.removeListener(listener); - } - } - - /** - * <p> - * This method may be removed soon. Avoid adding dependencies to it. - * </p> - * <p> - * This method is considered internal and not published as API. - * </p> - * @param editModel - * @return - */ - public boolean hasEditModel(EditModel editModel) { - if(isBinary()){ - return false; - } - return artifactEditModel == editModel; - } - /** - * - * @return IProject - returns the project of the underlying workbench component. - */ - public IProject getProject() { - if(isBinary()){ - return null; - } - return project; - } - /** - * - * @return IVirtualComponent - returns the underlying workbench component. - */ - public IVirtualComponent getComponent() { - if(isBinary()){ - return binaryComponentHelper.getComponent(); - } - return getArtifactEditModel().getVirtualComponent(); - } - - /** - * @return The underlying managed edit model - */ - protected ArtifactEditModel getArtifactEditModel() { - if(isBinary()){ - throwAttemptedBinaryEditModelAccess(); - } - return artifactEditModel; - } - - protected BinaryComponentHelper getBinaryComponentHelper() { - return binaryComponentHelper; - } - - /** - * @return The EMF command stack managed by the underlying editmodel - */ - public CommandStack getCommandStack() { - if(isBinary()){ - return new BasicCommandStack(); - } - return artifactEditModel.getCommandStack(); - } - /** - * - * @deprecated Use ((ArtifactEditModel)getAdapter(ArtifactEditModel.ADAPTER_TYPE)).deleteResource(aResource); - */ - public void deleteResource(Resource aResource) { - if(isBinary()){ - throwAttemptedBinaryEditModelAccess(); - } - artifactEditModel.deleteResource(aResource); - } - /** - * @return The isDirty flag based the underlying editmodel's list of resources. - */ - public boolean isDirty() { - if(isBinary()){ - return false; - } - return artifactEditModel.isDirty(); - } - - private void throwAttemptedReadOnlyModification() { - throw new IllegalStateException("Attempt to modify an ArtifactEdit instance facade that was loaded as read-only."); - } - - protected void throwAttemptedBinaryEditModelAccess() { - throw new IllegalStateException("Attempt to modify an ArtifactEdit instance facade that was loaded as binary."); - } - - public boolean isReadOnly() { - return isReadOnly; - } - - public boolean isBinary() { - return isBinary; - } - - /** - * Force all of the known resource URIs to be loaded - * if they are not already. - */ - public void forceLoadKnownResources() { - if(isBinary()){ - - } else { - List uris = getArtifactEditModel().getKnownResourceUris(); - URI uri = null; - for (int i = 0; i < uris.size(); i++) { - uri = (URI) uris.get(i); - getArtifactEditModel().getResource(uri); - } - } - } - - /** - * Return a Resource for @aUri. - * @deprecated Use ((ArtifactEditModel)getAdapter(ArtifactEditModel.ADAPTER_TYPE)).getResource(aResource); - */ - public Resource getResource(URI aUri) { - if(isBinary()){ - return binaryComponentHelper.getResource(aUri); - } - return getArtifactEditModel().getResource(aUri); - } - - public Object getAdapter(Class adapterType) { - if (adapterType == ArtifactEditModel.class) - return getArtifactEditModel(); - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - - public void commandStackChanged(EventObject event) { - getArtifactEditModel().commandStackChanged(event); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ComponentCore.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ComponentCore.java deleted file mode 100644 index 062a5e577..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ComponentCore.java +++ /dev/null @@ -1,214 +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.wst.common.componentcore; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeNode; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualFile; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualReference; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualResource; -import org.eclipse.wst.common.componentcore.internal.util.ComponentImplManager; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -/** - * Provides a handle creation factory for the Virtual Path API. Clients may use - * this class to convert Platform IResource model elements to IVirtualResource - * model elements. - * <p> - * ComponentCore provides a consistent entry point to the IVirtual Path model - * that allows clients to group resources together in logical collections with a - * path structure that varies from their actual source location structures. - * </p> - * - * @plannedfor 1.0 - */ -public class ComponentCore { - - private static final IVirtualResource[] NO_RESOURCES = new VirtualResource[0]; - - /** - * Return an IVirtualComponent with the given name (aComponentName) - * contained by the given project (aProject). Component names should be - * unique across a project. - * - * @param aProject - * A valid, accessible project to contain the component - * @return A handle to an IVirtualComponent that may or may not exist or - * null if passed project does not contain ModuleCoreNature. - * @see org.eclipse.core.runtime.IProgressMonitor#create(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public static IVirtualComponent createComponent(IProject aProject) { - if (aProject == null || !aProject.isAccessible()){ - return null; - } - return ComponentImplManager.instance().createComponent(aProject); - } - - /** - * Return an IVirtualComponent with the given name (aComponentName) - * contained by the given project (aProject). Component names should be - * unique across a project. - * - * @param aProject - * A valid, accessible project to contain the component - * @param checkForComponentFile - * A flag to indicate if the presence of the component file should be checked - * @return A handle to an IVirtualComponent that may or may not exist or - * null if passed project does not contain ModuleCoreNature. - * @see org.eclipse.core.runtime.IProgressMonitor#create(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public static IVirtualComponent createComponent(IProject aProject, boolean checkForComponentFile) { - if (aProject == null || !aProject.isAccessible()){ - return null; - } - return ComponentImplManager.instance().createComponent(aProject, checkForComponentFile); - } - - /** - * Return an IVirtualComponent with the given name (aComponentName) - * contained by the given project (aProject). Component names should be - * unique across a project. - * - * @param aProject - * A valid, accessible project to contain the component - * @return A handle to an IVirtualComponent that may or may not exist or - * null if passed project does not contain ModuleCoreNature. - * @deprecated - * @see org.eclipse.core.runtime.IProgressMonitor#create(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public static IVirtualComponent createComponent(IProject aProject, String aName) { - return createComponent(aProject); - } - - /** - * Return an IVirtualComponent with the given name (aComponentName) - * - * @param aComponentName - * A name to identify the component, the name can be - * lib/<Absolute path of a jar> or - * var/<CLASSPATH_VARIABLE/library namer> - * @return A handle to an IVirtualComponent that may or may not exist. - * @see org.eclipse.core.runtime.IProgressMonitor#create(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public static IVirtualComponent createArchiveComponent(IProject aProject, String aComponentName) { - return ComponentImplManager.instance().createArchiveComponent(aProject, aComponentName); - } - - /** - * Return an IVirtualFolder with a runtime path specified by aRuntimePath - * contained by aProject, in a component named aComponentName. The resultant - * IVirtualFolder may or may not exist. - * - * @param aProject - * A valid, accessible project to contain the component - * @param aRuntimePath - * The runtime path of the IVirtualFolder to return. - * @return An IVirtualFolder contained by the specified component with the - * given runtime path - * @see org.eclipse.core.runtime.IProgressMonitor#create(int, org.eclipse.core.runtime.IProgressMonitor) - * @see IVirtualResource#createLink(IPath, int, org.eclipse.core.runtime.IProgressMonitor) - */ - public static IVirtualFolder createFolder(IProject aProject, IPath aRuntimePath) { - return ComponentImplManager.instance().createFolder(aProject, aRuntimePath); - } - - /** - * Return an IVirtualFile with a runtime path specified by aRuntimePath - * contained by aProject, in a component named aComponentName. IVirtualFiles - * can only be created as links. Use - * {@link IVirtualResource#getUnderlyingResource()} or - * {@link IVirtualFile#getUnderlyingFile()} to create a resource with real - * contents. - * - * @param aProject - * A valid, accessible project to contain the component - * @param aRuntimePath - * The runtime path of the IVirtualFolder to return. - * @return An IVirtualFile contained by the specified component with the - * given runtime path - * @see IVirtualResource#createLink(IPath, int, org.eclipse.core.runtime.IProgressMonitor) - */ - public static IVirtualFile createFile(IProject aProject, IPath aRuntimePath) { - return new VirtualFile(aProject, aRuntimePath); - } - - /** - * Return an IVirtualReference that captures a relationship between - * aComponent and aReferencedComponent. The IVirtualReference will be stored - * with aComponent and target aReferencedComponent. IVirtualReferences may - * span projects. - * - * @param aComponent - * A valid, existing IVirtualComponent - * @param aReferencedComponent - * A valid, existing IVirtualComponent - * @return An IVirtualReference that captures the relationship between - * aComponent and aReferencedComponent. - * @see IVirtualReference#create(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public static IVirtualReference createReference(IVirtualComponent aComponent, IVirtualComponent aReferencedComponent) { - return new VirtualReference(aComponent, aReferencedComponent); - } - - public static IVirtualReference createReference(IVirtualComponent aComponent, IVirtualComponent aReferencedComponent, IPath runtimePath) { - return new VirtualReference(aComponent, aReferencedComponent, runtimePath); - } - - /** - * Return an array of IVirtualResources that represent the given IResource. - * Each IResource could be mapped to multiple components, and thus an array - * of each IVirtualResource that represents the IResource will be returned. - * Each IVirtualResource may also map to other existing IResources, so the - * mapping is not 1:1. - * - * @param aResource - * An accessible IResource - * @return An array of IVirtualResources from the model that represent the - * IResource. - */ - public static IVirtualResource[] createResources(IResource aResource) { - IProject proj = aResource.getProject(); - StructureEdit se = null; - List foundResources = new ArrayList(); - try { - se = StructureEdit.getStructureEditForRead(proj); - if (se != null) { - ComponentResource[] resources = se.findResourcesBySourcePath(aResource.getProjectRelativePath(), aResource.exists() ? ResourceTreeNode.CREATE_NONE : ResourceTreeNode.CREATE_RESOURCE_ALWAYS); - for (int i = 0; i < resources.length; i++) { - if (aResource.getType() == IResource.FILE) - foundResources.add(new VirtualFile(proj, resources[i].getRuntimePath())); - else - foundResources.add(ComponentCore.createFolder(proj, resources[i].getRuntimePath())); - } - } - } catch (UnresolveableURIException e) { - e.printStackTrace(); - } finally { - if (se != null) { - se.dispose(); - } - } - if (foundResources.size() > 0) - return (IVirtualResource[]) foundResources.toArray(new VirtualResource[foundResources.size()]); - return NO_RESOURCES; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/IEditModelHandler.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/IEditModelHandler.java deleted file mode 100644 index 7d89b16ee..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/IEditModelHandler.java +++ /dev/null @@ -1,60 +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.wst.common.componentcore; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * <p> - * Provides a standard interface for managing the lifecycle of an Edit Model. Clients which use - * instances of this interface are <b>required to invoke {@see #dispose()}</b> when they have - * completed their usage. Once clients have disposed that instance, they will not be able to invoke - * {@see #save(IProgressMonitor)}or {@see #saveIfNecessary(IProgressMonitor)} and should be wary of - * using any model objects acquired from the handler, as they may be or become stale. - * </p> - * @see org.eclipse.wst.common.componentcore.internal.StructureEdit - * @see org.eclipse.wst.common.componentcore.ArtifactEdit - * @plannedfor 1.0 - */ -public interface IEditModelHandler { - - /** - * <p> - * Force a save of the underlying edit model and keep track of progress using the supplied - * progress monitor. Clients should avoid calling this version of save unless they are certain - * they require the model to be saved. Clients are encouraged to use - * {@see #saveIfNecessary(IProgressMonitor)} instead. - * </p> - * - * @param aMonitor - * A valid progress monitor or null - */ - void save(IProgressMonitor aMonitor); - - /** - * <p> - * Save the underlying edit model, if no other consumers are using the edit model, and keep - * track of progress using the supplied progress monitor. This version of save will only save if - * the underlying edit model is not shared with other consumers. - * </p> - * - * @param aMonitor - * A valid progress monitor or null - */ - void saveIfNecessary(IProgressMonitor aMonitor); - - /** - * <p> - * Clients must invoke this method when they have finished using the handler. - * </p> - */ - void dispose(); -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java deleted file mode 100644 index a3704cfa7..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java +++ /dev/null @@ -1,678 +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.wst.common.componentcore; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.IJobManager; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.URIConverter; -import org.eclipse.jem.util.emf.workbench.EMFWorkbenchContextBase; -import org.eclipse.jem.util.emf.workbench.ISynchronizerExtender; -import org.eclipse.jem.util.emf.workbench.ProjectResourceSet; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel; -import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.impl.ArtifactEditModelFactory; -import org.eclipse.wst.common.componentcore.internal.impl.ComponentCoreURIConverter; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleStructuralModelFactory; -import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesResourceFactory; -import org.eclipse.wst.common.componentcore.internal.impl.WTPResourceFactoryRegistry; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.internal.util.ModuleCoreMessages; -import org.eclipse.wst.common.internal.emfworkbench.edit.EditModelRegistry; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelNature; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; - -/** - * <p> - * Allows projects to support flexible project structures. The ModuleCoreNature manages the - * configuration of a module structural builder that prepares WorkbenchModules for deployment. - * </p> - * <p> - * To determine if a project supports flexible project structures, check for the existence of the - * ModuleCoreNature: - * <p> - * <code>(ModuleCoreNature.getModuleCoreNature(project) != null)</code> - * </p> - * <p> - * If the project has a ModuleCoreNature, then the project supports flexible module structures. - * </p> - * <p> - * In general, clients are expected to use the utility methods available on this class to acquire - * the ModuleCoreNature instance from a given project ({@see #getModuleCoreNature(IProject)} - * or to make a flexible project flexible by adding a ModuleCoreNature ( - * {@see #addModuleCoreNatureIfNecessary(IProject, IProgressMonitor)}). - * </p> - * <a name="model-discussion"/> -* <a name="module-structural-model"/> -* <p> -* Each ModuleCoreNature from a given project can provide access to the -* {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel} of the project. -* {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel} is a subclass of -* {@see org.eclipse.wst.common.internal.emfworkbench.integration.EditModel} that manages -* resources associated with the Module Structural Metamodel. As an EditModel, the -* {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel} references EMF resources, -* that contain EMF models -- in this case, the EMF model of <i>.component </i> file. -* </p> -* <p> -* Clients are encouraged to use the Edit Facade pattern (via -* {@see org.eclipse.wst.common.modulecore.ArtifactEdit} or one if its relevant subclasses) -* to work directly with the Module Structural Metamodel. -* </p> -* <a name="artifact-editmodel"/> -* <p> -* Each ModuleCoreNature from a given project can also provide access to the -* {@see org.eclipse.wst.common.modulecore.ArtifactEditModel} for each -* {@see org.eclipse.wst.common.modulecore.WorkbenchComponent} contained by the project. Like -* {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel}, -* {@see org.eclipse.wst.common.modulecore.ArtifactEditModel} is a subclass of -* {@see org.eclipse.wst.common.internal.emfworkbench.integration.EditModel} that contains -* EMF resources, which in turn contain the EMF models of module metadata files (such as J2EE -* deployment descriptors). -* </p> -* <p> -* The following diagram highlights the relationships of these subclasses of EditModel, and the -* relationship of the EditModel to the EMF resources. In the diagram, "MetamodelResource" and -* "MetamodelObject" are used as placeholders for the specific subclasses of -* {@see org.eclipse.emf.ecore.resource.Resource} and {@see org.eclipse.emf.ecore.EObject} -* respectively. -* </p> -* <table cellspacing="10" cellpadding="10"> -* <tr> -* <td> -* <p> -* <img src="../../../../../overview/metamodel_components.jpg" /> -* </p> -* </td> -* </tr> -* <tr> -* <td> -* <p> -* <i>Figure 1: A component diagram of the Module Edit Models. </i> -* </p> -* </td> -* </tr> -* </table> -* <p> -* Clients are encouraged to use the Edit Facade pattern (via -* {@see org.eclipse.wst.common.modulecore.ArtifactEdit} or what if its relevant subclasses) -* to work directly with the Module Structural Metamodel. -* </p> -* <a name="accessor-key"/> -* <p> -* All EditModels have a lifecycle that must be enforced to keep the resources loaded that are in -* use, and to unload resources that are not in use. To access an EditModel, clients are required to -* supply an object token referred to as an accessor key. The accessor key allows the framework to -* better track which clients are using the EditModel, and to ensure that only a client which has -* accessed the EditModel with an accessor key may invoke save*()s on that EditModel. -* </p> - * @see org.eclipse.wst.common.componentcore.internal.StructureEdit - * @see org.eclipse.wst.common.componentcore.internal.StructureEdit#getStructureEditForRead(IProject) - * @see org.eclipse.wst.common.componentcore.internal.StructureEdit#getStructureEditForWrite(IProject) - * @see org.eclipse.wst.common.componentcore.ArtifactEdit - * @see org.eclipse.wst.common.componentcore.ArtifactEdit#getArtifactEditForRead(org.eclipse.wst.common.componentcore.internal.WorkbenchComponent) - * @see org.eclipse.wst.common.componentcore.ArtifactEdit#getArtifactEditForWrite(org.eclipse.wst.common.componentcore.internal.WorkbenchComponent) - * @plannedfor 1.0 - */ -public class ModuleCoreNature extends EditModelNature implements IProjectNature, IModuleConstants, ISynchronizerExtender { - - public static final String VALIDATION_BUILDER_ID = ValidationPlugin.VALIDATION_BUILDER_ID; - private ModuleStructuralModel cachedWriteHandle; - private ModuleStructuralModel cachedReadHandle; - /** - * <p> - * Find and return the ModuleCoreNature of aProject, if available. - * <p> - * <b>This method may return null. </b> - * </p> - * - * @param aProject - * An accessible project - * @return The ModuleCoreNature of aProject, if it exists - */ - public static ModuleCoreNature getModuleCoreNature(IProject aProject) { - try { - if (aProject != null && aProject.isAccessible()) - return (ModuleCoreNature) aProject.getNature(IModuleConstants.MODULE_NATURE_ID); - } catch (CoreException e) { - //Ignore - } - return null; - } - // The existence of this Nature plus the component file on disk makes a flexible project - public static boolean isFlexibleProject(IProject project) { - boolean foundNature = ModuleCoreNature.getModuleCoreNature(project) != null; - if (foundNature) { - return componentResourceExists(project); - } - return false; - } - public static boolean componentResourceExists(IProject project) { - - IFile compFile = project.getFile(StructureEdit.MODULE_META_FILE_NAME); - if (compFile.isAccessible()) - return true; - else { //Need to check for legacy file locations also.... - compFile = project.getFile(ModuleStructuralModel.R1_MODULE_META_FILE_NAME); - if (compFile.isAccessible()) - return true; - else { - compFile = project.getFile(ModuleStructuralModel.R0_7_MODULE_META_FILE_NAME); - if (compFile.isAccessible()) - return true; - else { - compFile = project.getFile(WTPModulesResourceFactory.FIRST_WTP_MODULES_SHORT_NAME); - return compFile.isAccessible(); - } - } - } - } - - /** - * <p> - * Adds a ModuleCoreNature to the project. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * @param aProject - * A accessible project. - * @param aMonitor - * A progress monitor to track the time to completion - * @return The ModuleCoreNature of aProject, if it exists - */ - public static ModuleCoreNature addModuleCoreNatureIfNecessary(final IProject aProject, IProgressMonitor aMonitor) { - try { - if (aProject.hasNature(IModuleConstants.MODULE_NATURE_ID)) - return getModuleCoreNature(aProject); - - IJobManager manager = Platform.getJobManager(); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - if (aMonitor != null) - aMonitor.beginTask("Add ModuleCore Nature", 5); //$NON-NLS-1$ - manager.beginRule(root, aMonitor); - try { - IProjectDescription description = aProject.getDescription(); - String[] currentNatureIds = description.getNatureIds(); - String[] newNatureIds = new String[currentNatureIds.length + 1]; - System.arraycopy(currentNatureIds, 0, newNatureIds, 0, currentNatureIds.length); - newNatureIds[currentNatureIds.length] = IModuleConstants.MODULE_NATURE_ID; - description.setNatureIds(newNatureIds); - aProject.setDescription(description, aMonitor); - } catch (CoreException e) { - e.printStackTrace(); - } finally { - manager.endRule(root); - } - if (aMonitor != null) - aMonitor.done(); - } catch (CoreException e) { - e.printStackTrace(); - } - /* Return the new nature */ - return getModuleCoreNature(aProject); - } - - /** - * <p> - * Return a {@see ModuleStructuralModel} for read-only access. - * </p> - * <p> - * Clients are encouraged to use {@see ModuleCore#getModuleCoreForRead(IProject)} to work - * with the Module Structural Metamodels of flexible projects. - * </p> - * <p> - * See the discussion what a {@see ModuleStructuralModel} is and <a - * href="#module-structural-model">how it relates to the Module Structural Metamodel </a>. - * </p> - * <p> - * Also see the discussion of <a href="#accessor-key">the purpose of an accessor key </a>. - * </p> - * - * @param anAccessorKey - * Typically client supplies the object that invoked this method, or a proxy ( - * <code>new Object()</code>) in the case of other static methods requesting a - * {@see ModuleStructuralModel}. - * @return A {@see ModuleStructuralModel}for the project of the current nature. - */ - public ModuleStructuralModel getModuleStructuralModelForRead(Object anAccessorKey) { - // Return self managed edit model - will always cache locally - ModuleStructuralModel editModel = (ModuleStructuralModel)getEmfContext().getExistingEditModel(ModuleStructuralModelFactory.MODULE_STRUCTURAL_MODEL_ID, null,true); - if (editModel == null) { - editModel = (ModuleStructuralModel)EditModelRegistry.getInstance().createEditModelForRead(ModuleStructuralModelFactory.MODULE_STRUCTURAL_MODEL_ID, getEmfContext(), null); - synchronized (editModel) { - getEmfContext().cacheEditModel(editModel, null); - editModel.access(anAccessorKey); - } - } else { - synchronized (editModel) { - editModel.access(anAccessorKey); - } - } - return editModel; - } - - /** - * <p> - * Return a {@see ModuleStructuralModel} for write access. - * </p> - * <p> - * Clients are encouraged to use {@see ModuleCore#getModuleCoreForWrite(IProject)} to work - * with the Module Structural Metamodels of flexible projects. - * </p> - * <p> - * See the discussion what a {@see ModuleStructuralModel} is and <a - * href="#module-structural-model">how it relates to the Module Structural Metamodel </a>. - * </p> - * <p> - * Also see the discussion of <a href="#accessor-key">the purpose of an accessor key </a>. - * </p> - * - * @param anAccessorKey - * Typically client supplies the object that invoked this method, or a proxy ( - * <code>new Object()</code>) in the case of other static methods requesting a - * {@see ModuleStructuralModel}. - * @return A {@see ModuleStructuralModel}for the project of the current nature. - */ - public ModuleStructuralModel getModuleStructuralModelForWrite(Object anAccessorKey) { - // Return self managed edit model - will always cache locally - ModuleStructuralModel editModel = (ModuleStructuralModel)getEmfContext().getExistingEditModel(ModuleStructuralModelFactory.MODULE_STRUCTURAL_MODEL_ID, null,false); - if (editModel == null) { - editModel = (ModuleStructuralModel)EditModelRegistry.getInstance().createEditModelForWrite(ModuleStructuralModelFactory.MODULE_STRUCTURAL_MODEL_ID, getEmfContext(), null); - synchronized (editModel) { - getEmfContext().cacheEditModel(editModel, null); - editModel.access(anAccessorKey); - } - } else { - synchronized (editModel) { - editModel.access(anAccessorKey); - } - } - return editModel; - } - - /** - * <p> - * Returns an {@see ArtifactEditModel} to work with the underlying content of an - * individual {@see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent} contained in the project. {@see ArtifactEditModel}s - * are used to manipulate the content models for individual {@see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent}s. In - * general, a content model will contain an EMF representation of the module's relevant - * deployment descriptor, and possibly other EMF resources as well. - * </p> - * <p> - * {@see ArtifactEditModel}s that are returned from this method may not be used to modify and - * persist changes to the underlying Module Content Metamodel. Clients that need to make changes - * to the underlying Module Content Module, and that choose to work directly with the - * {@see ArtifactEditModel} should use {@see #getArtifactEditModelForWrite(URI, Object)}. - * </p> - * <p> - * Clients are encouraged to use {@see ArtifactEdit} or one of its relevant subclasses to - * work with the module content model, instead of working with directly with the EditModel: - * </p> - * <p> - * <code>ArtifactEdit editFacade = ArtifactEdit.getArtifactEditForRead(aWorkbenchModule);</code> - * </p> - * <p> - * When a client is aware of the underlying type of module, more specific Edit Facades may be - * acquired: - * </p> - * <p> - * <code>WebEdit editFacade = WebEdit.getWebEditForRead(aWorkbenchModule);</code> - * </p> - * <p> - * If a particular Edit Facade is not applicable to the supplied {@see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent}, then - * <b>null </b> will be returned. - * </p> - * - * <p> - * See the discussion what a {@see ArtifactEditModel} is and <a - * href="#artifact-editmodel">how it relates to the Module Content Metamodel </a>. - * </p> - * <p> - * Also see the discussion of <a href="#accessor-key">the purpose of an accessor key </a>. - * </p> - * - * @param aModuleURI - * A fully qualified URI of the form "module:/resource/ <project-name>/ - * <module-deployed-name>" - * @param anAccessorKey - * Typically client supplies the object that invoked this method, or a proxy ( - * <code>new Object()</code>) in the case of other static methods requesting a - * {@see ModuleStructuralModel}. - * @return - * @see ArtifactEdit - * @see ArtifactEdit#getArtifactEditForRead(org.eclipse.wst.common.componentcore.internal.WorkbenchComponent) - */ - public ArtifactEditModel getArtifactEditModelForRead(URI aModuleURI, Object anAccessorKey) { - return getArtifactEditModelForRead(aModuleURI, anAccessorKey, null); - } - - /** - * @param aModuleURI - used to lookup project - * @param anAccessorKey - used to set client accessor - * @param projectType - used to determine editmodel factory - * @param params - passed for specialized processing in factory - * @return ArtifactEditModel instance - */ - public ArtifactEditModel getArtifactEditModelForRead(URI aModuleURI, Object anAccessorKey, String projectType, Map params) { - - if (params == null) - params = new HashMap(); - params.put(ArtifactEditModelFactory.PARAM_MODULE_URI, aModuleURI); - if (projectType !=null) - return (ArtifactEditModel) getEditModelForRead(projectType, anAccessorKey, params); - try { - IProject aProject = StructureEdit.getContainingProject(aModuleURI); - IFacetedProject facetedProject = ProjectFacetsManager.create(aProject); - if (facetedProject != null) { - String[] editModelIDs = EditModelRegistry.getInstance().getRegisteredEditModelIDs(); - for (int i=0; i<editModelIDs.length; i++) { - try { - IProjectFacet facet = ProjectFacetsManager.getProjectFacet(editModelIDs[i]); - if (facet != null && facetedProject.hasProjectFacet(facet)) { - ArtifactEditModel editModel = (ArtifactEditModel) getEditModelForRead(editModelIDs[i], anAccessorKey, params); - if (editModel !=null) - return editModel; - } - } catch (IllegalArgumentException e) { - // Ignore exceptions that come from ProjectFacetsManager - continue; - } catch (Exception e) { - ModulecorePlugin.logError(Status.ERROR, ModuleCoreMessages.Acquiring_ArtifactEdit_For_Read_Exception, e); - } - } - } - } catch (Exception e){ - ModulecorePlugin.logError(Status.ERROR, ModuleCoreMessages.Acquiring_ArtifactEdit_For_Read_Exception, e); - } - return null; - } - - public ArtifactEditModel getArtifactEditModelForRead(URI aModuleURI, Object anAccessorKey, String projectType) { - Map params = new HashMap(); - return getArtifactEditModelForRead(aModuleURI, anAccessorKey, projectType, params); - } - - /** - * <p> - * Returns an {@see ArtifactEditModel} to work with the underlying content of an - * individual {@see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent} contained in the project. {@see ArtifactEditModel}s - * are used to manipulate the content models for individual {@see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent}s. In - * general, a content model will contain an EMF representation of the module's relevant - * deployment descriptor, and possibly other EMF resources as well. - * </p> - * - * <p> - * {@see ArtifactEditModel}s that are returned from this method may be used to modify and - * persist changes to the underlying Module Content Metamodel. For clients that do not expect to - * make modifications are encouraged to use {@see #getArtifactEditModelForRead(URI, Object)} - * instead. - * </p> - * <p> - * Clients are encouraged to use {@see ArtifactEdit} or one of its relevant subclasses to - * work with the module content model, instead of working with directly with the EditModel: - * </p> - * <p> - * <code>ArtifactEdit editFacade = ArtifactEdit.getArtifactEditForWrite(aWorkbenchModule);</code> - * </p> - * <p> - * When a client is aware of the underlying type of module, more specific Edit Facades may be - * acquired: - * </p> - * <p> - * <code>WebEdit editFacade = WebEdit.getWebEditForWrite(aWorkbenchModule);</code> - * </p> - * <p> - * If a particular Edit Facade is not applicable to the supplied {@see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent}, then - * <b>null </b> will be returned. - * </p> - * - * <p> - * See the discussion what a {@see ArtifactEditModel} is and <a - * href="#artifact-editmodel">how it relates to the Module Content Metamodel </a>. - * </p> - * <p> - * Also see the discussion of <a href="#accessor-key">the purpose of an accessor key </a>. - * </p> - * - * @param aModuleURI - * A fully qualified URI of the form "module:/resource/ <project-name>/ - * <module-deployed-name>" - * @param anAccessorKey - * Typically client supplies the object that invoked this method, or a proxy ( - * <code>new Object()</code>) in the case of other static methods requesting a - * {@see ModuleStructuralModel}. - * @return - * @see ArtifactEdit - * @see ArtifactEdit#getArtifactEditForRead(org.eclipse.wst.common.componentcore.internal.WorkbenchComponent) - */ - public ArtifactEditModel getArtifactEditModelForWrite(URI aModuleURI, Object anAccessorKey) { - return getArtifactEditModelForWrite(aModuleURI, anAccessorKey, null); - } - /** - * @param aModuleURI - used to lookup project - * @param anAccessorKey - used to set client accessor - * @param projectType - used to determine editmodel factory - * @param params - passed for specialized processing in factory - * @return ArtifactEditModel instance - */ - public ArtifactEditModel getArtifactEditModelForWrite(URI aModuleURI, Object anAccessorKey, String projectType, Map params) { - - if (params == null) - params = new HashMap(); - params.put(ArtifactEditModelFactory.PARAM_MODULE_URI, aModuleURI); - if (projectType != null) - return (ArtifactEditModel) getEditModelForWrite(projectType, anAccessorKey, params); - try { - IProject aProject = StructureEdit.getContainingProject(aModuleURI); - IFacetedProject facetedProject = ProjectFacetsManager.create(aProject); - if (facetedProject != null) { - String[] editModelIDs = EditModelRegistry.getInstance().getRegisteredEditModelIDs(); - for (int i=0; i<editModelIDs.length; i++) { - try { - IProjectFacet facet = ProjectFacetsManager.getProjectFacet(editModelIDs[i]); - if (facet != null && facetedProject.hasProjectFacet(facet)) { - ArtifactEditModel editModel = (ArtifactEditModel) getEditModelForWrite(editModelIDs[i], anAccessorKey, params); - if (editModel !=null) - return editModel; - } - } catch (IllegalArgumentException e) { - // Ignore exceptions that come from ProjectFacetsManager - continue; - } catch (Exception e) { - ModulecorePlugin.logError(Status.ERROR, ModuleCoreMessages.Acquiring_ArtifactEdit_For_Write_Exception, e); - } - } - } - } catch (Exception e){ - ModulecorePlugin.logError(Status.ERROR, ModuleCoreMessages.Acquiring_ArtifactEdit_For_Write_Exception, e); - } - return null; - } - public ArtifactEditModel getArtifactEditModelForWrite(URI aModuleURI, Object anAccessorKey, String projectType) { - Map params = new HashMap(); - return getArtifactEditModelForWrite(aModuleURI, anAccessorKey, projectType, params); - } - - public String getNatureID() { - return MODULE_NATURE_ID; - } - - - /** - * <p> - * This method should not be invoked by clients. - * </p> - * - * @see org.eclipse.jem.util.emf.workbench.IEMFContextContributor#primaryContributeToContext(org.eclipse.jem.util.emf.workbench.EMFWorkbenchContextBase) - */ - public void primaryContributeToContext(EMFWorkbenchContextBase aNature) { - if (emfContext == aNature) - return; - emfContext = aNature; - getEmfContext().setDefaultToMOF5Compatibility(true); - // Overriding superclass to use our own URI converter, which knows about binary projects - ProjectResourceSet projectResourceSet = aNature.getResourceSet(); - projectResourceSet.setResourceFactoryRegistry(WTPResourceFactoryRegistry.INSTANCE); - projectResourceSet.setURIConverter(createURIConverter(getProject(), projectResourceSet)); - - // initializeCacheEditModel(); - // addAdapterFactories(set); - // set.getSynchronizer().addExtender(this); // added so we can be informed of closes to the - // new J2EEResourceDependencyRegister(set); // This must be done after the URIConverter is - projectResourceSet.getSynchronizer().addExtender(this); // added so we can be informed of closes - cacheModuleStructuralModels(); - } - - /** - * @see org.eclipse.jem.util.emf.workbench.nature.EMFNature.primConfigure - */ - protected void primConfigure() throws CoreException { - super.primConfigure(); - // add Validation Builder to all flex Project's builder list - ProjectUtilities.addToBuildSpec(VALIDATION_BUILDER_ID,project); - - } - - /** - * @param project - * @return - */ - private URIConverter createURIConverter(IProject aProject, ProjectResourceSet aResourceSet ) { - ComponentCoreURIConverter uriConverter = new ComponentCoreURIConverter(aProject, aResourceSet.getSynchronizer()); - uriConverter.addInputContainer(getProject()); - return uriConverter; - } - - - /** - * <p> - * This method should not be invoked by clients. - * </p> - */ - public ResourceSet getResourceSet() { - return getEmfContextBase().getResourceSet(); - } - - /** - * <p> - * This method should not be invoked by clients. - * </p> - * - * @see org.eclipse.jem.util.emf.workbench.IEMFContextContributor#secondaryContributeToContext(org.eclipse.jem.util.emf.workbench.EMFWorkbenchContextBase) - */ - public void secondaryContributeToContext(EMFWorkbenchContextBase aNature) { - //Default - } - - /** - * <p> - * This method should not be invoked by clients. - * </p> - * - * @see org.eclipse.jem.util.emf.workbench.nature.EMFNature#configure() - */ - public void configure() throws CoreException { - super.configure(); - - } - - private void cacheModuleStructuralModels() { - if (cachedWriteHandle == null) - cachedWriteHandle = getModuleStructuralModelForWrite(this); - if (cachedReadHandle == null) - cachedReadHandle = getModuleStructuralModelForRead(this); - } - - protected String getPluginID() { - return MODULE_PLUG_IN_ID; - } - - public EditModel getExistingEditModel(String artifactEditModelId,Map params, boolean isReadOnly) { - return getEmfContext().getExistingEditModel(artifactEditModelId,params,isReadOnly); - } - - public void shutdown() { - super.shutdown(); - if (cachedWriteHandle != null) { - if (cachedWriteHandle.isDirty()) - cachedWriteHandle.saveIfNecessary(this); - cachedWriteHandle.dispose(); - cachedWriteHandle = null; - } - if (cachedReadHandle != null) { - if (cachedReadHandle.isDirty()) - cachedReadHandle.saveIfNecessary(this); - cachedReadHandle.dispose(); - cachedReadHandle = null; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emfworkbench.ISynchronizerExtender#projectChanged(org.eclipse.core.resources.IResourceDelta) - */ - public void projectChanged(IResourceDelta delta) { - if (delta.getKind() == IResourceDelta.OPEN) { - if (cachedWriteHandle == null) - cachedWriteHandle = getModuleStructuralModelForWrite(this); - if (cachedReadHandle == null) - cachedReadHandle = getModuleStructuralModelForRead(this); - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emfworkbench.ISynchronizerExtender#projectClosed() - */ - public void projectClosed() { -// StringBuffer buffer = new StringBuffer("Disposing Module models for project: "); -// buffer.append(this.getProject()); -// System.out.println(buffer.toString()); - this.emfContext = null; - if (cachedWriteHandle != null) { - if (cachedWriteHandle.isDirty()) - cachedWriteHandle.saveIfNecessary(this); - cachedWriteHandle.dispose(); - cachedWriteHandle = null; - } - if (cachedReadHandle != null) { - cachedReadHandle.dispose(); - cachedReadHandle = null; - } - } - - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/UnresolveableURIException.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/UnresolveableURIException.java deleted file mode 100644 index 3957c0045..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/UnresolveableURIException.java +++ /dev/null @@ -1,32 +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.wst.common.componentcore; - -import org.eclipse.emf.common.util.URI; - -/** - * <p> - * Thrown whenever a URI cannot be appropriately resolved. - * </p> - * - * @plannedfor 1.0 - */ -public class UnresolveableURIException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public UnresolveableURIException(URI anUnresolveableURI) { - super("Could not resolve: " + anUnresolveableURI); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetDataModelConfigAdapter.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetDataModelConfigAdapter.java deleted file mode 100644 index 431c7ee7c..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetDataModelConfigAdapter.java +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.wst.common.componentcore.datamodel; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.ActionConfig; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class FacetDataModelConfigAdapter - - extends ActionConfig - -{ - private final IDataModel dm; - - public FacetDataModelConfigAdapter( final IDataModel dm ) - { - this.dm = dm; - } - - public void setProjectFacetVersion( final IProjectFacetVersion fv ) - { - dm.setProperty( IFacetDataModelProperties.FACET_VERSION, fv ); - } - - public void setFacetedProjectWorkingCopy( final IFacetedProjectWorkingCopy fpjwc ) - { - dm.setProperty( IFacetDataModelProperties.FACETED_PROJECT_WORKING_COPY, fpjwc ); - - final IFacetedProjectListener nameChangeListener = new IFacetedProjectListener() - { - public void handleEvent( final IFacetedProjectEvent event ) - { - dm.setStringProperty( IFacetDataModelProperties.FACET_PROJECT_NAME, fpjwc.getProjectName() ); - } - }; - - fpjwc.addListener( nameChangeListener, IFacetedProjectEvent.Type.PROJECT_NAME_CHANGED ); - nameChangeListener.handleEvent( null ); - } - - public IStatus validate() - { - return dm.validate(); - } - - public static final class Factory - - implements IAdapterFactory - - { - private static final Class[] ADAPTER_TYPES = { ActionConfig.class }; - - public Object getAdapter( final Object adaptable, - final Class adapterType ) - { - if( adapterType == ActionConfig.class ) - { - return new FacetDataModelConfigAdapter( (IDataModel) adaptable ); - } - else - { - return null; - } - } - - public Class[] getAdapterList() - { - return ADAPTER_TYPES; - } - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetDataModelProvider.java deleted file mode 100644 index 59a3b2d5b..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetDataModelProvider.java +++ /dev/null @@ -1,81 +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.wst.common.componentcore.datamodel; - -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.FacetDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action.Type; - -public class FacetDataModelProvider extends AbstractDataModelProvider implements IFacetDataModelProperties { - - public static final String NOTIFICATION_OPERATION = "FacetDataModelProvider.NOTIFICATION_OPERATION"; //$NON-NLS-1$ - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(FACETED_PROJECT_WORKING_COPY); - names.add(FACET_PROJECT_NAME); - names.add(FACET_ID); - names.add(FACET_VERSION_STR); - names.add(FACET_TYPE); - names.add(FACET_VERSION); - names.add(FACET_ACTION); - names.add(SHOULD_EXECUTE); - names.add(NOTIFICATION_OPERATION); - return names; - } - - public Object getDefaultProperty(String propertyName) { - if (FACET_VERSION.equals(propertyName)) { - return ProjectFacetsManager.getProjectFacet(getStringProperty(FACET_ID)).getVersion(getStringProperty(FACET_VERSION_STR)); - } else if (FACET_ACTION.equals(propertyName)) { - return new IFacetedProject.Action((Type) model.getProperty(FACET_TYPE), (IProjectFacetVersion) model.getProperty(FACET_VERSION), model); - } else if (SHOULD_EXECUTE.equals(propertyName)) { - return Boolean.TRUE; - } else if (NOTIFICATION_OPERATION.equals(propertyName)) { - return getFacetNotificationOperation(); - } - return super.getDefaultProperty(propertyName); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - if (FACET_ACTION.equals(propertyName)) { - throw new RuntimeException(); - } - return super.propertySet(propertyName, propertyValue); - } - - public final IDataModelOperation getDefaultOperation() { - return new FacetDataModelOperation(model); - } - - protected IDataModelOperation getFacetNotificationOperation() { - return new DataModelPausibleOperationImpl(new AbstractDataModelOperation(this.model) { - public String getID() { - return "FacetDataModelProvider.Notification." + model.getProperty(FACET_TYPE) + "." + model.getStringProperty(FACET_ID); //$NON-NLS-1$//$NON-NLS-2$ - } - - public org.eclipse.core.runtime.IStatus execute(IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws ExecutionException { - return AbstractDataModelProvider.OK_STATUS; - } - }); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetInstallDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetInstallDataModelProvider.java deleted file mode 100644 index 50223489c..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetInstallDataModelProvider.java +++ /dev/null @@ -1,110 +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.wst.common.componentcore.datamodel; - -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.project.facet.core.IActionConfigFactory; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class FacetInstallDataModelProvider extends FacetDataModelProvider implements IActionConfigFactory { - - public static final String MASTER_PROJECT_DM = "FacetInstallDataModelProvider.MASTER_PROJECT_DM"; //$NON-NLS-1$ - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(MASTER_PROJECT_DM); - return names; - } - - public FacetInstallDataModelProvider() { - super(); - } - - public Object getDefaultProperty(String propertyName) { - if (FACET_TYPE.equals(propertyName)) { - return FACET_TYPE_INSTALL; - } else if (FACET_VERSION_STR.equals(propertyName)) { - IProjectFacetVersion version = (IProjectFacetVersion) getProperty(FACET_VERSION); - return version.getVersionString(); - } else if (FACET_VERSION.equals(propertyName)) { - IProjectFacetVersion version = ProjectFacetsManager.getProjectFacet(getStringProperty(FACET_ID)).getDefaultVersion(); - return version; - } - return super.getDefaultProperty(propertyName); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - if (FACET_TYPE.equals(propertyName)) { - throw new RuntimeException(); - } else if (FACET_VERSION_STR.equals(propertyName)) { - DataModelPropertyDescriptor[] descriptors = getValidPropertyDescriptors(FACET_VERSION); - for (int i = 0; i < descriptors.length; i++) { - if (descriptors[i].getPropertyDescription().equals(propertyValue)) { - setProperty(FACET_VERSION, descriptors[i].getPropertyValue()); - break; - } - } - } else if (null != propertyValue && FACET_VERSION.equals(propertyName)) { - IProjectFacetVersion version = (IProjectFacetVersion) propertyValue; - setProperty(FACET_VERSION_STR, version.getVersionString()); - } - return super.propertySet(propertyName, propertyValue); - } - - protected DataModelPropertyDescriptor[] cachedVersionDescriptors; - protected DataModelPropertyDescriptor[] cachedVersionStringDescriptors; - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - if (FACET_VERSION.equals(propertyName)) { - if (null == cachedVersionDescriptors) { - Set versions = ProjectFacetsManager.getProjectFacet(getStringProperty(FACET_ID)).getVersions(); - List list = Collections.list(Collections.enumeration(versions)); - Collections.sort(list, new Comparator(){ - public int compare(Object o1, Object o2) { - return ((IProjectFacetVersion)o1).getVersionString().compareTo(((IProjectFacetVersion)o2).getVersionString()); - } - }); - - cachedVersionDescriptors = new DataModelPropertyDescriptor[list.size()]; - Iterator iterator = list.iterator(); - for (int i = 0; i < cachedVersionDescriptors.length; i++) { - IProjectFacetVersion version = (IProjectFacetVersion) iterator.next(); - cachedVersionDescriptors[i] = new DataModelPropertyDescriptor(version, version.getVersionString()); - } - } - return cachedVersionDescriptors; - } - if (FACET_VERSION_STR.equals(propertyName)) { - if (null == cachedVersionStringDescriptors) { - DataModelPropertyDescriptor[] versionDescriptors = getValidPropertyDescriptors(FACET_VERSION); - cachedVersionStringDescriptors = new DataModelPropertyDescriptor[versionDescriptors.length]; - for (int i = 0; i < cachedVersionStringDescriptors.length; i++) { - cachedVersionStringDescriptors[i] = new DataModelPropertyDescriptor(versionDescriptors[i].getPropertyDescription()); - } - } - return cachedVersionStringDescriptors; - } - return super.getValidPropertyDescriptors(propertyName); - } - - public Object create() { - return DataModelFactory.createDataModel(this); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java deleted file mode 100644 index d8cb5d6a0..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java +++ /dev/null @@ -1,460 +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.wst.common.componentcore.datamodel; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.FacetProjectCreationOperation; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProviderNew; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; -import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager; - -public class FacetProjectCreationDataModelProvider extends AbstractDataModelProvider implements IFacetProjectCreationDataModelProperties { - - /** - * Type java.util.Collection. This is a smallest Collection of - * IProjectFacets that are absolutely required by this project type. This - * Collection will be used to filter runtimes. This property is not meant to - * be exposed to clients. Subclasses should initialize this Collection in - * their init() methods - */ - public static final String REQUIRED_FACETS_COLLECTION = "FacetProjectCreationDataModelProvider.REQUIRED_FACETS_COLLECTION"; - - public static final String FORCE_VERSION_COMPLIANCE = "FacetProjectCreationDataModelProvider.FORCE_VERSION_COMPLIANCE"; - - public FacetProjectCreationDataModelProvider() { - super(); - } - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(FACETED_PROJECT_WORKING_COPY); - names.add(FACET_PROJECT_NAME); - names.add(FACET_DM_MAP); - names.add(FACET_ACTION_MAP); - names.add(FACET_RUNTIME); - names.add(REQUIRED_FACETS_COLLECTION); - names.add(FORCE_VERSION_COMPLIANCE); - return names; - } - - public void init() { - super.init(); - - final IFacetedProjectWorkingCopy fpjwc = FacetedProjectFramework.createNewProject(); - model.setProperty(FACETED_PROJECT_WORKING_COPY, fpjwc); - - fpjwc.addListener - ( - new IFacetedProjectListener() - { - public void handleEvent( final IFacetedProjectEvent event ) - { - for( IFacetedProject.Action action : fpjwc.getProjectFacetActions() ) - { - final Object config = action.getConfig(); - - if( config != null && config instanceof IDataModel ) - { - final IDataModel dm = (IDataModel) config; - - if( dm.getAllProperties().contains( FacetInstallDataModelProvider.MASTER_PROJECT_DM ) ) - { - dm.setProperty( FacetInstallDataModelProvider.MASTER_PROJECT_DM, model ); - } - } - } - } - }, - IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED - ); - - fpjwc.addListener - ( - new IFacetedProjectListener() - { - public void handleEvent( final IFacetedProjectEvent event ) - { - model.notifyPropertyChange(FACET_RUNTIME, IDataModel.VALID_VALUES_CHG); - } - }, - IFacetedProjectEvent.Type.AVAILABLE_RUNTIMES_CHANGED - ); - - IDataModel projectDataModel = DataModelFactory.createDataModel(new ProjectCreationDataModelProviderNew()); - projectDataModel.addListener(new IDataModelListener() { - public void propertyChanged(DataModelEvent event) - { - final String prop = event.getPropertyName(); - - if( event.getFlag() == IDataModel.VALUE_CHG && - prop.equals( IProjectCreationPropertiesNew.PROJECT_NAME ) ) - { - final String projectName = (String) event.getProperty(); - getDataModel().setProperty(FACET_PROJECT_NAME, projectName); - fpjwc.setProjectName( projectName ); - } - else if( prop.equals( IProjectCreationPropertiesNew.PROJECT_LOCATION ) ) - { - final String location = (String) event.getProperty(); - fpjwc.setProjectLocation( location == null ? null : new Path( location ) ); - } - } - }); - model.addNestedModel(NESTED_PROJECT_DM, projectDataModel); - } - - protected class FacetActionMapImpl extends HashMap implements FacetActionMap { - private static final long serialVersionUID = 1L; - private boolean supressNotification = false; - - public void add(Action action) { - put(action.getProjectFacetVersion().getProjectFacet().getId(), action); - } - - public Action getAction(String facetID) { - return (Action) get(facetID); - } - - public void clear() { - try { - supressNotification = true; - super.clear(); - } finally { - supressNotification = false; - getDataModel().notifyPropertyChange(FACET_ACTION_MAP, IDataModel.VALUE_CHG); - } - } - - public Object remove(Object key) { - try { - return super.remove(key); - } finally { - if (!supressNotification) { - getDataModel().notifyPropertyChange(FACET_ACTION_MAP, IDataModel.VALUE_CHG); - } - } - } - - public Object put(Object key, Object value) { - try { - return super.put(key, value); - } finally { - if (!supressNotification) { - getDataModel().notifyPropertyChange(FACET_ACTION_MAP, IDataModel.VALUE_CHG); - } - } - } - - public void putAll(Map m) { - try { - supressNotification = true; - super.putAll(m); - } finally { - supressNotification = false; - getDataModel().notifyPropertyChange(FACET_ACTION_MAP, IDataModel.VALUE_CHG); - } - } - } - - protected class FacetDataModelMapImpl extends HashMap implements FacetDataModelMap, IDataModelListener { - private static final long serialVersionUID = 1L; - private boolean supressNotification = false; - - public void add(IDataModel facetDataModel) { - put(facetDataModel.getProperty(IFacetDataModelProperties.FACET_ID), facetDataModel); - } - - public IDataModel getFacetDataModel(String facetID) { - return (IDataModel) get(facetID); - } - - public void clear() { - try { - supressNotification = true; - for (Iterator iterator = values().iterator(); iterator.hasNext();) { - ((IDataModel) iterator.next()).removeListener(this); - } - super.clear(); - } finally { - supressNotification = false; - getDataModel().notifyPropertyChange(FACET_DM_MAP, IDataModel.VALUE_CHG); - } - } - - public Object put(Object key, Object value) { - try { - IDataModel dm = (IDataModel) value; - Object lastValue = super.put(key, value); - if (lastValue != null) { - ((IDataModel) lastValue).removeListener(this); - ((IDataModel) lastValue).setProperty(FacetInstallDataModelProvider.MASTER_PROJECT_DM, null); - } - dm.setProperty(FACET_PROJECT_NAME, getDataModel().getProperty(FACET_PROJECT_NAME)); - dm.setProperty(FacetInstallDataModelProvider.MASTER_PROJECT_DM, FacetProjectCreationDataModelProvider.this.model); - dm.addListener(this); - return lastValue; - } finally { - if (!supressNotification) { - getDataModel().notifyPropertyChange(FACET_DM_MAP, IDataModel.VALUE_CHG); - } - } - } - - public void putAll(Map m) { - try { - supressNotification = true; - super.putAll(m); - } finally { - supressNotification = false; - getDataModel().notifyPropertyChange(FACET_DM_MAP, IDataModel.VALUE_CHG); - } - } - - public Object remove(Object key) { - try { - IDataModel dm = (IDataModel) super.remove(key); - dm.removeListener(this); - return dm; - } finally { - if (!supressNotification) { - getDataModel().notifyPropertyChange(FACET_DM_MAP, IDataModel.VALUE_CHG); - } - } - } - - public void propertyChanged(DataModelEvent event) { - if (event.getPropertyName().equals(FACET_PROJECT_NAME)) { - if (containsValue(event.getDataModel())) { - getDataModel().setProperty(FACET_PROJECT_NAME, event.getProperty()); - } else { - event.getDataModel().removeListener(this); - } - } else if (event.getPropertyName().equals(FACET_RUNTIME)) { - if (containsValue(event.getDataModel())) { - if (event.getFlag() == IDataModel.VALID_VALUES_CHG) { - getDataModel().notifyPropertyChange(FACET_RUNTIME, IDataModel.VALID_VALUES_CHG); - } else if(event.getFlag() == IDataModel.ENABLE_CHG) { - getDataModel().notifyPropertyChange(FACET_RUNTIME, IDataModel.ENABLE_CHG); - } else { - getDataModel().setProperty(FACET_RUNTIME, event.getProperty()); - } - } else { - event.getDataModel().removeListener(this); - } - } - } - - } - - public boolean propertySet(String propertyName, Object propertyValue) { - if (FACET_PROJECT_NAME.equals(propertyName)) { - for (Iterator iterator = ((Map) getDataModel().getProperty(FACET_DM_MAP)).values().iterator(); iterator.hasNext();) { - ((IDataModel) iterator.next()).setProperty(FACET_PROJECT_NAME, propertyValue); - } - IDataModel projModel = model.getNestedModel(NESTED_PROJECT_DM); - projModel.setProperty(IProjectCreationPropertiesNew.PROJECT_NAME, propertyValue); - } else if (FACET_RUNTIME.equals(propertyName)) { - IRuntime runtime = (IRuntime) propertyValue; - for (Iterator iterator = ((Map) getDataModel().getProperty(FACET_DM_MAP)).values().iterator(); iterator.hasNext();) { - IDataModel dm = (IDataModel) iterator.next(); - if (dm.isProperty(FACET_RUNTIME)) { - dm.setProperty(FACET_RUNTIME, runtime); - } - } - if (runtime != null) { - if(getBooleanProperty(FORCE_VERSION_COMPLIANCE)){ - Map facetDMs = (Map) getProperty(FACET_DM_MAP); - - for (Iterator iterator = facetDMs.values().iterator(); iterator.hasNext();) { - IDataModel facetDataModel = (IDataModel) iterator.next(); - IProjectFacet facet = ProjectFacetsManager.getProjectFacet((String) facetDataModel.getProperty(IFacetDataModelProperties.FACET_ID)); - - try { - IDataModel facetModel = ((FacetDataModelMap) facetDMs).getFacetDataModel(facet.getId()); - IProjectFacetVersion oldVersion = (IProjectFacetVersion) facetModel.getProperty(IFacetDataModelProperties.FACET_VERSION); - IProjectFacetVersion newVersion = facet.getLatestSupportedVersion(runtime); - if (newVersion != null && (oldVersion == null || oldVersion.getVersionString().compareTo(newVersion.getVersionString()) > 0 || !runtime.supports(oldVersion))) { - facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, newVersion); - } - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - } - } - } - else if( REQUIRED_FACETS_COLLECTION.equals(propertyName) ) - { - final IFacetedProjectWorkingCopy fpjwc - = (IFacetedProjectWorkingCopy) this.model.getProperty( FACETED_PROJECT_WORKING_COPY ); - - final Collection<IProjectFacet> fixedFacets = (Collection<IProjectFacet>) propertyValue; - - fpjwc.setFixedProjectFacets( new HashSet<IProjectFacet>( fixedFacets ) ); - - final FacetDataModelMap facetDmMap = (FacetDataModelMap) getProperty( FACET_DM_MAP ); - - for( IProjectFacet facet : fixedFacets ) - { - final IFacetedProject.Action action = fpjwc.getProjectFacetAction( facet ); - Object config = action.getConfig(); - - if( ! ( config instanceof IDataModel ) ) - { - config = Platform.getAdapterManager().getAdapter( config, IDataModel.class ); - } - - facetDmMap.add( (IDataModel) config ); - } - } - return super.propertySet(propertyName, propertyValue); - } - - public Object getDefaultProperty(String propertyName) { - if (FACET_DM_MAP.equals(propertyName)) { - Object obj = new FacetDataModelMapImpl(); - setProperty(FACET_DM_MAP, obj); - return obj; - } else if (FACET_ACTION_MAP.equals(propertyName)) { - Object obj = new FacetActionMapImpl(); - setProperty(FACET_ACTION_MAP, obj); - return obj; - } else if(REQUIRED_FACETS_COLLECTION.equals(propertyName)){ - Collection c = new ArrayList(); - setProperty(REQUIRED_FACETS_COLLECTION, c); - return c; - } else if(FORCE_VERSION_COMPLIANCE.equals(propertyName)){ - return Boolean.TRUE; - } - return super.getDefaultProperty(propertyName); - } - - public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) { - if (FACET_RUNTIME.equals(propertyName)) { - IRuntime runtime = (IRuntime) getProperty(propertyName); - if (null != runtime) { - return new DataModelPropertyDescriptor(runtime, runtime.getLocalizedName()); - } - return new DataModelPropertyDescriptor(null, WTPCommonPlugin.getResourceString(WTPCommonMessages.RUNTIME_NONE, null)); - } - return super.getPropertyDescriptor(propertyName); - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - if (FACET_RUNTIME.equals(propertyName)) - { - final IFacetedProjectWorkingCopy fpjwc - = (IFacetedProjectWorkingCopy) this.model.getProperty( FACETED_PROJECT_WORKING_COPY ); - - final Set<IProjectFacet> fixedFacets = fpjwc.getFixedProjectFacets(); - final ArrayList list = new ArrayList(); - - for( IRuntime rt : RuntimeManager.getRuntimes() ) - { - // add this runtime in the list only if it supports all of the required facets - - boolean supports = true; - - for( IProjectFacet facet : fixedFacets ) - { - if( ! rt.supports( facet ) ) - { - supports = false; - break; - } - } - - if( supports ) - { - list.add(rt); - } - } - - DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[list.size() + 1]; - Iterator iterator = list.iterator(); - for (int i = 0; i < descriptors.length - 1; i++) { - IRuntime runtime = (IRuntime) iterator.next(); - descriptors[i] = new DataModelPropertyDescriptor(runtime, runtime.getLocalizedName()); - } - if(descriptors.length > 2){ - Arrays.sort(descriptors, 0, descriptors.length - 2, new Comparator() { - public int compare(Object arg0, Object arg1) { - DataModelPropertyDescriptor d1 = (DataModelPropertyDescriptor)arg0; - DataModelPropertyDescriptor d2 = (DataModelPropertyDescriptor)arg1; - return d1.getPropertyDescription().compareTo(d2.getPropertyDescription()); - } - }); - } - - descriptors[descriptors.length - 1] = new DataModelPropertyDescriptor(null, WTPCommonPlugin.getResourceString(WTPCommonMessages.RUNTIME_NONE, null)); - return descriptors; - } - return super.getValidPropertyDescriptors(propertyName); - } - - public IStatus validate(String propertyName) - { - if (FACET_PROJECT_NAME.equals(propertyName)) - { - IDataModel projModel = model.getNestedModel(NESTED_PROJECT_DM); - return projModel.validateProperty(IProjectCreationPropertiesNew.PROJECT_NAME); - } - else if( propertyName.equals( FACETED_PROJECT_WORKING_COPY ) ) - { - final IFacetedProjectWorkingCopy fpjwc - = (IFacetedProjectWorkingCopy) this.model.getProperty( FACETED_PROJECT_WORKING_COPY ); - - return fpjwc.validate(); - } - - return super.validate(propertyName); - } - - public IDataModelOperation getDefaultOperation() { - return new FacetProjectCreationOperation(model); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/ProjectMigratorDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/ProjectMigratorDataModelProvider.java deleted file mode 100644 index 21c3ca3bf..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/ProjectMigratorDataModelProvider.java +++ /dev/null @@ -1,32 +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.wst.common.componentcore.datamodel; - -import java.util.Set; - -import org.eclipse.wst.common.componentcore.datamodel.properties.IProjectMigratorDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.ProjectMigratorDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class ProjectMigratorDataModelProvider extends AbstractDataModelProvider implements IProjectMigratorDataModelProperties { - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(PROJECT_NAME); - return names; - } - - public final IDataModelOperation getDefaultOperation() { - return new ProjectMigratorDataModelOperation(model); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IComponentCreationDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IComponentCreationDataModelProperties.java deleted file mode 100644 index c8dcf5614..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IComponentCreationDataModelProperties.java +++ /dev/null @@ -1,83 +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.wst.common.componentcore.datamodel.properties; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -/** - * <p> - * IComponentCreationDataModelProperties provides properties to the DataModel associated with the - * ComponentCreationDataModelProvider as well as all extending interfaces extending - * IComponentCreationDataModelProperties specifically, but not limited to all J2EE component related - * creation. - * - * @see org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationDataModelProvider - * </p> - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider - * @see org.eclipse.wst.common.frameworks.datamodel.DataModelFactory - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties - * - * @plannedfor 1.0 - */ -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see IConnectorFacetInstallDataModelProperties - */ -public interface IComponentCreationDataModelProperties extends IDataModelProperties, DoNotUseMeThisWillBeDeletedPost15 { - - /** - * Required, type String. The user defined name of the target project for the component to be - * created. - */ - public static final String PROJECT_NAME = "IComponentCreationDataModelProperties.PROJECT_NAME"; //$NON-NLS-1$ - /** - * Required, type String. The user defined name of the component to be created. - */ - public static final String COMPONENT_NAME = "IComponentCreationDataModelProperties.COMPONENT_NAME"; //$NON-NLS-1$ - /** - * Required, type String. The user defined location on disk of the target project for the - * component to be created. Defaulted to default eclipse workspace location - */ - public static final String LOCATION = "IFlexibleProjectCreationDataModelProperties.LOCATION"; //$NON-NLS-1$ - - - /** - * Required, type String. The user defined deploy name of the component to be created. The - * DataModelProvider will default the name to the COMPONENT_NAME. - */ - public static final String COMPONENT_DEPLOY_NAME = "IComponentCreationDataModelProperties.COMPONENT_DEPLOY_NAME"; //$NON-NLS-1$ - /** - * Required, type String. Nested operation to create a new project. - */ - public static final String NESTED_PROJECT_CREATION_DM = "IComponentCreationDataModelProperties.NESTED_PROJECT_CREATION_DM"; //$NON-NLS-1$ - // TODO delete this - /** - * Optional, type Boolean The default value is <code>Boolean.TRUE</code>. If this property is - * set to <code>Boolean.TRUE</code> then a default deployment descriptor and supporting - * bindings files will be generated. - */ - public static final String CREATE_DEFAULT_FILES = "IComponentCreationDataModelProperties.CREATE_DEFAULT_FILES"; //$NON-NLS-1$ - - /** - * An unsettable result property used to retreive the created virtual component after the - * operation has executed. - */ - public static final String COMPONENT = "IComponentCreationDataModelProperties.COMPONENT"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/ICreateReferenceComponentsDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/ICreateReferenceComponentsDataModelProperties.java deleted file mode 100644 index 0dec0834a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/ICreateReferenceComponentsDataModelProperties.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.datamodel.properties; - -public interface ICreateReferenceComponentsDataModelProperties { - - /** - * <p> - * This required property is the {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent} which will reference the - * {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent}s specified by {@link #TARGET_COMPONENT_LIST}. - * </p> - * <p> - * For example, if {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent}s A, B, and C exist and references are required - * from A to B and A to C, then {@link #SOURCE_COMPONENT} should be set to A, and - * {@link #TARGET_COMPONENT_LIST} should be set to a {@link java.util.List} containing B and C. - * </p> - */ - public static final String SOURCE_COMPONENT = "ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT"; //$NON-NLS-1$ - - /** - * <p> - * This required property is the {@link java.util.List} containing the {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent}s that - * will be referenced from the {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent} specified by {@link #SOURCE_COMPONENT}. - * </p> - */ - public static final String TARGET_COMPONENT_LIST = "ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT"; //$NON-NLS-1$ - - /** - * Optional, deploy path for the dependent component, default is "/" - * Note: this is the default for the entire archive. See {@link #TARGET_COMPONENTS_DEPLOY_PATH_MAP} - */ - public static final String TARGET_COMPONENTS_DEPLOY_PATH = "ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_DEPLOY_PATH"; //$NON-NLS-1$ - - /** - * <p> - * This optional property is the {@link Map} containing keys of {@link IVirtualComponent}s and - * values of {@link String}s. This map is used to specify the String which should be used by - * the {@link IVirtualComponent} specified by the {@link #SOURCE_COMPONENT} property to lookup - * the deploy path. The {@link Set} of {@link IVirtualComponent}s in the - * keys of this {@link Map} should have the same contents as the {@link List}. - * </p> - */ - public static final String TARGET_COMPONENTS_DEPLOY_PATH_MAP = "ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_DEPLOY_PATH_MAP"; //$NON-NLS-1$ - - /** - * <p> - * This optional property is the {@link java.util.Map} containing keys of {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent}s and - * values of {@link String}s. This map is used to specify the String which should be used by - * the {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent} specified by the {@link #SOURCE_COMPONENT} property to lookup - * the keyed {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent}. The {@link java.util.Set} of {@link org.eclipse.wst.common.componentcore.resources.IVirtualComponent}s in the - * keys of this {@link java.util.Map} should have the same contents as the {@link java.util.List}. - * </p> - */ - public static final String TARGET_COMPONENTS_TO_URI_MAP = "ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetDataModelProperties.java deleted file mode 100644 index 91c694d28..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetDataModelProperties.java +++ /dev/null @@ -1,43 +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.wst.common.componentcore.datamodel.properties; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; -import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action; - -public interface IFacetDataModelProperties extends IDataModelProperties { - - public static final Object FACET_TYPE_INSTALL = Action.Type.INSTALL; - public static final Object FACET_TYPE_UNINSTALL = Action.Type.UNINSTALL; - public static final Object FACET_TYPE_VERSION_CHANGE = Action.Type.VERSION_CHANGE; - - public static final String FACET_PROJECT_NAME = "IFacetDataModelProperties.FACET_PROJECT_NAME"; //$NON-NLS-1$ - - public static final String FACET_TYPE = "IFacetDataModelProperties.FACET_TYPE"; //$NON-NLS-1$ - - public static final String FACET_ID = "IFacetDataModelProperties.FACET_ID"; //$NON-NLS-1$ - - public static final String FACET_VERSION_STR = "IFacetDataModelProperties.FACET_VERSION_STR"; //$NON-NLS-1$ - - /** - * an IProjectFacetVersion - */ - public static final String FACET_VERSION = "IFacetDataModelPropeties.FACET_VERSION"; //$NON-NLS-1$ - - /** - * an IFacetedProject.Action - */ - public static final String FACET_ACTION = "IFacetDataModelProperties.FACET_ACTION"; //$NON-NLS-1$ - - public static final String SHOULD_EXECUTE = "IFacetDataModelProperties.SHOULD_EXECUTE"; //$NON-NLS-1$ - - public static final String FACETED_PROJECT_WORKING_COPY = "IFacetDataModelProperties.FACETED_PROJECT_WORKING_COPY"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetInstallDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetInstallDataModelProperties.java deleted file mode 100644 index 1ae3fa738..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetInstallDataModelProperties.java +++ /dev/null @@ -1,15 +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.wst.common.componentcore.datamodel.properties; - -public interface IFacetInstallDataModelProperties extends IFacetDataModelProperties { - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetProjectCreationDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetProjectCreationDataModelProperties.java deleted file mode 100644 index 0d76a0ff9..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IFacetProjectCreationDataModelProperties.java +++ /dev/null @@ -1,69 +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.wst.common.componentcore.datamodel.properties; - -import java.util.Map; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; - -public interface IFacetProjectCreationDataModelProperties extends IDataModelProperties { - - public static final String FACETED_PROJECT_WORKING_COPY - = "IFacetProjectCreationDataModelProperties.FACETED_PROJECT_WORKING_COPY"; //$NON-NLS-1$"; - - /** - * A String - */ - public static final String FACET_PROJECT_NAME = IFacetDataModelProperties.FACET_PROJECT_NAME; - - /** - * A Nested IDataModel of type IProjectCreationDataModelProperties - */ - public static final String NESTED_PROJECT_DM = "IFacetProjectCreationDataModelProperties.NESTED_PROJECT_DM"; //$NON-NLS-1$"; - - /** - * An instanceof FacetDataModelMap. - */ - public static final String FACET_DM_MAP = "IFacetProjectCreationDataModelProperties.FACET_DM_MAP"; //$NON-NLS-1$ - - /** - * An instance of FacetActionMap - */ - public static final String FACET_ACTION_MAP = "IFacetProjectCreationDataModelProperties.FACET_ACTION_MAP"; //$NON-NLS-1$ - - - /** - * An instanceof of IRuntime - */ - public static final String FACET_RUNTIME = "IFacetProjectCreationDataModelProperties.FACET_RUNTIME"; //$NON-NLS-1$ - - - /** - * This map is used for tracking individual IDataModels implementing IFacetDataModelProperties. - * The facet ids are the keys for retieving the specific IFacetataModelProperties IDataModels - */ - public interface FacetDataModelMap extends Map { - public void add(IDataModel facetDataModel); - public IDataModel getFacetDataModel(String facetID); - } - - /** - * This map is used for tracing indivdual IFacetedProject.Actions for facets that either do not - * have any config data, or facets whose config data is not an IDataModel. - */ - public interface FacetActionMap extends Map { - public void add(IFacetedProject.Action action); - public IFacetedProject.Action getAction(String facetID); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IProjectMigratorDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IProjectMigratorDataModelProperties.java deleted file mode 100644 index 1e93fff79..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IProjectMigratorDataModelProperties.java +++ /dev/null @@ -1,20 +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.wst.common.componentcore.datamodel.properties; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; - -public interface IProjectMigratorDataModelProperties extends IDataModelProperties { - - - public static final String PROJECT_NAME = "IProjectMigratorDataModelProperties.PROJECT_NAME"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IServerContextRootDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IServerContextRootDataModelProperties.java deleted file mode 100644 index c939138e7..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/IServerContextRootDataModelProperties.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.wst.common.componentcore.datamodel.properties; - -import org.eclipse.wst.common.componentcore.internal.operation.ServerContextRootDataModelProvider; - -public interface IServerContextRootDataModelProperties { - /** - * This field should not be used. It is not part of the API and may be modified in the future. - */ - public static Class _provider_class = ServerContextRootDataModelProvider.class; - - public static final String PROJECT = "IServerContextRootDataModelProperties.PROJECT"; //$NON-NLS-1$ - public static final String CONTEXT_ROOT = "IServerContextRootDataModelProperties.CONTEXT_ROOT"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/package.xml b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/package.xml deleted file mode 100644 index 535937f76..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/properties/package.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../../../" /> - <title>Component creation and Referenced Component api overview</title> - </head> - - <body> - <abstract> - This package includes API for creating components in a Flexible project and - adding referenced components to existing components.(see <a href="ComponentCore.html">ComponentCore</a>). - Clients should also review the <b>org.eclipse.wst.common.componentcore.resources</b> - package. - </abstract> - - <a href="#top">top</a> - </body> -</html> -
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ArtifactEditModel.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ArtifactEditModel.java deleted file mode 100644 index 9e38950ff..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ArtifactEditModel.java +++ /dev/null @@ -1,345 +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.wst.common.componentcore.internal; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.impl.PlatformURLModuleConnection; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; -import org.eclipse.wst.common.frameworks.internal.enablement.EnablementManager; -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectListener; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * - * Provides resource life cycle management between an EditModel and a WTP flexible module pattern. - * <p> - * ArtifactEditModel provides a framework for managing a set of EMF resources within a unit of work. - * Management of these resources includes basic services such as loads, saves, and synchronization - * for the managed resources. ArtifactEditModels are reference counted so that a single instance can - * be shared by more than one operation or editor. - * </p> - * <p> - * AritfactEditModel utilizes - * {@see org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext} to manage the life - * cycle of an EMF {@see org.eclipse.emf.ecore.resource.Resource} in a given EMF - * {@see org.eclipse.emf.ecore.resource.ResourceSet}. There is one ArtifactEditModel per - * {@see org.eclipse.wst.common.modulecore.WorkbenchComponent} in each project. - * </p> - * - * @see org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext - * @see org.eclipse.emf.ecore.resource.Resource - * @see org.eclipse.emf.ecore.resource.ResourceSet - * @see org.eclipse.wst.common.componentcore.internal.StructureEdit - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource - */ - -public class ArtifactEditModel extends EditModel implements IAdaptable, IFacetedProjectListener { - - public static final Class ADAPTER_TYPE = ArtifactEditModel.class; - private final IProject componentProject; - private final IPath modulePath; - private URI rootURI; - private String rootContentType; - private final IVirtualComponent virtualComponent; - private final URI componentURI; - - /** - * <p> - * Creates a ArtifactEditModel instance that uses information from the - * <b>org.eclipse.wst.common.emfworkbench.integration.editModelFactory </b> extension point - * associated with anEditModelId attached to the project managed by aContext for a specific - * module referenced by aModuleURI. Resoures that are not recognized as defined Resources via - * the appropriate EditModel extension points will be accessed as read-only. - * </p> - * <p> - * This method is functionally equivalent to: - * </p> - * <p> - * <code>ArtifactEditModel(anEditModelId, aContext, toMakeReadOnly, true, aModuleURI)</code> - * </p> - * - * @param anEditModelId - * A unique identifier for the EditModel defined by the appropriate - * <b>org.eclipse.wst.common.emfworkbench.integration.editModelFactory </b> extension - * point. - * @param aContext - * A valid EMFWorkbenchContext which helps manage the lifecycle of EMF resources for - * a given project. - * @param toMakeReadOnly - * True indicates that Resources loaded by the EditModel will not allow - * modifications. - * @param aModuleURI - * A fully-qualified URI that conforms to the "module:" format. - */ - - public ArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, URI aModuleURI) { - this(anEditModelId, aContext, toMakeReadOnly, true, aModuleURI); - } - - public ArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, boolean toAccessUnknownResourcesAsReadOnly, URI aModuleURI,URI rootURI, - String rootContentType) { - this(anEditModelId, aContext, toMakeReadOnly, toAccessUnknownResourcesAsReadOnly, aModuleURI); - this.rootURI = rootURI; - this.rootContentType = rootContentType; - - } - - - /** - * - * <p> - * Creates a ArtifactEditModel instance that uses information from the - * <b>org.eclipse.wst.common.emfworkbench.integration.editModelFactory </b> extension point - * associated with anEditModelId attached to the project managed by aContext for a specific - * module referenced by aModuleURI. Resoures that are not recognized as defined - * </p>* - * - * @param anEditModelId - * A unique identifier for the EditModel defined by the appropriate - * <b>org.eclipse.wst.common.emfworkbench.integration.editModelFactory </b> extension - * point. - * @param aContext - * A valid EMFWorkbenchContext which helps manage the lifecycle of EMF resources for - * a given project. - * @param toMakeReadOnly - * True indicates that Resources loaded by the EditModel will not allow - * modifications. - * @param toAccessUnknownResourcesAsReadOnly - * True indicates that Resources not recognized by the EditModel be loaded as - * read-only - such those loaded via {@see #getResource(URI)}. - * @param aModuleURI - * A fully-qualified URI that conforms to the "module:" format. - * - */ - - public ArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, boolean toAccessUnknownResourcesAsReadOnly, URI aModuleURI) { - super(anEditModelId, aContext, toMakeReadOnly, toAccessUnknownResourcesAsReadOnly); - IProject aProject = null; - try { - aProject = StructureEdit.getContainingProject(aModuleURI); - IFacetedProject facetProj; - facetProj = ProjectFacetsManager.create(project); - if (facetProj != null) - facetProj.addListener(this); - } catch (UnresolveableURIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }finally { - componentProject = aProject; - } - - virtualComponent = ComponentCore.createComponent(componentProject); - componentURI = aModuleURI; - modulePath = new Path(aModuleURI.path()); - processLoadedResources(componentProject); - } - - public ArtifactEditModel(String editModelID, EMFWorkbenchContext context, boolean toMakeReadOnly, URI moduleURI, URI rootURI, - String rootContentType) { - this(editModelID, context, toMakeReadOnly, true, moduleURI); - this.rootURI = rootURI; - this.rootContentType = rootContentType; - - } - - /** - * <p> - * Accesses resources within the underlying resource set. Takes a standard URI attaches module - * protocol and information. This data can be used to determine if the resource is part of a - * flexible module structure. If the resource does not exist in the resource set it will try and - * load the resource. - * </p> - * - * @param aUri - - * location of resource - * - * @return Resource (@see Resource) - */ - public Resource getResource(URI aUri) { - IPath requestPath; - //If requesting rootURI, use content type describer if available - if (rootURI != null && rootURI.equals(aUri) && rootContentType != null) { - requestPath = modulePath.append(new Path(rootContentType)); - requestPath = requestPath.append(new Path(aUri.path())); - } - else {// First check if passed URI is already normalized... - requestPath = modulePath.append(new Path(aUri.path())); - } - URI resourceURI = URI.createURI(PlatformURLModuleConnection.MODULE_PROTOCOL + requestPath.toString()); - return super.getResource(resourceURI); - } - - public IProject getComponentProject() { - return componentProject; - } - - public URI getModuleURI() { - return componentURI; - } - - /** - * <p> - * Accesses resoureces within the underlying resource set. Takes a starndard URI attaches module - * information. This data can be used to determine if the resource is part of a flexible module - * structure. - * </p> - * - * @param aUri - - * location of resource - * - * @return Resource (@see Resource) - */ - - public Resource getOrCreateResource(URI aUri) { - - return super.getOrCreateResource(aUri); - } - - /** - * <p> - * Overridden to prevent super() implementation, processLoadedResources(aModuleURI) used - * instead. (@link processLoadedResources(URI aModuleURI) - * </p> - * - * @param aUri - - * location of resource - */ - - - - protected void processLoadedResources() { - } - - /** - * <p> - * Gathers resources from the underlying resource set, determines if interested (@link - * processLoadedResources(URI aModuleURI))and request access (@link access(ReferencedResource - * aResource))to each resource incrementing the write/read count. - * </p> - * - * @param aUri - - * location of resource - */ - - - protected void processLoadedResources(IProject aComponentProject) { - List loadedResources = getResourceSet().getResources(); - if (!loadedResources.isEmpty()) { - processResourcesIfInterrested(loadedResources); - } - } - - /** - * <p> - * Checks to make sure a flexible module structure exist for the resources in the resource set. - * This is achieved by querying ModuleCore(@see ModuleCore) for existing - * WorkbenchModuleResources (@see WorkbenchModuleResources). If the resource exist it processes - * the resource (@link processResource(Resource aResource)). Processing the resource increments - * the read/write count. - * </p>* - * - * @param theResources - - * list of resources to verify flexible module status, and process - * @throws UnresolveableURIException - * could not WorkbenchResource with the corresponding URI. - */ - protected boolean processResourcesIfInterrested(List theResources) { - int size = theResources.size(); - Resource resourceToProcess; - boolean processed = false; - - IResource resourceResource; - IVirtualResource[] virtualResources; - for (int i = 0; i < size; i++) { - resourceToProcess = (Resource) theResources.get(i); - if (resourceToProcess == null) continue; - String lastSegment = resourceToProcess.getURI().lastSegment(); - if (null != lastSegment && lastSegment.endsWith(IModuleConstants.COMPONENT_FILE_NAME)) continue; - resourceResource = WorkbenchResourceHelper.getFile(resourceToProcess); - if (resourceResource != null) { - virtualResources = ComponentCore.createResources(resourceResource); - for (int resourcesIndex = 0; resourcesIndex < virtualResources.length; resourcesIndex++) { - if (virtualComponent.equals(virtualResources[resourcesIndex].getComponent())) { - if (resourceToProcess !=null && isInterrestedInResource(resourceToProcess)) { - processResource(resourceToProcess); - processed = true; - } - } - } - } - } - return processed; - } - - /** - * - * <p> - * Generic way to retrieve containing information, within the platform. - * </p> - * - * @return instance of the adapterType for this adapter class from adapter factory stored in the - * adapter manager (@see AdapterManager) - * - */ - - public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - - public IVirtualComponent getVirtualComponent() { - return virtualComponent; - } - - public void projectChanged() { - try { - EnablementManager.INSTANCE.notifyFunctionGroupChanged(null,getComponentProject()); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - protected void doDispose() { - //Remove the listener from the faceted project - try { - IFacetedProject facetProj = ProjectFacetsManager.create(getComponentProject()); - if (facetProj != null) - facetProj.removeListener(this); - } catch (Exception e) { - Logger.getLogger().logError(e); - } - super.doDispose(); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/BinaryComponentHelper.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/BinaryComponentHelper.java deleted file mode 100644 index ea71b40e4..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/BinaryComponentHelper.java +++ /dev/null @@ -1,37 +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.wst.common.componentcore.internal; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public abstract class BinaryComponentHelper { - - private IVirtualComponent component; - - protected BinaryComponentHelper(IVirtualComponent component) { - this.component = component; - } - - public IVirtualComponent getComponent() { - return component; - } - - public abstract EObject getPrimaryRootObject(); - - public abstract Resource getResource(URI uri); - - public void dispose(){ - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentResource.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentResource.java deleted file mode 100644 index efe8adc9b..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentResource.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * <copyright></copyright> - * - * $Id: ComponentResource.java,v 1.6 2006/04/27 04:17:40 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> Provides an abstract mapping of workbench resources to deployable - * resources. - * <p> - * The underlying eclipse resource could be a container or a file. However, if the - * {@see #getSourcePath()} is a container, then the {@see #getDeployedPath()} will be - * a container as well. - * </p>Clients that require access to the underlying Eclipse Resource for a given - * ComponentResource should use - * {@see org.eclipse.wst.common.modulecore.ModuleCore#getEclipseResource(ComponentResource)} - * <p> - * See the package overview for an <a href="package-summary.html">overview of the model components </a>. - * </p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getSourcePath <em>Source Path</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getRuntimePath <em>Runtime Path</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getExclusions <em>Exclusions</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getComponent <em>Component</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getResourceType <em>Resource Type</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentResource() - * @model - * @generated - */ -public interface ComponentResource extends EObject { - /** - * Returns the value of the '<em><b>Source Path</b></em>' attribute. - * <!-- begin-user-doc - * --> - * <p> - * If the meaning of the '<em>Source Path</em>' attribute isn't clear, there really should - * be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Source Path</em>' attribute. - * @see #setSourcePath(IPath) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentResource_SourcePath() - * @model dataType="org.eclipse.wst.common.componentcore.internal.IPath" required="true" - * @generated - */ - IPath getSourcePath(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getSourcePath <em>Source Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Source Path</em>' attribute. - * @see #getSourcePath() - * @generated - */ - void setSourcePath(IPath value); - - /** - * Returns the value of the '<em><b>Runtime Path</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Runtime Path</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Runtime Path</em>' attribute. - * @see #setRuntimePath(IPath) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentResource_RuntimePath() - * @model dataType="org.eclipse.wst.common.componentcore.internal.IPath" required="true" - * @generated - */ - IPath getRuntimePath(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getRuntimePath <em>Runtime Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Runtime Path</em>' attribute. - * @see #getRuntimePath() - * @generated - */ - void setRuntimePath(IPath value); - - /** - * Returns the value of the '<em><b>Exclusions</b></em>' attribute list. - * The list contents are of type {@link java.lang.String}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Exclusions</em>' attribute list isn't clear, there really - * should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Exclusions</em>' attribute list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentResource_Exclusions() - * @model type="java.lang.String" default="" - * @generated - */ - EList getExclusions(); - - /** - * Returns the value of the '<em><b>Component</b></em>' container reference. - * It is bidirectional and its opposite is '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getResources <em>Resources</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Component</em>' container reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Component</em>' container reference. - * @see #setComponent(WorkbenchComponent) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentResource_Component() - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getResources - * @model opposite="resources" required="true" - * @generated - */ - WorkbenchComponent getComponent(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getComponent <em>Component</em>}' container reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Component</em>' container reference. - * @see #getComponent() - * @generated - */ - void setComponent(WorkbenchComponent value); - - /** - * Returns the value of the '<em><b>Resource Type</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Resource Type</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Resource Type</em>' attribute. - * @see #setResourceType(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentResource_ResourceType() - * @model default="" required="true" - * @generated - */ - String getResourceType(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getResourceType <em>Resource Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Resource Type</em>' attribute. - * @see #getResourceType() - * @generated - */ - void setResourceType(String value); - - IProject getOwningProject(); - void setOwningProject(IProject aProject); - -} // ComponentResource diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentType.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentType.java deleted file mode 100644 index 48a0703f4..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentType.java +++ /dev/null @@ -1,131 +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.wst.common.componentcore.internal; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * Indicates how the {@see org.eclipse.wst.common.modulecore.WorkbenchComponent} should be handled by - * the tooling. - * <p> - * In particular, the {@see #getModuleTypeId()} is used to coordinate other - * extensions such as EditModels and the module structure preparation builder. - * </p> - * - * <p> - * See the package overview for an <a href="package-summary.html">overview of the model components </a>. - * </p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getComponentTypeId <em>Component Type Id</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getVersion <em>Version</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getProperties <em>Properties</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getMetadataResources <em>Metadata Resources</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentType() - * @model - * @generated - */ -public interface ComponentType extends EObject { - /** - * Returns the value of the '<em><b>Component Type Id</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Component Type Id</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Component Type Id</em>' attribute. - * @see #setComponentTypeId(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentType_ComponentTypeId() - * @model default="" required="true" - * @generated - */ - String getComponentTypeId(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getComponentTypeId <em>Component Type Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Component Type Id</em>' attribute. - * @see #getComponentTypeId() - * @generated - */ - void setComponentTypeId(String value); - - /** - * Returns the value of the '<em><b>Metadata Resources</b></em>' attribute list. - * The list contents are of type {@link org.eclipse.core.runtime.IPath}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Metadata Resources</em>' attribute list isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Metadata Resources</em>' attribute list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentType_MetadataResources() - * @model type="org.eclipse.core.runtime.IPath" dataType="org.eclipse.wst.common.componentcore.internal.IPath" - * @generated - */ - EList getMetadataResources(); - - /** - * Returns the value of the '<em><b>Version</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Version</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Version</em>' attribute. - * @see #setVersion(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentType_Version() - * @model default="" required="true" - * @generated - */ - String getVersion(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getVersion <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Version</em>' attribute. - * @see #getVersion() - * @generated - */ - void setVersion(String value); - - /** - * Returns the value of the '<em><b>Properties</b></em>' reference list. - * The list contents are of type {@link org.eclipse.wst.common.componentcore.internal.Property}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Properties</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Properties</em>' reference list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getComponentType_Properties() - * @model type="org.eclipse.wst.common.componentcore.internal.Property" - * @generated - */ - EList getProperties(); - -} // ComponentType diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentcoreFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentcoreFactory.java deleted file mode 100644 index 25de4f9f5..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentcoreFactory.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentcoreFactory.java,v 1.2 2006/04/27 04:17:40 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal; - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.wst.common.componentcore.internal.impl.ComponentcoreFactoryImpl; - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.ComponentcorePackage - * @generated - */ -public interface ComponentcoreFactory extends EFactory { - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - ComponentcoreFactory eINSTANCE = ComponentcoreFactoryImpl.init(); - - /** - * Returns a new object of class '<em>Workbench Component</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Workbench Component</em>'. - * @generated - */ - WorkbenchComponent createWorkbenchComponent(); - - /** - * Returns a new object of class '<em>Component Resource</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Component Resource</em>'. - * @generated - */ - ComponentResource createComponentResource(); - - /** - * Returns a new object of class '<em>Component Type</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Component Type</em>'. - * @generated - */ - ComponentType createComponentType(); - - /** - * Returns a new object of class '<em>Property</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Property</em>'. - * @generated - */ - Property createProperty(); - - /** - * Returns a new object of class '<em>Referenced Component</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Referenced Component</em>'. - * @generated - */ - ReferencedComponent createReferencedComponent(); - - /** - * Returns a new object of class '<em>Project Components</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Project Components</em>'. - * @generated - */ - ProjectComponents createProjectComponents(); - - /** - * Returns the package supported by this factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the package supported by this factory. - * @generated - */ - ComponentcorePackage getComponentcorePackage(); - -} //ComponentcoreFactory diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentcorePackage.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentcorePackage.java deleted file mode 100644 index eed4fe3c0..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ComponentcorePackage.java +++ /dev/null @@ -1,1118 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentcorePackage.java,v 1.8 2006/04/27 04:17:40 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; - -/** - * <!-- begin-user-doc --> - * The <b>Package</b> for the model. - * It contains accessors for the meta objects to represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.ComponentcoreFactory - * @model kind="package" - * @generated - */ -public interface ComponentcorePackage extends EPackage { - /** - * The package name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNAME = "componentcore"; - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_URI = "componentcore.xmi"; - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_PREFIX = "org.eclipse.wst.common.componentcore"; - - /** - * The singleton instance of the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - ComponentcorePackage eINSTANCE = org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl.init(); - - /** - * The meta object id for the '{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl <em>Workbench Component</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getWorkbenchComponent() - * @generated - */ - int WORKBENCH_COMPONENT = 0; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int WORKBENCH_COMPONENT__NAME = 0; - - /** - * The feature id for the '<em><b>Resources</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int WORKBENCH_COMPONENT__RESOURCES = 1; - - /** - * The feature id for the '<em><b>Component Type</b></em>' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int WORKBENCH_COMPONENT__COMPONENT_TYPE = 2; - - /** - * The feature id for the '<em><b>Referenced Components</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int WORKBENCH_COMPONENT__REFERENCED_COMPONENTS = 3; - - /** - * The feature id for the '<em><b>Properties</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int WORKBENCH_COMPONENT__PROPERTIES = 4; - - /** - * The feature id for the '<em><b>Metadata Resources</b></em>' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int WORKBENCH_COMPONENT__METADATA_RESOURCES = 5; - - /** - * The number of structural features of the '<em>Workbench Component</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int WORKBENCH_COMPONENT_FEATURE_COUNT = 6; - - /** - * The meta object id for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl <em>Component Resource</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getComponentResource() - * @generated - */ - int COMPONENT_RESOURCE = 1; - - /** - * The feature id for the '<em><b>Source Path</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_RESOURCE__SOURCE_PATH = 0; - - /** - * The feature id for the '<em><b>Runtime Path</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_RESOURCE__RUNTIME_PATH = 1; - - /** - * The feature id for the '<em><b>Exclusions</b></em>' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_RESOURCE__EXCLUSIONS = 2; - - /** - * The feature id for the '<em><b>Component</b></em>' container reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_RESOURCE__COMPONENT = 3; - - /** - * The feature id for the '<em><b>Resource Type</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_RESOURCE__RESOURCE_TYPE = 4; - - /** - * The number of structural features of the '<em>Component Resource</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_RESOURCE_FEATURE_COUNT = 5; - - /** - * The meta object id for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl <em>Component Type</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getComponentType() - * @generated - */ - int COMPONENT_TYPE = 2; - - /** - * The feature id for the '<em><b>Component Type Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_TYPE__COMPONENT_TYPE_ID = 0; - - /** - * The feature id for the '<em><b>Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_TYPE__VERSION = 1; - - /** - * The feature id for the '<em><b>Properties</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_TYPE__PROPERTIES = 2; - - /** - * The feature id for the '<em><b>Metadata Resources</b></em>' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_TYPE__METADATA_RESOURCES = 3; - - /** - * The number of structural features of the '<em>Component Type</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int COMPONENT_TYPE_FEATURE_COUNT = 4; - - /** - * The meta object id for the '{@link org.eclipse.wst.common.componentcore.internal.impl.PropertyImpl <em>Property</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.PropertyImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getProperty() - * @generated - */ - int PROPERTY = 3; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PROPERTY__NAME = 0; - - /** - * The feature id for the '<em><b>Value</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PROPERTY__VALUE = 1; - - /** - * The number of structural features of the '<em>Property</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PROPERTY_FEATURE_COUNT = 2; - - /** - * The meta object id for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl <em>Referenced Component</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getReferencedComponent() - * @generated - */ - int REFERENCED_COMPONENT = 4; - - /** - * The feature id for the '<em><b>Handle</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int REFERENCED_COMPONENT__HANDLE = 0; - - /** - * The feature id for the '<em><b>Runtime Path</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int REFERENCED_COMPONENT__RUNTIME_PATH = 1; - - /** - * The feature id for the '<em><b>Dependency Type</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int REFERENCED_COMPONENT__DEPENDENCY_TYPE = 2; - - /** - * The feature id for the '<em><b>Dependent Object</b></em>' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int REFERENCED_COMPONENT__DEPENDENT_OBJECT = 3; - - /** - * The feature id for the '<em><b>Archive Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int REFERENCED_COMPONENT__ARCHIVE_NAME = 4; - - /** - * The number of structural features of the '<em>Referenced Component</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int REFERENCED_COMPONENT_FEATURE_COUNT = 5; - - /** - * The meta object id for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ProjectComponentsImpl <em>Project Components</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ProjectComponentsImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getProjectComponents() - * @generated - */ - int PROJECT_COMPONENTS = 5; - - /** - * The feature id for the '<em><b>Project Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PROJECT_COMPONENTS__PROJECT_NAME = 0; - - /** - * The feature id for the '<em><b>Components</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PROJECT_COMPONENTS__COMPONENTS = 1; - - /** - * The feature id for the '<em><b>Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PROJECT_COMPONENTS__VERSION = 2; - - /** - * The number of structural features of the '<em>Project Components</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PROJECT_COMPONENTS_FEATURE_COUNT = 3; - - /** - * The meta object id for the '{@link org.eclipse.wst.common.componentcore.internal.DependencyType <em>Dependency Type</em>}' enum. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.DependencyType - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getDependencyType() - * @generated - */ - int DEPENDENCY_TYPE = 6; - - /** - * The meta object id for the '<em>IPath</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.core.runtime.IPath - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getIPath() - * @generated - */ - int IPATH = 7; - - /** - * The meta object id for the '<em>URI</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.common.util.URI - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getURI() - * @generated - */ - int URI = 8; - - - /** - * Returns the meta object for class '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent <em>Workbench Component</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Workbench Component</em>'. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent - * @generated - */ - EClass getWorkbenchComponent(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getName <em>Name</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Name</em>'. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getName() - * @see #getWorkbenchComponent() - * @generated - */ - EAttribute getWorkbenchComponent_Name(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getResources <em>Resources</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Resources</em>'. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getResources() - * @see #getWorkbenchComponent() - * @generated - */ - EReference getWorkbenchComponent_Resources(); - - /** - * Returns the meta object for the containment reference '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getComponentType <em>Component Type</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference '<em>Component Type</em>'. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getComponentType() - * @see #getWorkbenchComponent() - * @generated - */ - EReference getWorkbenchComponent_ComponentType(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getReferencedComponents <em>Referenced Components</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Referenced Components</em>'. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getReferencedComponents() - * @see #getWorkbenchComponent() - * @generated - */ - EReference getWorkbenchComponent_ReferencedComponents(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getProperties <em>Properties</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference list '<em>Properties</em>'. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getProperties() - * @see #getWorkbenchComponent() - * @generated - */ - EReference getWorkbenchComponent_Properties(); - - /** - * Returns the meta object for the attribute list '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getMetadataResources <em>Metadata Resources</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute list '<em>Metadata Resources</em>'. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getMetadataResources() - * @see #getWorkbenchComponent() - * @generated - */ - EAttribute getWorkbenchComponent_MetadataResources(); - - /** - * Returns the meta object for class '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource <em>Component Resource</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Component Resource</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource - * @generated - */ - EClass getComponentResource(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getSourcePath <em>Source Path</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Source Path</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource#getSourcePath() - * @see #getComponentResource() - * @generated - */ - EAttribute getComponentResource_SourcePath(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getRuntimePath <em>Runtime Path</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Runtime Path</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource#getRuntimePath() - * @see #getComponentResource() - * @generated - */ - EAttribute getComponentResource_RuntimePath(); - - /** - * Returns the meta object for the attribute list '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getExclusions <em>Exclusions</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute list '<em>Exclusions</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource#getExclusions() - * @see #getComponentResource() - * @generated - */ - EAttribute getComponentResource_Exclusions(); - - /** - * Returns the meta object for the container reference '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getComponent <em>Component</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the container reference '<em>Component</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource#getComponent() - * @see #getComponentResource() - * @generated - */ - EReference getComponentResource_Component(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getResourceType <em>Resource Type</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Resource Type</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource#getResourceType() - * @see #getComponentResource() - * @generated - */ - EAttribute getComponentResource_ResourceType(); - - /** - * Returns the meta object for class '{@link org.eclipse.wst.common.componentcore.internal.ComponentType <em>Component Type</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Component Type</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentType - * @generated - */ - EClass getComponentType(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getComponentTypeId <em>Component Type Id</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Component Type Id</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentType#getComponentTypeId() - * @see #getComponentType() - * @generated - */ - EAttribute getComponentType_ComponentTypeId(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getVersion <em>Version</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Version</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentType#getVersion() - * @see #getComponentType() - * @generated - */ - EAttribute getComponentType_Version(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getProperties <em>Properties</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference list '<em>Properties</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentType#getProperties() - * @see #getComponentType() - * @generated - */ - EReference getComponentType_Properties(); - - /** - * Returns the meta object for the attribute list '{@link org.eclipse.wst.common.componentcore.internal.ComponentType#getMetadataResources <em>Metadata Resources</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute list '<em>Metadata Resources</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ComponentType#getMetadataResources() - * @see #getComponentType() - * @generated - */ - EAttribute getComponentType_MetadataResources(); - - /** - * Returns the meta object for class '{@link org.eclipse.wst.common.componentcore.internal.Property <em>Property</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Property</em>'. - * @see org.eclipse.wst.common.componentcore.internal.Property - * @generated - */ - EClass getProperty(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.Property#getName <em>Name</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Name</em>'. - * @see org.eclipse.wst.common.componentcore.internal.Property#getName() - * @see #getProperty() - * @generated - */ - EAttribute getProperty_Name(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.Property#getValue <em>Value</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Value</em>'. - * @see org.eclipse.wst.common.componentcore.internal.Property#getValue() - * @see #getProperty() - * @generated - */ - EAttribute getProperty_Value(); - - /** - * Returns the meta object for class '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent <em>Referenced Component</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Referenced Component</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ReferencedComponent - * @generated - */ - EClass getReferencedComponent(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getHandle <em>Handle</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Handle</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getHandle() - * @see #getReferencedComponent() - * @generated - */ - EAttribute getReferencedComponent_Handle(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getRuntimePath <em>Runtime Path</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Runtime Path</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getRuntimePath() - * @see #getReferencedComponent() - * @generated - */ - EAttribute getReferencedComponent_RuntimePath(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependencyType <em>Dependency Type</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Dependency Type</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependencyType() - * @see #getReferencedComponent() - * @generated - */ - EAttribute getReferencedComponent_DependencyType(); - - /** - * Returns the meta object for the reference '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependentObject <em>Dependent Object</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference '<em>Dependent Object</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependentObject() - * @see #getReferencedComponent() - * @generated - */ - EReference getReferencedComponent_DependentObject(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getArchiveName <em>Archive Name</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Archive Name</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getArchiveName() - * @see #getReferencedComponent() - * @generated - */ - EAttribute getReferencedComponent_ArchiveName(); - - /** - * Returns the meta object for class '{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents <em>Project Components</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Project Components</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ProjectComponents - * @generated - */ - EClass getProjectComponents(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getProjectName <em>Project Name</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Project Name</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ProjectComponents#getProjectName() - * @see #getProjectComponents() - * @generated - */ - EAttribute getProjectComponents_ProjectName(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getComponents <em>Components</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Components</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ProjectComponents#getComponents() - * @see #getProjectComponents() - * @generated - */ - EReference getProjectComponents_Components(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getVersion <em>Version</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Version</em>'. - * @see org.eclipse.wst.common.componentcore.internal.ProjectComponents#getVersion() - * @see #getProjectComponents() - * @generated - */ - EAttribute getProjectComponents_Version(); - - /** - * Returns the meta object for enum '{@link org.eclipse.wst.common.componentcore.internal.DependencyType <em>Dependency Type</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for enum '<em>Dependency Type</em>'. - * @see org.eclipse.wst.common.componentcore.internal.DependencyType - * @generated - */ - EEnum getDependencyType(); - - /** - * Returns the meta object for data type '{@link org.eclipse.core.runtime.IPath <em>IPath</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for data type '<em>IPath</em>'. - * @see org.eclipse.core.runtime.IPath - * @model instanceClass="org.eclipse.core.runtime.IPath" - * annotation="keywords datatype='null'" - * @generated - */ - EDataType getIPath(); - - /** - * Returns the meta object for data type '{@link org.eclipse.emf.common.util.URI <em>URI</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for data type '<em>URI</em>'. - * @see org.eclipse.emf.common.util.URI - * @model instanceClass="org.eclipse.emf.common.util.URI" - * annotation="keywords datatype='null'" - * @generated - */ - EDataType getURI(); - - /** - * Returns the factory that creates the instances of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the factory that creates the instances of the model. - * @generated - */ - ComponentcoreFactory getComponentcoreFactory(); - - /** - * <!-- begin-user-doc --> - * Defines literals for the meta objects that represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @generated - */ - interface Literals { - /** - * The meta object literal for the '{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl <em>Workbench Component</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getWorkbenchComponent() - * @generated - */ - EClass WORKBENCH_COMPONENT = eINSTANCE.getWorkbenchComponent(); - - /** - * The meta object literal for the '<em><b>Name</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute WORKBENCH_COMPONENT__NAME = eINSTANCE.getWorkbenchComponent_Name(); - - /** - * The meta object literal for the '<em><b>Resources</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference WORKBENCH_COMPONENT__RESOURCES = eINSTANCE.getWorkbenchComponent_Resources(); - - /** - * The meta object literal for the '<em><b>Component Type</b></em>' containment reference feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference WORKBENCH_COMPONENT__COMPONENT_TYPE = eINSTANCE.getWorkbenchComponent_ComponentType(); - - /** - * The meta object literal for the '<em><b>Referenced Components</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference WORKBENCH_COMPONENT__REFERENCED_COMPONENTS = eINSTANCE.getWorkbenchComponent_ReferencedComponents(); - - /** - * The meta object literal for the '<em><b>Properties</b></em>' reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference WORKBENCH_COMPONENT__PROPERTIES = eINSTANCE.getWorkbenchComponent_Properties(); - - /** - * The meta object literal for the '<em><b>Metadata Resources</b></em>' attribute list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute WORKBENCH_COMPONENT__METADATA_RESOURCES = eINSTANCE.getWorkbenchComponent_MetadataResources(); - - /** - * The meta object literal for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl <em>Component Resource</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getComponentResource() - * @generated - */ - EClass COMPONENT_RESOURCE = eINSTANCE.getComponentResource(); - - /** - * The meta object literal for the '<em><b>Source Path</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute COMPONENT_RESOURCE__SOURCE_PATH = eINSTANCE.getComponentResource_SourcePath(); - - /** - * The meta object literal for the '<em><b>Runtime Path</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute COMPONENT_RESOURCE__RUNTIME_PATH = eINSTANCE.getComponentResource_RuntimePath(); - - /** - * The meta object literal for the '<em><b>Exclusions</b></em>' attribute list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute COMPONENT_RESOURCE__EXCLUSIONS = eINSTANCE.getComponentResource_Exclusions(); - - /** - * The meta object literal for the '<em><b>Component</b></em>' container reference feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference COMPONENT_RESOURCE__COMPONENT = eINSTANCE.getComponentResource_Component(); - - /** - * The meta object literal for the '<em><b>Resource Type</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute COMPONENT_RESOURCE__RESOURCE_TYPE = eINSTANCE.getComponentResource_ResourceType(); - - /** - * The meta object literal for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl <em>Component Type</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getComponentType() - * @generated - */ - EClass COMPONENT_TYPE = eINSTANCE.getComponentType(); - - /** - * The meta object literal for the '<em><b>Component Type Id</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute COMPONENT_TYPE__COMPONENT_TYPE_ID = eINSTANCE.getComponentType_ComponentTypeId(); - - /** - * The meta object literal for the '<em><b>Version</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute COMPONENT_TYPE__VERSION = eINSTANCE.getComponentType_Version(); - - /** - * The meta object literal for the '<em><b>Properties</b></em>' reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference COMPONENT_TYPE__PROPERTIES = eINSTANCE.getComponentType_Properties(); - - /** - * The meta object literal for the '<em><b>Metadata Resources</b></em>' attribute list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute COMPONENT_TYPE__METADATA_RESOURCES = eINSTANCE.getComponentType_MetadataResources(); - - /** - * The meta object literal for the '{@link org.eclipse.wst.common.componentcore.internal.impl.PropertyImpl <em>Property</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.PropertyImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getProperty() - * @generated - */ - EClass PROPERTY = eINSTANCE.getProperty(); - - /** - * The meta object literal for the '<em><b>Name</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute PROPERTY__NAME = eINSTANCE.getProperty_Name(); - - /** - * The meta object literal for the '<em><b>Value</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute PROPERTY__VALUE = eINSTANCE.getProperty_Value(); - - /** - * The meta object literal for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl <em>Referenced Component</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getReferencedComponent() - * @generated - */ - EClass REFERENCED_COMPONENT = eINSTANCE.getReferencedComponent(); - - /** - * The meta object literal for the '<em><b>Handle</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute REFERENCED_COMPONENT__HANDLE = eINSTANCE.getReferencedComponent_Handle(); - - /** - * The meta object literal for the '<em><b>Runtime Path</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute REFERENCED_COMPONENT__RUNTIME_PATH = eINSTANCE.getReferencedComponent_RuntimePath(); - - /** - * The meta object literal for the '<em><b>Dependency Type</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute REFERENCED_COMPONENT__DEPENDENCY_TYPE = eINSTANCE.getReferencedComponent_DependencyType(); - - /** - * The meta object literal for the '<em><b>Dependent Object</b></em>' reference feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference REFERENCED_COMPONENT__DEPENDENT_OBJECT = eINSTANCE.getReferencedComponent_DependentObject(); - - /** - * The meta object literal for the '<em><b>Archive Name</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute REFERENCED_COMPONENT__ARCHIVE_NAME = eINSTANCE.getReferencedComponent_ArchiveName(); - - /** - * The meta object literal for the '{@link org.eclipse.wst.common.componentcore.internal.impl.ProjectComponentsImpl <em>Project Components</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.impl.ProjectComponentsImpl - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getProjectComponents() - * @generated - */ - EClass PROJECT_COMPONENTS = eINSTANCE.getProjectComponents(); - - /** - * The meta object literal for the '<em><b>Project Name</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute PROJECT_COMPONENTS__PROJECT_NAME = eINSTANCE.getProjectComponents_ProjectName(); - - /** - * The meta object literal for the '<em><b>Components</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference PROJECT_COMPONENTS__COMPONENTS = eINSTANCE.getProjectComponents_Components(); - - /** - * The meta object literal for the '<em><b>Version</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute PROJECT_COMPONENTS__VERSION = eINSTANCE.getProjectComponents_Version(); - - /** - * The meta object literal for the '{@link org.eclipse.wst.common.componentcore.internal.DependencyType <em>Dependency Type</em>}' enum. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.DependencyType - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getDependencyType() - * @generated - */ - EEnum DEPENDENCY_TYPE = eINSTANCE.getDependencyType(); - - /** - * The meta object literal for the '<em>IPath</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.core.runtime.IPath - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getIPath() - * @generated - */ - EDataType IPATH = eINSTANCE.getIPath(); - - /** - * The meta object literal for the '<em>URI</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.common.util.URI - * @see org.eclipse.wst.common.componentcore.internal.impl.ComponentcorePackageImpl#getURI() - * @generated - */ - EDataType URI = eINSTANCE.getURI(); - - } - -} //ComponentcorePackage diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/DependencyType.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/DependencyType.java deleted file mode 100644 index 09914ab01..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/DependencyType.java +++ /dev/null @@ -1,159 +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.wst.common.componentcore.internal; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.util.AbstractEnumerator; - -/** - * - * <!-- begin-user-doc --> - * Indicates how a particular {@see org.eclipse.wst.common.modulecore.ReferencedComponent} should be - * absorbed by a {@see org.eclipse.wst.common.modulecore.WorkbenchComponent}. - * <p> - * Provides two types ("uses", "consumes") which are used by - * {@see org.eclipse.wst.common.modulecore.ReferencedComponent}s to specify how the - * {@see org.eclipse.wst.common.modulecore.ReferencedComponent} should be absorbed by the - * containing {@see org.eclipse.wst.common.modulecore.WorkbenchComponent}. - * </p> - * For clients that need to create one of these objects from scratch, - * {@see org.eclipse.wst.common.modulecore.ModuleCoreFactory}. - * <p> - * A representation of the literals of the enumeration '<em><b>Dependency Type</b></em>', and - * utility methods for working with them. - * </p> - * <p> - * See the package overview for an <a href="package-summary.html">overview of the model components</a>. - * </p> - * <!-- end-user-doc --> <!-- end-user-doc --> <!-- begin-model-doc --> uses=0 consumes=1 <!-- - * end-model-doc --> - * - * @see org.eclipse.wst.common.componentcore.internal.ModuleCorePackage#getDependencyType() - * @model - * @generated - */ -public final class DependencyType extends AbstractEnumerator { - /** - * The '<em><b>Uses</b></em>' literal value. - * <!-- begin-user-doc --> - * <p> - * If the meaning of '<em><b>Uses</b></em>' literal object isn't clear, there really should - * be more of a description here... - * </p> - * <!-- end-user-doc --> - * @see #USES_LITERAL - * @model name="uses" - * @generated - * @ordered - */ - public static final int USES = 0; - - /** - * The '<em><b>Consumes</b></em>' literal value. - * <!-- begin-user-doc --> - * <p> - * If the meaning of '<em><b>Consumes</b></em>' literal object isn't clear, there really - * should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @see #CONSUMES_LITERAL - * @model name="consumes" - * @generated - * @ordered - */ - public static final int CONSUMES = 1; - - /** - * The '<em><b>Uses</b></em>' literal object. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @see #USES - * @generated - * @ordered - */ - public static final DependencyType USES_LITERAL = new DependencyType(USES, "uses"); - - /** - * The '<em><b>Consumes</b></em>' literal object. <!-- begin-user-doc --> <!-- end-user-doc - * --> - * - * @see #CONSUMES - * @generated - * @ordered - */ - public static final DependencyType CONSUMES_LITERAL = new DependencyType(CONSUMES, "consumes"); - - /** - * An array of all the '<em><b>Dependency Type</b></em>' enumerators. - * <!-- begin-user-doc - * --> <!-- end-user-doc --> - * @generated - */ - private static final DependencyType[] VALUES_ARRAY = - new DependencyType[] { - USES_LITERAL, - CONSUMES_LITERAL, - }; - - /** - * A public read-only list of all the '<em><b>Dependency Type</b></em>' enumerators. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); - - /** - * Returns the '<em><b>Dependency Type</b></em>' literal with the specified name. - * <!-- begin-user-doc --> - * @param name passes literal name - * @return literal instance - * <!-- end-user-doc --> - * @generated - */ - public static DependencyType get(String name) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - DependencyType result = VALUES_ARRAY[i]; - if (result.toString().equals(name)) { - return result; - } - } - return null; - } - - /** - * Returns the '<em><b>Dependency Type</b></em>' literal with the specified value. - * <!-- begin-user-doc --> - * @param value passes literal value - * @return literal instance - * <!-- end-user-doc --> - * @generated - */ - public static DependencyType get(int value) { - switch (value) { - case USES: return USES_LITERAL; - case CONSUMES: return CONSUMES_LITERAL; - } - return null; - } - - /** - * Only this class can construct instances. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - private DependencyType(int value, String name) { - super(value, name); - } - -} //DependencyType diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/IComponentProjectMigrator.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/IComponentProjectMigrator.java deleted file mode 100644 index 0f66ad107..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/IComponentProjectMigrator.java +++ /dev/null @@ -1,18 +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.wst.common.componentcore.internal; - -import org.eclipse.core.resources.IProject; - -public interface IComponentProjectMigrator { - public void migrateProject(IProject project); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleCoreValidator.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleCoreValidator.java deleted file mode 100644 index 0372d3c3c..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleCoreValidator.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.xmi.XMIResource; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesResource; -import org.eclipse.wst.common.internal.emf.resource.TranslatorResource; -import org.eclipse.wst.common.internal.emfworkbench.edit.EMFWorkbenchEditContextFactory; -import org.eclipse.wst.common.project.facet.core.internal.FacetedProjectNature; -import org.eclipse.wst.validation.internal.core.Message; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob; - - -public class ModuleCoreValidator implements IValidatorJob { - protected IReporter _reporter; - - public ModuleCoreValidator() { - super(); - // TODO Auto-generated constructor stub - } - - public Resource getPrimaryResource(IProject project) { - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=181334; Changing this method to call ModuleStructuralModel.getPrimaryResource() method instead. - // This does two things: - // 1. Reorders the locks to prevent deadlock between locking the resource (Bugzilla 181334), - // then the edit model and - // 2. Reuses code. (The code between this method and MSM.getPrimaryResource() is identical. - StructureEdit structureEdit = StructureEdit.getStructureEditForRead(project); - if (structureEdit != null) { - ModuleStructuralModel structuralModel = structureEdit.getModuleStructuralModel(); - if (structuralModel != null) { - // acquiring the ModuleStructuralModel lock here first because the call to getPrimaryResource() - // will cause this lock to be acquired later resulting in a potential deadlock - ILock lock = EMFWorkbenchEditContextFactory.getProjectLockObject(structuralModel.getProject()); - try{ - if(null != lock){ - lock.acquire(); - } - synchronized(structuralModel){ - return structuralModel.getPrimaryResource(); - } - } finally{ - if(null != lock){ - lock.release(); - } - } - } - } - return null; - } - -/* bug197531 - standardize compiler settings - private ResourceSet getResourceSet(IProject proj) { - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(proj); - return nature.getResourceSet(); - } -*/ - - public IStatus validateInJob(IValidationContext helper, IReporter reporter) - throws ValidationException { - _reporter = reporter; - //Remove all markers related to this validator - _reporter.removeAllMessages(this); - //Using the helper class, load the module model - IProject proj = (IProject) helper - .loadModel(ModuleCoreValidatorHelper.MODULECORE, null); - try { - if (proj.isAccessible() && proj.hasNature(ModuleCoreNature.MODULE_NATURE_ID)) { - if (needsMigrating(proj)) - _reporter.addMessage(this, new Message("modulecore", - IMessage.HIGH_SEVERITY, - "NEEDSMIGRATING", null, proj)); - } - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return Status.OK_STATUS; - } - public ISchedulingRule getSchedulingRule(IValidationContext helper) { - return null; - } - - public void cleanup(IReporter reporter) { - _reporter = null; - - } - private boolean needsMigrating(IProject project) throws CoreException { - XMIResource res = (XMIResource)getPrimaryResource(project); - boolean multiComps = false; - if (project==null) - return false; - boolean needsMigrating = (!project.hasNature(FacetedProjectNature.NATURE_ID)) || res == null || ((res != null) && ((WTPModulesResource)res).getRootObject() == null); //|| (res!=null && !res.isLoaded() && ((WTPModulesResource)res).getRootObject() != null); - if (!needsMigrating) { - if (res instanceof TranslatorResource && ((TranslatorResource)res).getRootObject() instanceof ProjectComponents) { - ProjectComponents components = (ProjectComponents) ((WTPModulesResource)res).getRootObject(); - if (components.getComponents() != null) { - multiComps = components.getComponents().size() > 1; - return multiComps; - } - } - } - return needsMigrating; - } - - public void validate(IValidationContext helper, IReporter reporter) - throws ValidationException { - // Forwarding to job method - validateInJob(helper, reporter); - } - } diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleCoreValidatorHelper.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleCoreValidatorHelper.java deleted file mode 100644 index 1969f6193..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleCoreValidatorHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal; - -import org.eclipse.core.resources.IResource; -import org.eclipse.wst.validation.internal.operations.WorkbenchContext; - - -public class ModuleCoreValidatorHelper extends WorkbenchContext { - - public static final String MODULECORE = "MODULECORE"; - public ModuleCoreValidatorHelper() { - super(); - // the following will register the helper's symbolic methods - Class [] args = new Class[0] ; - registerModel(MODULECORE, "loadModel", args); - } - /** - * Load the Trading Session for validation - */ - public Object loadModel() { - return getProject(); - - } - /** - * Given a resource, return its non-eclipse-specific location. If this - * resource, or type of resource, isn't handled by this helper, return - * null. - */ - public String getPortableName(IResource resource) { - - return resource.getFullPath().toString(); - } - } diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleMigratorManager.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleMigratorManager.java deleted file mode 100644 index 88a90787a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleMigratorManager.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal; - -import java.util.HashMap; -import java.util.HashSet; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.datamodel.ProjectMigratorDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IProjectMigratorDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.IWorkspaceRunnableWithStatus; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class ModuleMigratorManager { - - private static HashMap managerCache = new HashMap(); - private static HashSet migrated = new HashSet(); - private boolean migrating; - public ModuleMigratorManager() { - super(); - } - public static ModuleMigratorManager getManager(IProject proj) { - ModuleMigratorManager manager = (ModuleMigratorManager)managerCache.get(proj); - if (manager == null) { - manager = new ModuleMigratorManager(); - managerCache.put(proj,manager); - } - return manager; - } - private void migrateComponentsIfNecessary(IProject project, boolean multiComps) { - - setupAndMigrateComponentProject(project); - - } - private void setupAndMigrateComponentProject(IProject proj) { - migrated.add(proj); - IDataModel dm = DataModelFactory.createDataModel(new ProjectMigratorDataModelProvider()); - dm.setStringProperty(IProjectMigratorDataModelProperties.PROJECT_NAME,proj.getName()); - try { - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - public synchronized void migrateOldMetaData(IProject aProject, final boolean multiComps) throws CoreException { - migrating = true; - IWorkspaceRunnableWithStatus workspaceRunnable = new IWorkspaceRunnableWithStatus(aProject) { - public void run(IProgressMonitor pm) throws CoreException { - IProject aProj = (IProject)this.getInfo(); - try { - if (aProj.isAccessible() && ModuleCoreNature.isFlexibleProject(aProj)) { - if (aProj.findMember(".wtpmodules") != null) { - moveOldMetaDataFile(aProj); - } - if (needsComponentMigration(aProj,multiComps)) - migrateComponentsIfNecessary(aProj,multiComps); - } - } finally { - migrating = false; - } - } - - private boolean needsComponentMigration(IProject aProj,boolean multiComps) throws CoreException { - - boolean needs = true; - if (multiComps) - return (needs && multiComps); - else - return ((aProj.findMember(StructureEdit.MODULE_META_FILE_NAME) == null) && (aProj.findMember(".settings/.component") == null)) || - (ProjectFacetsManager.create(aProj) == null) && needs; - } - }; - - ResourcesPlugin.getWorkspace().run(workspaceRunnable, null,IWorkspace.AVOID_UPDATE,null); - - - - - } - private void moveMetaDataFile(IProject project) { - IResource oldfile = project.findMember(".wtpmodules"); - if (oldfile != null && oldfile.exists()) { - - try { - IFolder settingsFolder = project.getFolder(".settings"); - if (!settingsFolder.exists()) - settingsFolder.create(true,true,null); - oldfile.move(new Path(StructureEdit.MODULE_META_FILE_NAME),true,null); - } catch (CoreException e) { - Platform.getLog(ModulecorePlugin.getDefault().getBundle()).log(new Status(IStatus.ERROR, ModulecorePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); - } - } - } - private void moveOldMetaDataFile(IProject project) { - - try { - moveMetaDataFile(project); - IFolder depFolder = project.getFolder(".deployables"); - if (depFolder.exists()) - depFolder.delete(true, null); - project.refreshLocal(IResource.DEPTH_INFINITE, null); - - } catch (Exception e) { - } - } - public boolean isMigrating() { - return migrating; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleStructuralModel.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleStructuralModel.java deleted file mode 100644 index 2bdacb156..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleStructuralModel.java +++ /dev/null @@ -1,426 +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.wst.common.componentcore.internal; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -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.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.xmi.XMIResource; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeNode; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeRoot; -import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesResource; -import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesResourceFactory; -import org.eclipse.wst.common.frameworks.internal.SaveFailedException; -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; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorPresenter; -import org.eclipse.wst.common.project.facet.core.internal.FacetedProjectNature; -/** - * Manages the underlying Module Structural Metamodel. -* <a name="module-structural-model"/> -* <p> -* Each ModuleCoreNature from a given project can provide access to the -* {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel} of the project. -* {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel} is a subclass of -* {@see org.eclipse.wst.common.internal.emfworkbench.integration.EditModel} that manages -* resources associated with the Module Structural Metamodel. As an EditModel, the -* {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel} references EMF resources, -* that contain EMF models -- in this case, the EMF model of <i>.component </i> file. -* </p> -* <p> -* Clients are encouraged to use the Edit Facade pattern (via -* {@see org.eclipse.wst.common.modulecore.ModuleCore} or one if its relevant subclasses) -* to work directly with the Module Structural Metamodel. -* </p> -* <p> -* <a href="ModuleCoreNature.html#model-discussion">See the discussion</a> of how ModuleStructuralModel relates to the ArtifactEditModel and ModuleCoreNature. -* <a name="accessor-key"/> -* <p> -* All EditModels have a lifecycle that must be enforced to keep the resources loaded that are in -* use, and to unload resources that are not in use. To access an EditModel, clients are required to -* supply an object token referred to as an accessor key. The accessor key allows the framework to -* better track which clients are using the EditModel, and to ensure that only a client which has -* accessed the EditModel with an accessor key may invoke save*()s on that EditModel. -* </p> -*/ -public class ModuleStructuralModel extends EditModel implements IAdaptable { - - public static final String R0_7_MODULE_META_FILE_NAME = ".component"; - public static final String R1_MODULE_META_FILE_NAME = ".settings/.component"; - public static final String MODULE_CORE_ID = "moduleCoreId"; //$NON-NLS-1$ - private static final String PROJECT_VERSION_1_5 = "1.5.0"; - private boolean useOldFormat = false; - public ModuleStructuralModel(String editModelID, EMFWorkbenchContext context, boolean readOnly) { - super(editModelID, context, readOnly); - } - /** - * Release each of the referenced resources. - */ - protected void release(ReferencedResource aResource) { - if (isReadOnly() && aResource.getReadCount() != 0) - aResource.releaseFromRead(); - else - aResource.releaseFromWrite(); - - } - protected boolean removeResource(Resource aResource) { - if (aResource != null) { - //First checking if resource is loaded (Which will prevent removing in middle of loading by checking resource adapter lock) - aResource.isLoaded(); - synchronized (aResource) { - aResource.eAdapters().remove(resourceAdapter); - return getResources().remove(aResource); - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModel#getPrimaryRootObject() - */ - public EObject getPrimaryRootObject() { - - try { - Resource res = prepareProjectModulesIfNecessary(); - if (res == null) - return null; - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - EObject modelRoot = null; - modelRoot = super.getPrimaryRootObject(); - if (modelRoot != null) { - // if the workspace tree is locked we cannot try to change the .component resource - if (ResourcesPlugin.getWorkspace().isTreeLocked()) - return modelRoot; - List components = ((ProjectComponents)modelRoot).getComponents(); - if (components.size()>0) { - WorkbenchComponent wbComp = (WorkbenchComponent)components.get(0); - // Check and see if we need to clean up spurrious redundant map entries - if (!isVersion15(modelRoot)) { - ((ProjectComponents)modelRoot).setVersion(PROJECT_VERSION_1_5); - cleanupWTPModules(wbComp); - } - } - } - return modelRoot; - } - private boolean isVersion15(EObject modelRoot){ - return ((ProjectComponents)modelRoot).getVersion().equals(PROJECT_VERSION_1_5); - } - - /** - * This method is used to remove spurrious redundant entries from the .component file - * - * @param wbComp - */ - public void cleanupWTPModules(WorkbenchComponent wbComp) { - if (wbComp == null) - return; - ResourceTreeRoot root = ResourceTreeRoot.getSourceResourceTreeRoot(wbComp); - List rootResources = getModuleResources(root); - // Only if we need to do a clean, do we clear, add all required root resource mappings, and save - if (!(wbComp.getResources().containsAll(rootResources) && wbComp.getResources().size()==rootResources.size())) { - final ModuleStructuralModel model = new ModuleStructuralModel(getEditModelID(),getEmfContext(),false); - if(model == null){ - return; - } - boolean jobScheduled = false; - try { - final Object key = new Object(); - model.access(key); - - wbComp.getResources().clear(); - wbComp.getResources().addAll(rootResources); - URI uri = wbComp.eResource().getURI(); - //need to get this resource into the model - Resource resource = model.getResource(uri); - //need to manually dirty this resource in order for it to save. - resource.setModified(true); - //this job is necessary to avoid the deadlock in - //https://bugs.eclipse.org/bugs/show_bug.cgi?id=181253 - class SaveJob extends Job { - - public SaveJob() { - super("Save ModuleStructuralModel Job"); - } - - protected IStatus run(IProgressMonitor monitor) { - try { - model.save(key); - return OK_STATUS; - } finally { - disposeOnce(); - } - } - - private boolean disposedAlready = false; - - public void disposeOnce(){ - if(!disposedAlready){ - disposedAlready = true; - model.dispose(); - } - } - }; - final SaveJob saveJob = new SaveJob(); - saveJob.addJobChangeListener(new JobChangeAdapter(){ - public void done(IJobChangeEvent event) { - saveJob.disposeOnce(); - } - }); - saveJob.setSystem(true); - saveJob.schedule(); - jobScheduled = true; - } finally { - if (!jobScheduled && model != null) - model.dispose(); - } - } - } - - /** - * This is a recursive method to find all the root level resources in the children's resource tree roots - * - * @param node - * @return List of module resources - */ - public List getModuleResources(ResourceTreeNode node) { - // If the resource node has module resources just return them - if (node.getModuleResources().length>0) - return Arrays.asList(node.getModuleResources()); - // Otherwise, the root resource maps are really at the next level or lower - List rootResources = new ArrayList(); - Map children = node.getChildren(); - Iterator iter = children.values().iterator(); - while (iter.hasNext()) { - ResourceTreeNode subNode = (ResourceTreeNode) iter.next(); - // recursively call method to obtain module resources - rootResources.addAll(getModuleResources(subNode)); - } - return rootResources; - } - public Resource prepareProjectModulesIfNecessary() throws CoreException { - XMIResource res; - if (!isComponentSynchronizedOrNull()) { - //Return if component file is out of sync from workspace - return null; - } - res = (XMIResource) getPrimaryResource(); - if (res != null && resNeedsMigrating(res) && !useOldFormat) - return null; - if(res == null) - res = makeWTPModulesResource(); - try { - addProjectModulesIfNecessary(res); - } catch (IOException e) { - Platform.getLog(ModulecorePlugin.getDefault().getBundle()).log(new Status(IStatus.ERROR, ModulecorePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); - } - return res; - } - - /** - * This methods checks the status of the component file, and first checks for existance, then if its locally synchronized - * @return boolean - */ - private boolean isComponentSynchronizedOrNull() { - IFile componentFile = getProject().getFile(StructureEdit.MODULE_META_FILE_NAME); - IPath componentFileLocation = componentFile.getLocation(); - if (componentFileLocation != null && !componentFileLocation.toFile().exists()) { - componentFile = getProject().getFile(R1_MODULE_META_FILE_NAME); - componentFileLocation = componentFile.getLocation(); - if (componentFileLocation != null && !componentFileLocation.toFile().exists()) { - componentFile = getProject().getFile(R0_7_MODULE_META_FILE_NAME); - componentFileLocation = componentFile.getLocation(); - if (componentFileLocation != null && !componentFileLocation.toFile().exists()) - return true; - } - } - if (componentFileLocation == null) - return true; - else return componentFile.isSynchronized(IResource.DEPTH_ZERO); - } - - public IFile getComponentFile() { - IFile compFile = getProject().getFile(StructureEdit.MODULE_META_FILE_NAME); - if (compFile.isAccessible()) - return compFile; - else { //Need to check for legacy file locations also.... - compFile = getProject().getFile(ModuleStructuralModel.R1_MODULE_META_FILE_NAME); - if (compFile.isAccessible()) - return compFile; - else { - compFile = getProject().getFile(ModuleStructuralModel.R0_7_MODULE_META_FILE_NAME); - if (compFile.isAccessible()) - return compFile; - } - } - return getProject().getFile(StructureEdit.MODULE_META_FILE_NAME); - } - - public WTPModulesResource makeWTPModulesResource() { - return (WTPModulesResource) createResource(WTPModulesResourceFactory.WTP_MODULES_URI_OBJ); - } - 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); - } - } - /** - * @see org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidator#checkActivation(ResourceStateValidatorPresenter) - */ - public void checkActivation(ResourceStateValidatorPresenter presenter) throws CoreException { - super.checkActivation(presenter); - } - /** - * Subclasses can override - by default this will return the first resource referenced by the - * known resource URIs for this EditModel - * - * @return - */ - public Resource getPrimaryResource() { - // Overriden to handle loading the .component resource in new and old forms - // First will try to load from .settings/org.eclipse.wst.common.component - // Second will try to load from the old location(s) .settings/.component or .component - - URI uri = URI.createURI(StructureEdit.MODULE_META_FILE_NAME); - WTPModulesResource res = (WTPModulesResource)getResource(uri); - if (res == null || !res.isLoaded()) { - removeResource(res); - uri = URI.createURI(R1_MODULE_META_FILE_NAME); - res = (WTPModulesResource)getResource(uri); - if (res == null || !res.isLoaded()) { - removeResource(res); - uri = URI.createURI(R0_7_MODULE_META_FILE_NAME); - res = (WTPModulesResource)getResource(uri); - if (res == null || !res.isLoaded()) { - removeResource(res); - res = null; - } - } - } - return res; - } - - public Object getAdapter(Class anAdapter) { - return Platform.getAdapterManager().getAdapter(this, anAdapter); - } - - protected void addProjectModulesIfNecessary(XMIResource aResource) throws IOException { - - if (aResource != null) { - if(aResource.getContents().isEmpty()) { - ProjectComponents projectModules = ComponentcorePackage.eINSTANCE.getComponentcoreFactory().createProjectComponents(); - projectModules.setProjectName(project.getName()); - aResource.getContents().add(projectModules); - aResource.setID(projectModules, MODULE_CORE_ID); - } - } - } - private boolean resNeedsMigrating(XMIResource res) throws CoreException { - boolean multiComps = false; - if (project==null) - return false; - boolean needsMigrating = (!project.hasNature(FacetedProjectNature.NATURE_ID)) || res == null || ((res != null) && ((WTPModulesResource)res).getRootObject() == null); - if (!needsMigrating) { - if (res instanceof TranslatorResource && ((TranslatorResource)res).getRootObject() instanceof ProjectComponents) { - ProjectComponents components = (ProjectComponents) ((WTPModulesResource)res).getRootObject(); - if (components.getComponents() != null) { - multiComps = components.getComponents().size() > 1; - return multiComps; - } - } - } - return needsMigrating; - } - protected Resource getAndLoadLocalResource(URI aUri) { - - Resource resource = getLocalResource(aUri); - if (null != resource) { - if (!resource.isLoaded()) { - try { - resource.load(Collections.EMPTY_MAP); // reload it - } catch (IOException e) { - // Ignore - } - } - } - return resource; - } - - public void setUseOldFormat(boolean useOldFormat) { - this.useOldFormat = useOldFormat; - } - - public void saveIfNecessary(IProgressMonitor monitor, Object accessorKey) { - // Always force save - super.save(monitor, accessorKey); - } - @Override - public void access(Object accessorKey) { - - super.access(accessorKey); -// StringBuffer buffer = new StringBuffer("Access Module model ("); -// buffer.append(this.hashCode()); -// buffer.append(") Project: "); -// buffer.append(this.getProject()); -// if (isReadOnly()) -// buffer.append(" R = "); //$NON-NLS-1$ -// else -// buffer.append(" W = "); //$NON-NLS-1$ -// buffer.append(getRegistry().size()); -// System.out.println(buffer.toString()); - - } - @Override - public void releaseAccess(Object accessorKey) { - - super.releaseAccess(accessorKey); -// StringBuffer buffer = new StringBuffer("Release Module model ("); -// buffer.append(this.hashCode()); -// buffer.append(") Project: "); -// buffer.append(this.getProject()); -// if (isReadOnly()) -// buffer.append(" R = "); //$NON-NLS-1$ -// else -// buffer.append(" W = "); //$NON-NLS-1$ -// buffer.append(getRegistry().size()); -// System.out.println(buffer.toString()); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModulecorePlugin.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModulecorePlugin.java deleted file mode 100644 index abb55db01..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModulecorePlugin.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.impl.PlatformURLModuleConnection; -import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesInit; -import org.eclipse.wst.common.componentcore.internal.util.ArtifactEditAdapterFactory; -import org.eclipse.wst.common.componentcore.internal.util.ModuleCoreEclipseAdapterFactory; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.osgi.framework.BundleContext; -import java.lang.Throwable; -import org.eclipse.core.runtime.CoreException; - -/** - * The main plugin class to be used in the desktop. - */ -public class ModulecorePlugin extends Plugin { - //The shared instance. - private static ModulecorePlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; - //plugin id - public static final String PLUGIN_ID = "org.eclipse.wst.common.modulecore"; //$NON-NLS-1$ - - /** - * The constructor. - */ - public ModulecorePlugin() { - super(); - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public synchronized void start(BundleContext context) throws Exception { - - super.start(context); - IAdapterManager manager = Platform.getAdapterManager(); - - manager.registerAdapters(new ModuleCoreEclipseAdapterFactory(), ModuleStructuralModel.class); - manager.registerAdapters(new ArtifactEditAdapterFactory(), ArtifactEditModel.class); - manager.registerAdapters(new ArtifactEditAdapterFactory(), ArtifactEdit.class); - manager.registerAdapters(new ArtifactEditAdapterFactory(), IVirtualComponent.class); - manager.registerAdapters(new ModuleCoreEclipseAdapterFactory(), IResource.class); - - PlatformURLModuleConnection.startup(); - WTPModulesInit.init(); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - resourceBundle = null; - } - - /** - * Returns the shared instance. - */ - public static ModulecorePlugin getDefault() { - return plugin; - } - - /** - * Returns the string from the plugin's resource bundle, - * or 'key' if not found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = ModulecorePlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - try { - if (resourceBundle == null) - resourceBundle = ResourceBundle.getBundle("modulecore"); //$NON-NLS-1$ - } catch (MissingResourceException x) { - resourceBundle = null; - } - return resourceBundle; - } - - - /** - * Record an error against this plugin's log. - * - * @param aCode - * @param aMessage - * @param anException - */ - public static void logError(int aCode, String aMessage, - Throwable anException) { - getDefault().getLog().log( - createErrorStatus(aCode, aMessage, anException)); - } - - /** - * - * Record a message against this plugin's log. - * - * @param severity - * @param aCode - * @param aMessage - * @param exception - */ - public static void log(int severity, int aCode, String aMessage, - Throwable exception) { - log(createStatus(severity, aCode, aMessage, exception)); - } - - /** - * - * Record a status against this plugin's log. - * - * @param aStatus - */ - public static void log(IStatus aStatus) { - getDefault().getLog().log(aStatus); - } - - /** - * Create a status associated with this plugin. - * - * @param severity - * @param aCode - * @param aMessage - * @param exception - * @return A status configured with this plugin's id and the given parameters. - */ - public static IStatus createStatus(int severity, int aCode, - String aMessage, Throwable exception) { - return new Status(severity, PLUGIN_ID, aCode, - aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$ - } - - /** - * - * @param aCode - * @param aMessage - * @param exception - * @return A status configured with this plugin's id and the given parameters. - */ - public static IStatus createErrorStatus(int aCode, String aMessage, - Throwable exception) { - return createStatus(IStatus.ERROR, aCode, aMessage, exception); - } - - 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.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ProjectComponents.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ProjectComponents.java deleted file mode 100644 index 70a8a807d..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ProjectComponents.java +++ /dev/null @@ -1,110 +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.wst.common.componentcore.internal; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * Provides a root object to store and manage the - * {@see org.eclipse.wst.common.modulecore.WorkbenchComponent}s. * - * <p> - * See the package overview for an <a href="package-summary.html">overview of the model components </a>. - * </p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getProjectName <em>Project Name</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getComponents <em>Components</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getVersion <em>Version</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getProjectComponents() - * @model - * @generated - */ -public interface ProjectComponents extends EObject { - /** - * Returns the value of the '<em><b>Project Name</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc - * --> - * <p> - * If the meaning of the '<em>Project Name</em>' attribute isn't clear, there really should - * be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Project Name</em>' attribute. - * @see #setProjectName(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getProjectComponents_ProjectName() - * @model default="" required="true" - * @generated - */ - String getProjectName(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getProjectName <em>Project Name</em>}' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @param value the new value of the '<em>Project Name</em>' attribute. - * @see #getProjectName() - * @generated - */ - void setProjectName(String value); - - /** - * Returns the value of the '<em><b>Components</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Components</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Components</em>' containment reference list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getProjectComponents_Components() - * @model type="org.eclipse.wst.common.componentcore.internal.WorkbenchComponent" containment="true" - * @generated - */ - EList getComponents(); - - /** - * Returns the value of the '<em><b>Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Version</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Version</em>' attribute. - * @see #setVersion(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getProjectComponents_Version() - * @model required="true" - * @generated - */ - String getVersion(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents#getVersion <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Version</em>' attribute. - * @see #getVersion() - * @generated - */ - void setVersion(String value); - - public WorkbenchComponent findWorkbenchModule(String aDeployName); - -} // ProjectComponents diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ProjectMigratorRegistry.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ProjectMigratorRegistry.java deleted file mode 100644 index f6883caec..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ProjectMigratorRegistry.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 29, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.componentcore.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jem.util.RegistryReader; - -/** - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class ProjectMigratorRegistry extends RegistryReader { - - static final String EXTENSION_NAME = "ComponentProjectMigrator"; //$NON-NLS-1$ - static final String ELEMENT_MIGRATOR_EXTENSION = "migratorExtension"; //$NON-NLS-1$ - static final String MIGRATOR_CLASS = "class"; //$NON-NLS-1$ - private List projectMigrators = new ArrayList(); - private static ProjectMigratorRegistry INSTANCE = null; - - public ProjectMigratorRegistry() { - super(ModulecorePlugin.PLUGIN_ID, EXTENSION_NAME); - } - - public static ProjectMigratorRegistry getInstance() { - if (INSTANCE == null) { - INSTANCE = new ProjectMigratorRegistry(); - INSTANCE.readRegistry(); - } - return INSTANCE; - } - - /** - * readElement() - parse and deal w/ an extension like: <earModuleExtension extensionClass = - * "com.ibm.etools.web.plugin.WebModuleExtensionImpl"/> - */ - public boolean readElement(IConfigurationElement element) { - if (!element.getName().equals(ELEMENT_MIGRATOR_EXTENSION)) - return false; - - IComponentProjectMigrator migrator = null; - try { - migrator = (IComponentProjectMigrator) element.createExecutableExtension(MIGRATOR_CLASS); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (migrator != null) - addModuleExtension(migrator); - return true; - } - - public IComponentProjectMigrator[] getProjectMigrators(){ - return (IComponentProjectMigrator[])projectMigrators.toArray(new IComponentProjectMigrator[projectMigrators.size()]); - } - private void addModuleExtension(IComponentProjectMigrator ext) { - projectMigrators.add(ext); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/Property.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/Property.java deleted file mode 100644 index 350f111ed..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/Property.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: Property.java,v 1.2 2006/04/27 04:17:40 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Property</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.Property#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.Property#getValue <em>Value</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getProperty() - * @model - * @generated - */ -public interface Property extends EObject { - /** - * Returns the value of the '<em><b>Name</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Name</em>' attribute. - * @see #setName(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getProperty_Name() - * @model default="" required="true" - * @generated - */ - String getName(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.Property#getName <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Name</em>' attribute. - * @see #getName() - * @generated - */ - void setName(String value); - - /** - * Returns the value of the '<em><b>Value</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Value</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Value</em>' attribute. - * @see #setValue(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getProperty_Value() - * @model default="" required="true" - * @generated - */ - String getValue(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.Property#getValue <em>Value</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Value</em>' attribute. - * @see #getValue() - * @generated - */ - void setValue(String value); - -} // Property diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ReferencedComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ReferencedComponent.java deleted file mode 100644 index dea5cf0be..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ReferencedComponent.java +++ /dev/null @@ -1,183 +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.wst.common.componentcore.internal; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * Used to reference {@see org.eclipse.wst.common.modulecore.WorkbenchComponent}s either contained in - * the same project or remotely. - * <p> - * Each {@see org.eclipse.wst.common.modulecore.WorkbenchComponent} contains a list of its - * DependentModules. - * </p> - * <p> - * The referenced {@see WorkbenchComponent} may be in the same project as the - * {@see WorkbenchComponent} that contains the current ReferencedComponent. Use - * {@see ModuleCore#isLocalDependency(ReferencedComponent)} to make the determination. - * </p> - * <p> - * See the package overview for an <a href="package-summary.html">overview of the model components </a>. - * </p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getHandle <em>Handle</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getRuntimePath <em>Runtime Path</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependencyType <em>Dependency Type</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependentObject <em>Dependent Object</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getArchiveName <em>Archive Name</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getReferencedComponent() - * @model - * @generated - */ -public interface ReferencedComponent extends EObject { - /** - * Returns the value of the '<em><b>Handle</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * Returns a fully-qualified URI that conforms to the standard "module:" URI format. The handle - * references the {@see WorkbenchComponent}represented by the current ReferencedComponent. - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Handle</em>' attribute. - * @see #setHandle(URI) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getReferencedComponent_Handle() - * @model dataType="org.eclipse.wst.common.componentcore.internal.URI" required="true" - * @generated - */ - URI getHandle(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getHandle <em>Handle</em>}' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @param value the new value of the '<em>Handle</em>' attribute. - * @see #getHandle() - * @generated - */ - void setHandle(URI value); - - /** - * Returns the value of the '<em><b>Runtime Path</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Runtime Path</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Runtime Path</em>' attribute. - * @see #setRuntimePath(IPath) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getReferencedComponent_RuntimePath() - * @model dataType="org.eclipse.wst.common.componentcore.internal.IPath" required="true" - * @generated - */ - IPath getRuntimePath(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getRuntimePath <em>Runtime Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Runtime Path</em>' attribute. - * @see #getRuntimePath() - * @generated - */ - void setRuntimePath(IPath value); - - /** - * Returns the value of the '<em><b>Dependency Type</b></em>' attribute. The literals are - * from the enumeration {@link org.eclipse.wst.common.componentcore.internal.DependencyType}. <!-- - * begin-user-doc --> - * <p> - * See the class documentation {@see DependencyType}for information on the purpose of this - * field. - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Dependency Type</em>' attribute. - * @see org.eclipse.wst.common.componentcore.internal.DependencyType - * @see #setDependencyType(DependencyType) - * @see org.eclipse.wst.common.componentcore.internal.ModuleCorePackage#getDependentModule_DependencyType() - * @model - * @generated - */ - DependencyType getDependencyType(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependencyType <em>Dependency Type</em>}' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @param value the new value of the '<em>Dependency Type</em>' attribute. - * @see org.eclipse.wst.common.componentcore.internal.DependencyType - * @see #getDependencyType() - * @generated - */ - void setDependencyType(DependencyType value); - - /** - * Returns the value of the '<em><b>Dependent Object</b></em>' reference. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Dependent Object</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Dependent Object</em>' reference. - * @see #setDependentObject(EObject) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getReferencedComponent_DependentObject() - * @model - * @generated - */ - EObject getDependentObject(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getDependentObject <em>Dependent Object</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Dependent Object</em>' reference. - * @see #getDependentObject() - * @generated - */ - void setDependentObject(EObject value); - - /** - * Returns the value of the '<em><b>Archive Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Archive Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Archive Name</em>' attribute. - * @see #setArchiveName(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getReferencedComponent_ArchiveName() - * @model - * @generated - */ - String getArchiveName(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent#getArchiveName <em>Archive Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Archive Name</em>' attribute. - * @see #getArchiveName() - * @generated - */ - void setArchiveName(String value); - -} // ReferencedComponent diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/StructureEdit.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/StructureEdit.java deleted file mode 100644 index 9b04b0097..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/StructureEdit.java +++ /dev/null @@ -1,972 +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.wst.common.componentcore.internal; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jem.util.UIContextDetermination; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.IEditModelHandler; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.impl.PlatformURLModuleConnection; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeNode; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualReference; -import org.eclipse.wst.common.componentcore.internal.util.EclipseResourceAdapter; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil; -import org.eclipse.wst.common.internal.emfworkbench.edit.EMFWorkbenchEditContextFactory; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.IValidateEditContext; - -/** - * <p> - * Provides a Facade pattern for accessing the Web Tools Platform EMF Module Model. ModuleCore can - * be used as a static utility or an instance adapter. - * </p> - * <p> - * ModuleCore hides the management of accessing EditModels ( - * {@see org.eclipse.wst.common.modulecore.ModuleStructuralModel}) correctly. Each project has - * exactly one ({@see org.eclipse.wst.common.modulecore.ModuleStructuralModel}) for read and - * exactly one for write. Each of these is shared among all clients and reference counted as - * necessary. Clients should use ModuleCore when working with the WTP Modules Strcutrual Model. - * </p> - * - * <p> - * Each ModuleCore edit facade is designed to manage the EditModel lifecycle for clients. However, - * while each ModuleCore is designed to be passed around as needed, clients must enforce the - * ModuleCore lifecycle. The most common method of acquiring a ModuleCore edit facade is to use - * {@see #getModuleCoreForRead(IProject)} or {@see #getModuleCoreForWrite(IProject)}. - * </p> - * <p> - * When clients have concluded their use of their ModuleCore instance adapter , <b>clients must call - * {@see #dispose()}</b>. - * </p> - * <p> - * For more information about the underlying EditModel, see <a - * href="ModuleCoreNature.html#module-structural-model">the discussion of the ModuleStructuralModel - * </a>. - * <p> - * The following class is experimental until fully documented. - * </p> - * - * @see org.eclipse.wst.common.componentcore.ModuleCoreNature - * @see org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel - */ -public class StructureEdit implements IEditModelHandler { - - public static final Class ADAPTER_TYPE = StructureEdit.class; - - public static String MODULE_META_FILE_NAME = ".settings/org.eclipse.wst.common.component"; //$NON-NLS-1$ - - private final static ComponentcoreFactory COMPONENT_FACTORY = ComponentcoreFactory.eINSTANCE; - private static final ComponentResource[] NO_RESOURCES = new ComponentResource[0]; - - private final ModuleStructuralModel structuralModel; - private final Map dependentCores = new HashMap(); - private IProject aProject; - private boolean isStructuralModelSelfManaged; - private boolean isReadOnly; - - private static final WorkbenchComponent[] NO_COMPONENTS = new WorkbenchComponent[0]; - - /** - * - * <p> - * Each ModuleCore edit facade is tied to a specific project. A project - * may have multiple ModuleCore edit facades live at any given time. - * </p> - * <p> - * Use to acquire a ModuleCore facade for a specific project that will not - * be used for editing. Invocations of any save*() API on an instance - * returned from This method will throw exceptions. - * </p> - * - * @param aProject - * The IProject that contains the WTP Modules model to load - * @return A ModuleCore edit facade to access the WTP Modules Model, null - * for non-flexible projects - */ - public static StructureEdit getStructureEditForRead(IProject aProject) { - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(aProject); - return nature != null ? new StructureEdit(nature, true) : null; - } - - /** - * - * <p> - * Each ModuleCore edit facade is tied to a specific project. A project may have multiple - * ModuleCore edit facades live at any given time. - * </p> - * <p> - * Use to acquire a ModuleCore facade for a specific project that may be used to modify the - * model. - * </p> - * - * @param aProject - * The IProject that contains the WTP Modules model to load - * @return A ModuleCore edit facade to access the WTP Modules Model - */ - public static StructureEdit getStructureEditForWrite(IProject aProject) { - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(aProject); - return nature != null ? new StructureEdit(nature, false) : null; - } - - /** - * <p> - * A convenience API to fetch the {@see ModuleCoreNature} for a particular module URI. The - * module URI must be of the valid form, or an exception will be thrown. The module URI must be - * contained by a project that has a {@see ModuleCoreNature} or null will be returned. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * @param aModuleURI - * A valid, fully-qualified module URI - * @return The ModuleCoreNature of the project associated with aModuleURI - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public static ModuleCoreNature getModuleCoreNature(URI aModuleURI) throws UnresolveableURIException { - IProject container = getContainingProject(aModuleURI); - if (container != null) - return ModuleCoreNature.getModuleCoreNature(container); - return null; - } - - /** - * <p> - * For {@see WorkbenchComponent}s that are contained within a project, the containing project - * can be determined with the {@see WorkbenchComponent}'s fully-qualified module URI. - * </p> - * <p> - * The following method will return the the corresponding project for the supplied module URI, - * if it can be determined. - * </p> - * <p> - * The method will not return an inaccessible project. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * @param aModuleURI - * A valid, fully-qualified module URI - * @return The project that contains the module referenced by the module URI - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public static IProject getContainingProject(WorkbenchComponent aComponent) { - IProject project = ProjectUtilities.getProject(aComponent); - if (project != null && project.isAccessible()) - return project; - return null; - } - - /** - * <p> - * For {@see WorkbenchComponent}s that are contained within a project, the containing project - * can be determined with the {@see WorkbenchComponent}'s fully-qualified module URI. - * </p> - * <p> - * The following method will return the the corresponding project for the supplied module URI, - * if it can be determined. - * </p> - * <p> - * The method will not return an inaccessible project. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * @param aModuleURI - * A valid, fully-qualified module URI - * @return The project that contains the module referenced by the module URI - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public static IProject getContainingProject(URI aModuleURI) throws UnresolveableURIException { - ModuleURIUtil.ensureValidFullyQualifiedModuleURI(aModuleURI); - String projectName = aModuleURI.segment(ModuleURIUtil.ModuleURI.PROJECT_NAME_INDX); - if (projectName == null || projectName.length() == 0) - throw new UnresolveableURIException(aModuleURI); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if (project.isAccessible()) - return project; - return null; - } - - /** - * <p> - * Returns the corresponding Eclipse IResource, if it can be determined, for the given - * {@see ComponentResource}. The {@see ComponentResource#getSourcePath()} must return a - * valid resource path for This method to return a valid value. The returned value may be either - * an {@see org.eclipse.core.resources.IFile} or {@see org.eclipse.core.resources.IFolder}. - * A client may use the return value of {@see IResource#getType()} to determine what type - * of resource was returned. (@see IResource#FILE} or {@see IResource#FOLDER}). - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * @param aModuleResource - * A ComponentResource with a valid sourcePath - * @return The corresponding Eclipse IResource, if available. - */ - public static IResource getEclipseResource(ComponentResource aModuleResource) { - EclipseResourceAdapter eclipseResourceAdapter = (EclipseResourceAdapter) ExtendedEcoreUtil.getAdapter(aModuleResource,aModuleResource.eAdapters(), EclipseResourceAdapter.ADAPTER_TYPE); - if (eclipseResourceAdapter != null) - return eclipseResourceAdapter.getEclipseResource(); - eclipseResourceAdapter = new EclipseResourceAdapter(); - aModuleResource.eAdapters().add(eclipseResourceAdapter); - return eclipseResourceAdapter.getEclipseResource(); - } - - /** - * <p> - * Parses the supplied URI for the deployed name name of the {@see WorkbenchComponent} referenced - * by the URI. - * </p> - * - * @param aFullyQualifiedModuleURI - * A valid, fully-qualified module URI - * @return The deployed name of the referenced {@see WorkbenchComponent} - * @throws UnresolveableURIException - * If the supplied URI is invalid or unresolveable - */ - public static String getDeployedName(URI aFullyQualifiedModuleURI) throws UnresolveableURIException { - return ModuleURIUtil.getDeployedName(aFullyQualifiedModuleURI); - } - - //public static ComponentType getComponentType(IVirtualContainer aComponent) { - public static ComponentType getComponentType(IVirtualComponent aComponent) { - StructureEdit componentCore = null; - ComponentType componentType = null; - try { - componentCore = StructureEdit.getStructureEditForRead(aComponent.getProject()); - WorkbenchComponent wbComponent = componentCore.getComponent(); - componentType = wbComponent.getComponentType(); - } finally { - if (componentCore != null) - componentCore.dispose(); - } - return componentType; - } - - public static IVirtualReference createVirtualReference(IVirtualComponent context, ReferencedComponent referencedComponent) { - - IVirtualComponent targetComponent = null; - IProject targetProject = null; - URI uri = referencedComponent.getHandle(); - if (uri == null) - return null; - boolean isClassPathURI = ModuleURIUtil.isClassPathURI(uri); - if( !isClassPathURI ){ - try { - targetProject = StructureEdit.getContainingProject(uri); - } catch(UnresolveableURIException uurie) { - //Ignore - } - // if the project cannot be resolved, assume it's local - really it probably deleted - - targetComponent = ComponentCore.createComponent(targetProject); - - - }else{ - String archiveType = ""; //$NON-NLS-1$ - String archiveName = ""; //$NON-NLS-1$ - try { - archiveType = ModuleURIUtil.getArchiveType(uri); - archiveName = ModuleURIUtil.getArchiveName(uri); - - } catch (UnresolveableURIException e) { - //Ignore - } - targetComponent = ComponentCore.createArchiveComponent(context.getProject(), archiveType + IPath.SEPARATOR + archiveName ); - } - return new VirtualReference(context, targetComponent, referencedComponent.getRuntimePath(), referencedComponent.getDependencyType().getValue()); - } - - protected StructureEdit(ModuleCoreNature aNature, boolean toAccessAsReadOnly) { - if (toAccessAsReadOnly) - structuralModel = aNature.getModuleStructuralModelForRead(this); - else - structuralModel = aNature.getModuleStructuralModelForWrite(this); - aProject = aNature.getProject(); - isReadOnly = toAccessAsReadOnly; - isStructuralModelSelfManaged = true; - } - - /** - * <p> - * The following constructor is used to manage an already loaded model. Clients should use the - * following line if they intend to use this constructor: <br> - * <br> - * <code>ModuleCore componentCore = (ModuleCore) aStructuralModel.getAdapter(ModuleCore.ADAPTER_TYPE)</code>. - * </p> - * - * @param aStructuralModel - * The edit model to be managed by this ModuleCore - */ - public StructureEdit(ModuleStructuralModel aStructuralModel) { - structuralModel = aStructuralModel; - aProject = aStructuralModel.getProject(); - } - - /** - * <p> - * Force a save of the underlying model. The following method should be used with care. Unless - * required, use {@see #saveIfNecessary(IProgressMonitor) instead. - * </p> - * {@inheritDoc} - * - * @see org.eclipse.wst.common.componentcore.IEditModelHandler#save() - * @throws IllegalStateException - * If the ModuleCore object was created as read-only - */ - public void save(IProgressMonitor aMonitor) { - if (isReadOnly) - throwAttemptedReadOnlyModification(); - else if (validateEdit().isOK()) { - synchronized (structuralModel) { - if (!structuralModel.isDisposed()) - structuralModel.save(aMonitor, this); - } - } - } - - /** - * <p> - * Save the underlying model only if no other clients are currently using the model. If the - * model is not shared, it will be saved. If it is shared, the save will be deferred. - * </p> - * {@inheritDoc} - * - * @see org.eclipse.wst.common.componentcore.IEditModelHandler#saveIfNecessary() - * @throws IllegalStateException - * If the ModuleCore object was created as read-only - */ - public void saveIfNecessary(IProgressMonitor aMonitor) { - if (isReadOnly) - throwAttemptedReadOnlyModification(); - else if (validateEdit().isOK()) { - if (!structuralModel.isDisposed()) - structuralModel.saveIfNecessary(aMonitor, this); - } - } - - /** - * <p> - * Clients must call the following method when they have finished using the model, even if the - * ModuleCore edit facade was created as read-only. - * </p> - * {@inheritDoc} - * - * @see org.eclipse.wst.common.componentcore.IEditModelHandler#dispose() - */ - public void dispose() { - if (isStructuralModelSelfManaged && structuralModel!=null) { - synchronized (structuralModel) { - if (!structuralModel.isDisposed()) - structuralModel.releaseAccess(this); - } - } - if (dependentCores!=null && dependentCores.size() > 0) { - synchronized (dependentCores) { - for (Iterator cores = dependentCores.values().iterator(); cores.hasNext();) { - StructureEdit core = (StructureEdit) cores.next(); - if (core != null) - core.dispose(); - } - } - } - } - - /** - * <p> - * Creates a default WTP Module Structural Metamodel file if necessary. - * </p> - */ - public void prepareProjectComponentsIfNecessary() { - - synchronized (structuralModel) { - if (!structuralModel.isDisposed()) { - try { - structuralModel.prepareProjectModulesIfNecessary(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - } - - /** - * <p> - * When loaded for write, the current ModuleCore may return the root object, which can be used - * to add or remove {@see WorkbenchComponent}s. If a client needs to just read the existing - * {@see WorkbenchComponent}s, use {@see #getWorkbenchModules()}. - * </p> - * <p> - * Deadlock Warning: Calling this method requires two locks. First the component file's file lock - * is required and then the EMFWorkbenchEditContextFactory's projectILock is required. If another - * thread acquires these same two locks in the opposite order, deadlock could occur. - * </p> - * - * @return The root object of the underlying model - */ - public ProjectComponents getComponentModelRoot() { - IFile file = structuralModel.getComponentFile(); - if (!file.isSynchronized(IResource.DEPTH_ONE)) { - try { - File iofile = file.getFullPath().toFile(); - if (iofile.exists() || file.exists()) - file.refreshLocal(IResource.DEPTH_ONE, null); - } catch (CoreException ce) { - //ignore - } - } - ProjectComponents comps = null; - ILock lock = EMFWorkbenchEditContextFactory.getProjectLockObject(structuralModel.getProject()); - try{ - if(null != lock){ - lock.acquire(); - } - synchronized(structuralModel){ - if (!structuralModel.isDisposed()) - comps = (ProjectComponents) structuralModel.getPrimaryRootObject(); - } - } finally{ - if(null != lock){ - lock.release(); - } - } - - return comps; - } - - /** - * <p> - * Return the an array of ComponentResource which basically represent the source containers of a - * WorkbenchResource. - * <p> - * - * @param component - * @return - */ - public ComponentResource[] getSourceContainers(WorkbenchComponent component) { - // TODO Api in progress: Need to return the Java Source containers of the project - // TODO MDE: I don't know if I agree with the placement of this method. - return null; - } - - /** - * <p> - * Clients that wish to modify the individual {@see WorkbenchComponent} instances may use - * this method. If clients need to add or remove {@see WorkbenchComponent} instances, use - * {@see #getProjectModules()} to get the root object and then access the contained - * {@see WorkbenchComponent}s through {@see ProjectComponents#getWorkbenchModules()}. - * - * @return The WorkbenchModules of the underlying model, if any. - */ - public WorkbenchComponent[] getWorkbenchModules() { - ProjectComponents pc = getComponentModelRoot(); - if(pc != null) { - List wbModules = pc.getComponents(); - return (WorkbenchComponent[]) wbModules.toArray(new WorkbenchComponent[wbModules.size()]); - } - return NO_COMPONENTS; - } - - /** - * <p> - * Create a {@see WorkbenchComponent} with the given deployed name. The returned module - * will be contained by the root object of the current ModuleCore (so no need to re-add it to - * the Module Module root object). The current ModuleCore must not be read-only to invoke This - * method. - * </p> - * - * @param aDeployName - * A non-null String that will be assigned as the deployed-name - * @return A {@see WorkbenchComponent}associated with the current ModuleCore with the supplied - * deployed name - * @throws IllegalStateException - * If the current ModuleCore was created as read-only - */ - public WorkbenchComponent createWorkbenchModule(String aDeployName) { - if (isReadOnly) - throwAttemptedReadOnlyModification(); - WorkbenchComponent module = COMPONENT_FACTORY.createWorkbenchComponent(); - module.setName(aDeployName); - getComponentModelRoot().getComponents().add(module); - return module; - } - - /** - * <p> - * Create a {@see ComponentResource} with the sourcePath of aResource. The current - * ModuleCore must not be read-only to invoke This method. - * </p> - * - * @param aModule - * A non-null {@see WorkbenchComponent}to contain the created - * {@see ComponentResource} - * @param aResource - * A non-null IResource that will be used to set the sourcePath - * @return A {@see ComponentResource}associated with the current ModuleCore with its sourcePath - * equivalent to aResource - * @throws IllegalStateException - * If the current ModuleCore was created as read-only - */ - public ComponentResource createWorkbenchModuleResource(IResource aResource) { - if (isReadOnly) - throwAttemptedReadOnlyModification(); - - ComponentResource moduleResource = COMPONENT_FACTORY.createComponentResource(); - moduleResource.setSourcePath(aResource.getProjectRelativePath().makeAbsolute()); - return moduleResource; - } - - /** - * <p> - * Create a {@see ComponentType} with the sourcePath of aResource. The returned resource - * will be associated with the current ModuleCore. The current ModuleCore must not be read-only - * to invoke This method. - * </p> - * - * @param aResource - * A non-null IResource that will be used to set the sourcePath - * @return A {@see ComponentResource}associated with the current ModuleCore with its sourcePath - * equivalent to aResource - * @throws IllegalStateException - * If the current ModuleCore was created as read-only - */ - public ComponentType createModuleType(String aModuleTypeId) { - if (isReadOnly) - throwAttemptedReadOnlyModification(); - - ComponentType moduleType = COMPONENT_FACTORY.createComponentType(); - moduleType.setComponentTypeId(aModuleTypeId); - return moduleType; - } - - /** - * <p> - * Search the given module (indicated by aModuleURI) for the {@see ComponentResource}s - * identified by the module-relative path (indicated by aDeployedResourcePath). - * </p> - * @deprecated To be removed at next Integration Build 04/14/05 MDE. No substitute. (No clients). - * - * @param aModuleURI - * A valid, fully-qualified module URI - * @param aDeployedResourcePath - * A module-relative path to a deployed file - * @return An array of WorkbenchModuleResources that contain the URI specified by the - * module-relative aDeployedResourcePath - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public ComponentResource[] findResourcesByRuntimePath(URI aModuleURI, URI aDeployedResourcePath) throws UnresolveableURIException { - WorkbenchComponent module = getComponent(); - return module.findResourcesByRuntimePath(new Path(aDeployedResourcePath.path())); - } - - /** - * <p> - * Search the the module (indicated by the root of aModuleResourcePath) for the - * {@see ComponentResource}s identified by the module-qualified path (indicated by - * aDeployedResourcePath). - * </p> - * @deprecated To be removed at next Integration Build 04/14/05 MDE Use IPath Signature instead. - * - * @param aModuleResourcePath - * A valid fully-qualified URI of a deployed resource within a specific - * WorkbenchComponent - * @return An array of WorkbenchModuleResources that contain the URI specified by - * aModuleResourcePath - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public ComponentResource[] findResourcesByRuntimePath(URI aModuleResourcePath) throws UnresolveableURIException { - - URI deployedURI = ModuleURIUtil.trimToDeployPathSegment(aModuleResourcePath); - IPath deployedPath = new Path(deployedURI.path()); - return findResourcesByRuntimePath(ModuleURIUtil.getDeployedName(aModuleResourcePath), deployedPath); - } - - /** - * <p> - * Search the the module (indicated by the root of aModuleResourcePath) for the - * {@see ComponentResource}s identified by the module-qualified path (indicated by - * aDeployedResourcePath). - * </p> - * - * @param aModuleResourcePath - * A valid fully-qualified URI of a deployed resource within a specific - * WorkbenchComponent - * @return An array of WorkbenchModuleResources that contain the URI specified by - * aModuleResourcePath - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public ComponentResource[] findResourcesByRuntimePath(String aModuleName, IPath aModuleResourcePath) { - WorkbenchComponent module = getComponent(); - return module.findResourcesByRuntimePath(aModuleResourcePath); - } - public ComponentResource[] findResourcesBySourcePath(URI aWorkspaceRelativePath) throws UnresolveableURIException { - return findResourcesBySourcePath(aWorkspaceRelativePath,ResourceTreeNode.CREATE_NONE); - } - /** - * <p> - * Locates the {@see ComponentResource}s that contain the supplied resource in their source - * path. There are no representations about the containment of the {@see ComponentResource}s - * which are returned. The only guarantee is that the returned elements are contained within the - * same project. - * </p> - * <p> - * The sourcePath of each {@see ComponentResource} will be mapped to either an IFile or an - * IFolder. As a result, if the {@see ComponentResource} is a container mapping, the path - * of the supplied resource may not be identical the sourcePath of the {@see ComponentResource}. - * </p> - * @deprecated To be removed at next Integration Build 04/14/05 MDE Use IPath Signature instead. - * - * @param aWorkspaceRelativePath - * A valid fully-qualified workspace-relative path of a given resource - * @return An array of WorkbenchModuleResources which have sourcePaths that contain the given - * resource - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public ComponentResource[] findResourcesBySourcePath(URI aWorkspaceRelativePath, int resourceFlag) throws UnresolveableURIException { - return findResourcesBySourcePath(new Path(aWorkspaceRelativePath.path()),resourceFlag); - } - public ComponentResource[] findResourcesBySourcePath(IPath aProjectRelativePath) throws UnresolveableURIException { - return findResourcesBySourcePath(aProjectRelativePath,ResourceTreeNode.CREATE_NONE); - } - /** - * <p> - * Locates the {@see WorkbenchComponent}s that contains the resource with the given source - * path. There are no representations about the containment of the {@see ComponentResource}s - * which are returned. The only guarantee is that the returned elements are contained within the - * same project. - * </p> - * <p> - * The sourcePath of each {@see ComponentResource} will be mapped to either an IFile or an - * IFolder. As a result, if the {@see ComponentResource} is a container mapping, the path - * of the supplied resource may not be identical the sourcePath of the {@see ComponentResource}. - * </p> - * - * @param aProjectRelativePath - * A valid project-relative path of a given resource - * resourceFlag - * A bit flag that determines if Resources should be created during the search - * CREATE_NONE - * CREATE_RESOURCE_ALWAYS - * CREATE_TREENODE_IFNEC - * @return An array of WorkbenchModuleResources which have sourcePaths that contain the given - * resource - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public WorkbenchComponent findComponent(IPath aProjectRelativeResourcePath, int resourceFlag) throws UnresolveableURIException { - ProjectComponents projectModules = getComponentModelRoot(); - if (projectModules == null) return null; - EList modules = projectModules.getComponents(); - - WorkbenchComponent module = null; - boolean resourceExists = false; - for (int i = 0; i < modules.size(); i++) { - module = (WorkbenchComponent) modules.get(i); - resourceExists = module.exists(aProjectRelativeResourcePath,resourceFlag); - if (!resourceExists && aProjectRelativeResourcePath.segments().length > 1) { - resourceExists = module.exists(aProjectRelativeResourcePath.removeFirstSegments(1),resourceFlag); - } - if (resourceExists) - return module; - } - return null; - } - /** - * <p> - * Locates the {@see ComponentResource}s that contain the supplied resource in their source - * path. There are no representations about the containment of the {@see ComponentResource}s - * which are returned. The only guarantee is that the returned elements are contained within the - * same project. - * </p> - * <p> - * The sourcePath of each {@see ComponentResource} will be mapped to either an IFile or an - * IFolder. As a result, if the {@see ComponentResource} is a container mapping, the path - * of the supplied resource may not be identical the sourcePath of the {@see ComponentResource}. - * </p> - * - * @param aProjectRelativePath - * A valid project-relative path of a given resource - * resourceFlag - * A bit flag that determines if Resources should be created during the search - * CREATE_NONE - * CREATE_RESOURCE_ALWAYS - * CREATE_TREENODE_IFNEC - * @return An array of WorkbenchModuleResources which have sourcePaths that contain the given - * resource - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public ComponentResource[] findResourcesBySourcePath(IPath aProjectRelativePath, int resourceFlag) throws UnresolveableURIException { - ProjectComponents projectModules = getComponentModelRoot(); - if (projectModules==null) - return NO_RESOURCES; - EList modules = projectModules.getComponents(); - - WorkbenchComponent module = null; - ComponentResource[] resources = null; - List foundResources = new ArrayList(); - for (int i = 0; i < modules.size(); i++) { - module = (WorkbenchComponent) modules.get(i); - resources = module.findResourcesBySourcePath(aProjectRelativePath,resourceFlag); - if (resources != null && resources.length != 0) - foundResources.addAll(Arrays.asList(resources)); - else if (aProjectRelativePath.segments().length > 1) { - resources = module.findResourcesBySourcePath(aProjectRelativePath.removeFirstSegments(1),resourceFlag); - if (resources != null && resources.length != 0) - foundResources.addAll(Arrays.asList(resources)); - } - } - if (foundResources.size() > 0) - return (ComponentResource[]) foundResources.toArray(new ComponentResource[foundResources.size()]); - return NO_RESOURCES; - } - - /** - * <p> - * Returns the {@see WorkbenchComponent} contained by the current ModuleCore with the - * deploy name aModuleName. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * @param aModuleName - * @return The {@see WorkbenchComponent}contained by the current ModuleCore with the deploy - * name aModuleName - * @see WorkbenchComponent#getDeployedName() - * @deprecated - Use getComponent() - Only one component per project - */ - public WorkbenchComponent findComponentByName(String aModuleName) { - return getComponentModelRoot() != null ? getComponentModelRoot().findWorkbenchModule(aModuleName) : null; - } - - /** - * <p> - * Locate and return the {@see WorkbenchComponent} referenced by the fully-qualified - * aModuleURI. The method will work correctly even if the requested {@see WorkbenchComponent} - * is contained by another project. - * </p> - * - * @param aModuleURI - * A valid, fully-qualified module URI - * @return The {@see WorkbenchComponent}referenced by aModuleURI - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - * @see WorkbenchComponent#getHandle() - */ - public WorkbenchComponent findComponentByURI(URI aModuleURI) throws UnresolveableURIException { - if (aModuleURI == null) - return null; - if(aModuleURI.scheme() == null && aModuleURI.segmentCount() == 1) - return getComponent(); - ModuleURIUtil.ensureValidFullyQualifiedModuleURI(aModuleURI); - String projectName = aModuleURI.segment(ModuleURIUtil.ModuleURI.PROJECT_NAME_INDX); - /* Accessing a local module */ - if (getProject()!=null && getProject().getName().equals(projectName)) - return getComponent(); - StructureEdit dependentCore = getDependentModuleCore(aModuleURI); - if (dependentCore != null) - return dependentCore.getComponent(); - return null; - } - - /** - * <p> - * Searches the available {@see WorkbenchComponent}s as available through - * {@see #getWorkbenchModules()} for {@see WorkbenchComponent}s that have a - * {@see WorkbenchComponent#getModuleType()}with a a module type Id as specified by - * aModuleTypeId. - * </p> - * - * @param aModuleTypeId - * A non-null module type id ({@see ComponentType#getModuleTypeId()}) - * @return A non-null array of the {@see WorkbenchComponent}s that match the given module type - * id - */ -// public WorkbenchComponent[] findComponentsByType(String aModuleTypeId) { -// WorkbenchComponent[] availableModules = getWorkbenchModules(); -// ComponentType moduleType; -// List results = new ArrayList(); -// for (int i = 0; i < availableModules.length; i++) { -// moduleType = availableModules[i].getComponentType(); -// if (moduleType != null && aModuleTypeId.equals(moduleType.getComponentTypeId())) -// results.add(availableModules[i]); -// } -// if (results.size() == 0) -// return NO_MODULES; -// return (WorkbenchComponent[]) results.toArray(new WorkbenchComponent[results.size()]); -// } - - /** - * Find and return the ReferencedComponent that represents the depedency from aComponent to aReferencedComponent. - * <p>This method could return null.</p> - * @param aComponent - * @param aReferencedComponent - * @return - */ - public ReferencedComponent findReferencedComponent(WorkbenchComponent aComponent, WorkbenchComponent aReferencedComponent) { - if(aComponent == null || aReferencedComponent == null) - return null; - - IProject referencedProject = getContainingProject(aReferencedComponent); - EList referencedComponents = aComponent.getReferencedComponents(); - String dependentProjectName = null; - for (Iterator iter = referencedComponents.iterator(); iter.hasNext();) { - ReferencedComponent referencedComponent = (ReferencedComponent) iter.next(); - dependentProjectName = referencedComponent.getHandle().segment(ModuleURIUtil.ModuleURI.PROJECT_NAME_INDX); - if(referencedProject.getName().equals(dependentProjectName)) - return referencedComponent; - - } - return null; - } - - /** - * <p> - * Returns true if the {@see ReferencedComponent} references a {@see WorkbenchComponent}( - * {@see ReferencedComponent#getHandle()}) which is contained by the project that the current - * ModuleCore is managing. The following method will determine if the dependency can be - * satisfied by the current project. - * </p> - * - * @param aDependentModule - * @return True if the {@see ReferencedComponent}references a {@see WorkbenchComponent}managed - * directly by the current ModuleCore - */ - public boolean isLocalDependency(ReferencedComponent aDependentModule) { - if (aDependentModule == null || aDependentModule.getHandle()==null) - return false; - URI dependentHandle = aDependentModule.getHandle(); - // with no scheme and a simple name, the referenced component must be local - if(dependentHandle.scheme() == null && dependentHandle.segmentCount() == 1) - return true; - try { - - String localProjectName = getProject().getName(); - if(ModuleURIUtil.ensureValidFullyQualifiedModuleURI(dependentHandle, false)) { - String dependentProjectName = aDependentModule.getHandle().segment(ModuleURIUtil.ModuleURI.PROJECT_NAME_INDX); - return localProjectName.equals(dependentProjectName); - } - } catch (UnresolveableURIException e) { - // Ignore - } - return false; - } - - /** - * @param aModuleURI - * A valid, fully-qualified module URI - * @return The ModuleCore facade for the supplied URI - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - private StructureEdit getDependentModuleCore(URI aModuleURI) throws UnresolveableURIException { - StructureEdit dependentCore = (StructureEdit) dependentCores.get(aModuleURI); - if (dependentCore != null) - return dependentCore; - synchronized (dependentCores) { - dependentCore = (StructureEdit) dependentCores.get(aModuleURI); - if (dependentCore == null) { - IProject container = getContainingProject(aModuleURI); - if (container != null) { - dependentCore = getStructureEditForRead(container); - dependentCores.put(aModuleURI, dependentCore); - } else - throw new UnresolveableURIException(aModuleURI); - } - } - return dependentCore; - } - - private void throwAttemptedReadOnlyModification() { - throw new IllegalStateException("Attempt to modify a ModuleCore edit facade that was loaded as read-only."); - } - - /** - * temporary method to return first module in the project - * - * @return first module in the project - * @deprecated - */ - public WorkbenchComponent getFirstModule() { - return getComponent(); - } - /** - * returns the one and only component in the project - * - * @return the component in the project if exists or null - * - */ - public WorkbenchComponent getComponent() { - WorkbenchComponent[] comps = getWorkbenchModules(); - if (comps.length > 0) - return comps[0]; - return null; - } - - public static URI createComponentURI(IProject aContainingProject, String aComponentName) { - return URI.createURI(PlatformURLModuleConnection.MODULE_PROTOCOL + IPath.SEPARATOR + PlatformURLModuleConnection.RESOURCE_MODULE + aContainingProject.getName() + IPath.SEPARATOR + aComponentName); - } - - - protected IProject getProject() { - return aProject; - } - - public ModuleStructuralModel getModuleStructuralModel() { - return structuralModel; - } - - /** - * Validate edit for resource state - */ - protected IStatus validateEdit() { - IValidateEditContext validator = (IValidateEditContext) UIContextDetermination.createInstance(IValidateEditContext.CLASS_KEY); - return validator.validateState(getModuleStructuralModel()); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/WorkbenchComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/WorkbenchComponent.java deleted file mode 100644 index e8d758682..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/WorkbenchComponent.java +++ /dev/null @@ -1,170 +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.wst.common.componentcore.internal; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * An EMF representation of a development-time module contained by an Eclipse project. - * <p> - * See the package overview for an <a href="package-summary.html">overview of the model components</a>. - * </p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getResources <em>Resources</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getComponentType <em>Component Type</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getReferencedComponents <em>Referenced Components</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getProperties <em>Properties</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getMetadataResources <em>Metadata Resources</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getWorkbenchComponent() - * @model - * @generated - */ -public interface WorkbenchComponent extends EObject { - /** - * Returns the value of the '<em><b>Name</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Name</em>' attribute. - * @see #setName(String) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getWorkbenchComponent_Name() - * @model default="" required="true" - * @generated - */ - String getName(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getName <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Name</em>' attribute. - * @see #getName() - * @generated - */ - void setName(String value); - - /** - * Returns the value of the '<em><b>Resources</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.wst.common.componentcore.internal.ComponentResource}. - * It is bidirectional and its opposite is '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource#getComponent <em>Component</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Resources</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Resources</em>' containment reference list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getWorkbenchComponent_Resources() - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource#getComponent - * @model type="org.eclipse.wst.common.componentcore.internal.ComponentResource" opposite="component" containment="true" - * @generated - */ - EList getResources(); - - /** - * Returns the value of the '<em><b>Component Type</b></em>' containment reference. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Component Type</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Component Type</em>' containment reference. - * @see #setComponentType(ComponentType) - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getWorkbenchComponent_ComponentType() - * @model containment="true" required="true" - * @generated - */ - ComponentType getComponentType(); - - /** - * Sets the value of the '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent#getComponentType <em>Component Type</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Component Type</em>' containment reference. - * @see #getComponentType() - * @generated - */ - void setComponentType(ComponentType value); - - /** - * Returns the value of the '<em><b>Referenced Components</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Referenced Components</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Referenced Components</em>' containment reference list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getWorkbenchComponent_ReferencedComponents() - * @model type="org.eclipse.wst.common.componentcore.internal.ReferencedComponent" containment="true" - * @generated - */ - EList getReferencedComponents(); - - /** - * Returns the value of the '<em><b>Properties</b></em>' reference list. - * The list contents are of type {@link org.eclipse.wst.common.componentcore.internal.Property}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Properties</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Properties</em>' reference list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getWorkbenchComponent_Properties() - * @model type="org.eclipse.wst.common.componentcore.internal.Property" - * @generated - */ - EList getProperties(); - - /** - * Returns the value of the '<em><b>Metadata Resources</b></em>' attribute list. - * The list contents are of type {@link org.eclipse.core.runtime.IPath}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Metadata Resources</em>' attribute list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Metadata Resources</em>' attribute list. - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#getWorkbenchComponent_MetadataResources() - * @model type="org.eclipse.core.runtime.IPath" dataType="org.eclipse.wst.common.componentcore.internal.IPath" - * @generated - */ - EList getMetadataResources(); - - URI getHandle(); - - ComponentResource[] findResourcesByRuntimePath(IPath aDeployPath); - - ComponentResource[] findResourcesBySourcePath(IPath aSourcePath, int resourceFlag); - - boolean exists(IPath aSourcePath, int resourceFlag); - -} // WorkbenchComponent diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraph.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraph.java deleted file mode 100644 index 74341f220..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraph.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.componentcore.internal.builder; - -import java.util.Collections; -import java.util.Set; - -import org.eclipse.core.resources.IProject; - -/** - * @deprecated use {@link IDependencyGraph} - */ -public class DependencyGraph { - - private static final DependencyGraph INSTANCE = new DependencyGraph(); - - public static DependencyGraph getInstance() { - return INSTANCE; - } - - public IProject[] getReferencingComponents(IProject target) { - Set<IProject> referencingComponents = IDependencyGraph.INSTANCE.getReferencingComponents(target); - return (IProject[]) referencingComponents.toArray(new IProject[referencingComponents.size()]); - } - - public void addReference(IProject target, IProject referencingComponent) { - // do nothing - } - - public void removeReference(IProject target, IProject referencingComponent) { - // do nothing - } - - protected Set internalGetReferencingComponents(IProject target) { - return Collections.EMPTY_SET; - } - - public void clear() { - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraphImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraphImpl.java deleted file mode 100644 index 678b9bdd1..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraphImpl.java +++ /dev/null @@ -1,502 +0,0 @@ -package org.eclipse.wst.common.componentcore.internal.builder; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -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.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; -import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesResourceFactory; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - -public class DependencyGraphImpl implements IDependencyGraph { - - /** - * Don't read or write the graph without first obtaining the graphLock. - */ - private Object graphLock = new Object(); - - /** - * If projects and and B both depend on C an entry in this graph would be {C -> - * {A, B} } - */ - private Map<IProject, Set<IProject>> graph = null; - - private long modStamp = 0; - - private Map<String, Object> referenceOptions = new HashMap<String, Object>(); - - - /** - * This is not public; only {@link IDependencyGraph#INSTANCE} should be - * used. - * - * @return - */ - static IDependencyGraph getInstance() { - if (instance == null) { - instance = new DependencyGraphImpl(); - instance.initGraph(); - } - return instance; - } - - private static DependencyGraphImpl instance = null; - - private DependencyGraphImpl() { - } - - public long getModStamp() { - synchronized (graphLock) { - return modStamp; - } - } - - public Set<IProject> getReferencingComponents(IProject targetProject) { - waitForAllUpdates(null); - synchronized (graphLock) { - Set<IProject> set = graph.get(targetProject); - if (set == null) { - return Collections.EMPTY_SET; - } else { - for (Iterator<IProject> iterator = set.iterator(); iterator.hasNext();) { - IProject project = iterator.next(); - if (!project.isAccessible()) { - iterator.remove(); - } - } - Set<IProject> copy = new HashSet<IProject>(); - copy.addAll(set); - return copy; - } - } - } - - private class DependencyGraphResourceChangedListener implements IResourceChangeListener, IResourceDeltaVisitor { - // only registered for post change events - public void resourceChanged(IResourceChangeEvent event) { - try { - preUpdate(); - event.getDelta().accept(this); - } catch (CoreException e) { - ModulecorePlugin.logError(e); - } finally { - postUpdate(); - } - } - - public boolean visit(IResourceDelta delta) throws CoreException { - IResource resource = delta.getResource(); - switch (resource.getType()) { - case IResource.ROOT: - return true; - case IResource.PROJECT: { - int kind = delta.getKind(); - if ((IResourceDelta.ADDED & kind) != 0) { - queueProjectAdded((IProject) resource); - return false; - } else if ((IResourceDelta.REMOVED & kind) != 0) { - queueProjectDeleted((IProject) resource); - return false; - } else if ((IResourceDelta.CHANGED & kind) != 0) { - int flags = delta.getFlags(); - if ((IResourceDelta.OPEN & flags) != 0) { - boolean isOpen = ((IProject) resource).isOpen(); - if (isOpen) { - queueProjectAdded((IProject) resource); - } else { - queueProjectDeleted((IProject) resource); - } - return false; - } - return true; - } - return false; - } - case IResource.FOLDER: - if (resource.getName().equals(".settings")) { - return true; - } - return false; - case IResource.FILE: - String name = resource.getName(); - if (name.equals(WTPModulesResourceFactory.WTP_MODULES_SHORT_NAME)) { - update(resource.getProject()); - } - default: - return false; - } - } - }; - - private DependencyGraphResourceChangedListener listener = null; - - /** - * The graph is built lazily once. Afterwards, the graph is updated as - * necessary. - */ - private void initGraph() { - synchronized (graphLock) { - referenceOptions.put("GET_JAVA_REFS", Boolean.FALSE); - try { - preUpdate(); - graph = new HashMap<IProject, Set<IProject>>(); - listener = new DependencyGraphResourceChangedListener(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE); - initAll(); - } finally { - postUpdate(); - } - } - } - - private void initAll(){ - synchronized (graphLock) { - try{ - preUpdate(); - IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (IProject sourceProject : allProjects) { - queueProjectAdded(sourceProject); - } - } finally{ - postUpdate(); - } - - } - } - - private void removeAllReferences(IProject project) { - synchronized (graphLock) { - graph.remove(project); - for (Iterator<Set<IProject>> iterator = graph.values().iterator(); iterator.hasNext();) { - iterator.next().remove(project); - } - modStamp++; - } - } - - private void removeReference(IProject sourceProject, IProject targetProject) { - synchronized (graphLock) { - Set<IProject> referencingProjects = graph.get(targetProject); - if (referencingProjects != null) { - referencingProjects.remove(sourceProject); - } - modStamp++; - } - } - - private void addReference(IProject sourceProject, IProject targetProject) { - synchronized (graphLock) { - Set<IProject> referencingProjects = graph.get(targetProject); - if (referencingProjects == null) { - referencingProjects = new HashSet<IProject>(); - graph.put(targetProject, referencingProjects); - } - referencingProjects.add(sourceProject); - modStamp++; - } - } - - public static final Object GRAPH_UPDATE_JOB_FAMILY = new Object(); - - private static final int JOB_DELAY = 100; - - private final GraphUpdateJob graphUpdateJob = new GraphUpdateJob(); - private final Object jobLock = new Object(); - - private class GraphUpdateJob extends Job { - - public GraphUpdateJob() { - super("Graph Update Job"); - setSystem(true); - //[Bug 238685] need to lock on workspace to avoid dead lock - setRule(ResourcesPlugin.getWorkspace().getRoot()); - } - - public boolean belongsTo(Object family) { - if (family == GRAPH_UPDATE_JOB_FAMILY) { - return true; - } - return super.belongsTo(family); - } - - // We use the listener list as a thread safe queue. - private class Queue extends ListenerList { - public synchronized Object[] getListeners() { - Object[] data = super.getListeners(); - clear(); - return data; - } - - public synchronized boolean isEmpty() { - return super.isEmpty(); - } - }; - - private Queue projectsAdded = new Queue(); - - private Queue projectsRemoved = new Queue(); - - private Queue projectsUpdated = new Queue(); - - public void queueProjectAdded(IProject project) { - synchronized (graphLock) { - modStamp++; - } - projectsAdded.add(project); - } - - public void queueProjectDeleted(IProject project) { - synchronized (graphLock) { - modStamp++; - } - projectsRemoved.add(project); - } - - public void queueProjectUpdated(IProject project) { - synchronized (graphLock) { - modStamp++; - } - projectsUpdated.add(project); - } - - @Override - public boolean shouldSchedule() { - boolean isEmpty = projectsAdded.isEmpty() && projectsRemoved.isEmpty() && projectsUpdated.isEmpty(); - return !isEmpty; - } - - protected IStatus run(IProgressMonitor monitor) { - final Object[] removed = projectsRemoved.getListeners(); - final Object[] updated = projectsUpdated.getListeners(); - final Object[] added = projectsAdded.getListeners(); - if (removed.length == 0 && updated.length == 0 && added.length == 0) { - return Status.OK_STATUS; - } - synchronized (graphLock) { - modStamp++; - } - SafeRunner.run(new ISafeRunnable() { - public void handleException(Throwable e) { - ModulecorePlugin.logError(e); - } - - public void run() throws Exception { - // this is the simple case; just remove them all - synchronized (graphLock) { - for (Object o : removed) { - IProject project = (IProject) o; - removeAllReferences(project); - } - } - // get the updated queue in case there are any adds - // if there are any added projects, then unfortunately the - // entire workspace needs to be processed - if (added.length > 0) { - IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (IProject sourceProject : allProjects) { - IVirtualComponent component = ComponentCore.createComponent(sourceProject); - if (component != null) { - IVirtualReference[] references = null; - if(referenceOptions != null && component instanceof VirtualComponent) { - references = ((VirtualComponent)component).getReferences(referenceOptions); - } else { - references = component.getReferences(); - } - for (IVirtualReference ref : references) { - IVirtualComponent targetComponent = ref.getReferencedComponent(); - if (targetComponent != null) { - IProject targetProject = targetComponent.getProject(); - if (targetProject != null && !targetProject.equals(sourceProject)) { - addReference(sourceProject, targetProject); - } - } - } - } - } - } else if (updated.length > 0) { - IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - Set<IProject> validRefs = new HashSet<IProject>(); - for (Object o : updated) { - IProject sourceProject = (IProject) o; - IVirtualComponent component = ComponentCore.createComponent(sourceProject); - if (component != null) { - validRefs.clear(); - IVirtualReference[] references = null; - if(referenceOptions != null && component instanceof VirtualComponent) { - references = ((VirtualComponent)component).getReferences(referenceOptions); - } else { - references = component.getReferences(); - } - for (IVirtualReference ref : references) { - IVirtualComponent targetComponent = ref.getReferencedComponent(); - if (targetComponent != null) { - IProject targetProject = targetComponent.getProject(); - if (targetProject != null && !targetProject.equals(sourceProject)) { - validRefs.add(targetProject); - } - } - } - synchronized (graphLock) { - for (IProject targetProject : allProjects) { - // if the reference was identified - // above, be sure to add it - // otherwise, remove it - if (validRefs.remove(targetProject)) { - addReference(sourceProject, targetProject); - } else { - removeReference(sourceProject, targetProject); - } - } - } - } else { - // if this project is not a component, then it - // should be completely removed. - removeAllReferences(sourceProject); - } - } - } - boolean scheduleUpdate = false; - synchronized (graphLock) { - if(referenceOptions != null){ - scheduleUpdate = true; - referenceOptions = null; - } - } - if(scheduleUpdate){ - initAll(); - } - - } - }); - // System.err.println(IDependencyGraph.INSTANCE); - return Status.OK_STATUS; - } - }; - - /** - * @deprecated use {@link #update(IProject, int)} - */ - public void queueProjectAdded(IProject project) { - update(project, IDependencyGraph.ADDED); - } - - /** - * @deprecated use {@link #update(IProject, int)} - */ - public void queueProjectDeleted(IProject project) { - update(project, IDependencyGraph.REMOVED); - } - - /** - * @deprecated use {@link #update(IProject, int)} - */ - public void update(IProject project) { - update(project, IDependencyGraph.MODIFIED); - } - - public void update(IProject project, final int updateType){ - switch(updateType){ - case IDependencyGraph.MODIFIED: - graphUpdateJob.queueProjectUpdated(project); - break; - case IDependencyGraph.ADDED: - graphUpdateJob.queueProjectAdded(project); - break; - case IDependencyGraph.REMOVED: - graphUpdateJob.queueProjectDeleted(project); - break; - } - synchronized (jobLock) { - if (pauseCount > 0) { - return; - } - } - graphUpdateJob.schedule(JOB_DELAY); - } - - - - private int pauseCount = 0; - - /** - * Pauses updates; any caller of this method must ensure through a - * try/finally block that resumeUpdates is subsequently called. - */ - public void preUpdate() { - synchronized (jobLock) { - pauseCount++; - } - } - - public void postUpdate() { - synchronized (jobLock) { - if (pauseCount > 0) { - pauseCount--; - } - if (pauseCount > 0) { - return; - } - } - graphUpdateJob.schedule(JOB_DELAY); - } - - /** - * Blocks until the graph is finished updating - */ - public void waitForAllUpdates(IProgressMonitor monitor) { - Thread graphUpdateThread = graphUpdateJob.getThread(); - if(graphUpdateThread != null && graphUpdateThread != Thread.currentThread()) { - try { - graphUpdateJob.join(); - } catch (InterruptedException e) { - ModulecorePlugin.logError(e); - } - } - - if(graphUpdateJob.shouldSchedule()){ - graphUpdateJob.run(monitor); - } - } - - public String toString() { - synchronized (graphLock) { - StringBuffer buff = new StringBuffer("Dependency Graph:\n{\n"); - for (Iterator<Map.Entry<IProject, Set<IProject>>> iterator = graph.entrySet().iterator(); iterator.hasNext();) { - Map.Entry<IProject, Set<IProject>> entry = iterator.next(); - buff.append(" " + entry.getKey().getName() + " -> {"); - for (Iterator<IProject> mappedProjects = entry.getValue().iterator(); mappedProjects.hasNext();) { - buff.append(mappedProjects.next().getName()); - if (mappedProjects.hasNext()) { - buff.append(", "); - } - } - buff.append("}\n"); - } - buff.append("}"); - return buff.toString(); - } - - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraphManager.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraphManager.java deleted file mode 100644 index 0b275c8c7..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/DependencyGraphManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.builder; - -import org.eclipse.core.resources.IProject; - -/** - * @deprecated use {@link IDependencyGraph} - */ -public class DependencyGraphManager { - - private static DependencyGraphManager INSTANCE = null; - - private DependencyGraphManager() { - super(); - } - - public synchronized static final DependencyGraphManager getInstance() { - if (INSTANCE == null) - INSTANCE = new DependencyGraphManager(); - return INSTANCE; - } - - public void construct(IProject project) { - // do nothing - } - - /** - * Return the dependency graph which was initialized if need be in the - * singleton manager method. - */ - public DependencyGraph getDependencyGraph() { - return DependencyGraph.getInstance(); - } - - public void forceRefresh() { - // do nothing - } - - public long getModStamp() { - return IDependencyGraph.INSTANCE.getModStamp(); - } - - public boolean checkIfStillValid(long timeStamp) { - return IDependencyGraph.INSTANCE.getModStamp() == timeStamp; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/IDependencyGraph.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/IDependencyGraph.java deleted file mode 100644 index aa4f58c71..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/builder/IDependencyGraph.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.eclipse.wst.common.componentcore.internal.builder; - -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -/** - * This graph provides a backward mapping of project component dependencies. It - * provides a project limited inverse of - * {@link IVirtualComponent#getReferences()}. - * - * For example: - * <ul> - * <li>if the IVirtualComponent for project A has a dependency on the - * IVirtualComponent for project B, then calling - * {@link #getReferencingComponents(IProject)} on project B will return project - * A. </li> - * <li>if the IVirtualComponent for project A has a dependency on on the - * IVirtualComponent for a jar in project B, then calling - * {@link #getReferencingComponents(IProject)} for project B will return project - * A. This is true even if project B is not defined as an IVirtualComponent. - * </li> - * </ul> - * - * Any call to {@link #getReferencingComponents(IProject)} is always expected to - * be up to date. The only case where a client may need to force an update is if - * that client is also defining dynamic IVirtualComponent dependencies, i.e. the - * client is using the org.eclipse.wst.common.modulecore.componentimpl extension - * point. Only in this case should a client be calling any of - * {@link #preUpdate()}, {@link #postUpdate()}, or {@link #update(IProject)} - * - */ -public interface IDependencyGraph { - - /** - * Flag used by {@link #update(IProject, int)} to specify that something has - * modified in a project which has changed the component dependencies. - */ - public static final int MODIFIED = 0; - - /** - * Flag used by {@link #update(IProject, int)} to specify a project has been - * added or opened. This flag should be used as sparingly as possible - * because there are performance implications. - */ - public static final int ADDED = 1; - - /** - * Flag used by {@link #update(IProject, int)} to specify a project has been - * removed or closed. - */ - public static final int REMOVED = 2; - - /** - * The static instance of this graph - */ - public static IDependencyGraph INSTANCE = DependencyGraphImpl.getInstance(); - - /** - * Returns the set of component projects referencing the specified target - * project. - * - * @param targetProject - * @return - */ - public Set<IProject> getReferencingComponents(IProject targetProject); - - /** - * Returns a modification stamp. This modification stamp will be different - * if the project dependencies ever change. - */ - public long getModStamp(); - - /** - * WARNING: this should only be called by implementors of the - * org.eclipse.wst.common.modulecore.componentimpl extension point. - * - * This method is part of the update API. - * - * @see {@link #update(IProject)} - */ - public void preUpdate(); - - /** - * WARNING: this should only be called by implementors of the - * org.eclipse.wst.common.modulecore.componentimpl extension point. - * - * This method is part of the update API. - * - * @see {@link #update(IProject)} - */ - public void postUpdate(); - - /** - * @deprecated use {@link #update(IProject, int) using the #MODIFIED flag. - */ - public void update(IProject sourceProject); - - /** - * WARNING: this should only be called by implementors of the - * org.eclipse.wst.common.modulecore.componentimpl extension point. - * - * This method must be called when a resource change is detected which will - * affect how dependencies behave. For example, the core IVirtualComponent - * framework updates when changes are made to the - * .settings/org.eclipse.wst.common.component file changes, and also when - * IProjects are added or removed from the workspace. In the case for J2EE, - * this occurs when changes are made to the META-INF/MANIFEST.MF file. In - * general a call to update should only be made from a fast - * {@link IResourceDeltaVisitor}. - * - * In order to improve efficiency and avoid unnecessary update processing, - * it is necessary to always proceed calls to update() with a call to - * preUpdate() and follow with a call to postUpdate() using a try finally - * block as follows: <code> - * try { - * preUpdate(); - * // perform 0 or more update() calls here - * } finally { - * IDependencyGraph.INSTANCE.postUpdate(); - * } - * </code> - * - * Valid updateType flags are {@link #MODIFIED}, {@link #ADDED}, and - * {@link #REMOVED} - * - */ - public void update(IProject sourceProject, int updateType); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ArtifactEditModelFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ArtifactEditModelFactory.java deleted file mode 100644 index 17c57ea08..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ArtifactEditModelFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.componentcore.internal.impl; - -import java.util.Map; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -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 ArtifactEditModelFactory extends EditModelFactory { - - public static final String MODULE_EDIT_MODEL_ID = "org.eclipse.wst.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) - */ - 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"); - - return new ArtifactEditModel(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) - */ - 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"); - return new ArtifactEditModel(editModelID, context, false, moduleURI, rootURI, rootContentType); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#getCacheID(java.lang.String, java.util.Map) - */ - 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.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentCoreURIConverter.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentCoreURIConverter.java deleted file mode 100644 index a2722b6de..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentCoreURIConverter.java +++ /dev/null @@ -1,195 +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.wst.common.componentcore.internal.impl; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -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.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.impl.URIMappingRegistryImpl; -import org.eclipse.jem.util.emf.workbench.ResourceSetWorkbenchSynchronizer; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.wst.common.componentcore.ComponentCore; -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.internal.emfworkbench.CompatibilityWorkbenchURIConverterImpl; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class ComponentCoreURIConverter extends CompatibilityWorkbenchURIConverterImpl { - - private IProject containingProject; -// private IFolder archiveRoot; - /** - * - */ - public ComponentCoreURIConverter() { - super(); - } - - /** - * @param anInputContainer - */ - public ComponentCoreURIConverter(IProject aContainingProject) { - super(); - containingProject = aContainingProject; - } - - /** - * @param aContainer - * @param aSynchronizer - */ - public ComponentCoreURIConverter(IProject aContainingProject, ResourceSetWorkbenchSynchronizer aSynchronizer) { - super(aContainingProject, aSynchronizer); - containingProject = aContainingProject; - } - - public IVirtualComponent findComponent(IResource res) { - - if (res != null && res.exists()) - return ComponentCore.createComponent(res.getProject()); - return null; - } - /* (non-Javadoc) - * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverterImpl#normalize(org.eclipse.emf.common.util.URI) - */ - public URI normalize(URI aURI) { - URI normalizedURI = null; - if(PlatformURLModuleConnection.MODULE.equals(aURI.scheme())) { - try { - normalizedURI = PlatformURLModuleConnection.resolve(aURI); - } catch(IOException ioe) { - ioe.printStackTrace(); - } - } else { - normalizedURI = super.normalize(aURI); - } - if(normalizedURI == null) { - normalizedURI = newPlatformURI(aURI); - } - else if(normalizedURI.scheme() == null || normalizedURI.scheme().length() == 0) { - normalizedURI = URI.createPlatformResourceURI(getInputContainer().getFullPath().append(normalizedURI.toString()).toString()); - } - return normalizedURI; - } - - private URI newPlatformURI(URI aNewURI) { - - try { -// String componentName = StructureEdit.getDeployedName(aNewURI); - IVirtualComponent component = ComponentCore.createComponent(containingProject); - - URI deployPathSegment = ModuleURIUtil.trimToDeployPathSegment(aNewURI); - - //IVirtualFile newFile = component.getFile(new Path(deployPathSegment.path())); - IVirtualFolder rootFolder = component.getRootFolder(); - IVirtualFile newFile = rootFolder.getFile(new Path(deployPathSegment.path())); - - return URI.createPlatformResourceURI(newFile.getWorkspaceRelativePath().toString()); - - } catch(Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * @see com.ibm.etools.xmi.helpers.CompatibilityURIConverter#deNormalize(URI) - */ - public URI deNormalize(URI uri) { - if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri)) { - IFile aFile = WorkbenchResourceHelper.getPlatformFile(uri); - - if (aFile != null) { - IVirtualComponent component = ComponentCore.createComponent(getContainingProject()); - - if (component != null) { - IProject fileProject = getContainingProject(); - - if (resourceSetSynchronizer.getProject() == fileProject){ - List list = Arrays.asList(component.getRootFolder().getUnderlyingFolders()); - IPath path = WorkbenchResourceHelperBase.getPathFromContainers(list, aFile.getFullPath()); - if (path != null) - return URI.createURI(path.toString()); - return null; - } - } else - return super.deNormalize(uri); - } - } - return uri; - } - - protected URI getContainerRelativeURI(IFile aFile) { - IPath path = WorkbenchResourceHelperBase.getPathFromContainers(inputContainers, aFile.getFullPath()); - if (path != null) - return URI.createURI(path.toString()); - return null; - } - protected URI getArchiveRelativeURI(IFile aFile, IContainer aContainer) { - IPath path = WorkbenchResourceHelperBase.getPathFromContainers(Collections.singletonList(aContainer), aFile.getFullPath()); - if (path != null) - return URI.createURI(path.toString()); - return null; - } - - - - protected IProject getContainingProject() { - return containingProject; - } - - @Override - protected URIMap getInternalURIMap() { - - if (uriMap == null) - { - URIMappingRegistryImpl mappingRegistryImpl = - new URIMappingRegistryImpl() - { - private static final long serialVersionUID = 1L; - - @Override - protected URI delegatedGetURI(URI uri) - { - if (ModuleURIUtil.hasContentTypeName(uri)) - return newPlatformURI(uri); - return URIMappingRegistryImpl.INSTANCE.getURI(uri); - } - }; - - uriMap = (URIMap)mappingRegistryImpl.map(); - } - - URIMap uriConverterImplURIMap = null; - if (uriMap instanceof URIMap) - { - uriConverterImplURIMap = (URIMap)uriMap; - } - return uriConverterImplURIMap; - - } - - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentResourceImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentResourceImpl.java deleted file mode 100644 index 914746639..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentResourceImpl.java +++ /dev/null @@ -1,434 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentResourceImpl.java,v 1.3 2006/01/11 18:40:31 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import java.util.Collection; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Workbench Module Resource</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getSourcePath <em>Source Path</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getRuntimePath <em>Runtime Path</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getExclusions <em>Exclusions</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getComponent <em>Component</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getResourceType <em>Resource Type</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ComponentResourceImpl extends EObjectImpl implements ComponentResource { - /** - * The default value of the '{@link #getSourcePath() <em>Source Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourcePath() - * @generated - * @ordered - */ - protected static final IPath SOURCE_PATH_EDEFAULT = null; - - /** - * The cached value of the '{@link #getSourcePath() <em>Source Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourcePath() - * @generated - * @ordered - */ - protected IPath sourcePath = SOURCE_PATH_EDEFAULT; - - /** - * The default value of the '{@link #getRuntimePath() <em>Runtime Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRuntimePath() - * @generated - * @ordered - */ - protected static final IPath RUNTIME_PATH_EDEFAULT = null; - - /** - * The cached value of the '{@link #getRuntimePath() <em>Runtime Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRuntimePath() - * @generated - * @ordered - */ - protected IPath runtimePath = RUNTIME_PATH_EDEFAULT; - - /** - * The cached value of the '{@link #getExclusions() <em>Exclusions</em>}' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getExclusions() - * @generated - * @ordered - */ - protected EList exclusions = null; - - /** - * The default value of the '{@link #getResourceType() <em>Resource Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getResourceType() - * @generated - * @ordered - */ - protected static final String RESOURCE_TYPE_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getResourceType() <em>Resource Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getResourceType() - * @generated - * @ordered - */ - protected String resourceType = RESOURCE_TYPE_EDEFAULT; - - protected IProject owningProject; - protected static final int VIRTUAL = 0; - protected static final int PERSISTED = 1; - - private int type = PERSISTED; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ComponentResourceImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ComponentcorePackage.eINSTANCE.getComponentResource(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPath getSourcePath() { - return sourcePath; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSourcePath(IPath newSourcePath) { - IPath oldSourcePath = sourcePath; - sourcePath = newSourcePath; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH, oldSourcePath, sourcePath)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPath getRuntimePath() { - return runtimePath; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setRuntimePath(IPath newRuntimePath) { - IPath oldRuntimePath = runtimePath; - runtimePath = newRuntimePath; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH, oldRuntimePath, runtimePath)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getExclusions() { - if (exclusions == null) { - exclusions = new EDataTypeUniqueEList(String.class, this, ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS); - } - return exclusions; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public WorkbenchComponent getComponent() { - if (eContainerFeatureID != ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT) return null; - return (WorkbenchComponent)eContainer; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setComponent(WorkbenchComponent newComponent) { - if (newComponent != eContainer || (eContainerFeatureID != ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT && newComponent != null)) { - if (EcoreUtil.isAncestor(this, newComponent)) - throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); - NotificationChain msgs = null; - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - if (newComponent != null) - msgs = ((InternalEObject)newComponent).eInverseAdd(this, ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES, WorkbenchComponent.class, msgs); - msgs = eBasicSetContainer((InternalEObject)newComponent, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, newComponent, newComponent)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getResourceType() { - return resourceType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setResourceType(String newResourceType) { - String oldResourceType = resourceType; - resourceType = newResourceType; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE, oldResourceType, resourceType)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT: - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, msgs); - default: - return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); - } - } - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT: - return eBasicSetContainer(null, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, msgs); - default: - return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) { - if (eContainerFeatureID >= 0) { - switch (eContainerFeatureID) { - case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT: - return eContainer.eInverseRemove(this, ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES, WorkbenchComponent.class, msgs); - default: - return eDynamicBasicRemoveFromContainer(msgs); - } - } - return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH: - return getSourcePath(); - case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH: - return getRuntimePath(); - case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS: - return getExclusions(); - case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT: - return getComponent(); - case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE: - return getResourceType(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH: - setSourcePath((IPath)newValue); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH: - setRuntimePath((IPath)newValue); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS: - getExclusions().clear(); - getExclusions().addAll((Collection)newValue); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT: - setComponent((WorkbenchComponent)newValue); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE: - setResourceType((String)newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH: - setSourcePath(SOURCE_PATH_EDEFAULT); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH: - setRuntimePath(RUNTIME_PATH_EDEFAULT); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS: - getExclusions().clear(); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT: - setComponent((WorkbenchComponent)null); - return; - case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE: - setResourceType(RESOURCE_TYPE_EDEFAULT); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH: - return SOURCE_PATH_EDEFAULT == null ? sourcePath != null : !SOURCE_PATH_EDEFAULT.equals(sourcePath); - case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH: - return RUNTIME_PATH_EDEFAULT == null ? runtimePath != null : !RUNTIME_PATH_EDEFAULT.equals(runtimePath); - case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS: - return exclusions != null && !exclusions.isEmpty(); - case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT: - return getComponent() != null; - case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE: - return RESOURCE_TYPE_EDEFAULT == null ? resourceType != null : !RESOURCE_TYPE_EDEFAULT.equals(resourceType); - } - return eDynamicIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (sourcePath: "); - result.append(sourcePath); - result.append(", runtimePath: "); - result.append(runtimePath); - result.append(", exclusions: "); - result.append(exclusions); - result.append(", resourceType: "); - result.append(resourceType); - result.append(')'); - return result.toString(); - } - - public int getType() { - return type; - } - - - public void setType(int type) { - this.type = type; - } - - public IProject getOwningProject() { - return owningProject; - } - - public void setOwningProject(IProject aProject) { - owningProject = aProject; - } - - -} //ComponentResourceImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentTypeImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentTypeImpl.java deleted file mode 100644 index b0c2f215f..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentTypeImpl.java +++ /dev/null @@ -1,290 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentTypeImpl.java,v 1.1 2005/04/04 07:04:59 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import java.util.Collection; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; -import org.eclipse.emf.ecore.util.EObjectResolvingEList; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.Property; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Module Type</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl#getComponentTypeId <em>Component Type Id</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl#getVersion <em>Version</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl#getProperties <em>Properties</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentTypeImpl#getMetadataResources <em>Metadata Resources</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ComponentTypeImpl extends EObjectImpl implements ComponentType { - /** - * The default value of the '{@link #getComponentTypeId() <em>Component Type Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getComponentTypeId() - * @generated - * @ordered - */ - protected static final String COMPONENT_TYPE_ID_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getComponentTypeId() <em>Component Type Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getComponentTypeId() - * @generated - * @ordered - */ - protected String componentTypeId = COMPONENT_TYPE_ID_EDEFAULT; - - /** - * The default value of the '{@link #getVersion() <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVersion() - * @generated - * @ordered - */ - protected static final String VERSION_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getVersion() <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVersion() - * @generated - * @ordered - */ - protected String version = VERSION_EDEFAULT; - - /** - * The cached value of the '{@link #getProperties() <em>Properties</em>}' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getProperties() - * @generated - * @ordered - */ - protected EList properties = null; - - /** - * The cached value of the '{@link #getMetadataResources() <em>Metadata Resources</em>}' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getMetadataResources() - * @generated - * @ordered - */ - protected EList metadataResources = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ComponentTypeImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ComponentcorePackage.eINSTANCE.getComponentType(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getComponentTypeId() { - return componentTypeId; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setComponentTypeId(String newComponentTypeId) { - String oldComponentTypeId = componentTypeId; - componentTypeId = newComponentTypeId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_TYPE__COMPONENT_TYPE_ID, oldComponentTypeId, componentTypeId)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getMetadataResources() { - if (metadataResources == null) { - metadataResources = new EDataTypeUniqueEList(IPath.class, this, ComponentcorePackage.COMPONENT_TYPE__METADATA_RESOURCES); - } - return metadataResources; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getVersion() { - return version; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setVersion(String newVersion) { - String oldVersion = version; - version = newVersion; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_TYPE__VERSION, oldVersion, version)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getProperties() { - if (properties == null) { - properties = new EObjectResolvingEList(Property.class, this, ComponentcorePackage.COMPONENT_TYPE__PROPERTIES); - } - return properties; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_TYPE__COMPONENT_TYPE_ID: - return getComponentTypeId(); - case ComponentcorePackage.COMPONENT_TYPE__VERSION: - return getVersion(); - case ComponentcorePackage.COMPONENT_TYPE__PROPERTIES: - return getProperties(); - case ComponentcorePackage.COMPONENT_TYPE__METADATA_RESOURCES: - return getMetadataResources(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_TYPE__COMPONENT_TYPE_ID: - setComponentTypeId((String)newValue); - return; - case ComponentcorePackage.COMPONENT_TYPE__VERSION: - setVersion((String)newValue); - return; - case ComponentcorePackage.COMPONENT_TYPE__PROPERTIES: - getProperties().clear(); - getProperties().addAll((Collection)newValue); - return; - case ComponentcorePackage.COMPONENT_TYPE__METADATA_RESOURCES: - getMetadataResources().clear(); - getMetadataResources().addAll((Collection)newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_TYPE__COMPONENT_TYPE_ID: - setComponentTypeId(COMPONENT_TYPE_ID_EDEFAULT); - return; - case ComponentcorePackage.COMPONENT_TYPE__VERSION: - setVersion(VERSION_EDEFAULT); - return; - case ComponentcorePackage.COMPONENT_TYPE__PROPERTIES: - getProperties().clear(); - return; - case ComponentcorePackage.COMPONENT_TYPE__METADATA_RESOURCES: - getMetadataResources().clear(); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.COMPONENT_TYPE__COMPONENT_TYPE_ID: - return COMPONENT_TYPE_ID_EDEFAULT == null ? componentTypeId != null : !COMPONENT_TYPE_ID_EDEFAULT.equals(componentTypeId); - case ComponentcorePackage.COMPONENT_TYPE__VERSION: - return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version); - case ComponentcorePackage.COMPONENT_TYPE__PROPERTIES: - return properties != null && !properties.isEmpty(); - case ComponentcorePackage.COMPONENT_TYPE__METADATA_RESOURCES: - return metadataResources != null && !metadataResources.isEmpty(); - } - return eDynamicIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (componentTypeId: "); - result.append(componentTypeId); - result.append(", version: "); - result.append(version); - result.append(", metadataResources: "); - result.append(metadataResources); - result.append(')'); - return result.toString(); - } - -} //ComponentTypeImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentcoreFactoryImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentcoreFactoryImpl.java deleted file mode 100644 index 0bcab2015..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentcoreFactoryImpl.java +++ /dev/null @@ -1,236 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentcoreFactoryImpl.java,v 1.8 2006/04/27 04:17:40 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EFactoryImpl; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.DependencyType; -import org.eclipse.wst.common.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * <!-- end-user-doc --> - * @generated - */ -public class ComponentcoreFactoryImpl extends EFactoryImpl implements ComponentcoreFactory { - - /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static ComponentcoreFactory init() { - try { - ComponentcoreFactory theComponentcoreFactory = (ComponentcoreFactory)EPackage.Registry.INSTANCE.getEFactory("componentcore.xmi"); - if (theComponentcoreFactory != null) { - return theComponentcoreFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new ComponentcoreFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentcoreFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case ComponentcorePackage.WORKBENCH_COMPONENT: return createWorkbenchComponent(); - case ComponentcorePackage.COMPONENT_RESOURCE: return createComponentResource(); - case ComponentcorePackage.COMPONENT_TYPE: return createComponentType(); - case ComponentcorePackage.PROPERTY: return createProperty(); - case ComponentcorePackage.REFERENCED_COMPONENT: return createReferencedComponent(); - case ComponentcorePackage.PROJECT_COMPONENTS: return createProjectComponents(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object createFromString(EDataType eDataType, String initialValue) { - switch (eDataType.getClassifierID()) { - case ComponentcorePackage.DEPENDENCY_TYPE: { - DependencyType result = DependencyType.get(initialValue); - if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); - return result; - } - case ComponentcorePackage.IPATH: - return createIPathFromString(eDataType, initialValue); - case ComponentcorePackage.URI: - return createURIFromString(eDataType, initialValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertToString(EDataType eDataType, Object instanceValue) { - switch (eDataType.getClassifierID()) { - case ComponentcorePackage.DEPENDENCY_TYPE: - return instanceValue == null ? null : instanceValue.toString(); - case ComponentcorePackage.IPATH: - return convertIPathToString(eDataType, instanceValue); - case ComponentcorePackage.URI: - return convertURIToString(eDataType, instanceValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public WorkbenchComponent createWorkbenchComponent() { - WorkbenchComponentImpl workbenchComponent = new WorkbenchComponentImpl(); - return workbenchComponent; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentResource createComponentResource() { - ComponentResourceImpl componentResource = new ComponentResourceImpl(); - return componentResource; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentType createComponentType() { - ComponentTypeImpl componentType = new ComponentTypeImpl(); - return componentType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Property createProperty() { - PropertyImpl property = new PropertyImpl(); - return property; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ReferencedComponent createReferencedComponent() { - ReferencedComponentImpl referencedComponent = new ReferencedComponentImpl(); - return referencedComponent; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ProjectComponents createProjectComponents() { - ProjectComponentsImpl projectComponents = new ProjectComponentsImpl(); - return projectComponents; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPath createIPathFromString(EDataType eDataType, String initialValue) { - return (IPath)super.createFromString(eDataType, initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertIPathToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public URI createURIFromString(EDataType eDataType, String initialValue) { - return (URI)super.createFromString(eDataType, initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertURIToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentcorePackage getComponentcorePackage() { - return (ComponentcorePackage)getEPackage(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @deprecated - * @generated - */ - public static ComponentcorePackage getPackage() { - return ComponentcorePackage.eINSTANCE; - } - -} //ComponentcoreFactoryImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentcorePackageImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentcorePackageImpl.java deleted file mode 100644 index 888ba5449..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ComponentcorePackageImpl.java +++ /dev/null @@ -1,646 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentcorePackageImpl.java,v 1.9 2006/04/27 04:17:40 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.DependencyType; -import org.eclipse.wst.common.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Package</b>. - * <!-- end-user-doc --> - * @generated - */ -public class ComponentcorePackageImpl extends EPackageImpl implements ComponentcorePackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass workbenchComponentEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass componentResourceEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass componentTypeEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass propertyEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass referencedComponentEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass projectComponentsEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EEnum dependencyTypeEEnum = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType iPathEDataType = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType uriEDataType = null; - - /** - * Creates an instance of the model <b>Package</b>, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - * <p>Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.wst.common.componentcore.ComponentcorePackage#eNS_URI - * @see #init() - * @generated - */ - private ComponentcorePackageImpl() { - super(eNS_URI, ComponentcoreFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this - * model, and for any others upon which it depends. Simple - * dependencies are satisfied by calling this method on all - * dependent packages before doing anything else. This method drives - * initialization for interdependent packages directly, in parallel - * with this package, itself. - * <p>Of this package and its interdependencies, all packages which - * have not yet been registered by their URI values are first created - * and registered. The packages are then initialized in two steps: - * meta-model objects for all of the packages are created before any - * are initialized, since one package's meta-model objects may refer to - * those of another. - * <p>Invocation of this method will not affect any packages that have - * already been initialized. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static ComponentcorePackage init() { - if (isInited) return (ComponentcorePackage)EPackage.Registry.INSTANCE.getEPackage(ComponentcorePackage.eNS_URI); - - // Obtain or create and register package - ComponentcorePackageImpl theComponentcorePackage = (ComponentcorePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof ComponentcorePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new ComponentcorePackageImpl()); - - isInited = true; - - // Create package meta-data objects - theComponentcorePackage.createPackageContents(); - - // Initialize created meta-data - theComponentcorePackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theComponentcorePackage.freeze(); - - return theComponentcorePackage; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getWorkbenchComponent() { - return workbenchComponentEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getWorkbenchComponent_Name() { - return (EAttribute)workbenchComponentEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getWorkbenchComponent_Resources() { - return (EReference)workbenchComponentEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getWorkbenchComponent_ComponentType() { - return (EReference)workbenchComponentEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getWorkbenchComponent_ReferencedComponents() { - return (EReference)workbenchComponentEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getWorkbenchComponent_Properties() { - return (EReference)workbenchComponentEClass.getEStructuralFeatures().get(4); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getWorkbenchComponent_MetadataResources() { - return (EAttribute)workbenchComponentEClass.getEStructuralFeatures().get(5); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getComponentResource() { - return componentResourceEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getComponentResource_SourcePath() { - return (EAttribute)componentResourceEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getComponentResource_RuntimePath() { - return (EAttribute)componentResourceEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getComponentResource_Exclusions() { - return (EAttribute)componentResourceEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getComponentResource_Component() { - return (EReference)componentResourceEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getComponentResource_ResourceType() { - return (EAttribute)componentResourceEClass.getEStructuralFeatures().get(4); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getComponentType() { - return componentTypeEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getComponentType_ComponentTypeId() { - return (EAttribute)componentTypeEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getComponentType_Version() { - return (EAttribute)componentTypeEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getComponentType_Properties() { - return (EReference)componentTypeEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getComponentType_MetadataResources() { - return (EAttribute)componentTypeEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getProperty() { - return propertyEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getProperty_Name() { - return (EAttribute)propertyEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getProperty_Value() { - return (EAttribute)propertyEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getReferencedComponent() { - return referencedComponentEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getReferencedComponent_Handle() { - return (EAttribute)referencedComponentEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getReferencedComponent_RuntimePath() { - return (EAttribute)referencedComponentEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getReferencedComponent_DependencyType() { - return (EAttribute)referencedComponentEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getReferencedComponent_DependentObject() { - return (EReference)referencedComponentEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getReferencedComponent_ArchiveName() { - return (EAttribute)referencedComponentEClass.getEStructuralFeatures().get(4); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getProjectComponents() { - return projectComponentsEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getProjectComponents_ProjectName() { - return (EAttribute)projectComponentsEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getProjectComponents_Components() { - return (EReference)projectComponentsEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getProjectComponents_Version() { - return (EAttribute)projectComponentsEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EEnum getDependencyType() { - return dependencyTypeEEnum; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getIPath() { - return iPathEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getURI() { - return uriEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentcoreFactory getComponentcoreFactory() { - return (ComponentcoreFactory)getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - workbenchComponentEClass = createEClass(WORKBENCH_COMPONENT); - createEAttribute(workbenchComponentEClass, WORKBENCH_COMPONENT__NAME); - createEReference(workbenchComponentEClass, WORKBENCH_COMPONENT__RESOURCES); - createEReference(workbenchComponentEClass, WORKBENCH_COMPONENT__COMPONENT_TYPE); - createEReference(workbenchComponentEClass, WORKBENCH_COMPONENT__REFERENCED_COMPONENTS); - createEReference(workbenchComponentEClass, WORKBENCH_COMPONENT__PROPERTIES); - createEAttribute(workbenchComponentEClass, WORKBENCH_COMPONENT__METADATA_RESOURCES); - - componentResourceEClass = createEClass(COMPONENT_RESOURCE); - createEAttribute(componentResourceEClass, COMPONENT_RESOURCE__SOURCE_PATH); - createEAttribute(componentResourceEClass, COMPONENT_RESOURCE__RUNTIME_PATH); - createEAttribute(componentResourceEClass, COMPONENT_RESOURCE__EXCLUSIONS); - createEReference(componentResourceEClass, COMPONENT_RESOURCE__COMPONENT); - createEAttribute(componentResourceEClass, COMPONENT_RESOURCE__RESOURCE_TYPE); - - componentTypeEClass = createEClass(COMPONENT_TYPE); - createEAttribute(componentTypeEClass, COMPONENT_TYPE__COMPONENT_TYPE_ID); - createEAttribute(componentTypeEClass, COMPONENT_TYPE__VERSION); - createEReference(componentTypeEClass, COMPONENT_TYPE__PROPERTIES); - createEAttribute(componentTypeEClass, COMPONENT_TYPE__METADATA_RESOURCES); - - propertyEClass = createEClass(PROPERTY); - createEAttribute(propertyEClass, PROPERTY__NAME); - createEAttribute(propertyEClass, PROPERTY__VALUE); - - referencedComponentEClass = createEClass(REFERENCED_COMPONENT); - createEAttribute(referencedComponentEClass, REFERENCED_COMPONENT__HANDLE); - createEAttribute(referencedComponentEClass, REFERENCED_COMPONENT__RUNTIME_PATH); - createEAttribute(referencedComponentEClass, REFERENCED_COMPONENT__DEPENDENCY_TYPE); - createEReference(referencedComponentEClass, REFERENCED_COMPONENT__DEPENDENT_OBJECT); - createEAttribute(referencedComponentEClass, REFERENCED_COMPONENT__ARCHIVE_NAME); - - projectComponentsEClass = createEClass(PROJECT_COMPONENTS); - createEAttribute(projectComponentsEClass, PROJECT_COMPONENTS__PROJECT_NAME); - createEReference(projectComponentsEClass, PROJECT_COMPONENTS__COMPONENTS); - createEAttribute(projectComponentsEClass, PROJECT_COMPONENTS__VERSION); - - // Create enums - dependencyTypeEEnum = createEEnum(DEPENDENCY_TYPE); - - // Create data types - iPathEDataType = createEDataType(IPATH); - uriEDataType = createEDataType(URI); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Add supertypes to classes - - // Initialize classes and features; add operations and parameters - initEClass(workbenchComponentEClass, WorkbenchComponent.class, "WorkbenchComponent", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getWorkbenchComponent_Name(), ecorePackage.getEString(), "name", "", 1, 1, WorkbenchComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getWorkbenchComponent_Resources(), this.getComponentResource(), this.getComponentResource_Component(), "resources", null, 0, -1, WorkbenchComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getWorkbenchComponent_ComponentType(), this.getComponentType(), null, "componentType", null, 1, 1, WorkbenchComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getWorkbenchComponent_ReferencedComponents(), this.getReferencedComponent(), null, "referencedComponents", null, 0, -1, WorkbenchComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getWorkbenchComponent_Properties(), this.getProperty(), null, "properties", null, 0, -1, WorkbenchComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getWorkbenchComponent_MetadataResources(), this.getIPath(), "metadataResources", null, 0, -1, WorkbenchComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(componentResourceEClass, ComponentResource.class, "ComponentResource", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getComponentResource_SourcePath(), this.getIPath(), "sourcePath", null, 1, 1, ComponentResource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getComponentResource_RuntimePath(), this.getIPath(), "runtimePath", null, 1, 1, ComponentResource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getComponentResource_Exclusions(), ecorePackage.getEString(), "exclusions", "", 0, -1, ComponentResource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getComponentResource_Component(), this.getWorkbenchComponent(), this.getWorkbenchComponent_Resources(), "component", null, 1, 1, ComponentResource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getComponentResource_ResourceType(), ecorePackage.getEString(), "resourceType", "", 1, 1, ComponentResource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(componentTypeEClass, ComponentType.class, "ComponentType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getComponentType_ComponentTypeId(), ecorePackage.getEString(), "componentTypeId", "", 1, 1, ComponentType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getComponentType_Version(), ecorePackage.getEString(), "version", "", 1, 1, ComponentType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getComponentType_Properties(), this.getProperty(), null, "properties", null, 0, -1, ComponentType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getComponentType_MetadataResources(), this.getIPath(), "metadataResources", null, 0, -1, ComponentType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(propertyEClass, Property.class, "Property", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getProperty_Name(), ecorePackage.getEString(), "name", "", 1, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getProperty_Value(), ecorePackage.getEString(), "value", "", 1, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(referencedComponentEClass, ReferencedComponent.class, "ReferencedComponent", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getReferencedComponent_Handle(), this.getURI(), "handle", null, 1, 1, ReferencedComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getReferencedComponent_RuntimePath(), this.getIPath(), "runtimePath", null, 1, 1, ReferencedComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getReferencedComponent_DependencyType(), this.getDependencyType(), "dependencyType", null, 1, 1, ReferencedComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getReferencedComponent_DependentObject(), ecorePackage.getEObject(), null, "dependentObject", null, 0, 1, ReferencedComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getReferencedComponent_ArchiveName(), ecorePackage.getEString(), "archiveName", null, 0, 1, ReferencedComponent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(projectComponentsEClass, ProjectComponents.class, "ProjectComponents", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getProjectComponents_ProjectName(), ecorePackage.getEString(), "projectName", "", 1, 1, ProjectComponents.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getProjectComponents_Components(), this.getWorkbenchComponent(), null, "components", null, 0, -1, ProjectComponents.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getProjectComponents_Version(), ecorePackage.getEString(), "version", null, 1, 1, ProjectComponents.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - // Initialize enums and add enum literals - initEEnum(dependencyTypeEEnum, DependencyType.class, "DependencyType"); - addEEnumLiteral(dependencyTypeEEnum, DependencyType.USES_LITERAL); - addEEnumLiteral(dependencyTypeEEnum, DependencyType.CONSUMES_LITERAL); - - // Initialize data types - initEDataType(iPathEDataType, IPath.class, "IPath", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - initEDataType(uriEDataType, org.eclipse.emf.common.util.URI.class, "URI", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - - // Create resource - createResource(eNS_URI); - - // Create annotations - // keywords - createKeywordsAnnotations(); - } - - /** - * Initializes the annotations for <b>keywords</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createKeywordsAnnotations() { - String source = "keywords"; - addAnnotation - (iPathEDataType, - source, - new String[] { - "datatype", null - }); - addAnnotation - (uriEDataType, - source, - new String[] { - "datatype", null - }); - } - -} //ComponentcorePackageImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IModuleStructureListener.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IModuleStructureListener.java deleted file mode 100644 index 82a97d770..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IModuleStructureListener.java +++ /dev/null @@ -1,24 +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.wst.common.componentcore.internal.impl; - - -/** - * - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public interface IModuleStructureListener { - - public void structureChanged(ModuleStructureEvent event); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IResourceFactoryExtPtConstants.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IResourceFactoryExtPtConstants.java deleted file mode 100644 index c6e1e450b..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IResourceFactoryExtPtConstants.java +++ /dev/null @@ -1,33 +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.wst.common.componentcore.internal.impl; - -public interface IResourceFactoryExtPtConstants { - - - String EXTPT_RESOURCE_FACTORIES = "resourceFactories"; //$NON-NLS-1$ - - String TAG_RESOURCE_FACTORY = "resourceFactory"; //$NON-NLS-1$ - - String ATT_CLASS = "class"; //$NON-NLS-1$ - - String ATT_SHORT_SEGMENT = "shortSegment"; //$NON-NLS-1$ - - String TAG_CONTENTTYPE = "contentTypeBinding"; //$NON-NLS-1$ - - String ATT_CONTENTTYPEID = "contentTypeId"; //$NON-NLS-1$ - - String ATT_ISDEFAULT = "isDefault"; //$NON-NLS-1$ - - String ATT_OVERRIDES_FACTORY ="overridesFactoryClass"; //$NON-NLS-1$ - - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/MappedComponentXMIHelper.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/MappedComponentXMIHelper.java deleted file mode 100644 index 250ccb7c8..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/MappedComponentXMIHelper.java +++ /dev/null @@ -1,86 +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.wst.common.componentcore.internal.impl; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.URIConverterImpl; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; -import org.eclipse.wst.common.internal.emf.resource.MappedXMIHelper; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - -public class MappedComponentXMIHelper extends MappedXMIHelper { - - public MappedComponentXMIHelper(XMLResource resource, Map prefixesToURIs) { - super(resource, prefixesToURIs); - } - - public URI resolve(URI relative, URI base) { - URI resolved = null; - if (!isMapped(relative)) - resolved = resolveURIFromComponent(relative,base); - else - resolved = relative; - - return resolved == null ? super.resolve(relative, base) : resolved; - } - - private boolean isMapped(URI relative) { - boolean isMapped = false; - ResourceSet set = getResource().getResourceSet(); - if (set != null) { - URI localresourceURI = relative; - if (relative.hasFragment()) - localresourceURI = relative.trimFragment(); - isMapped = !((URIConverterImpl.URIMap) set.getURIConverter().getURIMap()).getURI(localresourceURI).equals(localresourceURI); - } - return isMapped; - } - - private URI resolveURIFromComponent(URI relative, URI base) { - IVirtualComponent component = getComponent(base); - if (component != null) { - IVirtualFile virtualFile = component.getRootFolder().getFile(new Path(relative.toString())); - if (virtualFile != null) { - IPath resolvingPath = virtualFile.getWorkspaceRelativePath(); - if (resolvingPath !=null) - return URI.createPlatformResourceURI(resolvingPath.toString()); - } - } - return null; - } - - private IVirtualComponent getComponent(URI base) { - ResourceSet set = getResource().getResourceSet(); - if (set == null || set.getURIConverter()==null) - return null; - URI normalized = set.getURIConverter().normalize(base); - if (WorkbenchResourceHelperBase.isPlatformResourceURI(normalized)) { - IFile file = WorkbenchResourceHelper.getPlatformFile(normalized); - if (file !=null) { - IVirtualResource[] virtualResources = ComponentCore.createResources(file); - if (virtualResources.length>0) - return virtualResources[0].getComponent(); - } - } - return null; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleIndexingAdapter.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleIndexingAdapter.java deleted file mode 100644 index 5946e5014..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleIndexingAdapter.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.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class ModuleIndexingAdapter extends AdapterImpl { - - private static final Class MODULE_INDEXING_ADAPTER_CLASS = ModuleIndexingAdapter.class; - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification aNotification) { - if (aNotification.getNotifier() instanceof EObject) { - EObject notifier = (EObject) aNotification.getNotifier(); - if (notifier.eClass().getClassifierID() == ComponentcorePackage.PROJECT_COMPONENTS) { - ProjectComponentsImpl projectModules = (ProjectComponentsImpl) notifier; - synchronized (projectModules.getModulesIndex()) { - switch (aNotification.getEventType()) { - case Notification.ADD : - WorkbenchComponent module = (WorkbenchComponent) aNotification.getNewValue(); - projectModules.getModulesIndex().put(module.getName(), module); - } - } - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object type) { - return type == MODULE_INDEXING_ADAPTER_CLASS; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleStructuralModelFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleStructuralModelFactory.java deleted file mode 100644 index 792221ef2..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleStructuralModelFactory.java +++ /dev/null @@ -1,43 +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.wst.common.componentcore.internal.impl; - -import java.util.Map; - -import org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel; -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 ModuleStructuralModelFactory extends EditModelFactory { - - public static final String MODULE_STRUCTURAL_MODEL_ID = "org.eclipse.wst.modulecore.structuralModel"; //$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) - */ - public EditModel createEditModelForRead(String anEditModelId, EMFWorkbenchContext aContext, Map theParams) { - return new ModuleStructuralModel(anEditModelId, aContext, true); - } - - /* (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) - */ - public EditModel createEditModelForWrite(String anEditModelId, EMFWorkbenchContext aContext, Map theParams) { - return new ModuleStructuralModel(anEditModelId, aContext, false); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleStructureEvent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleStructureEvent.java deleted file mode 100644 index b692e3b87..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleStructureEvent.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 - *******************************************************************************/ -/* - * Created on Jan 26, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import java.util.EventObject; - -import org.eclipse.wst.common.componentcore.internal.ComponentResource; - -//in progress... - -public class ModuleStructureEvent extends EventObject { - /** - * - */ - private static final long serialVersionUID = 1L; - private ComponentResource[] resources; - - public ModuleStructureEvent(Object source) { - super(source); - } - - public ModuleStructureEvent(Object source, ComponentResource[] theModuleResources) { - super(source); - resources = theModuleResources; - - } - - public ComponentResource[] getMoudleResources() { - return resources; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleURIUtil.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleURIUtil.java deleted file mode 100644 index 170c513b8..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ModuleURIUtil.java +++ /dev/null @@ -1,226 +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.wst.common.componentcore.internal.impl; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -/** - * - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class ModuleURIUtil { - - protected static final String RESOURCE_URI_PROTOCOL = PlatformURLModuleConnection.MODULE_PROTOCOL+IPath.SEPARATOR+PlatformURLModuleConnection.RESOURCE_MODULE+IPath.SEPARATOR; - - protected static final String ARCHIVE_URI_PROTOCOL = PlatformURLModuleConnection.MODULE_PROTOCOL+IPath.SEPARATOR+PlatformURLModuleConnection.CLASSPATH +IPath.SEPARATOR; - - public static interface ModuleURI { - public static final int SUB_PROTOCOL_INDX = 0; - public static final int PROJECT_NAME_INDX = 1; - public static final int MODULE_NAME_INDX = 2; - public static final int CONTENT_TYPE_INDX = 3; - } - - - public static final String PLATFORM_SCHEME = "platform"; //$NON-NLS-1$ - public static final String RESOURCE_PROTOCOL = "resource"; //$NON-NLS-1$ - - - /** - * <p> - * A fully-qualified module URI will contain enough information to determine the deployed name - * of the module. - * </p> - * - * @param aModuleURI - * A valid, fully-qualified module URI - * @return The deployed name of the {@see WorkbenchComponent}referenced by the module URI - * @throws UnresolveableURIException - * If the supplied module URI is invalid or unresolveable. - */ - public static String getDeployedName(URI aModuleURI) throws UnresolveableURIException { - ensureValidFullyQualifiedModuleURI(aModuleURI); - return aModuleURI.segment(ModuleURI.MODULE_NAME_INDX); - } - - public static boolean ensureValidFullyQualifiedModuleURI(URI aModuleURI) throws UnresolveableURIException { - return ensureValidFullyQualifiedModuleURI(aModuleURI, true); - } - - public static boolean ensureValidFullyQualifiedModuleURI(URI aModuleURI, boolean toThrowExceptionIfNecessary) throws UnresolveableURIException { - if (aModuleURI.segmentCount() < 3) { - if(toThrowExceptionIfNecessary) - throw new UnresolveableURIException(aModuleURI); - return false; - } - return true; - } - public static boolean isValidFullyQualifiedModuleURI(URI aModuleURI) { - if (aModuleURI.segmentCount() < 3) { - return false; - } - return true; - } - - public static boolean ensureValidFullyQualifiedPlatformURI(URI aFullyQualifiedResourceURI, boolean toThrowExceptionIfNecessary) throws UnresolveableURIException { - if (aFullyQualifiedResourceURI.segmentCount() < 2 || !PLATFORM_SCHEME.equals(aFullyQualifiedResourceURI.scheme()) || !RESOURCE_PROTOCOL.equals(aFullyQualifiedResourceURI.segment(0))) { - if (toThrowExceptionIfNecessary) - throw new UnresolveableURIException(aFullyQualifiedResourceURI); - return false; - } - return true; - } - - public static void ensureValidFullyQualifiedPlatformURI(URI aFullyQualifiedResourceURI) throws UnresolveableURIException { - ensureValidFullyQualifiedPlatformURI(aFullyQualifiedResourceURI, true); - } - - public static URI trimModuleResourcePathToModuleURI(URI aModuleResourcePath) throws UnresolveableURIException { - ensureValidFullyQualifiedModuleURI(aModuleResourcePath); - int trimIndex = (hasContentTypeName(aModuleResourcePath) ? 4 : 3); - return aModuleResourcePath.trimSegments(aModuleResourcePath.segmentCount() - trimIndex); - } - - public static URI trimWorkspacePathToProjectRelativeURI(URI aFullyQualifiedResourceURI) throws UnresolveableURIException { - URI projectRelativePath = null; - /* Check for a non-hierachical Workspace-relative path of the form platform:/resource/<project>/...*/ - if (ensureValidFullyQualifiedPlatformURI(aFullyQualifiedResourceURI, false)) { - if (aFullyQualifiedResourceURI.segmentCount() == 2) - /* The URI points to a project, resolve to an empty URI */ - return URI.createURI(""); //$NON-NLS-1$ - - /* - * The URI has to be > 2 since the validation method above checks for < 2, and just - * checked for == 2 so if X NOT < 2 and X NOT == 2, THEN > 2 - */ - projectRelativePath = trimToRelativePath(aFullyQualifiedResourceURI, 2); - - } else if(aFullyQualifiedResourceURI.isHierarchical() && aFullyQualifiedResourceURI.path().startsWith(""+IPath.SEPARATOR)) { - projectRelativePath = trimToRelativePath(aFullyQualifiedResourceURI, 1); - } else { - throw new UnresolveableURIException(aFullyQualifiedResourceURI); - } - return projectRelativePath; - } - - public static URI trimToRelativePath(URI aURI, int aStartIndex) { - StringBuffer relativePath = new StringBuffer(); - for (int segmentIndex = aStartIndex; segmentIndex < aURI.segmentCount(); segmentIndex++) { - relativePath.append(aURI.segment(segmentIndex)); - if (segmentIndex < (aURI.segmentCount() - 1)) - relativePath.append(IPath.SEPARATOR); - } - return URI.createURI(relativePath.toString()); - } - - - /** - * @param aModuleResourcePath - * @return - */ - public static URI trimToDeployPathSegment(URI aFullyQualifiedModuleResourcePath) { - int segmentCount = aFullyQualifiedModuleResourcePath.segmentCount(); - URI uri; - int trimIndex = (hasContentTypeName(aFullyQualifiedModuleResourcePath) ? 5 : 4); - if(segmentCount > trimIndex){ - uri = aFullyQualifiedModuleResourcePath.deresolve(aFullyQualifiedModuleResourcePath.trimSegments(segmentCount - trimIndex), false,false,true); - } else { - uri = URI.createURI(aFullyQualifiedModuleResourcePath.segment(segmentCount-1)); - } - return uri; - } - - public static URI concat(URI uri1, URI uri2){ - URI concatURI = uri1.appendSegments(uri2.segments()); - return concatURI; - } - - public static URI fullyQualifyURI(WorkbenchComponent aComponent) { - try { - if(ensureValidFullyQualifiedModuleURI(aComponent.getHandle(), false)) - return aComponent.getHandle(); - IProject project = StructureEdit.getContainingProject(aComponent); - if(project != null) { - return URI.createURI(RESOURCE_URI_PROTOCOL + project.getName() + IPath.SEPARATOR + aComponent.getName()); - } - } catch (UnresolveableURIException e) { - // Ignore - } - return null; - } - - - public static URI fullyQualifyURI(IProject aProject) { - return URI.createURI(RESOURCE_URI_PROTOCOL + aProject.getName() + IPath.SEPARATOR + aProject.getName()); - } - public static URI fullyQualifyURI(IProject aProject, String contentTypeDescriber) { - return URI.createURI(RESOURCE_URI_PROTOCOL + aProject.getName() + IPath.SEPARATOR + aProject.getName() + IPath.SEPARATOR + contentTypeDescriber); - } - - public static URI archiveComponentfullyQualifyURI(String aComponentName) { - return URI.createURI(ARCHIVE_URI_PROTOCOL + aComponentName); - } - - public static boolean isClassPathURI(URI uri){ - if(uri!=null && PlatformURLModuleConnection.CLASSPATH.equals(uri.segment(0) )){ - return true; - } - return false; - } - - public static String getArchiveType(URI aModuleURI)throws UnresolveableURIException { - ensureValidFullyQualifiedModuleURI(aModuleURI); - return aModuleURI.segment(ModuleURI.PROJECT_NAME_INDX); - } - - public static String getArchiveName(URI aModuleURI)throws UnresolveableURIException { - ensureValidFullyQualifiedModuleURI(aModuleURI); - URI uri = trimToRelativePath(aModuleURI, ModuleURI.MODULE_NAME_INDX); - return uri.toString(); - } - public static String getHandleString(IVirtualComponent aComponent){ - if (aComponent.isBinary()) - return ModuleURIUtil.archiveComponentfullyQualifyURI(aComponent.getName()).toString(); - else - return "[" + aComponent.getProject().getFullPath() + "]:" + aComponent.getProject().getName(); - } - - public static String getContentTypeName(URI uri) { - - if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri) || !isValidFullyQualifiedModuleURI(uri)) - return null; - String contentTypeIdentifier = (uri.segmentCount() > 3 ? uri.segment(ModuleURI.CONTENT_TYPE_INDX) : null); - if (contentTypeIdentifier != null && Platform.getContentTypeManager().getContentType(uri.segment(ModuleURI.CONTENT_TYPE_INDX)) != null) - return contentTypeIdentifier; - else - return null; - } - public static boolean hasContentTypeName(URI uri) { - - if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri)) - return false; - String contentTypeIdentifier = (uri.segmentCount() > 3 ? uri.segment(ModuleURI.CONTENT_TYPE_INDX) : null); - if (contentTypeIdentifier != null && Platform.getContentTypeManager().getContentType(uri.segment(ModuleURI.CONTENT_TYPE_INDX)) != null) - return true; - else - return false; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/PlatformURLModuleConnection.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/PlatformURLModuleConnection.java deleted file mode 100644 index 603368707..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/PlatformURLModuleConnection.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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 - *******************************************************************************/ -/* - * Created on Jan 20, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import java.io.IOException; -import java.net.URL; - -import org.eclipse.core.internal.boot.PlatformURLConnection; -import org.eclipse.core.internal.boot.PlatformURLHandler; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; - -/** - * @author mdelder - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class PlatformURLModuleConnection extends PlatformURLConnection { - - public static final String MODULE = "module"; //$NON-NLS-1$ - public static final String MODULE_PROTOCOL = MODULE + PlatformURLHandler.PROTOCOL_SEPARATOR; - - public static final String CLASSPATH = "classpath"; //$NON-NLS-1$ - - public static final String RESOURCE_MODULE = "resource"; //$NON-NLS-1$ - public static final String BINARY_MODULE = "binary"; //$NON-NLS-1$ - - - public PlatformURLModuleConnection(URL aURL) { - super(aURL); - } - - public static URI resolve(URI aModuleResourceRuntimePath) throws IOException { - try { - IProject componentProject = StructureEdit.getContainingProject(aModuleResourceRuntimePath); - //String componentName = ModuleURIUtil.getDeployedName(aModuleResourceRuntimePath); - URI runtimeURI = ModuleURIUtil.trimToDeployPathSegment(aModuleResourceRuntimePath); - IPath runtimePath = new Path(runtimeURI.path()); - IVirtualComponent component = ComponentCore.createComponent(componentProject); - //IVirtualFile vFile = component.getFile(runtimePath); - IVirtualFolder rootFolder = component.getRootFolder(); - int matchingSegs = runtimePath.matchingFirstSegments(rootFolder.getProjectRelativePath()); - if(matchingSegs > 0) - runtimePath = runtimePath.removeFirstSegments(matchingSegs); - IVirtualFile vFile = rootFolder.getFile(runtimePath); - return URI.createPlatformResourceURI(vFile.getWorkspaceRelativePath().toString()); - } catch (Exception e) { - } - return aModuleResourceRuntimePath; - - } - -// private static URI normalizeToWorkspaceRelative(IProject project, IPath sourcePath, URI moduleResourceDeployPath) throws UnresolveableURIException { -// String projectName = project.getName(); -// return URI.createURI(projectName + '/' + sourcePath.toString()); -// } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.internal.boot.PlatformURLConnection#resolve() - */ - protected URL resolve() throws IOException { - System.out.println("URL: " + getURL()); - //IPath moduleRelativePath = new Path(getURL().toExternalForm()); - //String moduleName = moduleRelativePath.segment(1); - - IPath resolvedPath = null; // handle.getResolvedPath().append(moduleRelativePath.removeFirstSegments(2)); - - int count = resolvedPath.segmentCount(); - // if there are two segments then the second is a project name. - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(resolvedPath.segment(0)); - if (!project.exists()) { - // TODO Fix this string - String message = "Could not resolve URL"; //Policy.bind("url.couldNotResolve", project.getName(), url.toExternalForm()); //$NON-NLS-1$ - throw new IOException(message); - } - IPath result = null; - if (count == 2) - result = project.getLocation(); - else { - resolvedPath = resolvedPath.removeFirstSegments(2); - result = project.getFile(resolvedPath).getLocation(); - } - return new URL("file", "", result.toString()); //$NON-NLS-1$ //$NON-NLS-2$ - - } - - public static void startup() { - PlatformURLHandler.register(PlatformURLModuleConnection.MODULE, PlatformURLModuleConnection.class); - } - - // private IProject getRelevantProject(URI aModuleURI) { - // aModuleURI.segment() - // } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ProjectComponentsImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ProjectComponentsImpl.java deleted file mode 100644 index e0645d77e..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ProjectComponentsImpl.java +++ /dev/null @@ -1,313 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ProjectComponentsImpl.java,v 1.3 2006/04/27 04:17:40 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>Project Modules</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ProjectComponentsImpl#getProjectName <em>Project Name</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ProjectComponentsImpl#getComponents <em>Components</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ProjectComponentsImpl#getVersion <em>Version</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ProjectComponentsImpl extends EObjectImpl implements ProjectComponents { - /** - * The default value of the '{@link #getProjectName() <em>Project Name</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getProjectName() - * @generated - * @ordered - */ - protected static final String PROJECT_NAME_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getProjectName() <em>Project Name</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getProjectName() - * @generated - * @ordered - */ - protected String projectName = PROJECT_NAME_EDEFAULT; - - /** - * The cached value of the '{@link #getComponents() <em>Components</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getComponents() - * @generated - * @ordered - */ - protected EList components = null; - - /** - * The default value of the '{@link #getVersion() <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVersion() - * @generated - * @ordered - */ - protected static final String VERSION_EDEFAULT = "1.0.0"; - - /** - * The cached value of the '{@link #getVersion() <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVersion() - * @generated - * @ordered - */ - protected String version = VERSION_EDEFAULT; - - private boolean isIndexed; - - private final Map modulesIndex = new HashMap(); - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - protected ProjectComponentsImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ComponentcorePackage.Literals.PROJECT_COMPONENTS; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public String getProjectName() { - return projectName; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public void setProjectName(String newProjectName) { - String oldProjectName = projectName; - projectName = newProjectName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.PROJECT_COMPONENTS__PROJECT_NAME, oldProjectName, projectName)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getComponents() { - if (components == null) { - components = new EObjectContainmentEList(WorkbenchComponent.class, this, ComponentcorePackage.PROJECT_COMPONENTS__COMPONENTS); - } - return components; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getVersion() { - return version; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setVersion(String newVersion) { - String oldVersion = version; - version = newVersion; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.PROJECT_COMPONENTS__VERSION, oldVersion, version)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case ComponentcorePackage.PROJECT_COMPONENTS__COMPONENTS: - return ((InternalEList)getComponents()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ComponentcorePackage.PROJECT_COMPONENTS__PROJECT_NAME: - return getProjectName(); - case ComponentcorePackage.PROJECT_COMPONENTS__COMPONENTS: - return getComponents(); - case ComponentcorePackage.PROJECT_COMPONENTS__VERSION: - return getVersion(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ComponentcorePackage.PROJECT_COMPONENTS__PROJECT_NAME: - setProjectName((String)newValue); - return; - case ComponentcorePackage.PROJECT_COMPONENTS__COMPONENTS: - getComponents().clear(); - getComponents().addAll((Collection)newValue); - return; - case ComponentcorePackage.PROJECT_COMPONENTS__VERSION: - setVersion((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case ComponentcorePackage.PROJECT_COMPONENTS__PROJECT_NAME: - setProjectName(PROJECT_NAME_EDEFAULT); - return; - case ComponentcorePackage.PROJECT_COMPONENTS__COMPONENTS: - getComponents().clear(); - return; - case ComponentcorePackage.PROJECT_COMPONENTS__VERSION: - setVersion(VERSION_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case ComponentcorePackage.PROJECT_COMPONENTS__PROJECT_NAME: - return PROJECT_NAME_EDEFAULT == null ? projectName != null : !PROJECT_NAME_EDEFAULT.equals(projectName); - case ComponentcorePackage.PROJECT_COMPONENTS__COMPONENTS: - return components != null && !components.isEmpty(); - case ComponentcorePackage.PROJECT_COMPONENTS__VERSION: - return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (projectName: "); - result.append(projectName); - result.append(", version: "); - result.append(version); - result.append(')'); - return result.toString(); - } - - public WorkbenchComponent findWorkbenchModule(String aDeployName) { - if (getComponents().size() == 1) - return ((WorkbenchComponent)getComponents().get(0)).getName().equals(aDeployName) ? (WorkbenchComponent)getComponents().get(0) : null; - if (!isIndexed()) - indexModules(); - return (WorkbenchComponent) getModulesIndex().get(aDeployName); - } - - /** - * @return - */ - private boolean isIndexed() { - return isIndexed; - } - - /** - * - */ - private void indexModules() { - if (isIndexed) - return; - - synchronized (modulesIndex) { - Adapter adapter = EcoreUtil.getAdapter(eAdapters(), ModuleIndexingAdapter.class); - if (adapter == null) - eAdapters().add((adapter = new ModuleIndexingAdapter())); - - WorkbenchComponent module = null; - for(Iterator iter = getComponents().iterator(); iter.hasNext(); ) { - module = (WorkbenchComponent) iter.next(); - modulesIndex.put(module.getName(), module); - } - } - isIndexed = true; - } - - /** - * @return - */ - /* package */ Map getModulesIndex() { - return modulesIndex; - } - -} // ProjectComponentsImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/PropertyImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/PropertyImpl.java deleted file mode 100644 index eae8a933a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/PropertyImpl.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: PropertyImpl.java,v 1.1 2005/04/04 07:04:59 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.Property; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Property</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.PropertyImpl#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.PropertyImpl#getValue <em>Value</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class PropertyImpl extends EObjectImpl implements Property { - /** - * The default value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - - /** - * The default value of the '{@link #getValue() <em>Value</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getValue() - * @generated - * @ordered - */ - protected static final String VALUE_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getValue() - * @generated - * @ordered - */ - protected String value = VALUE_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected PropertyImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ComponentcorePackage.eINSTANCE.getProperty(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getName() { - return name; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setName(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.PROPERTY__NAME, oldName, name)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getValue() { - return value; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setValue(String newValue) { - String oldValue = value; - value = newValue; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.PROPERTY__VALUE, oldValue, value)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.PROPERTY__NAME: - return getName(); - case ComponentcorePackage.PROPERTY__VALUE: - return getValue(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.PROPERTY__NAME: - setName((String)newValue); - return; - case ComponentcorePackage.PROPERTY__VALUE: - setValue((String)newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.PROPERTY__NAME: - setName(NAME_EDEFAULT); - return; - case ComponentcorePackage.PROPERTY__VALUE: - setValue(VALUE_EDEFAULT); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.PROPERTY__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); - case ComponentcorePackage.PROPERTY__VALUE: - return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); - } - return eDynamicIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (name: "); - result.append(name); - result.append(", value: "); - result.append(value); - result.append(')'); - return result.toString(); - } - -} //PropertyImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentImpl.java deleted file mode 100644 index f17b3dcb0..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentImpl.java +++ /dev/null @@ -1,387 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ReferencedComponentImpl.java,v 1.4 2007/02/14 16:00:52 jsholl Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.DependencyType; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Dependent Module</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl#getHandle <em>Handle</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl#getRuntimePath <em>Runtime Path</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl#getDependencyType <em>Dependency Type</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl#getDependentObject <em>Dependent Object</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ReferencedComponentImpl#getArchiveName <em>Archive Name</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ReferencedComponentImpl extends EObjectImpl implements ReferencedComponent { - /** - * The default value of the '{@link #getHandle() <em>Handle</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getHandle() - * @generated - * @ordered - */ - protected static final URI HANDLE_EDEFAULT = null; - - /** - * The cached value of the '{@link #getHandle() <em>Handle</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getHandle() - * @generated - * @ordered - */ - protected URI handle = HANDLE_EDEFAULT; - - /** - * The default value of the '{@link #getRuntimePath() <em>Runtime Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRuntimePath() - * @generated - * @ordered - */ - protected static final IPath RUNTIME_PATH_EDEFAULT = null; - - /** - * The cached value of the '{@link #getRuntimePath() <em>Runtime Path</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRuntimePath() - * @generated - * @ordered - */ - protected IPath runtimePath = RUNTIME_PATH_EDEFAULT; - - /** - * The default value of the '{@link #getDependencyType() <em>Dependency Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDependencyType() - * @generated - * @ordered - */ - protected static final DependencyType DEPENDENCY_TYPE_EDEFAULT = DependencyType.USES_LITERAL; - - /** - * The cached value of the '{@link #getDependencyType() <em>Dependency Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDependencyType() - * @generated - * @ordered - */ - protected DependencyType dependencyType = DEPENDENCY_TYPE_EDEFAULT; - - /** - * The cached value of the '{@link #getDependentObject() <em>Dependent Object</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDependentObject() - * @generated - * @ordered - */ - protected EObject dependentObject = null; - - /** - * The default value of the '{@link #getArchiveName() <em>Archive Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getArchiveName() - * @generated - * @ordered - */ - protected static final String ARCHIVE_NAME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getArchiveName() <em>Archive Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getArchiveName() - * @generated - * @ordered - */ - protected String archiveName = ARCHIVE_NAME_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ReferencedComponentImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ComponentcorePackage.eINSTANCE.getReferencedComponent(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public URI getHandle() { - return handle; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setHandle(URI newHandle) { - URI oldHandle = handle; - handle = newHandle; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.REFERENCED_COMPONENT__HANDLE, oldHandle, handle)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPath getRuntimePath() { - return runtimePath; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setRuntimePath(IPath newRuntimePath) { - IPath oldRuntimePath = runtimePath; - runtimePath = newRuntimePath; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.REFERENCED_COMPONENT__RUNTIME_PATH, oldRuntimePath, runtimePath)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public DependencyType getDependencyType() { - return dependencyType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDependencyType(DependencyType newDependencyType) { - DependencyType oldDependencyType = dependencyType; - dependencyType = newDependencyType == null ? DEPENDENCY_TYPE_EDEFAULT : newDependencyType; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENCY_TYPE, oldDependencyType, dependencyType)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EObject getDependentObject() { - if (dependentObject != null && dependentObject.eIsProxy()) { - EObject oldDependentObject = dependentObject; - dependentObject = eResolveProxy((InternalEObject)dependentObject); - if (dependentObject != oldDependentObject) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENT_OBJECT, oldDependentObject, dependentObject)); - } - } - return dependentObject; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EObject basicGetDependentObject() { - return dependentObject; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDependentObject(EObject newDependentObject) { - EObject oldDependentObject = dependentObject; - dependentObject = newDependentObject; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENT_OBJECT, oldDependentObject, dependentObject)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getArchiveName() { - return archiveName; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setArchiveName(String newArchiveName) { - String oldArchiveName = archiveName; - archiveName = newArchiveName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.REFERENCED_COMPONENT__ARCHIVE_NAME, oldArchiveName, archiveName)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.REFERENCED_COMPONENT__HANDLE: - return getHandle(); - case ComponentcorePackage.REFERENCED_COMPONENT__RUNTIME_PATH: - return getRuntimePath(); - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENCY_TYPE: - return getDependencyType(); - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENT_OBJECT: - if (resolve) return getDependentObject(); - return basicGetDependentObject(); - case ComponentcorePackage.REFERENCED_COMPONENT__ARCHIVE_NAME: - return getArchiveName(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.REFERENCED_COMPONENT__HANDLE: - setHandle((URI)newValue); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__RUNTIME_PATH: - setRuntimePath((IPath)newValue); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENCY_TYPE: - setDependencyType((DependencyType)newValue); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENT_OBJECT: - setDependentObject((EObject)newValue); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__ARCHIVE_NAME: - setArchiveName((String)newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.REFERENCED_COMPONENT__HANDLE: - setHandle(HANDLE_EDEFAULT); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__RUNTIME_PATH: - setRuntimePath(RUNTIME_PATH_EDEFAULT); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENCY_TYPE: - setDependencyType(DEPENDENCY_TYPE_EDEFAULT); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENT_OBJECT: - setDependentObject((EObject)null); - return; - case ComponentcorePackage.REFERENCED_COMPONENT__ARCHIVE_NAME: - setArchiveName(ARCHIVE_NAME_EDEFAULT); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.REFERENCED_COMPONENT__HANDLE: - return HANDLE_EDEFAULT == null ? handle != null : !HANDLE_EDEFAULT.equals(handle); - case ComponentcorePackage.REFERENCED_COMPONENT__RUNTIME_PATH: - return RUNTIME_PATH_EDEFAULT == null ? runtimePath != null : !RUNTIME_PATH_EDEFAULT.equals(runtimePath); - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENCY_TYPE: - return dependencyType != DEPENDENCY_TYPE_EDEFAULT; - case ComponentcorePackage.REFERENCED_COMPONENT__DEPENDENT_OBJECT: - return dependentObject != null; - case ComponentcorePackage.REFERENCED_COMPONENT__ARCHIVE_NAME: - return ARCHIVE_NAME_EDEFAULT == null ? archiveName != null : !ARCHIVE_NAME_EDEFAULT.equals(archiveName); - } - return eDynamicIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (handle: "); - result.append(handle); - result.append(", runtimePath: "); - result.append(runtimePath); - result.append(", dependencyType: "); - result.append(dependencyType); - result.append(", archiveName: "); - result.append(archiveName); - result.append(')'); - return result.toString(); - } - -} //ReferencedComponentImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentXMIResourceFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentXMIResourceFactory.java deleted file mode 100644 index 2a157ad4b..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentXMIResourceFactory.java +++ /dev/null @@ -1,34 +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.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.wst.common.internal.emf.resource.ReferencedXMIFactoryImpl; - -public class ReferencedComponentXMIResourceFactory extends - ReferencedXMIFactoryImpl { - - public ReferencedComponentXMIResourceFactory() { - super(); - // TODO Auto-generated constructor stub - } - /** - * This is the method that subclasses can override to actually instantiate a new Resource - * - * @param uri - * @return - */ - protected Resource doCreateResource(URI uri) { - return new ReferencedComponentXMIResourceImpl(uri); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentXMIResourceImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentXMIResourceImpl.java deleted file mode 100644 index 333b4b0e3..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ReferencedComponentXMIResourceImpl.java +++ /dev/null @@ -1,34 +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.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.wst.common.internal.emf.resource.MappedXMIHelper; -import org.eclipse.wst.common.internal.emf.resource.ReferencedXMIResourceImpl; - -public class ReferencedComponentXMIResourceImpl extends - ReferencedXMIResourceImpl implements Resource { - - public ReferencedComponentXMIResourceImpl() { - super(); - // TODO Auto-generated constructor stub - } - - public ReferencedComponentXMIResourceImpl(URI uri) { - super(uri); - // TODO Auto-generated constructor stub - } - protected MappedXMIHelper doCreateXMLHelper() { - return new MappedComponentXMIHelper(this, getPrefixToPackageURIs()); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeNode.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeNode.java deleted file mode 100644 index eaab41da2..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeNode.java +++ /dev/null @@ -1,288 +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.wst.common.componentcore.internal.impl; - -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.util.IPathProvider; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class ResourceTreeNode { - - public static final int CREATE_NONE = 0x0; - /** - * Type constant (bit mask value 1) which identifies creating child nodes. - * - */ - public static final int CREATE_TREENODE_IFNEC = 0x1; - - /** - * Type constant (bit mask value 2) which identifies always creating a virtual resource. - * - */ - public static final int CREATE_RESOURCE_ALWAYS = 0x2; - - private final Set moduleResources = Collections.synchronizedSet(new LinkedHashSet()); - private final Map children = Collections.synchronizedMap(new LinkedHashMap()); - private final Map transientChildResources = Collections.synchronizedMap(new LinkedHashMap()); - private static final ComponentResource[] NO_MODULE_RESOURCES = new ComponentResource[]{}; - private IPathProvider pathProvider; -// private ResourceTreeNode parent; - private String pathSegment; - - public ResourceTreeNode(String aPathSegment, ResourceTreeNode parent, IPathProvider aPathProvider) { - pathSegment = aPathSegment; - pathProvider = aPathProvider; - } - - public ResourceTreeNode addChild(ResourceTreeNode aChild) { - children.put(aChild.getPathSegment(), aChild); - return aChild; - } - - public ResourceTreeNode addChild(ComponentResource aModuleResource) { - ResourceTreeNode newChild = findChild(getPathProvider().getPath(aModuleResource), CREATE_TREENODE_IFNEC); - if(newChild != null) { - newChild.addModuleResource(aModuleResource); - return newChild; - } - return null; - } - - public ResourceTreeNode removeChild(ResourceTreeNode aChild) { - return (ResourceTreeNode) children.remove(aChild.getPathSegment()); - } - - public ResourceTreeNode removeChild(ComponentResource aModuleResource) { - ResourceTreeNode containingChild = findChild(getPathProvider().getPath(aModuleResource), CREATE_NONE); - if(containingChild != null) { - containingChild.removeResource(aModuleResource); - if(containingChild.hasModuleResources()) - return containingChild; - return removeChild(containingChild); - } - return null; - } - - public ResourceTreeNode removeChild(IPath targetPath, ComponentResource aModuleResource) { - ResourceTreeNode containingChild = findChild(targetPath, CREATE_NONE); - if(containingChild != null) { - containingChild.removeResource(aModuleResource); - if(containingChild.hasModuleResources()) - return containingChild; - return removeChild(containingChild); - } - return null; - } - - public void removeResource(ComponentResource aResource) { - moduleResources.remove(aResource); - } - - public ResourceTreeNode findChild(IPath aPath) { - return findChild(aPath, CREATE_TREENODE_IFNEC); - } - - public ResourceTreeNode findChild(IPath aPath, int creationFlags) { - if(aPath == null) - return null; - ResourceTreeNode child = this; - if (aPath.segmentCount() > 0) { - child = findChild(aPath.segment(0), creationFlags); - if (child == null) - return null; - if (aPath.segmentCount() == 1) - return child; - child = child.findChild(aPath.removeFirstSegments(1), creationFlags); - - } - return child; - } - - public ResourceTreeNode findChild(String aPathSegment) { - if (aPathSegment == null || aPathSegment.length() == 0) - return this; - return findChild(aPathSegment, CREATE_NONE); - } - - public ResourceTreeNode findChild(String aPathSegment, int creationFlags) { - boolean toCreateChildIfNecessary = (creationFlags & CREATE_TREENODE_IFNEC) == CREATE_TREENODE_IFNEC; - ResourceTreeNode childNode = (ResourceTreeNode) children.get(aPathSegment); - if (childNode == null && toCreateChildIfNecessary) - childNode = addChild(aPathSegment); - return childNode; - } - - public ComponentResource[] findModuleResources(IPath aPath, int creationFlags) { - - Set foundModuleResources = findModuleResourcesSet(aPath, aPath, creationFlags); - if (foundModuleResources.size() == 0) - return NO_MODULE_RESOURCES; - return (ComponentResource[]) foundModuleResources.toArray(new ComponentResource[foundModuleResources.size()]); - } - public boolean exists(IPath aPath, int creationFlags) { - - Set foundModuleResources = findModuleResourcesSet(aPath, aPath, creationFlags); - if (foundModuleResources.size() == 0) { - if (true) { - ResourceTreeNode child = findChild(aPath.segment(0), creationFlags); - if (child != null) - return true; - } - return false; - } - return true; - } - - public boolean hasModuleResources() { - return moduleResources.size() > 0; - } - - public ComponentResource[] getModuleResources() { - return (ComponentResource[]) moduleResources.toArray(new ComponentResource[moduleResources.size()]); - } - - private Set findModuleResourcesSet(IPath aFullPath, IPath aPath, int creationFlags) { - - if (aPath.segmentCount() == 0) { - Set resources = aggregateResources(new LinkedHashSet()); - return resources; - } - ResourceTreeNode child = findChild(aPath.segment(0), creationFlags); - if (child == null) - return findMatchingVirtualPathsSet(aFullPath, aPath, creationFlags); - Set foundResources = new LinkedHashSet(); - foundResources.addAll(child.findModuleResourcesSet(aFullPath, aPath.removeFirstSegments(1), creationFlags)); - foundResources.addAll(findMatchingVirtualPathsSet(aFullPath, aPath, creationFlags)); - return foundResources; - } - - private Set findMatchingVirtualPathsSet(IPath aFullPath, IPath aPath, int creationFlags) { - boolean toCreateResourceAlways = (creationFlags & CREATE_RESOURCE_ALWAYS) == CREATE_RESOURCE_ALWAYS; - if (hasModuleResources()) { - ComponentResource moduleResource = null; - IResource eclipseResource = null; - IContainer eclipseContainer = null; - Set resultSet = new LinkedHashSet(); - for (Iterator resourceIter = moduleResources.iterator(); resourceIter.hasNext();) { - moduleResource = (ComponentResource) resourceIter.next(); - if(moduleResource.getRuntimePath() != null && moduleResource.eResource() != null) { - eclipseResource = StructureEdit.getEclipseResource(moduleResource); - - if (eclipseResource != null && (eclipseResource.getType() == IResource.FOLDER || eclipseResource.getType() == IResource.PROJECT)) { - eclipseContainer = (IContainer) eclipseResource; - - IPath runtimeURI = moduleResource.getRuntimePath().append(aPath); - IPath srcPath = eclipseContainer.getProjectRelativePath().append(aPath); - - // check for existing subpath in tree - ComponentResource newResource = findExistingComponentResource(moduleResource.getComponent(), runtimeURI, srcPath); - - // add new resource if null - if(newResource == null) { - // flesh out the tree - IResource eclipseRes = eclipseContainer.findMember(aPath); - if ((toCreateResourceAlways) || (eclipseRes != null)) { - newResource = (ComponentResource)transientChildResources.get(srcPath); - if (newResource == null) { - newResource = ComponentcorePackage.eINSTANCE.getComponentcoreFactory().createComponentResource(); - // Not setting the parent on this transient child resource - // newResource.setComponent(moduleResource.getComponent()); - newResource.setRuntimePath(runtimeURI); - newResource.setSourcePath(srcPath); - if (eclipseRes != null) - newResource.setOwningProject(eclipseRes.getProject()); - transientChildResources.put(srcPath,newResource); - } - resultSet.add(newResource); - } - } - } - - } - } - return resultSet.size() > 0 ? resultSet : Collections.EMPTY_SET; - } - return Collections.EMPTY_SET; - } - - private ComponentResource findExistingComponentResource(WorkbenchComponent component, IPath runtimeURI, IPath srcPath) { - List resources = component.getResources(); - for (Iterator iter = resources.iterator(); iter.hasNext();) { - ComponentResource element = (ComponentResource) iter.next(); - if(runtimeURI.equals(element.getRuntimePath()) && srcPath.equals(element.getSourcePath())) - return element; - - } - return null; - } - - private Set aggregateResources(Set anAggregationSet) { - if (hasModuleResources()) - anAggregationSet.addAll(moduleResources); - ResourceTreeNode childNode = null; - for (Iterator childrenIterator = children.values().iterator(); childrenIterator.hasNext();) { - childNode = (ResourceTreeNode) childrenIterator.next(); - childNode.aggregateResources(anAggregationSet); - } - return anAggregationSet; - } - - public int childrenCount() { - return children.size(); - } - - public String getPathSegment() { - return pathSegment; - } - - protected ResourceTreeNode addChild(String aPathSegment) { - ResourceTreeNode newChild = null; - if ((newChild = (ResourceTreeNode) children.get(aPathSegment)) == null) { - newChild = new ResourceTreeNode(aPathSegment, this, pathProvider); - children.put(newChild.getPathSegment(), newChild); - } - return newChild; - } - - protected ResourceTreeNode removeChild(String aPathSegment) { - return (ResourceTreeNode) children.remove(aPathSegment); - } - - /* package */void addModuleResource(ComponentResource aModuleResource) { - moduleResources.add(aModuleResource); - } - - /* package */IPathProvider getPathProvider() { - return pathProvider; - } - - public Map getChildren() { - return children; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeRoot.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeRoot.java deleted file mode 100644 index 53293cdcf..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeRoot.java +++ /dev/null @@ -1,177 +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.wst.common.componentcore.internal.impl; - -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.common.util.URI; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.util.IPathProvider; -import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class ResourceTreeRoot extends ResourceTreeNode { - - private class ResourceTreeResourceListener extends AdapterImpl { - public void notifyChanged(Notification msg) { - - if(msg.getFeature() == ComponentcorePackage.eINSTANCE.getWorkbenchComponent_Resources()) { - ComponentResource resource = null; - switch(msg.getEventType()) { - case Notification.ADD: - resource = (ComponentResource) msg.getNewValue(); - if(resource != null) - resource.eAdapters().add(getResourcePathListenerAdapter()); - break; - case Notification.ADD_MANY: - List newValues = (List) msg.getNewValue(); - for (int i = 0; i < newValues.size(); i++) { - resource = (ComponentResource) newValues.get(i); - resource.eAdapters().add(getResourcePathListenerAdapter()); - } - break; - case Notification.REMOVE: - resource = (ComponentResource) msg.getOldValue(); - if(resource != null){ - resource.eAdapters().remove(getResourcePathListenerAdapter()); - removeChild(resource); - } - break; - case Notification.REMOVE_MANY: - List removedValues = (List) msg.getOldValue(); - if (removedValues != null) { - for (int i = 0; i < removedValues.size(); i++) { - resource = (ComponentResource) removedValues.get(i); - resource.eAdapters().remove(getResourcePathListenerAdapter()); - removeChild(resource); - } - } - break; - } - } - } - } - - private class ResourcePathListener extends AdapterImpl { - - public void setTarget(Notifier newTarget) { - if(newTarget instanceof ComponentResource) { -// if(getTarget() != null) { -// if(getPathProvider().getPath((ComponentResource)getTarget()) != null) -// removeChild((ComponentResource)getTarget()); -// } - ComponentResource resource = (ComponentResource) newTarget; - if(resource != null) { - if(getPathProvider().getPath(resource) != null) - addChild(resource); - } - } - super.setTarget(newTarget); - } - - public void notifyChanged(Notification msg) { - - if(msg.getFeature() == getPathProvider().getFeature()) { - ComponentResource resource = (ComponentResource) msg.getNotifier(); - switch(msg.getEventType()) { - case Notification.SET: - - // remove the old value - IPath oldPath = (IPath)msg.getOldValue(); - if(oldPath!=null) - removeChild(oldPath, resource); - - IPath newPath = (IPath)msg.getNewValue(); - if(newPath!=null) - addChild(resource); - break; - } - } - } - } - - // TODO The source tree should be attached to the project modules root, not each module. - public static ResourceTreeRoot getSourceResourceTreeRoot(WorkbenchComponent aModule) { - ResourceTreeRootAdapter resourceTreeAdapter = (ResourceTreeRootAdapter) ExtendedEcoreUtil.getAdapter(aModule, aModule.eAdapters(), ResourceTreeRootAdapter.SOURCE_ADAPTER_TYPE); - if (resourceTreeAdapter != null) - return resourceTreeAdapter.getResourceTreeRoot(); - resourceTreeAdapter = new ResourceTreeRootAdapter(ResourceTreeRootAdapter.SOURCE_TREE); - aModule.eAdapters().add(resourceTreeAdapter); - return resourceTreeAdapter.getResourceTreeRoot(); - } - - public static ResourceTreeRoot getDeployResourceTreeRoot(WorkbenchComponent aModule) { - ResourceTreeRootAdapter resourceTreeAdapter = (ResourceTreeRootAdapter) ExtendedEcoreUtil.getAdapter(aModule, aModule.eAdapters(), ResourceTreeRootAdapter.DEPLOY_ADAPTER_TYPE); - if (resourceTreeAdapter != null) - return resourceTreeAdapter.getResourceTreeRoot(); - resourceTreeAdapter = new ResourceTreeRootAdapter(ResourceTreeRootAdapter.DEPLOY_TREE); - aModule.eAdapters().add(resourceTreeAdapter); - return resourceTreeAdapter.getResourceTreeRoot(); - } - - private final WorkbenchComponent module; - private ResourceTreeResourceListener listener; - private ResourcePathListener pathListener; - - public ResourceTreeRoot(WorkbenchComponent aModule, IPathProvider aPathProvider) { - super("/", null, aPathProvider); //$NON-NLS-1$ - module = aModule; - init(); - } - - private void init() { - module.eAdapters().add(getResourceTreeListenerAdapter()); - List moduleResources = module.getResources(); - ComponentResource moduleResource = null; - - for (int i = 0; i < moduleResources.size(); i++) { - moduleResource = (ComponentResource) moduleResources.get(i); - addChild(moduleResource); - } - - } - - protected ResourceTreeResourceListener getResourceTreeListenerAdapter() { - if(listener == null) - listener = new ResourceTreeResourceListener(); - return listener; - } - - protected ResourcePathListener getResourcePathListenerAdapter() { - if(pathListener == null) - pathListener = new ResourcePathListener(); - return pathListener; - } - - public ComponentResource[] findModuleResources(URI aURI) { - IPath path = new Path(aURI.toString()); - try { - if (ModuleURIUtil.ensureValidFullyQualifiedPlatformURI(aURI, false)) - path = path.removeFirstSegments(1); - } catch (UnresolveableURIException uurie) { - - } - return findModuleResources(path, ResourceTreeNode.CREATE_NONE); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeRootAdapter.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeRootAdapter.java deleted file mode 100644 index 24c4d17a4..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeRootAdapter.java +++ /dev/null @@ -1,71 +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.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.util.DeployedPathProvider; -import org.eclipse.wst.common.componentcore.internal.util.IPathProvider; -import org.eclipse.wst.common.componentcore.internal.util.SourcePathProvider; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class ResourceTreeRootAdapter extends AdapterImpl implements Adapter { - - public static final Object SOURCE_ADAPTER_TYPE = new Object(); - public static final Object DEPLOY_ADAPTER_TYPE = new Object(); - public static final int SOURCE_TREE = 0; - public static final int DEPLOY_TREE = 1; - - private ResourceTreeRoot resourceTreeRoot; - private int type; - - public ResourceTreeRootAdapter(int aType) { - type = aType; - } - - /* (non-Javadoc) - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification msg) { - super.notifyChanged(msg); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object anAdapterType) { - return (SOURCE_ADAPTER_TYPE == anAdapterType && type == SOURCE_TREE) || (DEPLOY_ADAPTER_TYPE == anAdapterType && type == DEPLOY_TREE); - } - - public ResourceTreeRoot getResourceTreeRoot() { - if(resourceTreeRoot != null) - return resourceTreeRoot; - synchronized(this) { - if(resourceTreeRoot == null) { - IPathProvider pathProvider= (type == DEPLOY_TREE) ? DeployedPathProvider.INSTANCE : SourcePathProvider.INSTANCE; - resourceTreeRoot = new ResourceTreeRoot((WorkbenchComponent)getTarget(), pathProvider); - } - } - return resourceTreeRoot; - } - - public void setResourceTreeRoot(ResourceTreeRoot r){ - - resourceTreeRoot = r; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPEntityResolver.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPEntityResolver.java deleted file mode 100644 index d7fe0b153..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPEntityResolver.java +++ /dev/null @@ -1,142 +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.wst.common.componentcore.internal.impl; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; - -// TODO: We need to port the strings used in the exceptions. -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class WTPEntityResolver implements EntityResolver { - - /** - * All the dtds that this resolver knows about; import strategies register these at startup - */ - protected static Map supportedDtDs; - - // static { - // registerDtD("http://www.w3.org/2001/xml.xsd", "xml.xsd"); //$NON-NLS-1$ //$NON-NLS-2$ - // registerDtD("XMLSchema.dtd", "XMLSchema.dtd"); //$NON-NLS-1$ //$NON-NLS-2$ - // registerDtD("datatypes.dtd", "datatypes.dtd"); //$NON-NLS-1$ //$NON-NLS-2$ - // } - - public static WTPEntityResolver INSTANCE = new WTPEntityResolver(); - - /** - * EjbXmlEntityResolver constructor comment. - */ - public WTPEntityResolver() { - super(); - } - - public static Map getSupportedDtDs() { - if (supportedDtDs == null) - supportedDtDs = new HashMap(); - return supportedDtDs; - } - - /** - * Maps the system id for the dtd to a local id to be retrieved loaded from the class path - */ - public static void registerDtD(String systemID, String localID) { - // TODO Removing Registration mechanism until final location is found - /* - * getSupportedDtDs().put(systemID, localID); getSupportedDtDs().put(getShortName(systemID), - * localID); - */ - } - - /** - * for a system id with a URL that begins with "http://java.sun.com/", check to see if that is a - * recognized dtd; if so, load the dtd from the class path using the value of the registered - * dtd. - * - * @return an Input source on a locally resolved dtd, or null of the systemid does not start - * with "http://java.sun.com/" - * - * @throws SAXException - * with a nested NotSupportedException if the dtd is not recognized - * @throws FileNotFoundException - * if the resolved dtd cannot be loaded from the classpath - */ - public org.xml.sax.InputSource resolveEntity(String publicId, String systemId) throws java.io.IOException, org.xml.sax.SAXException { - String localResourceName = null; - boolean isJavaSytemId = false; - if (shouldBeRegistered(systemId)) { - localResourceName = (String) getSupportedDtDs().get(systemId); - isJavaSytemId = true; - } else { - String shortName = getShortName(systemId); - localResourceName = (String) getSupportedDtDs().get(shortName); - if (localResourceName != null) - systemId = localResourceName; - } - - if (localResourceName == null) { - if (isJavaSytemId) { - String message = "Type is unrecognized or not yet supported: PUBLIC_ID= {0};SYSTEM_ID={1}"; - throw new org.xml.sax.SAXException(message); - } - return null; - } - ClassLoader loader = getClass().getClassLoader(); - URL url = null; - if (loader == null) { - url = ClassLoader.getSystemResource(localResourceName); - } else { - url = loader.getResource(localResourceName); - } - - - if (url == null) { - String message = "Could not parse xml because the resolved resource \"{0}\" could not be found in classpath"; - throw new java.io.FileNotFoundException(message); - } - - InputSource result = new InputSource(url.toString()); - result.setPublicId(publicId); - // force the encoding to be UTF8 - result.setEncoding("UTF-8"); //$NON-NLS-1$ - - return result; - } - - protected boolean shouldBeRegistered(String systemId) { - // TODO Removed Resolver function until file location is known... - return false; - /* - * return systemId.startsWith(J2EEConstants.JAVA_SUN_COM_URL) || - * systemId.startsWith(J2EEConstants.WWW_W3_ORG_URL) || - * systemId.startsWith(J2EEConstants.WWW_IBM_COM_URL); - */ - } - - /** - * Returns the filename from the uri, or the segment after the last occurrence of a separator - */ - private static String getShortName(String uri) { - String tempURI = uri.replace('\\', '/'); - while (tempURI.endsWith("/")) //$NON-NLS-1$ - tempURI = tempURI.substring(0, tempURI.length() - 1); - int lastIndex = tempURI.lastIndexOf('/'); - if (lastIndex == -1) - return uri; - return uri.substring(lastIndex + 1, tempURI.length()); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesInit.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesInit.java deleted file mode 100644 index 85b551650..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesInit.java +++ /dev/null @@ -1,79 +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.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactory; -import org.eclipse.wst.common.internal.emf.utilities.DOMUtilities; -import org.eclipse.wst.common.internal.emf.utilities.EncoderDecoderRegistry; -import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil; -import org.eclipse.wst.common.internal.emf.utilities.PasswordEncoderDecoder; - - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class WTPModulesInit { - - private static boolean isInitialized = false; - - public static void init() { - init(true); - } - - public static void init(boolean toPreregisterPackages) { - if (!isInitialized) { - isInitialized = true; - setDefaultEncoderDecoder(); - DOMUtilities.setDefaultEntityResolver(WTPEntityResolver.INSTANCE); - initResourceFactories(); - - //TODO: Remove this line after SED Adapter is restored. - EMF2DOMRendererFactory.INSTANCE.setValidating(false); - } - if(toPreregisterPackages) - preregisterPackages(); - } - - private static void initResourceFactories() { - WTPModulesResourceFactory.register(); - } - - /** - * If the currently defaulted encoder is the initial pass thru encoder, - * then register a Password encoder for security; otherwise if a more sophisticated - * encoder is already registered, then do nothing. - */ - private static void setDefaultEncoderDecoder() { - EncoderDecoderRegistry reg = EncoderDecoderRegistry.getDefaultRegistry(); - if (reg.getDefaultEncoderDecoder() == EncoderDecoderRegistry.INITIAL_DEFAULT_ENCODER) { - reg.setDefaultEncoderDecoder(new PasswordEncoderDecoder()); - } - } - - private static void preregisterPackages() { - ExtendedEcoreUtil.preRegisterPackage("moduleCore.xmi", new EPackage.Descriptor() { //$NON-NLS-1$ - public EPackage getEPackage() { - return ComponentcorePackage.eINSTANCE; - } - public EFactory getEFactory() { - return ComponentcoreFactory.eINSTANCE; - } - }); - } - - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesResource.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesResource.java deleted file mode 100644 index 93c2084c7..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesResource.java +++ /dev/null @@ -1,65 +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.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.wst.common.componentcore.internal.util.WTPModulesTranslator; -import org.eclipse.wst.common.internal.emf.resource.Renderer; -import org.eclipse.wst.common.internal.emf.resource.Translator; -import org.eclipse.wst.common.internal.emf.resource.TranslatorResource; -import org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class WTPModulesResource extends TranslatorResourceImpl implements TranslatorResource { - - public WTPModulesResource(URI aURI, Renderer aRenderer) { - super(aURI, aRenderer); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl#getDefaultPublicId() - */ - protected String getDefaultPublicId() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl#getDefaultSystemId() - */ - protected String getDefaultSystemId() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl#getDefaultVersionID() - */ - protected int getDefaultVersionID() { - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emf.resource.TranslatorResource#getDoctype() - */ - public String getDoctype() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emf.resource.TranslatorResource#getRootTranslator() - */ - public Translator getRootTranslator() { - return WTPModulesTranslator.INSTANCE; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesResourceFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesResourceFactory.java deleted file mode 100644 index ee2a6dd63..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPModulesResourceFactory.java +++ /dev/null @@ -1,88 +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.wst.common.componentcore.internal.impl; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactory; -import org.eclipse.wst.common.internal.emf.resource.Renderer; -import org.eclipse.wst.common.internal.emf.resource.RendererFactory; -import org.eclipse.wst.common.internal.emf.resource.TranslatorResource; -import org.eclipse.wst.common.internal.emf.resource.TranslatorResourceFactory; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class WTPModulesResourceFactory extends TranslatorResourceFactory { - - - public static final String WTP_MODULES_SHORT_NAME = "org.eclipse.wst.common.component"; //$NON-NLS-1$ - public static final String OLD_WTP_MODULES_SHORT_NAME = ".component"; //$NON-NLS-1$ - public static final String FIRST_WTP_MODULES_SHORT_NAME = ".wtpmodules"; //$NON-NLS-1$ - public static final URI WTP_MODULES_URI_OBJ = URI.createURI(StructureEdit.MODULE_META_FILE_NAME); - public static final URI OLD_WTP_MODULES_URI_OBJ = URI.createURI(".settings/.component"); - - - /** - * Method registerDtds. - */ - public static void registerDtds() { - //do nothing - } - - /** - * Constructor for ApplicationClientResourceFactory. - * @param aRendererFactory - */ - public WTPModulesResourceFactory(RendererFactory aRendererFactory) { - super(aRendererFactory); - } - /* - * (non-Javadoc) - * - * @see com.ibm.etools.emf2xml.RendererFactory.Listener#updateRendererFactory(com.ibm.etools.emf2xml.RendererFactory) - */ - public void updateRendererFactory(RendererFactory newRendererFactory) { - //Do Nothing... not allowed to switch - } - - /** - * @see com.ibm.etools.emf2xml.impl.TranslatorResourceFactory#createResource(URI, Renderer) - */ - protected TranslatorResource createResource(URI uri, Renderer aRenderer) { - return new WTPModulesResource(uri, aRenderer); - } - - /** - * Register myself with the Resource.Factory.Registry - */ - public static void registerWith(RendererFactory aRendererFactory) { - WTPResourceFactoryRegistry.INSTANCE.registerLastFileSegment(WTP_MODULES_SHORT_NAME, new WTPModulesResourceFactory(aRendererFactory)); - WTPResourceFactoryRegistry.INSTANCE.registerLastFileSegment(OLD_WTP_MODULES_SHORT_NAME, new WTPModulesResourceFactory(aRendererFactory)); - WTPResourceFactoryRegistry.INSTANCE.registerLastFileSegment(FIRST_WTP_MODULES_SHORT_NAME, new WTPModulesResourceFactory(aRendererFactory)); - } - /** - * register using the default renderer factory. - * @see #registerWith(RendererFactory) - */ - public static void register() { - registerWith(EMF2DOMRendererFactory.INSTANCE); - } - - - public static Resource.Factory getRegisteredFactory() { - return WTPResourceFactoryRegistry.INSTANCE.getFactory(WTP_MODULES_URI_OBJ); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPResourceFactoryRegistry.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPResourceFactoryRegistry.java deleted file mode 100644 index ecdb100d9..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPResourceFactoryRegistry.java +++ /dev/null @@ -1,489 +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.wst.common.componentcore.internal.impl; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.jobs.ILock; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.util.RegistryReader; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -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.internal.emf.resource.FileNameResourceFactoryRegistry; -import org.eclipse.wst.common.internal.emf.resource.ResourceFactoryDescriptor; -import org.eclipse.wst.common.internal.emf.utilities.DefaultOverridableResourceFactoryRegistry; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; -import org.eclipse.wst.common.internal.emfworkbench.edit.EMFWorkbenchEditContextFactory; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class WTPResourceFactoryRegistry extends FileNameResourceFactoryRegistry { - - public static final WTPResourceFactoryRegistry INSTANCE = new WTPResourceFactoryRegistry(); - - private final static boolean LOG_WARNINGS = false; - - - private WTPResourceFactoryRegistry() { - new ResourceFactoryRegistryReader().readRegistry(); - } - - public Resource.Factory delegatedGetFactory(URI uri) { - if (WTPResourceFactoryRegistry.INSTANCE == this) - return super.delegatedGetFactory(uri); - return WTPResourceFactoryRegistry.INSTANCE.getFactory(uri); - } - - public Resource.Factory getFactory(URI uri, IContentDescription description) { - IProject componentProject = null; - try { - componentProject = StructureEdit.getContainingProject(uri); - } catch (UnresolveableURIException e) { - // don't do anything - } - ILock lock = EMFWorkbenchEditContextFactory.getProjectLockObject(componentProject); - try{ - if(null != lock){ - lock.acquire(); - } - synchronized(this){ - Resource.Factory resourceFactory = null; - if(uri != null && uri.lastSegment() != null) { - ResourceFactoryDescriptor descriptor = null; - if(null == description){ - descriptor = getDescriptor(uri); - } else { - descriptor = getDescriptor(uri, description); - } - - if(descriptor != null) { - resourceFactory = getFactory(descriptor); - } - } - if(resourceFactory == null) - resourceFactory = super.getFactory(uri); - return resourceFactory; - } - } finally{ - if(null != lock){ - lock.release(); - } - } - } - - public Resource.Factory getFactory(URI uri) { - return getFactory(uri, (IContentDescription)null); - } - - - /** - * Register a file name representing the last segment of a URI with the corresponding - * Resource.Factory. - */ - public synchronized void registerLastFileSegment(String aSimpleFileName, Resource.Factory aFactory) { - - if(LOG_WARNINGS) { - /* the third entry in the array is this stack frame, we walk back from there. */ - StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); - if(stackTrace.length > 4) { - StringBuffer warningMessage = new StringBuffer("WTPResourceFactoryRegistry.registerLastFileSegment() was called explicitly from " + stackTrace[3]); - warningMessage.append("\nThis happened around: \n"); - for (int i = 4; (i < stackTrace.length) && i < 8; i++) { - warningMessage.append("\tnear ").append(stackTrace[i]).append('\n'); - } - warningMessage.append(".\nClients should use the org.eclipse.wst.common.modulecore.resourceFactories extension point instead."); - ModulecorePlugin.log(IStatus.INFO, 0, warningMessage.toString(), null); - } - } - - super.registerLastFileSegment(aSimpleFileName, aFactory); - - } - private WTPResourceFactoryRegistryKey getKey(ResourceFactoryDescriptor descriptor) { - WTPResourceFactoryRegistryKey key = new WTPResourceFactoryRegistryKey(); - key.shortName = descriptor.getShortSegment(); - key.type = descriptor.getContentType(); - key.isDefault = descriptor.isDefault(); - if(descriptor instanceof ConfigurationResourceFactoryDescriptor){ - ConfigurationResourceFactoryDescriptor configurationDescriptor = (ConfigurationResourceFactoryDescriptor)descriptor; - key.factoryClassName = configurationDescriptor.getFactoryClassName(); - key.overridesFactoryClassName = configurationDescriptor.getOverridesFactoryClassName(); - } - return key; - } - - /** - * Declares a subclass to create Resource.Factory(ies) from an extension. - */ - private class ConfigurationResourceFactoryDescriptor extends ResourceFactoryDescriptor implements IResourceFactoryExtPtConstants { - - private String shortSegment; - private IContentType contentType; - private boolean isDefault = true; - private String factoryClassName = null; - private String overridesFactoryClassName = null; - private final IConfigurationElement element; - - public ConfigurationResourceFactoryDescriptor(IConfigurationElement ext) throws CoreException { - Assert.isNotNull(ext); - element = ext; - init(); - } - - public String getOverridesFactoryClassName() { - return overridesFactoryClassName; - } - - public String getFactoryClassName() { - return factoryClassName; - } - - private void init() throws CoreException { - shortSegment = element.getAttribute(ATT_SHORT_SEGMENT); - - IConfigurationElement[] bindings = element.getChildren(TAG_CONTENTTYPE); - if (bindings.length > 0) { - String contentTypeId = null; - contentTypeId = bindings[0].getAttribute(ATT_CONTENTTYPEID); - if (contentTypeId != null) - contentType = Platform.getContentTypeManager().getContentType(contentTypeId); - } - - if ((shortSegment == null || shortSegment.trim().length() == 0) - && contentType == null) { - throw new CoreException( - ModulecorePlugin.createErrorStatus(0, - "Either the shortSegment attribute or the contentType element of " //$NON-NLS-1$ - + TAG_RESOURCE_FACTORY - + " must be specified in " - + element.getNamespaceIdentifier() - + ". The shortSegment attribute is specified with a valid, non-null, " //$NON-NLS-1$ - + "non-empty value, and the contentType element is specified with a " //$NON-NLS-1$ - + "valid, non-null, non-empty contentTypeId." //$NON-NLS-1$ - , null)); - } - - if ("false".equals(element.getAttribute(ATT_ISDEFAULT))) - isDefault = false; - - factoryClassName = element.getAttribute(ATT_CLASS); - overridesFactoryClassName = element.getAttribute(ATT_OVERRIDES_FACTORY); - } - - public boolean isEnabledFor(URI fileURI) { - // Not sure where this is actually used, so not sure what the proper - // implementation should be, so simply checking the short segment for now - if (fileURI != null && fileURI.lastSegment() != null && shortSegment != null) { - return shortSegment.equals(fileURI.lastSegment()); - } - return false; - } - - public Resource.Factory createFactory() { - - final Resource.Factory[] factory = new Resource.Factory[1]; - - SafeRunner.run(new ISafeRunnable() { - - public void run() throws Exception { - factory[0] = (Resource.Factory) element.createExecutableExtension(ATT_CLASS); - } - - public void handleException(Throwable exception) { - ModulecorePlugin.log(ModulecorePlugin.createErrorStatus(0, exception.getMessage(), exception)); - } - }); - - return factory[0] != null ? factory[0] : DefaultOverridableResourceFactoryRegistry.GLOBAL_FACTORY; - - } - - public String getShortSegment() { - return shortSegment; - } - - public IContentType getContentType() { - return contentType; - } - - public boolean isDefault() { - return isDefault; - } - - public int hashCode() { - int hashCode = 0; - if (getContentType() != null) { - hashCode |= getContentType().hashCode(); - } - if (getShortSegment() != null) { - hashCode |= getShortSegment().hashCode(); - } - return hashCode; - } - - public boolean equals(Object o) { - if (! (o instanceof ResourceFactoryDescriptor)) { - return false; - } - ResourceFactoryDescriptor rfdo = (ResourceFactoryDescriptor) o; - boolean equals = true; - equals &= (getContentType() == null) ? rfdo.getContentType() == null : - getContentType().equals(rfdo.getContentType()); - equals &= (getShortSegment() == null) ? rfdo.getShortSegment() == null : - getShortSegment().equals(rfdo.getShortSegment()); - return equals; - } - } - - - private class ResourceFactoryRegistryReader extends RegistryReader implements IResourceFactoryExtPtConstants { - - public ResourceFactoryRegistryReader() { - super(ModulecorePlugin.PLUGIN_ID, EXTPT_RESOURCE_FACTORIES); - } - - public boolean readElement(final IConfigurationElement element) { - - if(element != null && TAG_RESOURCE_FACTORY.equals(element.getName())) { - final boolean[] success = new boolean[] { true }; - SafeRunner.run(new ISafeRunnable() { - - public void run() throws Exception { - addDescriptor(new ConfigurationResourceFactoryDescriptor(element)); - } - - public void handleException(Throwable exception) { - ModulecorePlugin.log(ModulecorePlugin.createErrorStatus(0, exception.getMessage(), exception)); - success[0] = false; - } - }); - return success[0]; - } else { - return false; - } - } - } - private class WTPResourceFactoryRegistryKey { - - public String overridesFactoryClassName; - public String factoryClassName; - public String shortName; - public IContentType type; - public boolean isDefault = true; - public WTPResourceFactoryRegistryKey() { - super(); - } - - /** - * Sort in the following manner: - * First, sort by shortName, if shortName is null, then it comes last - * If shortNames are equal, then sort by isDefault - * If isDefault is also equal, then the one defining a factoryClassName wins - * If both have factoryClassNames, then check to see if one overrides the other via overridesFactoryClassName - * If neither override the other factory class, then sort by factoryClassname - * @param other - * @return - */ - public int compareTo(WTPResourceFactoryRegistryKey other){ - if(this == other){ - return 0; - } - if(shortName == null && other.shortName == null){ - return 0; - } else if(shortName == null){ - return 1; - } else if(other.shortName == null){ - return -1; - } - - int shortNameCompare = this.shortName.compareTo(other.shortName); - if(shortNameCompare != 0){ - return shortNameCompare; - } else { - if(this.isDefault != other.isDefault){ - if(this.isDefault){ - return -1; - } else { - return 1; - } - } else { - if(this.factoryClassName == null && other.factoryClassName == null){ - return 0; - } else if(other.factoryClassName == null){ - return -1; - } else if (this.factoryClassName == null){ - return 1; - } else if(other.factoryClassName.equals(this.overridesFactoryClassName)){ - return -1; - } else if(this.factoryClassName.equals(other.overridesFactoryClassName)){ - return 1; - } else { - return this.factoryClassName.compareTo(other.factoryClassName); - } - } - } - } - } - - protected void addDescriptor(ResourceFactoryDescriptor descriptor) { - getDescriptors().put(getKey(descriptor), descriptor); - } - - private WTPResourceFactoryRegistryKey [] sortedDescriptors = null; - - private WTPResourceFactoryRegistryKey [] getSortedDescriptorKeys() { - if(sortedDescriptors == null || sortedDescriptors.length != getDescriptors().size()){ - Set keys = getDescriptors().keySet(); - WTPResourceFactoryRegistryKey [] array = new WTPResourceFactoryRegistryKey [keys.size()]; - int count = 0; - for (Iterator iterator = keys.iterator(); iterator.hasNext();count++) { - WTPResourceFactoryRegistryKey key = (WTPResourceFactoryRegistryKey) iterator.next(); - array[count] = key; - } - Arrays.sort(array, new Comparator<WTPResourceFactoryRegistryKey>() { - public int compare(WTPResourceFactoryRegistryKey key1, - WTPResourceFactoryRegistryKey key2) { - return key1.compareTo(key2); - } - }); - sortedDescriptors = array; - } - return sortedDescriptors; - } - - protected synchronized ResourceFactoryDescriptor getDescriptor(URI uri, IContentDescription description) { - WTPResourceFactoryRegistryKey [] keys = getSortedDescriptorKeys(); - ResourceFactoryDescriptor defaultDescriptor = null; - - // first check content type - if (description != null) { - for (WTPResourceFactoryRegistryKey key : keys) { - ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor) getDescriptors().get(key); - - if ((key.type != null) && (description.getContentType().equals(key.type))) { - if ((defaultDescriptor == null) || (key.isDefault)) { - defaultDescriptor = descriptor; - } - } - } - } - - // then check short name, overriding default if necessary - for (WTPResourceFactoryRegistryKey key : keys) { - ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor) getDescriptors().get(key); - - if ((key.shortName != null) && (uri.lastSegment().equals(key.shortName))) { - if ((defaultDescriptor == null) - || ((description == null) && (key.isDefault))) { - defaultDescriptor = descriptor; - } - } - } - - return defaultDescriptor; - } - - private URI newPlatformURI(URI aNewURI, IProject project) { - - if (project == null) - return ModuleURIUtil.trimToDeployPathSegment(aNewURI); - try { - IVirtualComponent component = ComponentCore.createComponent(project); - - URI deployPathSegment = ModuleURIUtil.trimToDeployPathSegment(aNewURI); - - //IVirtualFile newFile = component.getFile(new Path(deployPathSegment.path())); - IVirtualFolder rootFolder = component.getRootFolder(); - IVirtualFile newFile = rootFolder.getFile(new Path(deployPathSegment.path())); - - return URI.createPlatformResourceURI(newFile.getWorkspaceRelativePath().toString()); - - } catch(Exception e) { - e.printStackTrace(); - } - return null; - } - - private IContentDescription getDescriptionFromURI(URI uri) { - String contentTypeIdentifier = ModuleURIUtil.getContentTypeName(uri); - if (contentTypeIdentifier != null) - return Platform.getContentTypeManager().getContentType(contentTypeIdentifier).getDefaultDescription(); - else - return null; - - } - - protected synchronized ResourceFactoryDescriptor getDescriptor(URI uri) { - IFile file = WorkbenchResourceHelper.getPlatformFile(uri); - IContentDescription description = null; - if (file != null && file.exists()) { - try { - description = file.getContentDescription(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - if (description == null) {//Check for optional embedded uri segment, then normalize - description = getDescriptionFromURI(uri); - try { - if (description != null) { - IProject componentProject = null; - try { - componentProject = StructureEdit.getContainingProject(uri); - } catch (UnresolveableURIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - uri = PlatformURLModuleConnection.resolve(uri); - uri = newPlatformURI(uri,componentProject); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - ResourceFactoryDescriptor defaultDesc = getDescriptor(uri, description); - // Ok no content type match - go to super - if (defaultDesc != null){ - return defaultDesc; - } - else{ - return super.getDescriptor(uri); - } - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WorkbenchComponentImpl.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WorkbenchComponentImpl.java deleted file mode 100644 index 883ebb9b8..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WorkbenchComponentImpl.java +++ /dev/null @@ -1,569 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: WorkbenchComponentImpl.java,v 1.14 2007/02/14 16:00:52 jsholl Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.impl; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.EObjectResolvingEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>Workbench Module</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl#getResources <em>Resources</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl#getComponentType <em>Component Type</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl#getReferencedComponents <em>Referenced Components</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl#getProperties <em>Properties</em>}</li> - * <li>{@link org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl#getMetadataResources <em>Metadata Resources</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class WorkbenchComponentImpl extends EObjectImpl implements WorkbenchComponent { - - - - public static class ESynchronizedAdapterList extends EAdapterList - { - - public ESynchronizedAdapterList(Notifier notifier) { - super(notifier); - } - - public boolean add(Object object) - { - synchronized (this) {return super.add(object);} - } - - public void add(int index, Object object) - { - synchronized (this) {super.add(index, object);} - } - - public boolean addAll(Collection collection) - { - synchronized (this) {return super.addAll(collection);} - } - - public boolean remove(Object object) - { - synchronized (this) {return super.remove(object);} - } - - public Object remove(int index) - { - synchronized (this) {return super.remove(index);} - } - - public boolean removeAll(Collection collection) - { - synchronized (this) {return super.removeAll(collection);} - } - - public void clear() - { - synchronized (this) {super.clear();}; - } - - - public Object set(int index, Object object) - { - synchronized (this) {return super.set(index, object);} - } - - public void move(int newPosition, Object object) - { - synchronized (this) {super.move(newPosition, object);} - } - - public Object move(int newPosition, int oldPosition) - { - synchronized (this) {return super.move(newPosition, oldPosition);} - } - } - - /** - * The default value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - - /** - * The cached value of the '{@link #getResources() <em>Resources</em>}' containment reference list. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @see #getResources() - * @generated - * @ordered - */ - protected EList resources = null; - - /** - * The cached value of the '{@link #getComponentType() <em>Component Type</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getComponentType() - * @generated - * @ordered - */ - protected ComponentType componentType = null; - - /** - * The cached value of the '{@link #getReferencedComponents() <em>Referenced Components</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getReferencedComponents() - * @generated - * @ordered - */ - protected EList referencedComponents = null; - - /** - * The cached value of the '{@link #getProperties() <em>Properties</em>}' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getProperties() - * @generated - * @ordered - */ - protected EList properties = null; - - /** - * The cached value of the '{@link #getMetadataResources() <em>Metadata Resources</em>}' attribute list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getMetadataResources() - * @generated - * @ordered - */ - protected EList metadataResources = null; - -// private final Map resourceIndexByDeployPath = new HashMap(); -// private final Map resourceIndexBySourcePath = new HashMap(); - -// private boolean isIndexedByDeployPath; - -// private boolean isIndexedBySourcePath; - -// private static final ComponentResource[] NO_MODULE_RESOURCES = new ComponentResource[0]; - - private URI handle; - - private IPath defaultSourceRoot; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - protected WorkbenchComponentImpl() { - super(); - } - - private IPath getFirstRootSource() { - - List res = getResources(); - for (Iterator iter = res.iterator(); iter.hasNext();) { - ComponentResource element = (ComponentResource) iter.next(); - if (element.getRuntimePath().equals(new Path("/"))) - return element.getSourcePath(); - - } - return null; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ComponentcorePackage.eINSTANCE.getWorkbenchComponent(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getName() { - return name; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setNameGen(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.WORKBENCH_COMPONENT__NAME, oldName, name)); - } - - public void setName(String newDeployedName) { - setNameGen(newDeployedName); - // TODO A more advanced adapter should be applied to keep the handle up to date. - if (eResource() != null) { - URI resourceURI = eResource().getURI(); -// String safeDeployedName = getName() != null ? getName() : ""; //$NON-NLS-1$ - if (resourceURI != null && resourceURI.segmentCount() >= 2) - setHandle(computeHandle()); - } - } - - protected void setHandle(URI aHandle) { - handle = aHandle; - } - - public URI getHandle() { - if(handle == null) - handle = computeHandle(); - return handle; - } - - private URI computeHandle() { - return URI.createURI(PlatformURLModuleConnection.MODULE_PROTOCOL + IPath.SEPARATOR + PlatformURLModuleConnection.RESOURCE_MODULE + IPath.SEPARATOR + computeProjectName() + IPath.SEPARATOR + getName()); - - } - - private String computeProjectName() { - IProject project = ProjectUtilities.getProject(this); - return (project!=null)?project.getName():"UNCONTAINED"; //$NON-NLS-1$ - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public EList getResources() { - if (resources == null) { - resources = new EObjectContainmentWithInverseEList(ComponentResource.class, this, ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT); - } - return resources; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentType getComponentType() { - return componentType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain basicSetComponentType(ComponentType newComponentType, NotificationChain msgs) { - ComponentType oldComponentType = componentType; - componentType = newComponentType; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE, oldComponentType, newComponentType); - if (msgs == null) msgs = notification; else msgs.add(notification); - } - return msgs; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setComponentType(ComponentType newComponentType) { - if (newComponentType != componentType) { - NotificationChain msgs = null; - if (componentType != null) - msgs = ((InternalEObject)componentType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE, null, msgs); - if (newComponentType != null) - msgs = ((InternalEObject)newComponentType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE, null, msgs); - msgs = basicSetComponentType(newComponentType, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE, newComponentType, newComponentType)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getReferencedComponents() { - if (referencedComponents == null) { - referencedComponents = new EObjectContainmentEList(ReferencedComponent.class, this, ComponentcorePackage.WORKBENCH_COMPONENT__REFERENCED_COMPONENTS); - } - return referencedComponents; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getProperties() { - if (properties == null) { - properties = new EObjectResolvingEList(Property.class, this, ComponentcorePackage.WORKBENCH_COMPONENT__PROPERTIES); - } - return properties; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getMetadataResources() { - if (metadataResources == null) { - metadataResources = new EDataTypeUniqueEList(IPath.class, this, ComponentcorePackage.WORKBENCH_COMPONENT__METADATA_RESOURCES); - } - return metadataResources; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES: - return ((InternalEList)getResources()).basicAdd(otherEnd, msgs); - default: - return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); - } - } - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES: - return ((InternalEList)getResources()).basicRemove(otherEnd, msgs); - case ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE: - return basicSetComponentType(null, msgs); - case ComponentcorePackage.WORKBENCH_COMPONENT__REFERENCED_COMPONENTS: - return ((InternalEList)getReferencedComponents()).basicRemove(otherEnd, msgs); - default: - return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.WORKBENCH_COMPONENT__NAME: - return getName(); - case ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES: - return getResources(); - case ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE: - return getComponentType(); - case ComponentcorePackage.WORKBENCH_COMPONENT__REFERENCED_COMPONENTS: - return getReferencedComponents(); - case ComponentcorePackage.WORKBENCH_COMPONENT__PROPERTIES: - return getProperties(); - case ComponentcorePackage.WORKBENCH_COMPONENT__METADATA_RESOURCES: - return getMetadataResources(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.WORKBENCH_COMPONENT__NAME: - setName((String)newValue); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES: - getResources().clear(); - getResources().addAll((Collection)newValue); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE: - setComponentType((ComponentType)newValue); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__REFERENCED_COMPONENTS: - getReferencedComponents().clear(); - getReferencedComponents().addAll((Collection)newValue); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__PROPERTIES: - getProperties().clear(); - getProperties().addAll((Collection)newValue); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__METADATA_RESOURCES: - getMetadataResources().clear(); - getMetadataResources().addAll((Collection)newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.WORKBENCH_COMPONENT__NAME: - setName(NAME_EDEFAULT); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES: - getResources().clear(); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE: - setComponentType((ComponentType)null); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__REFERENCED_COMPONENTS: - getReferencedComponents().clear(); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__PROPERTIES: - getProperties().clear(); - return; - case ComponentcorePackage.WORKBENCH_COMPONENT__METADATA_RESOURCES: - getMetadataResources().clear(); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case ComponentcorePackage.WORKBENCH_COMPONENT__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); - case ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES: - return resources != null && !resources.isEmpty(); - case ComponentcorePackage.WORKBENCH_COMPONENT__COMPONENT_TYPE: - return componentType != null; - case ComponentcorePackage.WORKBENCH_COMPONENT__REFERENCED_COMPONENTS: - return referencedComponents != null && !referencedComponents.isEmpty(); - case ComponentcorePackage.WORKBENCH_COMPONENT__PROPERTIES: - return properties != null && !properties.isEmpty(); - case ComponentcorePackage.WORKBENCH_COMPONENT__METADATA_RESOURCES: - return metadataResources != null && !metadataResources.isEmpty(); - } - return eDynamicIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (name: "); - result.append(name); - result.append(", metadataResources: "); - result.append(metadataResources); - result.append(')'); - return result.toString(); - } - - public ComponentResource[] findResourcesByRuntimePath(IPath aDeployPath) { - ResourceTreeRoot resourceTreeRoot = ResourceTreeRoot.getDeployResourceTreeRoot(this); - return resourceTreeRoot.findModuleResources(aDeployPath, ResourceTreeNode.CREATE_NONE); - } - - public ComponentResource[] findResourcesBySourcePath(IPath aSourcePath, int resourceFlag) { - ResourceTreeRoot resourceTreeRoot = ResourceTreeRoot.getSourceResourceTreeRoot(this); - return resourceTreeRoot.findModuleResources(aSourcePath, resourceFlag); - } - public boolean exists(IPath aSourcePath, int resourceFlag) { - ResourceTreeRoot resourceTreeRoot = ResourceTreeRoot.getSourceResourceTreeRoot(this); - return resourceTreeRoot.exists(aSourcePath, resourceFlag); - } - public EList eAdapters() - { - if (eAdapters == null) - { - eAdapters = new ESynchronizedAdapterList(this); - } - return eAdapters; - } - - - public void eNotify(Notification notification) { - synchronized (eAdapters()) { - super.eNotify(notification); - } - } - - public IPath getDefaultSourceRoot() { - if (defaultSourceRoot == null) - defaultSourceRoot = getFirstRootSource(); - return defaultSourceRoot; - } - - public void setDefaultSourceRoot(IPath defaultSourceRoot) { - this.defaultSourceRoot = defaultSourceRoot; - } - - -} // WorkbenchComponentImpl diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ArtifactEditOperationDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ArtifactEditOperationDataModelProvider.java deleted file mode 100644 index 1a614220a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ArtifactEditOperationDataModelProvider.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.operation; - -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class ArtifactEditOperationDataModelProvider extends AbstractDataModelProvider implements IArtifactEditOperationDataModelProperties { - - public ArtifactEditOperationDataModelProvider() { - super(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(TYPE_ID); - propertyNames.add(PROJECT_NAME); - propertyNames.add(COMPONENT_NAME); - propertyNames.add(PROMPT_ON_SAVE); - propertyNames.add(TARGET_PROJECT); - propertyNames.add(TARGET_COMPONENT); - return propertyNames; - } - - public IProject getTargetProject() { - String projectName = (String) model.getProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME); - if (projectName != null && projectName.length() > 0) - return ProjectUtilities.getProject(projectName); - return null; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(PROMPT_ON_SAVE)) - return Boolean.FALSE; - else if (propertyName.equals(TARGET_PROJECT)) - return getTargetProject(); - else if (propertyName.equals(TARGET_COMPONENT)) - return getTargetComponent(); - else if (propertyName.equals(COMPONENT_NAME)) - return getStringProperty(PROJECT_NAME); - return super.getDefaultProperty(propertyName); - } - - /** - * @return - */ - public WorkbenchComponent getWorkbenchModule() { - StructureEdit moduleCore = null; - WorkbenchComponent module = null; - try { - moduleCore = StructureEdit.getStructureEditForRead(getTargetProject()); - module = moduleCore.getComponent(); - } finally { - if (null != moduleCore) { - moduleCore.dispose(); - } - } - return module; - } - public boolean propertySet(String propertyName, Object propertyValue) { - boolean notify = super.propertySet(propertyName, propertyValue); - if (COMPONENT_NAME.equals(propertyName)) - setProperty(PROJECT_NAME, propertyValue); - return notify; - } - - public ArtifactEdit getArtifactEditForRead() { - WorkbenchComponent module = getWorkbenchModule(); - IProject proj = StructureEdit.getContainingProject(module); - return ArtifactEdit.getArtifactEditForRead(proj); - } - - public IStatus validate(String propertyName) { - IStatus result = super.validate(propertyName); - if (result != null && !result.isOK()) - return result; - else if (propertyName.equals(PROJECT_NAME)) - return validateModuleName(); - return result; - } - - protected IStatus validateModuleName() { - String moduleName = getStringProperty(PROJECT_NAME); - if (moduleName == null || moduleName.length() == 0) - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_NAME_EMPTY)); - return WTPCommonPlugin.OK_STATUS; - } - - public IVirtualComponent getTargetComponent() { - String moduleName = getStringProperty(COMPONENT_NAME); - if (moduleName != null && moduleName.length() > 0) - return ComponentCore.createComponent(getTargetProject()); - return null; - - - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ArtifactEditProviderOperation.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ArtifactEditProviderOperation.java deleted file mode 100644 index b95651646..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ArtifactEditProviderOperation.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.operation; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.util.UIContextDetermination; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.util.ArtifactEditRegistryReader; -import org.eclipse.wst.common.componentcore.internal.util.IArtifactEditFactory; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.IValidateEditContext; - -public abstract class ArtifactEditProviderOperation extends AbstractDataModelOperation { - - protected ArtifactEdit artifactEdit; - protected EMFWorkbenchContext emfWorkbenchContext; -// private CommandStack commandStack; - - public ArtifactEditProviderOperation() { - super(); - // TODO Auto-generated constructor stub - } - - public ArtifactEditProviderOperation(IDataModel model) { - super(model); - } - - protected final void initialize(IProgressMonitor monitor) { - emfWorkbenchContext = (EMFWorkbenchContext) WorkbenchResourceHelperBase.createEMFContext(getTargetProject(), null); - IVirtualComponent component = getTargetComponent(); - artifactEdit = getArtifactEditForModule(component); - doInitialize(monitor); - } - - public IProject getTargetProject() { - String projectName = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME); - return ProjectUtilities.getProject(projectName); - } - - public IVirtualComponent getTargetComponent() { - return ComponentCore.createComponent(getTargetProject()); - } - - private void doInitialize(IProgressMonitor monitor) { - //Default - } - - protected ArtifactEdit getArtifactEditForModule(IVirtualComponent comp) { - ArtifactEditRegistryReader reader = ArtifactEditRegistryReader.instance(); - IArtifactEditFactory factory = reader.getArtifactEdit(comp.getProject()); - if (factory == null) - return null; - return factory.createArtifactEditForWrite(comp); - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - - public void dispose() { - if (artifactEdit!=null) { - artifactEdit.saveIfNecessary(new NullProgressMonitor()); - artifactEdit.dispose(); - } - - super.dispose(); - - } - - public final IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - initialize(monitor); - if (validateEdit().isOK()) - return doExecute(monitor, info); - return Status.CANCEL_STATUS; - } finally { - dispose(); - } - } - - public abstract IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException; - - public ArtifactEdit getArtifactEdit(){ - return artifactEdit; - } - - /** - * Validate edit for resource state - */ - protected IStatus validateEdit() { - IValidateEditContext validator = (IValidateEditContext) UIContextDetermination.createInstance(IValidateEditContext.CLASS_KEY); - return validator.validateState((EditModel)getArtifactEdit().getAdapter(ArtifactEditModel.ADAPTER_TYPE)); - - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/CreateReferenceComponentsDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/CreateReferenceComponentsDataModelProvider.java deleted file mode 100644 index 3967a2aa7..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/CreateReferenceComponentsDataModelProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.operation; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class CreateReferenceComponentsDataModelProvider extends AbstractDataModelProvider implements ICreateReferenceComponentsDataModelProperties { - - public CreateReferenceComponentsDataModelProvider() { - super(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(SOURCE_COMPONENT); - propertyNames.add(TARGET_COMPONENT_LIST); - propertyNames.add(TARGET_COMPONENTS_DEPLOY_PATH); - propertyNames.add(TARGET_COMPONENTS_DEPLOY_PATH_MAP); - propertyNames.add(TARGET_COMPONENTS_TO_URI_MAP); - return propertyNames; - } - - public IDataModelOperation getDefaultOperation() { - return new CreateReferenceComponentsOp(model); - } - - public Object getDefaultProperty(String propertyName) { - if (TARGET_COMPONENTS_TO_URI_MAP.equals(propertyName)) { - Map map = new HashMap(); - setProperty(propertyName, map); - return map; - } - else if (TARGET_COMPONENTS_DEPLOY_PATH_MAP.equals(propertyName)) { - Map map = new HashMap(); - setProperty(propertyName, map); - return map; - } - - if (propertyName.equals(TARGET_COMPONENT_LIST)) - return new ArrayList(); - else if (propertyName.equals(TARGET_COMPONENTS_DEPLOY_PATH)){ - return "/"; //$NON-NLS-1$ - } - return super.getDefaultProperty(propertyName); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/CreateReferenceComponentsOp.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/CreateReferenceComponentsOp.java deleted file mode 100644 index dfcc62297..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/CreateReferenceComponentsOp.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.operation; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.util.UIContextDetermination; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.IValidateEditContext; - -public class CreateReferenceComponentsOp extends AbstractDataModelOperation { - - - public CreateReferenceComponentsOp(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if (!validateEdit().isOK()) - return Status.CANCEL_STATUS; - addReferencedComponents(monitor); - addProjectReferences(); - return OK_STATUS; - } - - /** - * Validate edit for resource state - */ - protected IStatus validateEdit() { - IStatus status = OK_STATUS; - IValidateEditContext validator = (IValidateEditContext) UIContextDetermination.createInstance(IValidateEditContext.CLASS_KEY); - IVirtualComponent sourceComp = (IVirtualComponent) model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT); - IProject project = sourceComp.getProject(); - - if (status.isOK()) { - StructureEdit sEdit = null; - try { - sEdit = StructureEdit.getStructureEditForWrite(project); - status = validator.validateState(sEdit.getModuleStructuralModel()); - } finally { - if (sEdit !=null) - sEdit.dispose(); - } - } - - IFile [] files = new IFile[1]; - files[0] = project.getFile(ProjectUtilities.DOT_PROJECT); - status = ResourcesPlugin.getWorkspace().validateEdit(files, null); - return status; - } - - protected void addProjectReferences() { - - IVirtualComponent sourceComp = (IVirtualComponent) model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT); - List modList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - List targetprojectList = new ArrayList(); - for (int i = 0; i < modList.size(); i++) { - IVirtualComponent IVirtualComponent = (IVirtualComponent) modList.get(i); - IProject targetProject = IVirtualComponent.getProject(); - targetprojectList.add(targetProject); - } - try { - ProjectUtilities.addReferenceProjects(sourceComp.getProject(), targetprojectList); - } catch (CoreException e) { - e.printStackTrace(); - } - - } - - protected void addReferencedComponents(IProgressMonitor monitor) { - IVirtualComponent sourceComp = (IVirtualComponent) model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT); - List vlist = new ArrayList(); - List modList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - Map modDeployPathMap = (Map) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH_MAP); - String deployPathStr = model.getStringProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH); - IPath deployPath = null; - IPath archiveDeployPath = null; - if (deployPathStr != null && deployPathStr.length() > 0){ - deployPath = new Path(deployPathStr); - } - for (int i = 0; i < modList.size(); i++) { - IVirtualComponent comp = (IVirtualComponent) modList.get(i); - if (!srcComponentContainsReference(sourceComp, comp, deployPath)) { - IVirtualReference ref = ComponentCore.createReference(sourceComp, comp); - deployPathStr = (String)modDeployPathMap.get(comp); - if (deployPathStr != null) - { - archiveDeployPath = new Path(deployPathStr); - } - else - { - archiveDeployPath = deployPath; - } - if(archiveDeployPath != null){ - ref.setRuntimePath(archiveDeployPath); - } - - String archiveName = getArchiveName(comp); - if (archiveName.length() > 0) { - ref.setArchiveName(archiveName); - } - vlist.add(ref); - } - } - - IVirtualReference[] refs = (IVirtualReference[]) vlist.toArray(new IVirtualReference[vlist.size()]); - sourceComp.addReferences(refs); - } - - protected String getArchiveName(IVirtualComponent comp) { - Map map = (Map) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP); - String uri = (String) map.get(comp); - return uri == null ? "" : uri; //$NON-NLS-1$ - } - - - private boolean srcComponentContainsReference(IVirtualComponent sourceComp, IVirtualComponent comp, IPath deployPath) { - if ((sourceComp != null && sourceComp.getProject() != null) && (comp != null && comp.getProject() != null)) { - IVirtualReference[] existingReferences = sourceComp.getReferences(); - IVirtualComponent referencedComponent = null; - if (existingReferences != null) { - for (int i = 0; i < existingReferences.length; i++) { - IVirtualReference ref = existingReferences[i]; - if(ref != null){ - //also check to see if the deploy path is the same (remember that it can be null) - if((ref.getRuntimePath() == null && deployPath != null) || ref.getRuntimePath().equals(deployPath)){ - referencedComponent = ref.getReferencedComponent(); - if (referencedComponent != null && referencedComponent.equals(comp) ){ - return true; - } - } - } - } - } - } - return false; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return null; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/FacetDataModelOperation.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/FacetDataModelOperation.java deleted file mode 100644 index 1558b1178..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/FacetDataModelOperation.java +++ /dev/null @@ -1,49 +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.wst.common.componentcore.internal.operation; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action.Type; - -public class FacetDataModelOperation extends AbstractDataModelOperation { - - public FacetDataModelOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - IFacetedProject facetProj; - try { - facetProj = ProjectFacetsManager.create(model.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME), null, monitor); - Set actions = new HashSet(); - actions.add(new IFacetedProject.Action((Type) model.getProperty(IFacetDataModelProperties.FACET_TYPE), (IProjectFacetVersion) model.getProperty(IFacetDataModelProperties.FACET_VERSION), model)); - facetProj.modify(actions, monitor); - } catch (CoreException e) { - throw new ExecutionException(e.getMessage(), e); - } - return OK_STATUS; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/FacetProjectCreationOperation.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/FacetProjectCreationOperation.java deleted file mode 100644 index abdcd14f5..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/FacetProjectCreationOperation.java +++ /dev/null @@ -1,163 +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.wst.common.componentcore.internal.operation; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -public class FacetProjectCreationOperation extends AbstractDataModelOperation { - - protected boolean runtimeAdded = false; - - public FacetProjectCreationOperation() { - super(); - } - - public FacetProjectCreationOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - IFacetedProject facetProj = createProject(monitor); - Set existingFacets = facetProj.getProjectFacets(); - - Map dmMap = (Map) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - Set actions = new HashSet(); - IDataModel facetDM = null; - for (Iterator iterator = dmMap.values().iterator(); iterator.hasNext();) { - facetDM = (IDataModel) iterator.next(); - if (facetDM.getBooleanProperty(IFacetDataModelProperties.SHOULD_EXECUTE)) { - String facetID = facetDM.getStringProperty(IFacetDataModelProperties.FACET_ID); - boolean shouldInstallFacet = true; - for (Iterator existingFacetsIterator = existingFacets.iterator(); shouldInstallFacet && existingFacetsIterator.hasNext();) { - IProjectFacetVersion version = (IProjectFacetVersion) existingFacetsIterator.next(); - if (version.getProjectFacet().getId().equals(facetID)) { - shouldInstallFacet = false; - } - } - if (shouldInstallFacet) { - actions.add(facetDM.getProperty(IFacetDataModelProperties.FACET_ACTION)); - } - } - } - Map actionsMap = (Map) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_ACTION_MAP); - for (Iterator iterator = actionsMap.values().iterator(); iterator.hasNext();) { - actions.add(iterator.next()); - } - if (!actions.isEmpty()) { - facetProj.modify(actions, monitor); - } - Set fixedFacets = new HashSet(), newFacetVersions = facetProj.getProjectFacets(), existingFixedFacets = facetProj.getFixedProjectFacets(); - for (Iterator iter = newFacetVersions.iterator(); iter.hasNext();) { - IProjectFacetVersion facetVersion = (IProjectFacetVersion) iter.next(); - String facetID = facetVersion.getProjectFacet().getId(); - boolean shouldInstallFacet = true; - for (Iterator existingFacetsIterator = existingFixedFacets.iterator(); shouldInstallFacet && existingFacetsIterator.hasNext();) { - IProjectFacet facet = (IProjectFacet) existingFacetsIterator.next(); - if (facet.getId().equals(facetID)) { - shouldInstallFacet = false; - } - } - if (shouldInstallFacet) { - fixedFacets.add(facetVersion.getProjectFacet()); - } - } - if (!fixedFacets.isEmpty()) { - facetProj.setFixedProjectFacets(fixedFacets); - } - if (runtimeAdded) { - IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME); - addDefaultFactets(facetProj, runtime); - } - - } catch (CoreException e) { - Logger.getLogger().logError(e); - throw new ExecutionException(e.getMessage(), e); - } catch (Exception e) { - Logger.getLogger().logError(e); - } - return OK_STATUS; - } - - private static void addDefaultFacets(IFacetedProject facetProj, Set defaultFacets) { - Set actions = new HashSet(); - for (Iterator iter = defaultFacets.iterator(); iter.hasNext();) { - IProjectFacetVersion facetVersion = (IProjectFacetVersion) iter.next(); - if (!facetProj.hasProjectFacet(facetVersion.getProjectFacet())) { - actions.add(new IFacetedProject.Action(Action.Type.INSTALL, facetVersion, null)); - } - } - - try { - if (!actions.isEmpty()) - facetProj.modify(actions, null); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - - public IFacetedProject createProject(IProgressMonitor monitor) throws CoreException { - IProject project = ProjectUtilities.getProject((String) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME)); - IFacetedProject facetProj = null; - if (project.exists()) { - facetProj = ProjectFacetsManager.create(project, true, monitor); - } else { - String location = (String) model.getProperty(IProjectCreationPropertiesNew.PROJECT_LOCATION); - IPath locationPath = null == location ? null : new Path(location); - facetProj = ProjectFacetsManager.create(model.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME), locationPath, monitor); - } - IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME); - IRuntime existingRuntime = facetProj.getPrimaryRuntime(); - if (runtime != null && (existingRuntime == null || !runtime.equals(existingRuntime))) { - facetProj.setTargetedRuntimes(Collections.singleton(runtime), null); - runtimeAdded = true; - } - return facetProj; - } - - public static void addDefaultFactets(IFacetedProject facetProj, IRuntime runtime) throws ExecutionException { - - if (runtime != null) { - final IFacetedProjectWorkingCopy fpjwc = facetProj.createWorkingCopy(); - Set<IProjectFacetVersion> presetFacets = fpjwc.getDefaultConfiguration().getProjectFacets(); - addDefaultFacets(facetProj, presetFacets); - } - - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/IArtifactEditOperationDataModelProperties.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/IArtifactEditOperationDataModelProperties.java deleted file mode 100644 index f3c39240a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/IArtifactEditOperationDataModelProperties.java +++ /dev/null @@ -1,38 +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.wst.common.componentcore.internal.operation; - - -public interface IArtifactEditOperationDataModelProperties { - - /** - * Required - */ - public static final String TYPE_ID = "IArtifactEditOperationDataModelProperties.TYPE_ID"; //$NON-NLS-1$ - - /** - * Required - */ - public static final String PROJECT_NAME = "IArtifactEditOperationDataModelProperties.PROJECT_NAME"; //$NON-NLS-1$ - /** - * Required - */ - public static final String COMPONENT_NAME = "IArtifactEditOperationDataModelProperties.COMPONENT_NAME"; //$NON-NLS-1$ - /** - * Optional, should save with prompt...defaults to false - */ - public static final String PROMPT_ON_SAVE = "IArtifactEditOperationDataModelProperties.PROMPT_ON_SAVE"; //$NON-NLS-1$ - - public static final String TARGET_PROJECT = "IArtifactEditOperationDataModelProperties.TARGET_PROJECT"; //$NON-NLS-1$ - - public static final String TARGET_COMPONENT = "IArtifactEditOperationDataModelProperties.TARGET_COMPONENT"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ProjectMigratorDataModelOperation.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ProjectMigratorDataModelOperation.java deleted file mode 100644 index d50738927..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ProjectMigratorDataModelOperation.java +++ /dev/null @@ -1,45 +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.wst.common.componentcore.internal.operation; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.datamodel.properties.IProjectMigratorDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.IComponentProjectMigrator; -import org.eclipse.wst.common.componentcore.internal.ProjectMigratorRegistry; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class ProjectMigratorDataModelOperation extends AbstractDataModelOperation { - - public ProjectMigratorDataModelOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - IProject proj = ProjectUtilities.getProject(model.getStringProperty(IProjectMigratorDataModelProperties.PROJECT_NAME)); - IComponentProjectMigrator[] migrators = ProjectMigratorRegistry.getInstance().getProjectMigrators(); - for (int i = 0; i < migrators.length; i++) { - IComponentProjectMigrator migrator = migrators[i]; - migrator.migrateProject(proj); - } - } catch (Exception e) { - e.printStackTrace(); - } - return OK_STATUS; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/RemoveReferenceComponentOperation.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/RemoveReferenceComponentOperation.java deleted file mode 100644 index bb1f2c37e..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/RemoveReferenceComponentOperation.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.operation; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class RemoveReferenceComponentOperation extends AbstractDataModelOperation { - - public RemoveReferenceComponentOperation() { - super(); - } - - public RemoveReferenceComponentOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - removeReferencedComponents(monitor); - return OK_STATUS; - } - - protected void removeReferencedComponents(IProgressMonitor monitor) { - - IVirtualComponent sourceComp = (IVirtualComponent) model.getProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT); - if (sourceComp == null || !sourceComp.getProject().isAccessible() || sourceComp.isBinary()) return; - - IVirtualReference [] existingReferencesArray = sourceComp.getReferences(); - if(existingReferencesArray == null || existingReferencesArray.length == 0){ - return; - } - - List existingReferences = new ArrayList(); - for(int i=0;i<existingReferencesArray.length; i++){ - existingReferences.add(existingReferencesArray[i]); - } - - String deployPath = model.getStringProperty( ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH ); - IPath path = new Path( deployPath ); - - List modList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - - List targetprojectList = new ArrayList(); - - for (int i = 0; i < modList.size() && !existingReferences.isEmpty(); i++) { - IVirtualComponent comp = (IVirtualComponent) modList.get(i); - if (comp==null ) - continue; - - IVirtualReference ref = findMatchingReference(existingReferences, comp, path); - //if a ref was found matching the specified deployPath, then remove it - if(ref != null){ - removeRefereneceInComponent(sourceComp, ref); - existingReferences.remove(ref); - //after removing the ref, check to see if it was the last ref removed to that component - //and if it was, then also remove the project reference - ref = findMatchingReference(existingReferences, comp); - if(ref == null){ - IProject targetProject = comp.getProject(); - targetprojectList.add(targetProject); - } - } - } - - try { - ProjectUtilities.removeReferenceProjects(sourceComp.getProject(),targetprojectList); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - - } - - private IVirtualReference findMatchingReference(List existingReferences, IVirtualComponent comp, IPath path) { - for(int i=0;i<existingReferences.size(); i++){ - IVirtualReference ref = (IVirtualReference)existingReferences.get(i); - IVirtualComponent c = ref.getReferencedComponent(); - if(c != null && c.getName().equals(comp.getName())){ - if(path == null){ - return ref; - } else if(path.equals(ref.getRuntimePath())){ - return ref; - } - } - } - return null; - } - - private IVirtualReference findMatchingReference(List existingReferences, IVirtualComponent comp) { - return findMatchingReference(existingReferences, comp, null); - } - - protected void removeRefereneceInComponent(IVirtualComponent component, IVirtualReference reference) { - ((VirtualComponent)component.getComponent()).removeReference(reference); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/RemoveReferenceComponentsDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/RemoveReferenceComponentsDataModelProvider.java deleted file mode 100644 index d48dbe0ab..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/RemoveReferenceComponentsDataModelProvider.java +++ /dev/null @@ -1,26 +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.wst.common.componentcore.internal.operation; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - - -public class RemoveReferenceComponentsDataModelProvider extends CreateReferenceComponentsDataModelProvider { - - public RemoveReferenceComponentsDataModelProvider() { - super(); - } - - public IDataModelOperation getDefaultOperation() { - return new RemoveReferenceComponentOperation(model); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ServerContextRootDataModelProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ServerContextRootDataModelProvider.java deleted file mode 100644 index 01ded490f..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ServerContextRootDataModelProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.eclipse.wst.common.componentcore.internal.operation; - -/******************************************************************************* - * Copyright (c) 2008 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 - *******************************************************************************/ - -import java.util.Set; - -import org.eclipse.wst.common.componentcore.datamodel.properties.IServerContextRootDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class ServerContextRootDataModelProvider - extends AbstractDataModelProvider - implements IServerContextRootDataModelProperties{ - - public ServerContextRootDataModelProvider(){ - super(); - } - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(PROJECT); - names.add(CONTEXT_ROOT); - return names; - } - - public IDataModelOperation getDefaultOperation() { - return new ServerContextRootUpdateOperation(model); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ServerContextRootUpdateOperation.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ServerContextRootUpdateOperation.java deleted file mode 100644 index 962b731c6..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ServerContextRootUpdateOperation.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.eclipse.wst.common.componentcore.internal.operation; - -/******************************************************************************* - * Copyright (c) 2008 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 - *******************************************************************************/ - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.IServerContextRootDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class ServerContextRootUpdateOperation - extends AbstractDataModelOperation - implements IServerContextRootDataModelProperties{ - - - public ServerContextRootUpdateOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - IProject project = (IProject)model.getProperty( IServerContextRootDataModelProperties.PROJECT ); - String contextRoot = model.getStringProperty( IServerContextRootDataModelProperties.CONTEXT_ROOT ); - if (contextRoot != null) { - IVirtualComponent comp = ComponentCore.createComponent(project); - comp.setMetaProperty(IModuleConstants.CONTEXTROOT, contextRoot); - } - return OK_STATUS; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/ResourceTimestampMappings.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/ResourceTimestampMappings.java deleted file mode 100644 index 47710ab04..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/ResourceTimestampMappings.java +++ /dev/null @@ -1,279 +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.wst.common.componentcore.internal.resources; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - - -/** - * Maps resources to cached data and remembers when the data was cached based on a timestamp - * signature of a given resource. - * - */ -public class ResourceTimestampMappings { - - private static final IPath COMPONENT_MANIFEST_PATH = new Path(".settings/org.eclipse.wst.common.component"); - private static final IPath FACET_CONFIG_PATH = new Path(".settings/org.eclipse.wst.common.project.facet.core.xml"); - - private static final Object NO_DATA = new Object(); - private static final Object ERROR = new Object(); - - private final Map timestamps = new HashMap(); - private final Map data = new HashMap(); - - - /** - * Record a timestamp signature for the given resource. - * <p> - * Clients may use {@link #hasChanged(IResource)} to determine if the resource has changed since - * it was recorded. - * </p> - * - * @param resource - * The resource that was processed. - * @return True if the recording was successfull. The recording may fail if the resource does - * not exist. - * - * @see #hasChanged(IResource) - */ - public synchronized boolean mark(IResource resource) { - return mark(resource, NO_DATA); - } - - /** - * Cache the data that was determined when processing the resource. The a timestamp signature - * will be recorded for the resource as well. - * - * <p> - * Clients may use {@link #hasChanged(IResource)} to determine if the cached data should be - * replaced. - * </p> - * - * @param resource - * The resource that was processed. - * @param cachedData - * The data that was determined when the Resource was processed. - * - * @return True if the recording was successfull. The recording may fail if the resource does - * not exist. - * - * - * @see #hasChanged(IResource) - * @see #hasCacheData(IResource) - */ - public synchronized boolean mark(IResource resource, Object cachedData) { - - if (resource.getModificationStamp() != IResource.NULL_STAMP) { - if (timestamps.containsKey(resource)) { - TimestampSignature signature = (TimestampSignature) timestamps.get(resource); - signature.update(resource); - } else { - timestamps.put(resource, createTimestampSignature(resource)); - } - data.put(resource, cachedData); - return true; - } - return false; - } - - /** - * Note that an error occurred when processing this resource. - * - * @param resource - * The resource that had some sort of error while processing. - * @return True if the error was recorded. The error may not be recorded if the resource does - * not exist. - * @see #hasCacheError(IResource) - */ - public synchronized boolean markError(IResource resource) { - - if (resource.getModificationStamp() != IResource.NULL_STAMP) { - if (timestamps.containsKey(resource)) { - TimestampSignature signature = (TimestampSignature) timestamps.get(resource); - signature.update(resource); - } else { - timestamps.put(resource, createTimestampSignature(resource)); - } - data.put(resource, ERROR); - return true; - } - return false; - } - - /** - * - * @param resource - * The resource that was or is about to be processed. - * @return True if the given resource has changed in a noticeable way since it was marked. - * - * @see #mark(IResource) - * @see #mark(IResource, Object) - * @see #markError(IResource) - */ - public boolean hasChanged(IResource resource) { - TimestampSignature signature = (TimestampSignature) timestamps.get(resource); - return signature == null || signature.hasChanged(resource); - } - - /** - * - * @param resource - * The resource that was or is about to be processed. - * @return True if there is any data cached for the given resource. - * - * @see #mark(IResource) - * @see #mark(IResource, Object) - * @see #markError(IResource) - */ - public boolean hasCacheData(IResource resource) { - Object datum = data.get(resource); - return datum != null && datum != NO_DATA; - - } - - - /** - * - * @param resource - * The resource that was or is about to be processed. - * @return True if there is any data cached for the given resource. - * - * @see #mark(IResource) - * @see #mark(IResource, Object) - * @see #markError(IResource) - */ - public boolean hasCacheError(IResource resource) { - return data.get(resource) == ERROR; - } - - public Object getData(IResource resource) { - Object datum = data.get(resource); - if (datum != NO_DATA) - return datum; - return null; - } - - - private TimestampSignature createTimestampSignature(IResource resource) { - switch (resource.getType()) { - case IResource.PROJECT : - return new ProjectTimestamp((IProject) resource); - default : - return new SimpleResourceTimestamp(resource); - } - } - - /** - * Provides a point in time signature of a Resource to determine whether that resource has - * changed in a meaningful way since the time this signature was created or last updated. - * - */ - public interface TimestampSignature { - - /** - * - * @param resource - * A resource related to this signature - * @return True if the current resource is different from this signature in a meaningful way - */ - boolean hasChanged(IResource resource); - - /** - * - * @param resource - * Update the signature details to the given resource's signature. - */ - void update(IResource resource); - - } - - /** - * Provides a signature based on the modificationStamp of a resource. - */ - public class SimpleResourceTimestamp implements TimestampSignature { - private long timestamp = 0; - - public SimpleResourceTimestamp(IResource resource) { - update(resource); - } - - public boolean hasChanged(IResource resource) { - return timestamp != resource.getModificationStamp(); - } - - public void update(IResource resource) { - timestamp = resource.getModificationStamp(); - } - } - - /** - * Provides a signature for a project based on the modificationStamp of the (1) project, (2) the - * component manifest, and (3) the facet configuration - */ - public class ProjectTimestamp implements TimestampSignature { - - private long projectTimestamp = 0; - private long componentManifestTimestamp = 0; - private long facetConfigTimestamp = 0; - - public ProjectTimestamp(IProject project) { - update(project); - } - - public boolean hasChanged(IResource resource) { - if (resource.getType() == IResource.PROJECT) { - IProject project = (IProject) resource; - if (projectTimestamp != project.getModificationStamp()) - return true; - - IFile file = project.getFile(COMPONENT_MANIFEST_PATH); - if (!file.exists() || componentManifestTimestamp != file.getModificationStamp()) - return true; - - file = project.getFile(FACET_CONFIG_PATH); - if (!file.exists() || facetConfigTimestamp != file.getModificationStamp()) - return true; - - return false; - } - return true; - - } - - public void update(IResource resource) { - - if (resource instanceof IProject) { - - IProject project = (IProject) resource; - - projectTimestamp = project.getModificationStamp(); - - IFile file = project.getFile(COMPONENT_MANIFEST_PATH); - componentManifestTimestamp = file.getModificationStamp(); - - file = project.getFile(FACET_CONFIG_PATH); - facetConfigTimestamp = file.getModificationStamp(); - - } else { - projectTimestamp = componentManifestTimestamp = facetConfigTimestamp = IResource.NULL_STAMP; - } - - } - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualArchiveComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualArchiveComponent.java deleted file mode 100644 index 0d66c2f0a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualArchiveComponent.java +++ /dev/null @@ -1,270 +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.wst.common.componentcore.internal.resources; - - -import java.io.File; -import java.util.Properties; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -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; -import org.eclipse.wst.common.frameworks.internal.HashUtil; - - -public class VirtualArchiveComponent implements IVirtualComponent, IAdaptable { - - public static final Class ADAPTER_TYPE = VirtualArchiveComponent.class; - public static final String LIBARCHIVETYPE = "lib"; - public static final String VARARCHIVETYPE = "var"; - /** - * VirtualArchiveComponent type for VirtualArchiveComponents that represent classpath component dependencies. - */ - public static final String CLASSPATHARCHIVETYPE = "cpe"; //$NON-NLS-1 - - private static final IVirtualReference[] NO_REFERENCES = new VirtualReference[0]; - private static final IVirtualComponent[] NO_COMPONENTS = new VirtualComponent[0]; -// private static final IResource[] NO_RESOURCES = null; - private static final IVirtualResource[] NO_VIRTUAL_RESOURCES = null; - private static final Properties NO_PROPERTIES = new Properties(); - private static final IPath[] NO_PATHS = new Path[0]; - -// private IPath runtimePath; - private IProject componentProject; -// private IVirtualFolder rootFolder; - private int flag = 1; -// private String archiveLocation; - - - private IPath archivePath; - private String archiveType; - - - - public VirtualArchiveComponent(IProject aComponentProject,String archiveLocation, IPath aRuntimePath) { - if(aComponentProject == null){ - throw new NullPointerException(); - } - componentProject = aComponentProject; -// runtimePath = aRuntimePath; - - String archivePathString = archiveLocation.substring(4, archiveLocation.length()); - archiveType = archiveLocation.substring(0, archiveLocation.length() - archivePathString.length() -1); - archivePath = new Path(archivePathString); - } - - public IVirtualComponent getComponent() { - return this; - } - - public String getName() { - return this.archiveType + IPath.SEPARATOR + this.archivePath.toString(); - } - - public String getDeployedName() { - return getName(); - } - - public void setComponentTypeId(String aComponentTypeId) { - return; - } - - public int getType() { - return IVirtualResource.COMPONENT; - } - - public boolean isBinary() { - boolean ret = (flag & BINARY) == 1 ? true : false; - return ret; - } - - public IPath[] getMetaResources() { - return NO_PATHS; - } - - public void setMetaResources(IPath[] theMetaResourcePaths) { - - } - - public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException { - - } - - public String getFileExtension() { - return archivePath.getFileExtension(); - } - - public IPath getWorkspaceRelativePath() { - if( archivePath.segmentCount() > 1 ){ - IFile aFile = ResourcesPlugin.getWorkspace().getRoot().getFile(archivePath); - if (aFile.exists()) - return aFile.getFullPath(); - } - return null; - } - - public IPath getProjectRelativePath() { - IFile aFile = ResourcesPlugin.getWorkspace().getRoot().getFile(getWorkspaceRelativePath()); - if (aFile.exists()) - return aFile.getProjectRelativePath(); - return null; - } - - public IProject getProject() { - return componentProject; - } - - public IPath getRuntimePath() { - return ROOT; - } - - public boolean isAccessible() { - return true; - } - - public Properties getMetaProperties() { - return NO_PROPERTIES; - } - - public IVirtualResource[] getResources(String aResourceType) { - return NO_VIRTUAL_RESOURCES; - } - - public void create(int updateFlags, IProgressMonitor aMonitor) throws CoreException { - - } - - public IVirtualReference[] getReferences() { - return NO_REFERENCES; - } - - public void setReferences(IVirtualReference[] theReferences) { - // no op - } - - public void addReferences(IVirtualReference[] references) { - // no op - } - - public IVirtualReference getReference(String aComponentName) { - return null; - } - - public boolean exists() { - boolean exists = false; - java.io.File diskFile = getUnderlyingDiskFile(); - if( diskFile != null ) - exists = diskFile.exists(); - - if( !exists ){ - IFile utilityJar = getUnderlyingWorkbenchFile(); - if( utilityJar != null ) - exists = utilityJar.exists(); - } - return exists; - } - - public IVirtualFolder getRootFolder() { - return null; - } - - public IVirtualComponent[] getReferencingComponents() { - return NO_COMPONENTS; - } - - - public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - - public String getArchiveType() { - return archiveType; - } - - public int hashCode() { - int hash = HashUtil.SEED; - hash = HashUtil.hash(hash, getProject().getName()); - hash = HashUtil.hash(hash, getName()); - hash = HashUtil.hash(hash, isBinary()); - return hash; - } - - public boolean equals(Object anOther) { - if (anOther instanceof VirtualArchiveComponent) { - VirtualArchiveComponent otherComponent = (VirtualArchiveComponent) anOther; - return getProject().equals(otherComponent.getProject()) && - getName().equals(otherComponent.getName()) && - isBinary() == otherComponent.isBinary(); - } - return false; - } - - public void setMetaProperty(String name, String value) { - - } - - public void setMetaProperties(Properties properties) { - - } - public IFile getUnderlyingWorkbenchFile() { - if (getWorkspaceRelativePath()==null) - return null; - return ResourcesPlugin.getWorkspace().getRoot().getFile(getWorkspaceRelativePath()); - } - - public File getUnderlyingDiskFile() { - String osPath = null; - IPath loc = null; - if (getArchiveType().equals(VirtualArchiveComponent.VARARCHIVETYPE)) { - Object adapted = getAdapter(VirtualArchiveComponent.ADAPTER_TYPE); - if (adapted instanceof IPath) { - IPath resolvedpath = (IPath) adapted; - osPath = resolvedpath.toOSString(); - } - } else if(!archivePath.isAbsolute()) { - IFile file = getProject().getFile(archivePath); - if(file.exists()) - loc = file.getLocation(); - else if(archivePath.segmentCount() > 1) { - file = ResourcesPlugin.getWorkspace().getRoot().getFile(archivePath); - if(file.exists()) - loc = file.getLocation(); - } - // this is a file on the local filesystem - if(loc != null) - osPath = loc.toOSString(); - } else { - osPath = archivePath.toOSString(); - } - if (osPath==null || osPath.length()==0) - return null; - File diskFile = new File(osPath); - return diskFile; - } - - public String toString() { - if(archivePath != null){ - return componentProject + " " +archivePath; - } - return super.toString(); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualComponent.java deleted file mode 100644 index 104db3041..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualComponent.java +++ /dev/null @@ -1,530 +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.wst.common.componentcore.internal.resources; - -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.DependencyType; -import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.builder.DependencyGraphManager; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -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; -import org.eclipse.wst.common.frameworks.internal.HashUtil; - - -public class VirtualComponent implements IVirtualComponent { - IPath runtimePath; - IProject componentProject; - IVirtualFolder rootFolder; - String componentTypeId; - private int flag = 0; - - - protected VirtualComponent(){ - } - - public VirtualComponent(IProject aProject, IPath aRuntimePath) { - if(aProject == null){ - throw new NullPointerException(); - } - componentProject = aProject; - runtimePath = aRuntimePath; - rootFolder = ComponentCore.createFolder(componentProject, new Path("/")); //$NON-NLS-1$ - } - - public IVirtualComponent getComponent() { - return this; - } - - public String getName() { - return getProject().getName(); - } - - public String getDeployedName() { - StructureEdit core = null; - IProject project = getProject(); - try { - if (project != null && getName() != null) { - core = StructureEdit.getStructureEditForRead(project); - if(core != null && core.getComponent() != null){ - WorkbenchComponent component = core.getComponent(); - if (component.getName()!=null && component.getName().length()>0) - return component.getName(); - } - } - } finally { - if(core != null) - core.dispose(); - } - return getProject().getName(); - } - - public boolean exists() { - IProject project = getProject(); - return ModuleCoreNature.isFlexibleProject(project); - } - - - public Properties getMetaProperties() { - StructureEdit core = null; - Properties props = new Properties(); - try { - core = StructureEdit.getStructureEditForRead(getProject()); - if (core == null) - return props; - WorkbenchComponent component = core.getComponent(); - if (component == null) return props; - List propList = component.getProperties(); - if(propList != null) { - for (int i = 0; i < propList.size(); i++) { - Property property = (Property)propList.get(i); - String name = property.getName(); - String value = property.getValue(); - if(value == null){ - value = ""; //$NON-NLS-1$ - String message = "WARNING: The component file in "+getProject().getName()+" has no value defined for the property: "+name; //$NON-NLS-1$//$NON-NLS-2$ - ModulecorePlugin.logError(IStatus.ERROR, message, null); - } - props.setProperty(name, value); - } - } - return props; - } finally { - if(core != null) - core.dispose(); - } - } - - public void setMetaProperties(Properties properties) { - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = core.getComponent(); - - List propList = component.getProperties(); - if (properties != null && !properties.isEmpty()) { - for(Enumeration itr = properties.keys(); itr.hasMoreElements();) { - final String key = (String) itr.nextElement(); - final Property prop = ComponentcoreFactory.eINSTANCE.createProperty(); - prop.setName(key); - prop.setValue(properties.getProperty(key)); - // Remove existing property first - for (int i=0; i<propList.size(); i++) { - Property existing = (Property) propList.get(i); - if (existing.getName().equals(key)) { - propList.remove(existing); - break; - } - } - // Add new property - propList.add(prop); - } - } - } finally { - if(core != null){ - core.saveIfNecessary(null); - core.dispose(); - } - } - } - - public void clearMetaProperties() { - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = core.getComponent(); - component.getProperties().clear(); - } finally { - if(core != null){ - core.saveIfNecessary(null); - core.dispose(); - } - } - } - - public void setMetaProperty(String key, String value) { - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = core.getComponent(); - //Remove existing property first - List properties = component.getProperties(); - for (int i=0; i<properties.size(); i++) { - Property existing = (Property) properties.get(i); - if (existing.getName().equals(key)) { - properties.remove(existing); - break; - } - } - //Set new property - final Property prop = ComponentcoreFactory.eINSTANCE.createProperty(); - prop.setName(key); - prop.setValue(value); - component.getProperties().add(prop); - - } finally { - if(core != null){ - core.saveIfNecessary(null); - core.dispose(); - } - } - } - - public IPath[] getMetaResources() { - StructureEdit moduleCore = null; - List metaResources = new ArrayList(); - try { - moduleCore = StructureEdit.getStructureEditForRead(getProject()); - if (moduleCore != null) { - WorkbenchComponent component = moduleCore.getComponent(); - if (component != null) - metaResources.addAll(component.getMetadataResources()); - } - } finally { - if (moduleCore != null) { - moduleCore.dispose(); - } - } - return (IPath[]) metaResources.toArray(new IPath[metaResources.size()]); - } - - public void setMetaResources(IPath[] theMetaResourcePaths) { - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore.getComponent(); - if (component != null) { - for (int i=0; i<theMetaResourcePaths.length; i++) { - if (!component.getMetadataResources().contains(theMetaResourcePaths[i])) - component.getMetadataResources().add(theMetaResourcePaths[i]); - } - } - } finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(null); - moduleCore.dispose(); - } - } - } - - public int getType() { - return IVirtualResource.COMPONENT; - } - - - public boolean isBinary(){ - boolean ret = (flag & BINARY) == 1 ? true :false; - return ret; - } - - public void create(int updateFlags, IProgressMonitor aMonitor) - throws CoreException { - - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore - .getComponent(); - if (component == null) - component = moduleCore - .createWorkbenchModule(getProject().getName()); - - } finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(null); - moduleCore.dispose(); - } - } - } - - public IVirtualReference[] getReferences(Map<String, Object> options) { - return getReferences(); - } - - public IVirtualReference[] getReferences() { - StructureEdit core = null; - List references = new ArrayList(); - try { - core = StructureEdit.getStructureEditForRead(getProject()); - if (core!=null && core.getComponent()!=null) { - WorkbenchComponent component = core.getComponent(); - if (component!=null) { - List referencedComponents = component.getReferencedComponents(); - for (Iterator iter = referencedComponents.iterator(); iter.hasNext();) { - ReferencedComponent referencedComponent = (ReferencedComponent) iter.next(); - if (referencedComponent==null) - continue; - IVirtualReference vReference = StructureEdit.createVirtualReference(this, referencedComponent); - if( vReference != null ){ - vReference.setArchiveName( referencedComponent.getArchiveName() ); - } - if (vReference != null && vReference.getReferencedComponent() != null && vReference.getReferencedComponent().exists()) - references.add(vReference); - } - } - } - return (IVirtualReference[]) references.toArray(new IVirtualReference[references.size()]); - } finally { - if(core != null) - core.dispose(); - } - } - - public void addReferences(IVirtualReference[] references) { - if (references==null || references.length==0) - return; - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForWrite(getProject()); - if (core == null) - return; - WorkbenchComponent component = core.getComponent(); - ReferencedComponent referencedComponent = null; - ComponentcoreFactory factory = ComponentcorePackage.eINSTANCE.getComponentcoreFactory(); - for (int i=0; i<references.length; i++) { - if (references[i] == null) - continue; - referencedComponent = factory.createReferencedComponent(); - referencedComponent.setDependencyType(DependencyType.get(references[i].getDependencyType())); - referencedComponent.setRuntimePath(references[i].getRuntimePath()); - - IVirtualComponent comp = references[i].getReferencedComponent(); - if(comp!=null && !comp.isBinary()) - referencedComponent.setHandle(ModuleURIUtil.fullyQualifyURI(comp.getProject())); - else if (comp!=null) - referencedComponent.setHandle(ModuleURIUtil.archiveComponentfullyQualifyURI(comp.getName())); - if (component != null) - component.getReferencedComponents().add(referencedComponent); - referencedComponent.setArchiveName(references[i].getArchiveName()); - } - //clean up any old obsolete references - if (component != null){ - cleanUpReferences(component); - } - } finally { - if(core != null) { - core.saveIfNecessary(null); - core.dispose(); - } - } - } - - private void cleanUpReferences(WorkbenchComponent component) { - List referencedComponents = component.getReferencedComponents(); - for (Iterator iter = referencedComponents.iterator(); iter.hasNext();) { - ReferencedComponent referencedComponent = (ReferencedComponent) iter.next(); - if (referencedComponent==null) - continue; - IVirtualReference vReference = StructureEdit.createVirtualReference(this, referencedComponent); - if (vReference == null || vReference.getReferencedComponent() == null || !vReference.getReferencedComponent().exists()){ - iter.remove(); - } - } - } - - public void setReferences(IVirtualReference[] references) { - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = core.getComponent(); - ReferencedComponent referencedComponent = null; - - component.getReferencedComponents().clear(); - ComponentcoreFactory factory = ComponentcorePackage.eINSTANCE.getComponentcoreFactory(); - for (int i=0; i<references.length; i++) { - referencedComponent = factory.createReferencedComponent(); - referencedComponent.setDependencyType(DependencyType.get(references[i].getDependencyType())); - referencedComponent.setRuntimePath(references[i].getRuntimePath()); - - IVirtualComponent comp = references[i].getReferencedComponent(); - if( !comp.isBinary()) - referencedComponent.setHandle(ModuleURIUtil.fullyQualifyURI(references[i].getReferencedComponent().getProject())); - else - referencedComponent.setHandle(ModuleURIUtil.archiveComponentfullyQualifyURI(references[i].getReferencedComponent().getName())); - - referencedComponent.setArchiveName(references[i].getArchiveName()); - component.getReferencedComponents().add(referencedComponent); - } - - } finally { - if(core != null) { - core.saveIfNecessary(null); - core.dispose(); - } - } - } - - public int hashCode() { - int hash = HashUtil.SEED; - hash = HashUtil.hash(hash, getProject().getName()); - hash = HashUtil.hash(hash, getName()); - hash = HashUtil.hash(hash, isBinary()); - return hash; - } - - public boolean equals(Object anOther) { - if(anOther instanceof IVirtualComponent) { - IVirtualComponent otherComponent = (IVirtualComponent) anOther; - return getProject().equals(otherComponent.getProject()) && - getName().equals(otherComponent.getName()) && - isBinary() == otherComponent.isBinary(); - } - return false; - } - - public IVirtualReference getReference(String aComponentName) { - IVirtualReference[] refs = getReferences(); - for (int i = 0; i < refs.length; i++) { - IVirtualReference reference = refs[i]; - if( reference.getReferencedComponent() != null ){ - if (reference.getReferencedComponent().getName().equals(aComponentName)) - return reference; - } - } - return null; - } - - public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - - public IVirtualFolder getRootFolder() { - return rootFolder; - } - - public IProject getProject() { - return componentProject; - } - - /** - * Return all components which have a reference to the passed in target component. - * - * @param target - * @return array of components - */ - public IVirtualComponent[] getReferencingComponents() { - IProject[] handles = DependencyGraphManager.getInstance().getDependencyGraph().getReferencingComponents(getProject()); - IVirtualComponent[] result = new IVirtualComponent[handles.length]; - for (int i=0; i<handles.length; i++) - result[i] = ComponentCore.createComponent(handles[i]); - return result; - } - - /** - * Remove the associated ReferencedComponent for the virtual reference from the workbench component - * associated with this virtual component - * - * @param aReference - */ - public void removeReference(IVirtualReference aReference) { - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForWrite(getProject()); - if (core == null || aReference == null) - return; - WorkbenchComponent component = core.getComponent(); - ReferencedComponent refComponent = getWorkbenchReferencedComponent(aReference, component); - if (component != null && refComponent != null) - component.getReferencedComponents().remove(refComponent); - } finally { - if(core != null) { - core.saveIfNecessary(null); - core.dispose(); - } - } - } - - /** - * Return the associated structure edit ReferencedComponent object for the given IVirtualReference based on the handle - * and module URI. - * - * @param aReference - * @param core - * @return ReferencedComponent - */ - protected ReferencedComponent getWorkbenchReferencedComponent(IVirtualReference aReference, WorkbenchComponent component) { - if (aReference == null || aReference.getReferencedComponent() == null || component == null) - return null; - List referencedComponents = component.getReferencedComponents(); - for (int i=0; i<referencedComponents.size(); i++) { - ReferencedComponent ref = (ReferencedComponent) referencedComponents.get(i); - if (!aReference.getReferencedComponent().isBinary()) { - if (ref.getHandle().equals(ModuleURIUtil.fullyQualifyURI(aReference.getReferencedComponent().getProject()))) - return ref; - } - else { - if (ref.getHandle().equals(ModuleURIUtil.archiveComponentfullyQualifyURI(aReference.getReferencedComponent().getName()))) - return ref; - } - } - return null; - } - - - /** - * @return IVirtualReference[] - All the references of this component, including potentially deleted references - */ - public IVirtualReference[] getAllReferences() { - StructureEdit core = null; - List references = new ArrayList(); - try { - core = StructureEdit.getStructureEditForRead(getProject()); - if (core!=null && core.getComponent()!=null) { - WorkbenchComponent component = core.getComponent(); - if (component!=null) { - List referencedComponents = component.getReferencedComponents(); - for (Iterator iter = referencedComponents.iterator(); iter.hasNext();) { - ReferencedComponent referencedComponent = (ReferencedComponent) iter.next(); - if (referencedComponent==null) - continue; - IVirtualReference vReference = StructureEdit.createVirtualReference(this, referencedComponent); - if( vReference != null ){ - vReference.setArchiveName( referencedComponent.getArchiveName() ); - } - if (vReference != null && vReference.getReferencedComponent() != null) - references.add(vReference); - } - } - } - return (IVirtualReference[]) references.toArray(new IVirtualReference[references.size()]); - } finally { - if(core != null) - core.dispose(); - } - } - - public String toString() { - return componentProject.toString(); - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualContainer.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualContainer.java deleted file mode 100644 index 51f4f1505..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualContainer.java +++ /dev/null @@ -1,363 +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.wst.common.componentcore.internal.resources; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.common.componentcore.ComponentCore; -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.impl.ResourceTreeNode; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeRoot; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualContainer; -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 abstract class VirtualContainer extends VirtualResource implements IVirtualContainer { - - - public VirtualContainer(IProject aComponentProject, IPath aRuntimePath) { - super(aComponentProject, aRuntimePath); - } - - // TODO WTP:Implement this method - public boolean exists(IPath path) { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - - } - - /** - * @see IContainer#findMember(java.lang.String) - */ - public IVirtualResource findMember(String aChildName) { - return findMember(new Path(aChildName), 0); - } - - /** - * @see IContainer#findMember(java.lang.String, boolean) - */ - public IVirtualResource findMember(String aChildName, int searchFlags) { - return findMember(new Path(aChildName), searchFlags); - } - - /** - * @see IContainer#findMember(org.eclipse.core.runtime.IPath) - */ - public IVirtualResource findMember(IPath aChildPath) { - return findMember(aChildPath, 0); - } - - public IVirtualResource findMember(IPath aPath, int theSearchFlags) { - - StructureEdit structureEdit = null; - try { - - structureEdit = StructureEdit.getStructureEditForRead(getProject()); - WorkbenchComponent component = structureEdit.getComponent(); - if (null != component) { - ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component); - ComponentResource[] resources = root.findModuleResources(getRuntimePath().append(aPath), ResourceTreeNode.CREATE_NONE); - - for (int i = 0; i < resources.length; i++) { - // return the resources corresponding to the root, not any of the children if its a folder - if (resources[i].getRuntimePath().equals(getRuntimePath().append(aPath))) { - IResource platformResource = getProject().findMember(resources[i].getSourcePath()); - if (platformResource == null) - platformResource = ResourcesPlugin.getWorkspace().getRoot().findMember(resources[i].getSourcePath()); - if (platformResource != null) { - switch (platformResource.getType()) { - case IResource.FOLDER : - case IResource.PROJECT : - return ComponentCore.createFolder(getProject(), getRuntimePath().append(aPath)); - case IResource.FILE : - return new VirtualFile(getProject(), getRuntimePath().append(aPath)); - } - } - } - } - } - } finally { - if (structureEdit != null) - structureEdit.dispose(); - } - return null; - } - - /** - * @see IContainer#getFile(org.eclipse.core.runtime.IPath) - */ - public IVirtualFile getFile(IPath aPath) { - return new VirtualFile(getProject(), getRuntimePath().append(aPath)); - } - - /** - * @see IContainer#getFolder(org.eclipse.core.runtime.IPath) - */ - public IVirtualFolder getFolder(IPath aPath) { - return ComponentCore.createFolder(getProject(), getRuntimePath().append(aPath)); - } - - /** - * @see org.eclipse.core.resources.IFolder#getFile(java.lang.String) - */ - public IVirtualFile getFile(String name) { - return new VirtualFile(getProject(), getRuntimePath().append(name)); - } - - /** - * @see org.eclipse.core.resources.IFolder#getFolder(java.lang.String) - */ - public IVirtualFolder getFolder(String name) { - return ComponentCore.createFolder(getProject(), getRuntimePath().append(name)); - } - - /** - * @see IContainer#members() - */ - public IVirtualResource[] members() throws CoreException { - return members(IResource.NONE); - } - - /** - * @see IContainer#members(boolean) - */ - public IVirtualResource[] members(boolean includePhantoms) throws CoreException { - return members(includePhantoms ? IGNORE_EXCLUSIONS : IResource.NONE); - } - - /** - * @see IContainer#members(int) - */ - public IVirtualResource[] members(int memberFlags) throws CoreException { - List virtualResources = new ArrayList(); // result - Set allNames = new HashSet(); - // Ignore all meta data paths in the virtual container resource set - IVirtualComponent component = getComponent(); - if (component == null) - return new IVirtualResource[0]; - IPath[] metaPaths = component.getMetaResources(); - for (int i = 0; i < metaPaths.length; i++) { - String localName = getLocalName(metaPaths[i]); - if (localName != null) - allNames.add(localName); - } - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForRead(getProject()); - WorkbenchComponent wbComponent = moduleCore.getComponent(); - if (wbComponent != null) { - ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(wbComponent); - ComponentResource[] componentResources = root.findModuleResources(getRuntimePath(), ResourceTreeNode.CREATE_NONE); - // componentResources = orderResourcesByFolder(componentResources); - - for (int componentResourceIndex = 0; componentResourceIndex < componentResources.length; componentResourceIndex++) { - IPath fullRuntimePath = componentResources[componentResourceIndex].getRuntimePath(); - // exact match - if (fullRuntimePath.equals(getRuntimePath())) { - - IResource realResource = getProject().findMember(componentResources[componentResourceIndex].getSourcePath()); - if ((realResource != null) && (realResource.getType() == IResource.FOLDER || realResource.getType() == IResource.PROJECT)) { - IContainer realContainer = (IContainer) realResource; - IResource[] realChildResources = realContainer.members(memberFlags); - for (int realResourceIndex = 0; realResourceIndex < realChildResources.length; realResourceIndex++) { - IResource child = realChildResources[realResourceIndex]; - String localName = child.getName(); - if (allNames.add(localName)) { - IPath newRuntimePath = getRuntimePath().append(localName); - if (child instanceof IFile) { - virtualResources.add(new VirtualFile(getProject(), newRuntimePath, (IFile) child)); - } else { - virtualResources.add(ComponentCore.createFolder(getProject(), newRuntimePath)); - } - } - } - } - // An IResource.FILE would be an error condition (as this is a container) - - } else { // fuzzy match - String localName = getLocalName(fullRuntimePath); - if (localName != null && allNames.add(localName)) { - IResource realResource = StructureEdit.getEclipseResource(componentResources[componentResourceIndex]); - if (realResource != null) { - IPath newRuntimePath = getRuntimePath().append(localName); - if (fullRuntimePath.segmentCount() > getRuntimePath().segmentCount() + 1) { // not a direct child - virtualResources.add(ComponentCore.createFolder(getProject(), newRuntimePath)); - } else { - if (realResource instanceof IFile) { - virtualResources.add(new VirtualFile(getProject(), newRuntimePath, (IFile) realResource)); - } else { - virtualResources.add(ComponentCore.createFolder(getProject(), newRuntimePath)); - } - } - } - } - } - } - } - } catch (Exception e) { - if (virtualResources == null) - return new IVirtualResource[0]; - } finally { - if (moduleCore != null) - moduleCore.dispose(); - } - return (IVirtualResource[]) virtualResources.toArray(new IVirtualResource[virtualResources.size()]); - } - - /** - * Local name within context of this virtual container. - */ - private String getLocalName(IPath path) { - if (!getRuntimePath().isPrefixOf(path)) - return null; - return path.segment(getRuntimePath().segmentCount()); - } - - public IVirtualFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor) throws CoreException { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - // return null; - } - - /** - * @see org.eclipse.core.resources.IFolder#createLink(org.eclipse.core.runtime.IPath, int, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public void createLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException { - - StructureEdit moduleCore = null; - try { - IContainer resource = null; - if (aProjectRelativeLocation.isRoot() || aProjectRelativeLocation.isEmpty()) { - resource = getProject(); - } else { - resource = getProject().getFolder(aProjectRelativeLocation); - } - - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore.getComponent(); - if (null != component) { - ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component); - ComponentResource[] resources = root.findModuleResources(getRuntimePath(), ResourceTreeNode.CREATE_NONE); - - if (resources.length == 0) { - ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource); - componentResource.setRuntimePath(getRuntimePath()); - component.getResources().add(componentResource); - } else { - boolean foundMapping = false; - for (int resourceIndx = 0; resourceIndx < resources.length && !foundMapping; resourceIndx++) { - if (aProjectRelativeLocation.makeAbsolute().equals(resources[resourceIndx].getSourcePath())) - foundMapping = true; - } - if (!foundMapping) { - ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource); - componentResource.setRuntimePath(getRuntimePath()); - component.getResources().add(componentResource); - } - } - createResource(resource, updateFlags, monitor); - } - - } finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(monitor); - moduleCore.dispose(); - } - } - } - - public int getType() { - return IVirtualResource.COMPONENT; - } - - public IResource getUnderlyingResource() { - return null; - } - - public IResource[] getUnderlyingResources() { - return NO_RESOURCES; - } - - protected void doDeleteMetaModel(int updateFlags, IProgressMonitor monitor) { - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore.getComponent(); - if (null != component) { - moduleCore.getComponentModelRoot().getComponents().remove(component); - } - } finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(monitor); - moduleCore.dispose(); - } - } - } - - protected void doDeleteRealResources(int updateFlags, IProgressMonitor monitor) throws CoreException { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - } - - public IVirtualResource[] getResources(String aResourceType) { - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForRead(getProject()); - WorkbenchComponent component = core.getComponent(); - if (null != component) { - List currentResources = component.getResources(); - List foundResources = new ArrayList(); - - if (aResourceType != null) { - for (Iterator iter = currentResources.iterator(); iter.hasNext();) { - ComponentResource resource = (ComponentResource) iter.next(); - if (aResourceType.equals(resource.getResourceType())) { - IVirtualResource vres = createVirtualResource(resource); - if (vres != null) - foundResources.add(vres); - } - } - } - return (IVirtualResource[]) foundResources.toArray(new IVirtualResource[foundResources.size()]); - } - return new IVirtualResource[0]; - } finally { - if (core != null) - core.dispose(); - } - } - - private IVirtualResource createVirtualResource(ComponentResource aComponentResource) { - IResource resource = StructureEdit.getEclipseResource(aComponentResource); - switch (resource.getType()) { - case IResource.FILE : - return ComponentCore.createFile(getProject(), aComponentResource.getRuntimePath()); - case IResource.FOLDER : - return ComponentCore.createFolder(getProject(), aComponentResource.getRuntimePath()); - } - return null; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFile.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFile.java deleted file mode 100644 index ee9ec0472..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFile.java +++ /dev/null @@ -1,122 +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.wst.common.componentcore.internal.resources; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.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.impl.ResourceTreeNode; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeRoot; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -public class VirtualFile extends VirtualResource implements IVirtualFile { - - private IFile underlyingFile; - - public VirtualFile(IProject aComponentProject, IPath aRuntimePath) { - super(aComponentProject, aRuntimePath); - } - - public VirtualFile(IProject aComponentProject, IPath aRuntimePath, IFile underlyingFile) { - super(aComponentProject, aRuntimePath); - this.underlyingFile = underlyingFile; - } - - /** - * @see org.eclipse.core.resources.IFolder#createLink(org.eclipse.core.runtime.IPath, int, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public void createLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException { - - StructureEdit moduleCore = null; - try { - IFile resource = getProject().getFile(aProjectRelativeLocation); - - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore.getComponent(); - - ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component); - ComponentResource[] resources = root.findModuleResources(getRuntimePath(), ResourceTreeNode.CREATE_NONE); - - if(resources.length == 0) { - ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource); - componentResource.setRuntimePath(getRuntimePath()); - component.getResources().add(componentResource); - } else { - boolean foundMapping = false; - for (int resourceIndx = 0; resourceIndx < resources.length && !foundMapping; resourceIndx++) { - if(aProjectRelativeLocation.equals(resources[resourceIndx].getSourcePath())) - foundMapping = true; - } - if(!foundMapping) { - ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource); - componentResource.setRuntimePath(getRuntimePath()); - component.getResources().add(componentResource); - } - } - - } finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(monitor); - moduleCore.dispose(); - } - } - } - - public int getType() { - return IVirtualResource.FILE; - } - - public IResource getUnderlyingResource() { - return getUnderlyingFile(); - } - - public IResource[] getUnderlyingResources() { - return getUnderlyingFiles(); - } - - public IFile getUnderlyingFile() { - if (underlyingFile == null) { - underlyingFile = getProject().getFile(getProjectRelativePath()); - } - return underlyingFile; - } - - public IFile[] getUnderlyingFiles() { - IPath[] paths = getProjectRelativePaths(); - List result = new ArrayList(); - for (int i=0; i<paths.length; i++) { - IFile file = getProject().getFile(paths[i]); - if (file!=null && file.exists() && !result.contains(file)) - result.add(file); - } - return (IFile[]) result.toArray(new IFile[result.size()]); - } - - protected void doDeleteMetaModel(int updateFlags,IProgressMonitor monitor) { - //Default - } - - protected void doDeleteRealResources(int updateFlags, IProgressMonitor monitor) throws CoreException { - //Default - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFolder.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFolder.java deleted file mode 100644 index b3fa912cb..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFolder.java +++ /dev/null @@ -1,150 +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.wst.common.componentcore.internal.resources; - -import java.util.ArrayList; -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.IProgressMonitor; -import org.eclipse.wst.common.componentcore.ComponentCore; -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.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -public class VirtualFolder extends VirtualContainer implements IVirtualFolder { - - - /** - * p> Creates an unassigned mapping contained by the component identified by aComponentHandle - * with a runtime path of aRuntimePath. - * </p> - * - * @param aComponentHandle - * @param aRuntimePath - */ - public VirtualFolder(IProject aComponentProject, IPath aRuntimePath) { - super(aComponentProject, aRuntimePath); - } - - // TODO WTP:Implement this method - public void create(int updateFlags, IProgressMonitor monitor) throws CoreException { - - IVirtualComponent container = ComponentCore.createComponent(getProject()); - if( !container.getRootFolder().getProjectRelativePath().isRoot()){ - IFolder realFolder = getProject().getFolder(container.getRootFolder().getProjectRelativePath()); - IFolder newFolder = realFolder.getFolder(getRuntimePath()); - createResource(newFolder, updateFlags, monitor); - } - else { - IFolder newFolder = getProject().getFolder(getRuntimePath()); - createResource(newFolder, updateFlags, monitor); - } - } - - // TODO WTP:Implement this method - public boolean exists(IPath path) { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - // return false; - } - - - public int getType() { - return IVirtualResource.FOLDER; - } - - public IResource getUnderlyingResource() { - return getUnderlyingFolder(); - } - - public IResource[] getUnderlyingResources() { - return getUnderlyingFolders(); - } - - public IContainer getUnderlyingFolder() { - IPath path = getProjectRelativePath(); - if( !path.isRoot() ) - return getProject().getFolder(getProjectRelativePath()); - return getProject(); - } - - public IContainer[] getUnderlyingFolders() { - IPath[] paths = getProjectRelativePaths(); - List result = new ArrayList(); - for (int i=0; i<paths.length; i++) { - if( !paths[i].isRoot() ){ - IContainer folder = getProject().getFolder(paths[i]); - if (folder!=null && folder.exists() && !result.contains(folder)) - result.add(folder); - } else - result.add(getProject()); - } - return (IContainer[]) result.toArray(new IContainer[result.size()]); - } - - protected void doDeleteMetaModel(int updateFlags, IProgressMonitor monitor) { - - // only handles explicit mappings - StructureEdit moduleCore = null; - try { - IPath runtimePath = getRuntimePath(); - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore.getComponent(); - ComponentResource[] resources = component.findResourcesByRuntimePath(runtimePath); - for (int i = 0; i < resources.length; i++) { - if(runtimePath.equals(resources[i].getRuntimePath())) - component.getResources().remove(resources[i]); - } - - } finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(null); - moduleCore.dispose(); - } - } - } - - protected void doDeleteRealResources(int updateFlags, IProgressMonitor monitor) throws CoreException { - - // only handles explicit mappings - StructureEdit moduleCore = null; - try { - IPath runtimePath = getRuntimePath(); - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore.getComponent(); - ComponentResource[] resources = component.findResourcesByRuntimePath(runtimePath); - IResource realResource; - for (int i = 0; i < resources.length; i++) { - if(runtimePath.equals(resources[i].getRuntimePath())) { - realResource = StructureEdit.getEclipseResource(resources[i]); - if(realResource != null && realResource.getType() == getType()) - realResource.delete(updateFlags, monitor); - } - - } - - } finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(null); - moduleCore.dispose(); - } - } - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualReference.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualReference.java deleted file mode 100644 index 007b1ce9a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualReference.java +++ /dev/null @@ -1,151 +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.wst.common.componentcore.internal.resources; - -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.ecore.EObject; -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.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - -public class VirtualReference implements IVirtualReference { - - private IVirtualComponent referencedComponent; - private IVirtualComponent enclosingComponent; - private IPath runtimePath; - private int dependencyType; - private String archiveName; - - public VirtualReference() { - - } - - public VirtualReference(IVirtualComponent anEnclosingComponent, IVirtualComponent aReferencedComponent) { - this(anEnclosingComponent, aReferencedComponent, new Path(String.valueOf(IPath.SEPARATOR)), DEPENDENCY_TYPE_USES); - } - - public VirtualReference(IVirtualComponent anEnclosingComponent, IVirtualComponent aReferencedComponent, IPath aRuntimePath) { - this(anEnclosingComponent, aReferencedComponent, aRuntimePath, DEPENDENCY_TYPE_USES); - } - - public VirtualReference(IVirtualComponent anEnclosingComponent, IVirtualComponent aReferencedComponent, IPath aRuntimePath, int aDependencyType) { - enclosingComponent = anEnclosingComponent; - referencedComponent = aReferencedComponent; - runtimePath = aRuntimePath; - dependencyType = aDependencyType; - } - - public void create(int updateFlags, IProgressMonitor aMonitor) { - StructureEdit core = null; - try { - core = StructureEdit.getStructureEditForWrite(enclosingComponent.getProject()); - WorkbenchComponent component = core.getComponent(); - List referencedComponents = component.getReferencedComponents(); - ReferencedComponent refComp = ComponentcorePackage.eINSTANCE.getComponentcoreFactory().createReferencedComponent(); - if( !referencedComponent.isBinary()) - refComp.setHandle(ModuleURIUtil.fullyQualifyURI(referencedComponent.getProject())); - else - refComp.setHandle(ModuleURIUtil.archiveComponentfullyQualifyURI(referencedComponent.getName())); - refComp.setRuntimePath(runtimePath); - refComp.setDependencyType(DependencyType.get(dependencyType)); - refComp.setArchiveName(archiveName); - if(!referencedComponents.contains(refComp)){ - referencedComponents.add(refComp); - } - } - finally{ - if(null != core){ - core.saveIfNecessary(aMonitor); - core.dispose(); - } - } - } - - public void setRuntimePath(IPath aRuntimePath) { - runtimePath = aRuntimePath; - } - - public IPath getRuntimePath() { - return runtimePath; - } - - public void setDependencyType(int aDependencyType) { - dependencyType = aDependencyType; - } - - public int getDependencyType() { - return dependencyType; - } - - public boolean exists() { - return false; - } - - public IVirtualComponent getEnclosingComponent() { - return enclosingComponent; - } - - public IVirtualComponent getReferencedComponent() { - return referencedComponent; - } - - /** - * This is a helper method to update the actual referenceComponent on the .component file for this virtual reference. - */ - public void setReferencedComponent(IVirtualComponent aReferencedComponent, EObject dependentObject) { - if (aReferencedComponent == null) - return; - StructureEdit enclosingCore = null; - StructureEdit refCore = null; - try { - enclosingCore = StructureEdit.getStructureEditForWrite(enclosingComponent.getProject()); - refCore = StructureEdit.getStructureEditForWrite(referencedComponent.getProject()); - WorkbenchComponent enclosingComp = enclosingCore.getComponent(); - WorkbenchComponent refComp = refCore.getComponent(); - ReferencedComponent actualReferencedComponent = enclosingCore.findReferencedComponent(enclosingComp, refComp); - if (actualReferencedComponent != null) { - referencedComponent = aReferencedComponent; - if(!referencedComponent.isBinary()) - actualReferencedComponent.setHandle(ModuleURIUtil.fullyQualifyURI(referencedComponent.getProject())); - else - actualReferencedComponent.setHandle(ModuleURIUtil.archiveComponentfullyQualifyURI(referencedComponent.getName())); - actualReferencedComponent.setDependentObject(dependentObject); - } - } finally { - if (enclosingCore != null) { - enclosingCore.saveIfNecessary(new NullProgressMonitor()); - enclosingCore.dispose(); - } - if (refCore != null) { - refCore.saveIfNecessary(new NullProgressMonitor()); - refCore.dispose(); - } - } - } - - public String getArchiveName() { - return archiveName; - } - - public void setArchiveName(String archiveName) { - this.archiveName = archiveName; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java deleted file mode 100644 index 5f637f96a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java +++ /dev/null @@ -1,344 +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.wst.common.componentcore.internal.resources; - -import java.util.ArrayList; -import java.util.Arrays; -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.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.wst.common.componentcore.ComponentCore; -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.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeNode; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeRoot; -import org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualContainer; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -public abstract class VirtualResource implements IVirtualResource { - - protected static final IResource[] NO_RESOURCES = null; - private final IProject componentProject; - private final IPath runtimePath; - private int hashCode; - private String toString; - private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - private IVirtualComponent component; - private String resourceType; - - private final ResourceTimestampMappings mapping = new ResourceTimestampMappings(); - - - protected VirtualResource(IProject aComponentProject, IPath aRuntimePath) { - componentProject = aComponentProject; - runtimePath = aRuntimePath; - } - - public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException { - - if ((updateFlags & IVirtualResource.IGNORE_UNDERLYING_RESOURCE) == 0) { - doDeleteRealResources(updateFlags, monitor); - } - - doDeleteMetaModel(updateFlags, monitor); - } - - protected void doDeleteMetaModel(int updateFlags, IProgressMonitor monitor) { - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent aComponent = moduleCore.getComponent(); - ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath()); - aComponent.getResources().removeAll(Arrays.asList(resources)); - } - finally { - if (moduleCore != null) { - moduleCore.saveIfNecessary(monitor); - moduleCore.dispose(); - } - } - } - - - protected abstract void doDeleteRealResources(int updateFlags, IProgressMonitor monitor) throws CoreException; - - public boolean exists() { - // verify all underlying resources exist for the virtual resource to - // exist - IResource[] resources = getUnderlyingResources(); - if (resources == null || resources.length == 0) - return false; - for (int i = 0; i < resources.length; i++) { - if (resources[i] == null || !resources[i].exists()) - return false; - } - return true; - } - - public String getFileExtension() { - String name = getName(); - int dot = name.lastIndexOf('.'); - if (dot == -1) - return null; - if (dot == name.length() - 1) - return EMPTY_STRING; - return name.substring(dot + 1); - } - - public IPath getWorkspaceRelativePath() { - return getProject().getFullPath().append(getProjectRelativePath()); - } - - public IPath getRuntimePath() { - return runtimePath; - } - - public IPath[] getProjectRelativePaths() { - - WorkbenchComponent aComponent = getReadOnlyComponent(); - if (aComponent != null) { - ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(aComponent); - // still need some sort of loop here to search subpieces of the - // runtime path. - ComponentResource[] componentResources = null; - - if (root != null) { - IPath[] estimatedPaths = null; - IPath searchPath = null; - do { - searchPath = (searchPath == null) ? getRuntimePath() : searchPath.removeLastSegments(1); - if (searchPath.isAbsolute()) - searchPath = searchPath.makeRelative(); - componentResources = root.findModuleResources(searchPath, ResourceTreeNode.CREATE_NONE); - estimatedPaths = findBestMatches(componentResources); - } - while (estimatedPaths.length == 0 && canSearchContinue(componentResources, searchPath)); - if (estimatedPaths == null || estimatedPaths.length == 0) - return new IPath[]{getRuntimePath()}; - return estimatedPaths; - } - } - - return new IPath[]{getRuntimePath()}; - } - - public IPath getProjectRelativePath() { - if (getRuntimePath().equals(new Path("/"))) { - WorkbenchComponent aComponent = getReadOnlyComponent(); - if (aComponent != null) { - if (((WorkbenchComponentImpl) aComponent).getDefaultSourceRoot() != null) - return ((WorkbenchComponentImpl) aComponent).getDefaultSourceRoot(); - } - } - return getProjectRelativePaths()[0]; - } - - private boolean canSearchContinue(ComponentResource[] componentResources, IPath searchPath) { - return (searchPath.segmentCount() > 0); - } - - private IPath[] findBestMatches(ComponentResource[] theComponentResources) { - List result = new ArrayList(); - int currentMatchLength = 0; - int bestMatchLength = -1; - IPath estimatedPath = null; - IPath currentPath = null; - final IPath aRuntimePath = getRuntimePath(); - for (int i = 0; i < theComponentResources.length; i++) { - currentPath = theComponentResources[i].getRuntimePath(); - if (currentPath.isPrefixOf(aRuntimePath)) { - if (currentPath.segmentCount() == aRuntimePath.segmentCount()) { - result.add(theComponentResources[i].getSourcePath()); - continue; - } - currentMatchLength = currentPath.matchingFirstSegments(aRuntimePath); - if (currentMatchLength == currentPath.segmentCount() && currentMatchLength > bestMatchLength) { - bestMatchLength = currentMatchLength; - IPath sourcePath = theComponentResources[i].getSourcePath(); - IPath subpath = aRuntimePath.removeFirstSegments(currentMatchLength); - estimatedPath = sourcePath.append(subpath); - } - } - } - if (result.size() > 0) - return (IPath[]) result.toArray(new IPath[result.size()]); - if (estimatedPath == null) - return new IPath[]{}; - return new IPath[]{estimatedPath}; - } - - public String getName() { - if (getRuntimePath().segmentCount() > 0) - return getRuntimePath().lastSegment(); - return getRuntimePath().toString(); - } - - public IVirtualComponent getComponent() { - if (component == null) - component = ComponentCore.createComponent(getProject()); - return component; - } - - // returns null if the folder is already the root folder - public IVirtualContainer getParent() { - if (getRuntimePath().segmentCount() >= 1) - return ComponentCore.createFolder(getProject(), getRuntimePath().removeLastSegments(1)); - return null; - } - - public IProject getProject() { - return componentProject; - } - - public boolean isAccessible() { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - // return false; - } - - public Object getAdapter(Class adapter) { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - // return null; - } - - public boolean contains(ISchedulingRule rule) { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - // return false; - } - - public boolean isConflicting(ISchedulingRule rule) { - throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ - // return false; - } - - public String toString() { - if (toString == null) - toString = "[" + ModuleURIUtil.getHandleString(getComponent()) + ":" + getRuntimePath() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return toString; - } - - public int hashCode() { - if (hashCode == 0) - hashCode = toString().hashCode(); - return hashCode; - } - - public boolean equals(Object anOther) { - return hashCode() == ((anOther != null && anOther instanceof VirtualResource) ? anOther.hashCode() : 0); - } - - public void setResourceType(String aResourceType) { - resourceType = aResourceType; - WorkbenchComponent aComponent = getReadOnlyComponent(); - ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath()); - for (int i = 0; i < resources.length; i++) { - resources[i].setResourceType(aResourceType); - } - - } - - // TODO Fetch the resource type from the model. - public String getResourceType() { - if (null == resourceType) { - WorkbenchComponent aComponent = getReadOnlyComponent(); - ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath()); - for (int i = 0; i < resources.length; i++) { - resourceType = resources[i].getResourceType(); - return resourceType; - } - - } - resourceType = ""; //$NON-NLS-1$ - return resourceType; - } - - - protected void createResource(IContainer resource, int updateFlags, IProgressMonitor monitor) throws CoreException { - - if (resource.exists()) - return; - if (!resource.getParent().exists()) - createResource(resource.getParent(), updateFlags, monitor); - if (!resource.exists() && resource.getType() == IResource.FOLDER) { - ((IFolder) resource).create(updateFlags, true, monitor); - } - } - - protected boolean isPotentalMatch(IPath aRuntimePath) { - return aRuntimePath.isPrefixOf(getRuntimePath()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.componentcore.resources.IVirtualResource#removeLink(org.eclipse.core.runtime.IPath, - * int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void removeLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException { - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForWrite(getProject()); - WorkbenchComponent component = moduleCore.getComponent(); - if (component != null) { - ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component); - ComponentResource[] resources = root.findModuleResources(getRuntimePath(), ResourceTreeNode.CREATE_NONE); - if (resources.length > 0) { - for (int resourceIndx = 0; resourceIndx < resources.length; resourceIndx++) { - if (aProjectRelativeLocation.makeAbsolute().equals(resources[resourceIndx].getSourcePath())) { - component.getResources().remove(resources[resourceIndx]); - } - } - } - } - } - finally { - if (moduleCore != null) { - if (component != null) - moduleCore.saveIfNecessary(monitor); - moduleCore.dispose(); - } - } - } - - protected final WorkbenchComponent getReadOnlyComponent() { - if (!mapping.hasChanged(getProject()) && mapping.hasCacheData(getProject())) - return (WorkbenchComponent) mapping.getData(getProject()); - - StructureEdit moduleCore = null; - WorkbenchComponent component = null; - try { - moduleCore = StructureEdit.getStructureEditForRead(getProject()); - if (moduleCore != null) { - component = moduleCore.getComponent(); - mapping.mark(getProject(), component); - } - } - finally { - if (moduleCore != null) { - moduleCore.dispose(); - } - } - return component; - - - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ArtifactEditAdapterFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ArtifactEditAdapterFactory.java deleted file mode 100644 index 14d94f8ad..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ArtifactEditAdapterFactory.java +++ /dev/null @@ -1,98 +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.wst.common.componentcore.internal.util; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.emf.common.util.URI; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.impl.ArtifactEditModelFactory; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.internal.emfworkbench.edit.EditModelRegistry; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; - -/** - * <p> - * The following class is not intended to be used by clients. - * </p> - * <p> - * Adapts {@see ArtifactEditModel} to an {@see ArtifactEdit) - * instance facade, if possible. The following class is - * registered with the Platform Adapter Manager in - * {@see org.eclipse.wst.common.componentcore.internal.ModulecorePlugin#start(BundleContext)} - * </p> - * @see org.eclipse.wst.common.componentcore.internal.ModulecorePlugin - */ -public class ArtifactEditAdapterFactory implements IAdapterFactory { - - private static final Class ARTIFACT_EDIT_MODEL_CLASS = ArtifactEditModel.class; - private static final Class ARTIFACT_EDIT_CLASS = ArtifactEdit.class; - - /** - * <p> - * Returns an instance facade for the given anAdaptableObject, if possible. - * </p> - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object anAdaptableObject, Class anAdapterType) { - if (anAdapterType == ArtifactEditModel.ADAPTER_TYPE) { - if (anAdaptableObject instanceof ArtifactEdit) { - ArtifactEdit edit = (ArtifactEdit)anAdaptableObject; - IProject aProject = edit.getProject(); - URI componentURI = ModuleURIUtil.fullyQualifyURI(aProject); - ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(edit.getComponent().getProject()); - Map params = new HashMap(); - params.put(ArtifactEditModelFactory.PARAM_MODULE_URI, componentURI); - try { - String[] editModelIDs = EditModelRegistry.getInstance().getRegisteredEditModelIDs(); - for (int i=0; i<editModelIDs.length; i++) { - try { - EditModel editModel = nature.getExistingEditModel(editModelIDs[i],params,edit.isReadOnly()); - if (editModel !=null) - return editModel; - } catch (Exception e) { - continue; - } - } - - } catch (Exception e){ - //Return null - } - return null; - } - } - if (anAdapterType == ArtifactEdit.ADAPTER_TYPE) { - if (anAdaptableObject instanceof ArtifactEditModel) - return new ArtifactEdit((ArtifactEditModel) anAdaptableObject); - if (anAdaptableObject instanceof IVirtualComponent) { - ArtifactEditRegistryReader reader = ArtifactEditRegistryReader.instance(); - IArtifactEditFactory factory = reader.getArtifactEdit(((IVirtualComponent)anAdaptableObject).getProject()); - if (factory != null) - return factory.createArtifactEditForRead((IVirtualComponent)anAdaptableObject); - } - } - return null; - } - - /** - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return new Class[]{ARTIFACT_EDIT_MODEL_CLASS,ARTIFACT_EDIT_CLASS}; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ArtifactEditRegistryReader.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ArtifactEditRegistryReader.java deleted file mode 100644 index 1eb05c31d..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ArtifactEditRegistryReader.java +++ /dev/null @@ -1,184 +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 Mar 29, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.wst.common.componentcore.internal.util; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.jem.util.RegistryReader; -import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class ArtifactEditRegistryReader extends RegistryReader { - - static final String ARTIFACT_EDIT_EXTENSION_POINT = "artifactedit"; //$NON-NLS-1$ - static final String ARTIFACTEDIT = "artifactedit"; //$NON-NLS-1$ - static final String TYPE = "typeID"; //$NON-NLS-1$ - static final String ARTIFACTEDITCLASS = "class"; //$NON-NLS-1$ - - private static final ArtifactEditRegistryReader instance = new ArtifactEditRegistryReader(); - - private final Map/*<String, ArtifactEditDescriptor>*/ descriptors = new HashMap(); - - private final Map/*<ArtifactEditDescriptor, IArtifactEditFactory>*/ instances = new HashMap(); - - /** - * @return Returns the instance. - */ - public static ArtifactEditRegistryReader instance() { - /* already initialized and registry read by the time the class initializes */ - return instance; - } - - public ArtifactEditRegistryReader() { - super(ModulecorePlugin.PLUGIN_ID, ARTIFACT_EDIT_EXTENSION_POINT); - SafeRunner.run(new ISafeRunnable() { - - public void handleException(Throwable exception) { - ModulecorePlugin.logError(0, exception.getMessage(), exception); - } - - public void run() throws Exception { - readRegistry(); - } - - }); - } - - /** - * @see org.eclipse.wst.common.frameworks.internal.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement) - */ - public boolean readElement(IConfigurationElement element) { - if (ARTIFACTEDIT.equals(element.getName())) { - - /* Because the only instance of this type is created from a static singleton - * field, and the registry is initialized in the constructor of this type, - * other threads cannot compete with readElement() for access to <i>descriptors</i> - */ - String type = element.getAttribute(TYPE); - if(type != null) - descriptors.put(element.getAttribute(TYPE), new ArtifactEditDescriptor(element)); - else - ModulecorePlugin.logError(0, "No type attribute is specified for " + //$NON-NLS-1$ - ModulecorePlugin.PLUGIN_ID + "." + ARTIFACT_EDIT_EXTENSION_POINT + //$NON-NLS-1$ - " extension in " + element.getDeclaringExtension().getNamespaceIdentifier(), null); //$NON-NLS-1$ - return true; - } - return false; - } - - public synchronized IArtifactEditFactory getArtifactEdit(String typeID) { - - ArtifactEditDescriptor descriptor = (ArtifactEditDescriptor) descriptors.get(typeID); - IArtifactEditFactory factory = null; - - if(descriptor != null) { - - factory = (IArtifactEditFactory) instances.get(descriptor); - - if(factory == null) { - - if((factory = descriptor.createFactory()) != null) { - instances.put(descriptor, factory); - } else { - descriptors.remove(descriptor); - } - } - } - return factory; - } - - // TODO Don't like this because it's going to cycle every project facet for each project - public IArtifactEditFactory getArtifactEdit(IProject project) { - try { - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - Iterator keys = descriptors.keySet().iterator(); - while (keys.hasNext()) { - String typeID = (String) keys.next(); - try { - IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(typeID); - if (projectFacet != null && facetedProject.hasProjectFacet(projectFacet)) - return getArtifactEdit(typeID); - } catch (Exception e) { - continue; - } - } - } catch (Exception e) { - //Just return null - } - return null; - } - - public class ArtifactEditDescriptor { - - private final IConfigurationElement element; - private final String type; - - public ArtifactEditDescriptor(IConfigurationElement configElement) { - element = configElement; - type = element.getAttribute(TYPE); - } - - /** - * Create and return an {@link IArtifactEditFactory} for the given descriptor or - * <b>null</b> if there are problems instantiating the extension. - * @return An {@link IArtifactEditFactory} for the given descriptor or - * <b>null</b> if there are problems instantiating the extension. - */ - public IArtifactEditFactory createFactory() { - - final IArtifactEditFactory[] factory = new IArtifactEditFactory[1]; - - SafeRunner.run(new ISafeRunnable() { - - public void handleException(Throwable exception) { - ModulecorePlugin.logError(0, exception.getMessage(), exception); - } - - public void run() throws Exception { - factory[0] = (IArtifactEditFactory) element.createExecutableExtension(ARTIFACTEDITCLASS); - } - - }); - - return factory[0]; - } - - /** - * - * @return The type id of this ArtifactEdit definition - */ - public String getType() { - return type; - } - - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentImplManager.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentImplManager.java deleted file mode 100644 index 60a9febf9..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentImplManager.java +++ /dev/null @@ -1,277 +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.wst.common.componentcore.internal.util; - -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.jem.util.RegistryReader; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; -import org.eclipse.wst.common.componentcore.internal.resources.ResourceTimestampMappings; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class ComponentImplManager { - - private static final String NO_FACETS = "NONE";//$NON-NLS-1$ - - private static final String COMPONENT_IMPL_EXTENSION_POINT = "componentimpl"; //$NON-NLS-1$ - private static final String TAG_COMPONENT_IMPL = "componentimpl"; //$NON-NLS-1$ - private static final String ATT_TYPE = "typeID"; //$NON-NLS-1$ - private static final String ATT_CLASS = "class"; //$NON-NLS-1$ - - private static final ComponentImplManager instance = new ComponentImplManager(); -// private static final Object LOAD_FAILED = new Object(); - - private final Map/* <String, ComponentImplDescriptor> */ descriptors = new Hashtable(); - - private final Map/* <ComponentImplDescriptor, IComponentImplFactory> */ instances = new Hashtable(); - private final ResourceTimestampMappings factoryMap = new ResourceTimestampMappings(); - - /** - * @return Returns the instance. - */ - public static ComponentImplManager instance() { - /* already initialized and registry read by the time the class initializes */ - return instance; - } - - public ComponentImplManager() { - SafeRunner.run(new ISafeRunnable() { - - public void handleException(Throwable exception) { - ModulecorePlugin.logError(0, exception.getMessage(), exception); - } - - public void run() throws Exception { - new ComponentImplRegistryReader().readRegistry(); - } - - }); - } - - - private IComponentImplFactory getComponentImplFactory(String typeID) { - - ComponentImplDescriptor descriptor = (ComponentImplDescriptor) descriptors.get(typeID); - IComponentImplFactory factory = null; - - if (descriptor != null) { - - factory = (IComponentImplFactory) instances.get(descriptor); - - if (factory == null) { - - if ((factory = descriptor.createFactory()) != null) { - instances.put(descriptor, factory); - } else { - descriptors.remove(descriptor); - } - } - } - return factory; - } - - private IComponentImplFactory findFactoryForProject(IProject project){ - try { - IComponentImplFactory factory = null; - - if( !factoryMap.hasChanged(project) ) { - - if( factoryMap.hasCacheError(project)) - return null; - - if( factoryMap.hasCacheData(project)) - return (IComponentImplFactory) factoryMap.getData(project); - } - - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - if (facetedProject == null){ - factory = getComponentImplFactory(NO_FACETS); - factoryMap.mark(project, factory); - return factory; - } - Iterator keys = descriptors.keySet().iterator(); - while (keys.hasNext()) { - String typeID = (String) keys.next(); - if(typeID.equals(NO_FACETS)){ - continue; - } - try { - IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(typeID); - if (projectFacet != null && facetedProject.hasProjectFacet(projectFacet)){ - factory = getComponentImplFactory(typeID); - if(null != factory){ - factoryMap.mark(project, factory); - return factory; - } - } - } catch (Exception e) { - continue; - } - } - - } catch (Exception e) { - ModulecorePlugin.logError(0, "Returning null factory for project: " + project, e); //$NON-NLS-1$ - factoryMap.markError(project); - } - return null; - } - - - - public IVirtualFolder createFolder(IProject aProject, IPath aRuntimePath){ - try { - IComponentImplFactory factory = findFactoryForProject(aProject); - if(null != factory){ - return factory.createFolder(aProject, aRuntimePath); - } - } catch (Exception e) { - // Just return a default folder - } - return new VirtualFolder(aProject, aRuntimePath); - } - - public IVirtualComponent createComponent(IProject project) { - try { - IComponentImplFactory factory = findFactoryForProject(project); - if(null != factory){ - return factory.createComponent(project); - } - } catch (Exception e) { - // Just return a default component - } - if (!ModuleCoreNature.isFlexibleProject(project)){ - return null; - } - return new VirtualComponent(project, new Path("/")); //$NON-NLS-1$ - } - - public IVirtualComponent createComponent(IProject project, boolean checkSettings) { - if (checkSettings) - return createComponent(project); - try { - IComponentImplFactory factory = findFactoryForProject(project); - if(null != factory){ - return factory.createComponent(project); - } - } catch (Exception e) { - // Just return a default component - } - if (ModuleCoreNature.getModuleCoreNature(project) == null){ - return null; - } - return new VirtualComponent(project, new Path("/")); //$NON-NLS-1$ - } - - public IVirtualComponent createArchiveComponent(IProject aProject, String aComponentName) { - try { - IComponentImplFactory factory = findFactoryForProject(aProject); - if(null != factory){ - return factory.createArchiveComponent(aProject, aComponentName, new Path("/")); //$NON-NLS-1$ - } - } catch (Exception e) { - // Just return a default archive component - } - return new VirtualArchiveComponent(aProject, aComponentName, new Path("/")); //$NON-NLS-1$ - } - - private class ComponentImplDescriptor { - - private final IConfigurationElement element; - private final String type; - - public ComponentImplDescriptor(IConfigurationElement configElement) { - element = configElement; - type = element.getAttribute(ATT_TYPE); - } - - /** - * Create and return an {@link IArtifactEditFactory} for the given descriptor or <b>null</b> - * if there are problems instantiating the extension. - * - * @return An {@link IArtifactEditFactory} for the given descriptor or <b>null</b> if there - * are problems instantiating the extension. - */ - public IComponentImplFactory createFactory() { - - final IComponentImplFactory[] factory = new IComponentImplFactory[1]; - - SafeRunner.run(new ISafeRunnable() { - - public void handleException(Throwable exception) { - ModulecorePlugin.logError(0, exception.getMessage(), exception); - } - - public void run() throws Exception { - factory[0] = (IComponentImplFactory) element.createExecutableExtension(ATT_CLASS); - } - - }); - - return factory[0]; - } - - /** - * - * @return The type id of this ArtifactEdit definition - */ - public String getType() { - return type; - } - - } - - private class ComponentImplRegistryReader extends RegistryReader { - - public ComponentImplRegistryReader() { - super(ModulecorePlugin.PLUGIN_ID, COMPONENT_IMPL_EXTENSION_POINT); - } - - /** - * @see org.eclipse.wst.common.frameworks.internal.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement) - */ - public boolean readElement(IConfigurationElement element) { - if (TAG_COMPONENT_IMPL.equals(element.getName())) { - - /* - * Because the only instance of this type is created from a static singleton field, and - * the registry is initialized in the constructor of this type, other threads cannot - * compete with readElement() for access to <i>descriptors</i> - */ - String type = element.getAttribute(ATT_TYPE); - if (type != null) - descriptors.put(element.getAttribute(ATT_TYPE), new ComponentImplDescriptor(element)); - else - ModulecorePlugin.logError(0, "No type attribute is specified for " + //$NON-NLS-1$ - ModulecorePlugin.PLUGIN_ID + "." + COMPONENT_IMPL_EXTENSION_POINT + //$NON-NLS-1$ - " extension in " + element.getDeclaringExtension().getNamespaceIdentifier(), null); //$NON-NLS-1$ - return true; - } - return false; - } - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentResolver.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentResolver.java deleted file mode 100644 index 94f833442..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentResolver.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.wst.common.componentcore.internal.util; - -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; -import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverExtension; -import org.osgi.framework.Bundle; - -public class ComponentResolver implements URIResolverExtension { - private static boolean _DEBUG = "true".equals(Platform.getDebugOption("org.eclipse.wst.common.modulecore/ComponentResolver")); //$NON-NLS-1$ //$NON-NLS-2$ - private static final String FILE_PROTOCOL = "file:///"; //$NON-NLS-1$ - private static final String FILE_PROTOCOL2 = "file://"; //$NON-NLS-1$ - private static final String ROOT_PATH_STRING = Path.ROOT.toString(); //$NON-NLS-1$ - private static final String HTTP_PROTOCOL = "http:"; //$NON-NLS-1$ - - /** - * Various resolvers disagree on how many preceding slashes should - * actually be used. On Win32, 2 slashes results in a URL object where the - * volume is stripped out of the file path as the host name, but on Unix 2 - * is the correct number. On Win32, java.io.File.toURL adds only 1 slash, - * and on Unix it adds 2. - * - * @param uri - * @return The IFile for this file location - */ - private IFile recalculateFile(String uri) { - IFile file = null; - String location = null; - - long time0 = -1; - if (_DEBUG) - time0 = System.currentTimeMillis(); - if (uri.startsWith(HTTP_PROTOCOL)) { - IFile files[] = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(URI.create(uri)); - for (int i = 0; i < files.length && file == null; i++) { - if (files[i].isAccessible()) { - file = files[i]; - } - } - if (_DEBUG) { - System.out.println("\"" + uri + "\" findFilesForLocationURI:" + (System.currentTimeMillis() - time0)); - time0 = System.currentTimeMillis(); - } - } - else { - if (uri.startsWith(FILE_PROTOCOL)) { - location = uri.substring(FILE_PROTOCOL.length()); - } - else if (uri.startsWith(FILE_PROTOCOL2)) { - location = uri.substring(FILE_PROTOCOL2.length()); - } - else { - location = uri; - } - IPath path = new Path(location); - IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(path); - for (int i = 0; i < files.length && file == null; i++) { - if (files[i].isAccessible()) { - file = files[i]; - } - } - } - if (_DEBUG) - System.out.println("\"" + location + "\" findFilesForLocation:" + (System.currentTimeMillis() - time0)); - return file; - } - - public String resolve(IFile file, String baseLocation, String publicId, String systemId) { - if (_DEBUG) { - System.out.print("ComponentResolver: resolve \"[{" + publicId + "}{" + systemId + "}]\" from \"" + baseLocation + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - // argument sanity checks - /* - * Check for a system reference; without one, there's no point in - * continuing (we can't resolve just a public identifier). - */ - if (systemId == null || systemId.length() == 0) { - if (_DEBUG) { - System.out.println(" (no system reference)"); //$NON-NLS-1$ - } - return null; - } - - /* Recompute the IFile, if needed, from the base location. */ - if (file == null) { - if (baseLocation == null || baseLocation.length() == 0) { - /* - * We can't proceed if we lack both an IFile and a system - * reference - */ - if (_DEBUG) { - System.out.println(" (no base location or file given)"); //$NON-NLS-1$ - } - return null; - } - file = recalculateFile(baseLocation); - } - - /* - * If a workspace IFile is (still) not the base point of reference, - * don't continue. - */ - if (file == null) { - if (_DEBUG) { - System.out.println(" (not a workspace file)"); //$NON-NLS-1$ - } - return null; - } - - /* Check for an absolute URL as the system reference. */ - try { - URL testURL = new URL(systemId); - if (testURL != null) { - if (_DEBUG) { - System.out.println(" (reference is already a URL)"); //$NON-NLS-1$ - } - return null; - } - } - catch (MalformedURLException e) { - // Continue resolving - } - - /* Check for a URI without a scheme, but with a host */ - try - { - URI uri = new URI(systemId); - if ((uri.getScheme() == null) && (uri.getHost() != null)) - { - return null; - } - } - catch (URISyntaxException use) - { - // do nothing- we need to check to see if this is a local file - } - - /* Check for a system file name as the system reference. */ - IPath systemPath = new Path(systemId); - if (systemPath.toFile().exists()) { - if (_DEBUG) { - System.out.println(" (reference is a system file)"); //$NON-NLS-1$ - } - return null; - } - - boolean prependFilePrefix = baseLocation.startsWith(FILE_PROTOCOL) && baseLocation.length() > 7; - boolean prependFilePrefix2 = baseLocation.startsWith(FILE_PROTOCOL2) && baseLocation.length() > 8; - - String resolvedPath = null; - - IVirtualResource[] virtualResources = null; - try { - virtualResources = ComponentCore.createResources(file); - } - catch (Exception e) { - Status statusObj = new Status(IStatus.ERROR, ModulecorePlugin.PLUGIN_ID, IStatus.ERROR, "Exception calling ComponentCore.createResources()", e); - Bundle bundle = Platform.getBundle(ModulecorePlugin.PLUGIN_ID); - if (bundle != null) { - Platform.getLog(bundle).log(statusObj); - } - } - - // Only return results for Flexible projects - if (virtualResources != null) { - for (int i = 0; i < virtualResources.length && resolvedPath == null; i++) { - IPath resolvedRuntimePath = null; - if (systemId.startsWith(ROOT_PATH_STRING)) { - resolvedRuntimePath = new Path(systemId); - } - else { - resolvedRuntimePath = new Path(virtualResources[i].getRuntimePath().removeLastSegments(1).append(systemId).toString()); - } - IVirtualFile virtualFile = ComponentCore.createFile(file.getProject(), resolvedRuntimePath); - IFile resolvedFile = null; - if (virtualFile.getWorkspaceRelativePath().segmentCount() > 1) { - resolvedFile = virtualFile.getUnderlyingFile(); - } - if (resolvedFile != null && resolvedFile.getLocation() != null) { - if (prependFilePrefix) { - resolvedPath = FILE_PROTOCOL + resolvedFile.getLocation().toString(); - } - else if (prependFilePrefix2) { - resolvedPath = FILE_PROTOCOL2 + resolvedFile.getLocation().toString(); - } - else { - resolvedPath = resolvedFile.getLocation().toString(); - } - } - } - } - else { - if (_DEBUG) { - System.out.println(" (not in flexible project)"); //$NON-NLS-1$ - } - } - if (_DEBUG) { - System.out.println(" -> \"" + resolvedPath + "\""); //$NON-NLS-1$ //$NON-NLS-2$ - } - return resolvedPath; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentUtilities.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentUtilities.java deleted file mode 100644 index 0ddeaf96b..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentUtilities.java +++ /dev/null @@ -1,362 +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.wst.common.componentcore.internal.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IServerContextRootDataModelProperties; -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.internal.operation.CreateReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsOp; -import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentOperation; -import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.resources.ResourceTimestampMappings; -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; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - -public class ComponentUtilities { - - private static final ResourceTimestampMappings ContextRootMapping = new ResourceTimestampMappings(); - - /** - * Ensure the container is not read-only. - * <p> - * For Linux, a Resource cannot be created in a ReadOnly folder. This is only necessary for new - * files. - * - * @param resource - * workspace resource to make read/write - * @plannedfor 1.0.0 - */ - public static void ensureContainerNotReadOnly(IResource resource) { - if (resource != null && !resource.exists()) { // it must be new - IContainer container = resource.getParent(); - if (container != null) { - ResourceAttributes attr = container.getResourceAttributes(); - if (!attr.isReadOnly()) - container = container.getParent(); - attr.setReadOnly(false); - } - } - } - - public static IFolder createFolderInComponent(IVirtualComponent component, String folderName) throws CoreException { - if (folderName != null) { - IVirtualFolder rootfolder = component.getRootFolder(); - IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(rootfolder.getProject().getName()).append(folderName)); - if (!folder.exists()) { - ProjectUtilities.ensureContainerNotReadOnly(folder); - folder.create(true, true, null); - } - return folder; - } - return null; - } - - - - public static ArtifactEdit getArtifactEditForRead(IVirtualComponent comp) { - if (comp != null) { - ArtifactEditRegistryReader reader = ArtifactEditRegistryReader.instance(); - IArtifactEditFactory factory = reader.getArtifactEdit(comp.getProject()); - if (factory != null) - return factory.createArtifactEditForRead(comp); - } - return null; - } - - public static ArtifactEdit getArtifactEditForRead(IVirtualComponent comp, String type) { - if (comp != null) { - ArtifactEditRegistryReader reader = ArtifactEditRegistryReader.instance(); - IArtifactEditFactory factory = reader.getArtifactEdit(type); - if (factory != null) - return factory.createArtifactEditForRead(comp); - } - return null; - } - - - public static IFile findFile(IVirtualComponent comp, IPath aPath) throws CoreException { - if (comp == null || aPath == null) - return null; - IVirtualFolder root = comp.getRootFolder(); - IVirtualResource file = root.findMember(aPath); - if (file != null && file.getType() == IVirtualResource.FILE){ - IResource resource = file.getUnderlyingResource(); - if(resource.getType() == IResource.FILE){ - return (IFile) resource; - } - } - return null; - } - - public static IVirtualComponent findComponent(IResource res) { - - return (IVirtualComponent)res.getAdapter(IVirtualComponent.class); - } - - /** - * **********************Please read java doc before using this api******************* - * This is a very expensive api from a performance point as it does a structure edit - * access and release for each component in the workspace. Use this api very sparingly - * and if used cached the information returned by this api for further processing - * @return - A an array of all virtual components in the workspace - * *********************************************************************************** - */ - - public static IVirtualComponent[] getAllWorkbenchComponents() { - List components = new ArrayList(); - List projects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()); - for (int i = 0; i < projects.size(); i++) { - if( ModuleCoreNature.isFlexibleProject((IProject)projects.get(i))){ - IVirtualComponent wbComp = ComponentCore.createComponent((IProject)projects.get(i)); - components.add(wbComp); - } - } - IVirtualComponent[] temp = (IVirtualComponent[]) components.toArray(new IVirtualComponent[components.size()]); - return temp; - } - - /** - * **********************Please read java doc before using this api******************* - * This is a very expensive api from a performance point as it does a structure edit - * access and release for each component in the workspace. Use this api very sparingly - * and if used cached the information returned by this api for further processing. - * - * @return - A virtual component in the workspace - * *********************************************************************************** - */ - public static IVirtualComponent getComponent(String componentName) { - IVirtualComponent[] allComponents = getAllWorkbenchComponents(); - for (int i = 0; i < allComponents.length; i++) { - if (allComponents[i].getName().equals(componentName)) - return allComponents[i]; - } - return null; - } - - - - public static ArtifactEdit getArtifactEditForWrite(IVirtualComponent comp) { - if (comp != null) { - ArtifactEditRegistryReader reader = ArtifactEditRegistryReader.instance(); - IArtifactEditFactory factory = reader.getArtifactEdit(comp.getProject()); - if (factory != null) - return factory.createArtifactEditForWrite(comp); - } - return null; - } - - public static IVirtualComponent findComponent(EObject anObject) { - Resource res = anObject.eResource(); - return findComponent(res); - } - - public static IVirtualComponent findComponent(Resource aResource) { - IFile file = WorkbenchResourceHelper.getFile(aResource); - if (file == null) - return null; - return (IVirtualComponent)file.getAdapter(IVirtualComponent.class); - } - -// public static JavaProjectMigrationOperation createFlexJavaProjectForProjectOperation(IProject project) { -// IDataModel model = DataModelFactory.createDataModel(new JavaProjectMigrationDataModelProvider()); -// model.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME, project.getName()); -// return new JavaProjectMigrationOperation(model); -// } - - public static CreateReferenceComponentsOp createReferenceComponentOperation(IVirtualComponent sourceComponent, List targetComponentProjects) { - IDataModel model = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, sourceComponent); - List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.addAll(targetComponentProjects); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - - return new CreateReferenceComponentsOp(model); - } - - public static CreateReferenceComponentsOp createWLPReferenceComponentOperation(IVirtualComponent sourceComponent, List targetComponentProjects) { - IDataModel model = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, sourceComponent); - List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.addAll(targetComponentProjects); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,"/WEB-INF/lib"); //$NON-NLS-1$ - if(modHandlesList != null){ - Map map = new HashMap(); - for(int i=0; i<modHandlesList.size();i++){ - IVirtualComponent comp = (IVirtualComponent)modHandlesList.get(i); - String uri = comp.getName().replace(' ', '_') + ".jar"; - map.put(comp, uri); - } - if(map.size() > 0){ - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, map); - } - } - - return new CreateReferenceComponentsOp(model); - } - - public static RemoveReferenceComponentOperation removeWLPReferenceComponentOperation(IVirtualComponent sourceComponent, List targetComponentProjects) { - IDataModel model = DataModelFactory.createDataModel(new RemoveReferenceComponentsDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, sourceComponent); - List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.addAll(targetComponentProjects); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,"/WEB-INF/lib"); //$NON-NLS-1$ - - return new RemoveReferenceComponentOperation(model); - - } - - public static RemoveReferenceComponentOperation removeReferenceComponentOperation(IVirtualComponent sourceComponent, List targetComponentProjects) { - IDataModel model = DataModelFactory.createDataModel(new RemoveReferenceComponentsDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, sourceComponent); - List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.addAll(targetComponentProjects); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - return new RemoveReferenceComponentOperation(model); - - } - - public static IVirtualComponent[] getComponents(IProject[] projects) { - List result = new ArrayList(); - if (projects!=null) { - for (int i=0; i<projects.length; i++) { - if (projects[i] != null) { - IVirtualComponent comp = ComponentCore.createComponent(projects[i]); - if (comp != null && comp.exists()) - result.add(comp); - } - } - } - return (IVirtualComponent[]) result.toArray(new IVirtualComponent[result.size()]); - } - - /** - * This method will retrieve the context root for the associated workbench module which is used - * by the server at runtime. This method is not yet completed as the context root has to be - * abstracted and added to the workbenchModule model. This API will not change though. - * Returns null for now. - * - * @return String value of the context root for runtime of the associated module - */ - public static String getServerContextRoot(IProject project) { - - if(!ContextRootMapping.hasChanged(project)) { - /*Simply return the cached data*/ - String data = null; - if(!ContextRootMapping.hasCacheError(project) && ContextRootMapping.hasCacheData(project)) - data = (String) ContextRootMapping.getData(project); - return data; - } - - StructureEdit moduleCore = null; - WorkbenchComponent wbComponent = null; - try { - moduleCore = StructureEdit.getStructureEditForRead(project); - if (moduleCore == null || moduleCore.getComponent() == null) { - ContextRootMapping.markError(project); - return null; - } - wbComponent = moduleCore.getComponent(); - } finally { - if (moduleCore != null) { - moduleCore.dispose(); - } - } - List existingProps = wbComponent.getProperties(); - for (int i = 0; i < existingProps.size(); i++) { - Property prop = (Property) existingProps.get(i); - if(prop.getName().equals(IModuleConstants.CONTEXTROOT)){ - ContextRootMapping.mark(project, prop.getValue()); - return prop.getValue(); - } - } - ContextRootMapping.markError(project); - // If all else fails... - return null; - } - - /** - * This method will set the context root on the associated workbench module with the given string - * value passed in. This context root is used by the server at runtime. This method is not yet - * completed as the context root still needs to be abstracted and added to the workbench module - * model. This API will not change though. - * Does nothing as of now. - * - * @param contextRoot string - */ - public static void setServerContextRoot(IProject project, String newContextRoot) { - - IDataModel model = DataModelFactory.createDataModel(IServerContextRootDataModelProperties.class); - model.setProperty(IServerContextRootDataModelProperties.PROJECT, project); - model.setStringProperty(IServerContextRootDataModelProperties.CONTEXT_ROOT, - newContextRoot); - - try { - model.getDefaultOperation().execute(new NullProgressMonitor(), null); - } - catch (ExecutionException e) { - org.eclipse.wst.common.componentcore.internal.ModulecorePlugin.logError(e); - } - } - - /** - * @deprecated use {@link #getDeployUriOfComponent(IVirtualReference, String)} - * @param reference - * @return - */ - public static String getDeployUriOfUtilComponent(IVirtualReference reference){ - return ComponentUtilities.getDeployUriOfComponent(reference, ".jar"); //$NON-NLS-1$ - } - - public static String getDeployUriOfComponent(IVirtualReference reference, String extension) { - String archiveName = reference.getArchiveName(); - String uri = null; - if( archiveName != null && !archiveName.equals("") ){ //$NON-NLS-1$ - uri = reference.getRuntimePath() + "/" + reference.getArchiveName(); //$NON-NLS-1$ - }else{ - uri = reference.getRuntimePath() + "/" + reference.getReferencedComponent().getProject().getName() + extension; //$NON-NLS-1$ - } - return uri; - }} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentcoreAdapterFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentcoreAdapterFactory.java deleted file mode 100644 index 371629875..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentcoreAdapterFactory.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentcoreAdapterFactory.java,v 1.6 2005/10/18 22:27:18 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <!-- begin-user-doc --> - * The <b>Adapter Factory</b> for the model. - * It provides an adapter <code>createXXX</code> method for each class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.ComponentcorePackage - * @generated - */ -public class ComponentcoreAdapterFactory extends AdapterFactoryImpl { - /** - * The cached model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static ComponentcorePackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentcoreAdapterFactory() { - if (modelPackage == null) { - modelPackage = ComponentcorePackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> - * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. - * <!-- end-user-doc --> - * @return whether this factory is applicable for the type of the object. - * @generated - */ - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch the delegates to the <code>createXXX</code> methods. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ComponentcoreSwitch modelSwitch = - new ComponentcoreSwitch() { - public Object caseWorkbenchComponent(WorkbenchComponent object) { - return createWorkbenchComponentAdapter(); - } - public Object caseComponentResource(ComponentResource object) { - return createComponentResourceAdapter(); - } - public Object caseComponentType(ComponentType object) { - return createComponentTypeAdapter(); - } - public Object caseProperty(Property object) { - return createPropertyAdapter(); - } - public Object caseReferencedComponent(ReferencedComponent object) { - return createReferencedComponentAdapter(); - } - public Object caseProjectComponents(ProjectComponents object) { - return createProjectComponentsAdapter(); - } - public Object defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the <code>target</code>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param target the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ - public Adapter createAdapter(Notifier target) { - return (Adapter)modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.wst.common.componentcore.internal.WorkbenchComponent <em>Workbench Component</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.wst.common.componentcore.internal.WorkbenchComponent - * @generated - */ - public Adapter createWorkbenchComponentAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.wst.common.componentcore.internal.ComponentResource <em>Component Resource</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.wst.common.componentcore.internal.ComponentResource - * @generated - */ - public Adapter createComponentResourceAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.wst.common.componentcore.internal.ComponentType <em>Component Type</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.wst.common.componentcore.internal.ComponentType - * @generated - */ - public Adapter createComponentTypeAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.wst.common.componentcore.internal.Property <em>Property</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.wst.common.componentcore.internal.Property - * @generated - */ - public Adapter createPropertyAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.wst.common.componentcore.internal.ReferencedComponent <em>Referenced Component</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.wst.common.componentcore.internal.ReferencedComponent - * @generated - */ - public Adapter createReferencedComponentAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.wst.common.componentcore.internal.ProjectComponents <em>Project Components</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.wst.common.componentcore.internal.ProjectComponents - * @generated - */ - public Adapter createProjectComponentsAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * <!-- begin-user-doc --> - * This default implementation returns null. - * <!-- end-user-doc --> - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //ComponentcoreAdapterFactory diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentcoreSwitch.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentcoreSwitch.java deleted file mode 100644 index f556abc70..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentcoreSwitch.java +++ /dev/null @@ -1,240 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ComponentcoreSwitch.java,v 1.6 2005/10/18 22:27:18 cbridgha Exp $ - */ -package org.eclipse.wst.common.componentcore.internal.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.ProjectComponents; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -/** - * <!-- begin-user-doc --> - * The <b>Switch</b> for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the <code>caseXXX</code> method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * <!-- end-user-doc --> - * @see org.eclipse.wst.common.componentcore.internal.ComponentcorePackage - * @generated - */ -public class ComponentcoreSwitch { - /** - * The cached model package - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static ComponentcorePackage modelPackage; - - /** - * Creates an instance of the switch. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ComponentcoreSwitch() { - if (modelPackage == null) { - modelPackage = ComponentcorePackage.eINSTANCE; - } - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - public Object doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - else { - List eSuperTypes = theEClass.getESuperTypes(); - return - eSuperTypes.isEmpty() ? - defaultCase(theEObject) : - doSwitch((EClass)eSuperTypes.get(0), theEObject); - } - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case ComponentcorePackage.WORKBENCH_COMPONENT: { - WorkbenchComponent workbenchComponent = (WorkbenchComponent)theEObject; - Object result = caseWorkbenchComponent(workbenchComponent); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ComponentcorePackage.COMPONENT_RESOURCE: { - ComponentResource componentResource = (ComponentResource)theEObject; - Object result = caseComponentResource(componentResource); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ComponentcorePackage.COMPONENT_TYPE: { - ComponentType componentType = (ComponentType)theEObject; - Object result = caseComponentType(componentType); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ComponentcorePackage.PROPERTY: { - Property property = (Property)theEObject; - Object result = caseProperty(property); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ComponentcorePackage.REFERENCED_COMPONENT: { - ReferencedComponent referencedComponent = (ReferencedComponent)theEObject; - Object result = caseReferencedComponent(referencedComponent); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ComponentcorePackage.PROJECT_COMPONENTS: { - ProjectComponents projectComponents = (ProjectComponents)theEObject; - Object result = caseProjectComponents(projectComponents); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Workbench Component</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Workbench Component</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseWorkbenchComponent(WorkbenchComponent object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Component Resource</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Component Resource</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseComponentResource(ComponentResource object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Component Type</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Component Type</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseComponentType(ComponentType object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Property</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Property</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseProperty(Property object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Referenced Component</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Referenced Component</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseReferencedComponent(ReferencedComponent object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Project Components</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Project Components</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseProjectComponents(ProjectComponents object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>EObject</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public Object defaultCase(EObject object) { - return null; - } - -} //ComponentcoreSwitch diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/DependencyTypeTranslator.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/DependencyTypeTranslator.java deleted file mode 100644 index 2a9127c5c..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/DependencyTypeTranslator.java +++ /dev/null @@ -1,49 +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 - *******************************************************************************/ -/* - * Created on Apr 2, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.componentcore.internal.util; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.DependencyType; -import org.eclipse.wst.common.internal.emf.resource.Translator; - -/** - * @author administrator - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class DependencyTypeTranslator extends Translator implements WTPModulesXmlMapperI{ - - public DependencyTypeTranslator(){ - super(DEPENDENCY_TYPE,ComponentcorePackage.eINSTANCE.getReferencedComponent_DependencyType()); - } - - /* (non-Javadoc) - * @see com.ibm.etools.emf2xml.impl.Translator#convertStringToValue(java.lang.String, org.eclipse.emf.ecore.EObject) - */ - public Object convertStringToValue(String strValue, EObject owner) { - String correct = strValue; - if (strValue.toUpperCase().equals("CONSUMES")) //$NON-NLS-1$ - correct = DependencyType.CONSUMES_LITERAL.getName(); - else if (strValue.toUpperCase().equals("USES")) //$NON-NLS-1$ - correct = DependencyType.USES_LITERAL.getName(); - - return super.convertStringToValue(correct, owner); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/DeployedPathProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/DeployedPathProvider.java deleted file mode 100644 index 69642333c..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/DeployedPathProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.componentcore.internal.util; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class DeployedPathProvider implements IPathProvider { - - public static IPathProvider INSTANCE = new DeployedPathProvider(); - - private DeployedPathProvider() {} - - /* (non-Javadoc) - * @see org.eclipse.wst.common.modulecore.util.IPathProvider#getPath(org.eclipse.wst.common.modulecore.WorkbenchComponent) - */ - public IPath getPath(ComponentResource aModuleResource) { - return aModuleResource.getRuntimePath(); - } - - public EStructuralFeature getFeature() { - return ComponentcorePackage.eINSTANCE.getComponentResource_RuntimePath(); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/EclipseResourceAdapter.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/EclipseResourceAdapter.java deleted file mode 100644 index 01095259c..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/EclipseResourceAdapter.java +++ /dev/null @@ -1,78 +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.wst.common.componentcore.internal.util; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class EclipseResourceAdapter extends AdapterImpl implements Adapter { - - public static final Class ADAPTER_TYPE = EclipseResourceAdapter.class; - private IResource resource; - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification aNotification) { - if (aNotification.getFeature() == ComponentcorePackage.eINSTANCE.getComponentResource_SourcePath()) { - if (aNotification.getEventType() == Notification.SET) { - resource = null; - - } - } - } - - public IResource getEclipseResource() { - synchronized (this) { - if (resource == null) { - - IProject container = null; - ComponentResource moduleResource = (ComponentResource) getTarget(); - if (moduleResource != null) { - IPath sourcePath = moduleResource.getSourcePath(); - if (moduleResource.getOwningProject() != null) - container = moduleResource.getOwningProject(); - else - container = StructureEdit.getContainingProject(moduleResource.getComponent()); - if (container != null) - resource = container.findMember(sourcePath); - if(resource == null) - resource = ResourcesPlugin.getWorkspace().getRoot().findMember(sourcePath); - } - } - } - return resource; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object aType) { - return ADAPTER_TYPE == aType; - } -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/HRefTranslator.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/HRefTranslator.java deleted file mode 100644 index 8fba627dd..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/HRefTranslator.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.util; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResource; -import org.eclipse.wst.common.internal.emf.resource.Translator; -import org.eclipse.wst.common.internal.emf.resource.TranslatorPath; - -public class HRefTranslator extends Translator { - - public HRefTranslator(String domNameAndPath, EClass eClass) { - super(domNameAndPath, eClass); - // TODO Auto-generated constructor stub - } - - public HRefTranslator(String domNameAndPath, EStructuralFeature aFeature) { - super(domNameAndPath, aFeature); - // TODO Auto-generated constructor stub - } - - public HRefTranslator(String domNameAndPath, EStructuralFeature aFeature, - EClass eClass) { - super(domNameAndPath, aFeature, eClass); - // TODO Auto-generated constructor stub - } - - public HRefTranslator(String domNameAndPath, EStructuralFeature aFeature, - TranslatorPath path) { - super(domNameAndPath, aFeature, path); - // TODO Auto-generated constructor stub - } - - public HRefTranslator(String domNameAndPath, EStructuralFeature aFeature, - TranslatorPath[] paths) { - super(domNameAndPath, aFeature, paths); - // TODO Auto-generated constructor stub - } - - public HRefTranslator(String domNameAndPath, EStructuralFeature aFeature, - int style) { - super(domNameAndPath, aFeature, style); - // TODO Auto-generated constructor stub - } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emf.resource.Translator#convertStringToValue(java.lang.String, - * org.eclipse.emf.ecore.EObject) - */ - public Object convertStringToValue(String aValue, EObject anOwner) { - Object retVal = null; - if (aValue != null) - { - Resource res = null; - try { - WorkbenchComponent earComp = (WorkbenchComponent)anOwner.eContainer(); - IVirtualComponent virtualComp = ComponentCore.createComponent(StructureEdit.getContainingProject(earComp)); - ArtifactEdit edit = (ArtifactEdit)virtualComp.getAdapter(ArtifactEdit.class); - if (edit != null) - { - EObject contentModelRoot = edit.getContentModelRoot(); - if( contentModelRoot != null ) - { - res = contentModelRoot.eResource(); - if (res != null && res instanceof CompatibilityXMIResource) - retVal = res.getEObject(aValue); - } - } - } finally { -// if ((res != null) && res.getResourceSet() != null) { -// res.getResourceSet().getResources().remove(res); -// res.unload(); -// } - } - } - return retVal; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emf.resource.Translator#convertValueToString(java.lang.Object, - * org.eclipse.emf.ecore.EObject) - */ - public String convertValueToString(Object aValue, EObject anOwner) { - String frag = null; - Resource theResource = ((EObject)aValue).eResource(); - if (theResource != null) - { - if (theResource instanceof CompatibilityXMIResource) - frag = theResource.getURIFragment((EObject)aValue); - else - frag = null; - } - else - frag = EcoreUtil.getID((EObject)aValue); - return frag; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IArtifactEditFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IArtifactEditFactory.java deleted file mode 100644 index cd5f471b3..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IArtifactEditFactory.java +++ /dev/null @@ -1,27 +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.wst.common.componentcore.internal.util; - -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public interface IArtifactEditFactory { - - public ArtifactEdit createArtifactEditForRead(IVirtualComponent aComponent); - - public ArtifactEdit createArtifactEditForWrite(IVirtualComponent aComponent); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IComponentImplFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IComponentImplFactory.java deleted file mode 100644 index 8673b16a2..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IComponentImplFactory.java +++ /dev/null @@ -1,26 +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.wst.common.componentcore.internal.util; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; - -public interface IComponentImplFactory { - - public IVirtualComponent createComponent(IProject aProject); - - public IVirtualFolder createFolder(IProject aProject, IPath aRuntimePath); - - public IVirtualComponent createArchiveComponent(IProject aProject, String archiveLocation, IPath aRuntimePath); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IModuleConstants.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IModuleConstants.java deleted file mode 100644 index f1c98d0c4..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IModuleConstants.java +++ /dev/null @@ -1,50 +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.wst.common.componentcore.internal.util; - -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public interface IModuleConstants { - - public static final String DOT_SETTINGS = ".settings"; //$NON-NLS-1$ - - public final static String COMPONENT_FILE_NAME = ".component"; //$NON-NLS-1$ - public final static Path COMPONENT_FILE_PATH = new Path(StructureEdit.MODULE_META_FILE_NAME); - public final static String WTPMODULE_FILE_NAME = ".wtpmodules"; //$NON-NLS-1$ - public final static Path R1_MODULE_META_FILE_PATH = new Path(".settings/.component"); //$NON-NLS-1$ - public final static Path WTPMODULE_FILE_PATH = new Path(WTPMODULE_FILE_NAME); - public final static String MODULE_PLUG_IN_ID = "org.eclipse.wst.common.modulecore"; //$NON-NLS-1$ - public final static String MODULE_NATURE_ID = "org.eclipse.wst.common.modulecore.ModuleCoreNature"; //$NON-NLS-1$ - - //moduleTypes - public final static String JST_WEB_MODULE = "jst.web"; //$NON-NLS-1$ - public final static String JST_EJB_MODULE = "jst.ejb"; //$NON-NLS-1$ - public final static String JST_UTILITY_MODULE = "jst.utility"; //$NON-NLS-1$ - public final static String WST_WEB_MODULE = "wst.web"; //$NON-NLS-1$ - public final static String JST_EAR_MODULE = "jst.ear"; //$NON-NLS-1$ - public final static String JST_APPCLIENT_MODULE = "jst.appclient"; //$NON-NLS-1$ - public final static String JST_CONNECTOR_MODULE = "jst.connector"; //$NON-NLS-1$ - public final static String JST_JAVA = "jst.java"; //$NON-NLS-1$ - - public final static String DEPENDENT_MODULE = "dependent"; //$NON-NLS-1$ - - //Property Constants - public final static String PROJ_REL_JAVA_OUTPUT_PATH = "java-output-path"; //$NON-NLS-1$ - - public final static String CONTEXTROOT = "context-root"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IPathProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IPathProvider.java deleted file mode 100644 index 389edd21f..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IPathProvider.java +++ /dev/null @@ -1,28 +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.wst.common.componentcore.internal.util; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public interface IPathProvider { - - IPath getPath(ComponentResource aModuleResource); - - EStructuralFeature getFeature(); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IPathTranslator.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IPathTranslator.java deleted file mode 100644 index 8012cb109..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/IPathTranslator.java +++ /dev/null @@ -1,65 +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.wst.common.componentcore.internal.util; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.internal.emf.resource.Translator; -import org.eclipse.wst.common.internal.emf.resource.TranslatorPath; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class IPathTranslator extends Translator { - - public IPathTranslator(String aDomPath, EStructuralFeature aFeature) { - super(aDomPath, aFeature); - } - - public IPathTranslator(String aDomPath, EStructuralFeature aFeature, TranslatorPath aTranslatorPath) { - super(aDomPath, aFeature, new TranslatorPath[]{aTranslatorPath}); - } - - public IPathTranslator(String aDomPath, EStructuralFeature aFeature, TranslatorPath[] theTranslatorPaths) { - super(aDomPath, aFeature, theTranslatorPaths); - } - - public IPathTranslator(String aDomPath, EStructuralFeature aFeature, int aStyleMask) { - super(aDomPath, aFeature, aStyleMask); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emf.resource.Translator#convertStringToValue(java.lang.String, - * org.eclipse.emf.ecore.EObject) - */ - public Object convertStringToValue(String aValue, EObject anOwner) { - return new Path(aValue); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emf.resource.Translator#convertValueToString(java.lang.Object, - * org.eclipse.emf.ecore.EObject) - */ - public String convertValueToString(Object aValue, EObject anOwner) { - if(aValue instanceof IPath) - return ((IPath)aValue).toString(); - return super.convertValueToString(aValue, anOwner); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ModuleCoreEclipseAdapterFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ModuleCoreEclipseAdapterFactory.java deleted file mode 100644 index ca3e606bf..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ModuleCoreEclipseAdapterFactory.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 - *******************************************************************************/ -package org.eclipse.wst.common.componentcore.internal.util; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeNode; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class ModuleCoreEclipseAdapterFactory implements IAdapterFactory { - - private static final Class MODULE_CORE_CLASS = StructureEdit.class; - private static final Class VIRTUAL_COMPONENT_CLASS = IVirtualComponent.class; - private static final Class[] ADAPTER_LIST = new Class[] { MODULE_CORE_CLASS, VIRTUAL_COMPONENT_CLASS}; - - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptable, Class anAdapterType) { - if(anAdapterType == MODULE_CORE_CLASS) - return new StructureEdit((ModuleStructuralModel)adaptable); - if(anAdapterType == VIRTUAL_COMPONENT_CLASS) - return getComponent((IResource)adaptable); - return null; - } - - private Object getComponent(IResource resource) { - StructureEdit moduleCore = null; - WorkbenchComponent module = null; - if (!resource.exists()) return null; - - try { - moduleCore = StructureEdit.getStructureEditForRead(resource.getProject()); - if (moduleCore == null) - return null; - if (resource.getType() == IResource.PROJECT) { - WorkbenchComponent[] comps = moduleCore.getWorkbenchModules(); - if (comps.length > 0) - return ComponentCore.createComponent(resource.getProject()); - return null; - } - module = moduleCore.findComponent(resource.getFullPath(),ResourceTreeNode.CREATE_NONE); - } catch (UnresolveableURIException e) { - // Ignore - } finally { - if (moduleCore != null) - moduleCore.dispose(); - } - return module == null ? null : ComponentCore.createComponent(resource.getProject()); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return ADAPTER_LIST; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ModuleCoreMessages.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ModuleCoreMessages.java deleted file mode 100644 index b3e395d99..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ModuleCoreMessages.java +++ /dev/null @@ -1,29 +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.wst.common.componentcore.internal.util; - -import org.eclipse.osgi.util.NLS; - -public class ModuleCoreMessages extends NLS { - - private static final String BUNDLE_NAME = "modulecoreNLS"; //$NON-NLS-1$ - - private ModuleCoreMessages() { - //do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, ModuleCoreMessages.class); - } - - public static String Acquiring_ArtifactEdit_For_Read_Exception; - public static String Acquiring_ArtifactEdit_For_Write_Exception; -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/SourcePathProvider.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/SourcePathProvider.java deleted file mode 100644 index 4cc4ab1da..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/SourcePathProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.componentcore.internal.util; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class SourcePathProvider implements IPathProvider { - - public static IPathProvider INSTANCE = new SourcePathProvider(); - - private SourcePathProvider() {} - - /* (non-Javadoc) - * @see org.eclipse.wst.common.modulecore.util.IPathProvider#getPath(org.eclipse.wst.common.modulecore.WorkbenchComponent) - */ - public IPath getPath(ComponentResource aModuleResource) { - return aModuleResource.getSourcePath(); - } - - public EStructuralFeature getFeature() { - return ComponentcorePackage.eINSTANCE.getComponentResource_SourcePath(); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/URITranslator.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/URITranslator.java deleted file mode 100644 index 84743f9f1..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/URITranslator.java +++ /dev/null @@ -1,64 +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.wst.common.componentcore.internal.util; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.internal.emf.resource.Translator; -import org.eclipse.wst.common.internal.emf.resource.TranslatorPath; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class URITranslator extends Translator { - - public URITranslator(String aDomPath, EStructuralFeature aFeature) { - super(aDomPath, aFeature); - } - - public URITranslator(String aDomPath, EStructuralFeature aFeature, TranslatorPath aTranslatorPath) { - super(aDomPath, aFeature, new TranslatorPath[]{aTranslatorPath}); - } - - public URITranslator(String aDomPath, EStructuralFeature aFeature, TranslatorPath[] theTranslatorPaths) { - super(aDomPath, aFeature, theTranslatorPaths); - } - - public URITranslator(String aDomPath, EStructuralFeature aFeature, int aStyleMask) { - super(aDomPath, aFeature, aStyleMask); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emf.resource.Translator#convertStringToValue(java.lang.String, - * org.eclipse.emf.ecore.EObject) - */ - public Object convertStringToValue(String aValue, EObject anOwner) { - return URI.createURI(aValue); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emf.resource.Translator#convertValueToString(java.lang.Object, - * org.eclipse.emf.ecore.EObject) - */ - public String convertValueToString(Object aValue, EObject anOwner) { - if(aValue instanceof URI) - return ((URI)aValue).toString(); - return super.convertValueToString(aValue, anOwner); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/WTPModulesTranslator.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/WTPModulesTranslator.java deleted file mode 100644 index b88af6be8..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/WTPModulesTranslator.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.util; - -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; -import org.eclipse.wst.common.internal.emf.resource.GenericTranslator; -import org.eclipse.wst.common.internal.emf.resource.IDTranslator; -import org.eclipse.wst.common.internal.emf.resource.RootTranslator; -import org.eclipse.wst.common.internal.emf.resource.Translator; - - -public class WTPModulesTranslator extends RootTranslator implements WTPModulesXmlMapperI{ - public static WTPModulesTranslator INSTANCE = new WTPModulesTranslator(); - private static Translator[] children; - private static final ComponentcorePackage MODULE_CORE_PKG = ComponentcorePackage.eINSTANCE; - /** - * @param domNameAndPath - * @param eClass - */ - public WTPModulesTranslator() { - super(PROJECT_MODULES, ComponentcorePackage.eINSTANCE.getProjectComponents()); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emf.resource.Translator#getChildren(java.lang.Object, int) - */ - public Translator[] getChildren(Object target, int versionID) { - if(children == null) - children = createWTPModulesTranslator(); - return children; - } - - private static Translator[] createWTPModulesTranslator() { - return new Translator[] { - IDTranslator.INSTANCE, - new Translator(PROJECT_VERSION, MODULE_CORE_PKG.getProjectComponents_Version(), DOM_ATTRIBUTE), - createWBModuleTranslator(MODULE_CORE_PKG.getProjectComponents_Components()) - }; - } - - /** - * @return - */ - private static Translator createWBModuleTranslator(EStructuralFeature afeature) { - GenericTranslator result = new GenericTranslator(WORKBENCH_COMPONENT, afeature); - result.setChildren(new Translator[] { - IDTranslator.INSTANCE, - //new Translator(HANDLE, MODULE_CORE_PKG.getWorkbenchComponent_Handle(), DOM_ATTRIBUTE), REMOVED SINCE HANDLE SHOULD NOW BE DERIVED -MDE - new Translator(RUNTIME_NAME, MODULE_CORE_PKG.getWorkbenchComponent_Name(), DOM_ATTRIBUTE), - createModuleTypeTranslator(MODULE_CORE_PKG.getWorkbenchComponent_ComponentType()), - createWBResourceTranslator(MODULE_CORE_PKG.getWorkbenchComponent_Resources()), - createDependentModuleTranslator(MODULE_CORE_PKG.getWorkbenchComponent_ReferencedComponents()), - new IPathTranslator(META_RESOURCES, MODULE_CORE_PKG.getWorkbenchComponent_MetadataResources()), - createPropertiesTranslator(MODULE_CORE_PKG.getWorkbenchComponent_Properties()) - }); - return result; - } - private static Translator createModuleTypeTranslator(EStructuralFeature afeature) { - GenericTranslator result = new GenericTranslator(MODULE_TYPE, afeature); - result.setChildren(new Translator[] { - new Translator(COMPONENT_TYPE_ID, MODULE_CORE_PKG.getComponentType_ComponentTypeId(), DOM_ATTRIBUTE), - new Translator(META_RESOURCES, MODULE_CORE_PKG.getComponentType_MetadataResources()), - new Translator(COMPONENT_TYPE_VERSION, MODULE_CORE_PKG.getComponentType_Version()), - createPropertiesTranslator(MODULE_CORE_PKG.getComponentType_Properties()) - - }); - return result; - } - - private static Translator createPropertiesTranslator(EStructuralFeature afeature){ - GenericTranslator result = new GenericTranslator(PROPERTY, afeature); - result.setChildren(new Translator[] { - new Translator(PROPERTY_NAME, MODULE_CORE_PKG.getProperty_Name(), DOM_ATTRIBUTE ), - new Translator(PROPERTY_VALUE, MODULE_CORE_PKG.getProperty_Value(), DOM_ATTRIBUTE ), - - }); - return result; - } - - - private static Translator createDependentModuleTranslator(EStructuralFeature afeature) { - GenericTranslator result = new GenericTranslator(REFERENCED_COMPONENT, afeature); - result.setChildren(new Translator[] { - new IPathTranslator(RUNTIME_PATH, MODULE_CORE_PKG.getReferencedComponent_RuntimePath(), DOM_ATTRIBUTE), - new URITranslator(HANDLE, MODULE_CORE_PKG.getReferencedComponent_Handle(), DOM_ATTRIBUTE), - new HRefTranslator(DEP_OBJECT,MODULE_CORE_PKG.getReferencedComponent_DependentObject()), - new Translator(ARCHIVE_NAME, MODULE_CORE_PKG.getReferencedComponent_ArchiveName(), DOM_ATTRIBUTE), - new DependencyTypeTranslator() - }); - return result; - } - - - private static Translator createWBResourceTranslator(EStructuralFeature afeature) { - GenericTranslator result = new GenericTranslator(COMPONENT_RESOURCE, afeature); - result.setChildren(new Translator[] { - IDTranslator.INSTANCE, - new IPathTranslator(SOURCE_PATH, MODULE_CORE_PKG.getComponentResource_SourcePath(), DOM_ATTRIBUTE), - new IPathTranslator(RUNTIME_PATH, MODULE_CORE_PKG.getComponentResource_RuntimePath(), DOM_ATTRIBUTE), - new Translator(RESOURCE_TYPE, MODULE_CORE_PKG.getComponentResource_ResourceType(), DOM_ATTRIBUTE), - new Translator(EXCLUSIONS, MODULE_CORE_PKG.getComponentResource_Exclusions()) - }); - return result; - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/WTPModulesXmlMapperI.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/WTPModulesXmlMapperI.java deleted file mode 100644 index 9ed9de908..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/WTPModulesXmlMapperI.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.wst.common.componentcore.internal.util; - -public interface WTPModulesXmlMapperI { - String PROJECT_MODULES = "project-modules";//$NON-NLS-1$ - String WORKBENCH_COMPONENT = "wb-module";//$NON-NLS-1$ - String REFERENCED_COMPONENT = "dependent-module";//$NON-NLS-1$ - String COMPONENT_RESOURCE = "wb-resource"; //$NON-NLS-1$ - String MODULE_TYPE = "module-type";//$NON-NLS-1$ - String META_RESOURCES = "meta-resources";//$NON-NLS-1$ - String COMPONENT_TYPE_VERSION = "version";//$NON-NLS-1$ - String HANDLE = "handle";//$NON-NLS-1$ - String DEP_OBJECT = "dependent-object";//$NON-NLS-1$ - String OBJECTREF = "href";//$NON-NLS-1$ - String DEPENDENCY_TYPE = "dependency-type";//$NON-NLS-1$ - String SOURCE_PATH = "source-path"; //$NON-NLS-1$ - String RUNTIME_PATH = "deploy-path"; //$NON-NLS-1$ - String EXCLUSIONS = "exclusions";//$NON-NLS-1$ - String COMPONENT_TYPE_ID = "module-type-id"; //$NON-NLS-1$ - String RUNTIME_NAME = "deploy-name"; //$NON-NLS-1$ - String PROPERTY = "property"; //$NON-NLS-1$ - String PROPERTY_NAME = "name";//$NON-NLS-1$ - String PROPERTY_VALUE = "value";//$NON-NLS-1$ - String RESOURCE_TYPE = "resource-type";//$NON-NLS-1$ - String ARCHIVE_NAME="archiveName";//$NON-NLS-1$ - String PROJECT_VERSION="project-version"; - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ZipFileExporter.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ZipFileExporter.java deleted file mode 100644 index cc0a5b6de..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ZipFileExporter.java +++ /dev/null @@ -1,140 +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.wst.common.componentcore.internal.util; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.CRC32; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; - -/** - * Exports resources to a .zip file - */ -public class ZipFileExporter { - private ZipOutputStream outputStream; - - private boolean useCompression = true; - - /** - * Create an instance of this class. - * - * @param filename - * java.lang.String - * @param compress - * boolean - * @param includeManifestFile - * boolean - * @exception java.io.IOException - */ - public ZipFileExporter(String filename, boolean compress) throws IOException { - Path directoryPath = new Path(filename); - directoryPath = (Path) directoryPath.removeLastSegments(1); - File newZipFile = new File(directoryPath.toString()); - newZipFile.mkdirs(); - outputStream = new ZipOutputStream(new FileOutputStream(filename)); - useCompression = compress; - } - - /** - * Do all required cleanup now that we're finished with the currently-open .zip - * - * @exception java.io.IOException - */ - public void finished() throws IOException { - outputStream.close(); - } - - /** - * Create a new ZipEntry with the passed pathname and contents, and write it to the current - * archive - * - * @param pathname - * java.lang.String - * @param contents - * byte[] - * @exception java.io.IOException - */ - protected void write(String pathname, byte[] contents) throws IOException { - ZipEntry newEntry = new ZipEntry(pathname); - - // if the contents are being compressed then we get the below for free. - if (!useCompression) { - newEntry.setMethod(ZipEntry.STORED); - newEntry.setSize(contents.length); - CRC32 checksumCalculator = new CRC32(); - checksumCalculator.update(contents); - newEntry.setCrc(checksumCalculator.getValue()); - } - - outputStream.putNextEntry(newEntry); - outputStream.write(contents); - outputStream.closeEntry(); - } - - public void writeFolder(String destinationPath) throws IOException { - if (!destinationPath.endsWith("/")) - destinationPath = destinationPath + '/'; - ZipEntry newEntry = new ZipEntry(destinationPath); - outputStream.putNextEntry(newEntry); - outputStream.closeEntry(); - } - - /** - * Write the passed resource to the current archive - * - * @param resource - * org.eclipse.core.resources.IFile - * @param destinationPath - * java.lang.String - * @exception java.io.IOException - * @exception org.eclipse.core.runtime.CoreException - */ - public void write(IFile resource, String destinationPath) throws IOException, CoreException { - InputStream contentStream = null; - try { - contentStream = resource.getContents(false); - write(contentStream, destinationPath); - } finally { - if (contentStream != null) - contentStream.close(); - } - } - - public void write(InputStream contentStream, String destinationPath) throws IOException, CoreException { - ByteArrayOutputStream output = null; - - try { - output = new ByteArrayOutputStream(); - int chunkSize = contentStream.available(); - byte[] readBuffer = new byte[chunkSize]; - int n = contentStream.read(readBuffer); - - while (n > 0) { - output.write(readBuffer); - n = contentStream.read(readBuffer); - } - } finally { - if (output != null) - output.close(); - } - - write(destinationPath, output.toByteArray()); - } - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/package.html b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/package.html deleted file mode 100644 index 9c904dafc..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/package.html +++ /dev/null @@ -1,368 +0,0 @@ -<html> -<head> -<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -<link rel="stylesheet" href="../../../../..//apistyles.css" type="text/css"> -<title>modulecore api overview</title> -</head> -<body> -<p> - The ComponentCore API allows clients to work with the Structural - Metamodels that define abstract modules within Eclipse projects. - These metamodels are exposed through the Virtual Path API layer - (see <a href="ComponentCore.html">ComponentCore</a>). Clients - should also review the <b>org.eclipse.wst.common.componentcore.resources</b> - package. - </p> -<a name="top"></a> -<table width="500"> -<tr> -<td> -<p> - The following document includes information on these topics: - <ul> - -<li> -<a href="#structural-metamodel">ComponentCore Metamodel (CCM)</a> - used to understand which files should or should not be - included within a module.</li> - -<li> -<a href="#constraints">Constraints</a> enforced by the - design</li> - -<li> -<a href="#module-core-examples">The API entry-point</a> -</li> - -</ul> - -</p> -</td> -</tr> -</table> -<a name="structural-metamodel"></a> -<table width="100%" cellspacing="5" cellpadding="2" border="0"> -<tbody> -<tr> -<td valign="top" bgcolor="#0080c0" align="left" colspan="2"><b><font face="Arial,Helvetica" color="#ffffff">ComponentCore Metamodel (CCM)</font></b></td> -</tr> -</tbody> -</table> -<BR> -<table width="500"> -<tr> -<td> -<p> - The ComponentCore Metamodel (CCM) is an EMF model that allows - the tooling to understand most project structures. Each project - has a single CCM which is stored under the project root named - <I>.wtpmodules</I> - . The XML format is defined by the - <a href="../../../../../overview/componentCore.xsd">ComponentCore schema</a>. - The following diagram is a UML representation of the - ComponentCore Metamodel. This information is published for - potential contributors of editors, but the EMF model is - not exposed directly as API, and could change in view of - changes for WTP 1.1. - </p> -</td> -</tr> -</table> -<table cellpadding="10" cellspacing="10"> -<tr> -<td> -<p> -<img src="../../../../../overview/componentcore_model.jpg"></p> -</td> -</tr> -<tr> -<td> -<p> -<i>Figure 1: The Component Core Metamodel</i> -</p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - Each logical component contained in the project is represented by a - <b>WorkbenchComponent</b> element. The <b>WorkbenchComponent</b> defines - information about the type of component, the resources consumed by the - module from the project, and the referenced components. The - <b>WorkbenchComponent</b> is very generic, and as modeled, does - not necessarily correspond to only J2EE artifacts. - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - The <b>WorkbenchComponent</b> has a - <i>name</i> - , which is the name that will be used when the runtime form of the - component is constructed. For a web application, the - <i>name</i> - might be "MyWebApplication". - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - The <b>WorkbenchComponent</b> may be uniquely referenced by a URI. The - fully qualified URI to any component must begin with the component - protocol ("component:"), specify a subprotocol ("resource|classpath") and - then a path to the referenced component. A <b>WorkbenchComponent</b> with the - name "MyWebApplication" defined in a project named - "MyWebModulesProject" would be referenced by the following URI: - "component:/resource/MyWebModulesProject/MyWebApplication". As a future - extension, a component referenced on the classpath of a project (perhaps - a Utility Jar or an EJB Client Jar), the URI might be something like: - "component:/classpath/MyWebModulesProject/CustomerEJBClient.jar". - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - The <b>WorkbenchComponent</b> has a <b>ComponentType</b>. The - <b>ComponentType</b> defines a <i>componentTypeId</i> - , which indicates the specific kind of component. The Web Tools Platform - uses the <i>componentTypeId</i> - to determine how to work with the content component of the <b>WorkbenchComponent</b> - and prepare the component for deployment. The <b>ComponentType</b> may - also define the runtime-paths of special metadata resources which are - important to the <b>WorkbenchComponent</b>. "Metadata" refers to resources - which explain the content details of the specific modules. An example of - such a file would be the "WEB-INF/web.xml" deployment descriptor for - Web Applications. - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - The <b>WorkbenchComponent</b> contains a list of ComponentResources. Each - <b>ComponentResource</b> has "sourcePath" and a corresponding - "runtimePath". The "sourcePath" can reference either a file or folder, - but the referenced resource must be contained in the same project as the - <b>WorkbenchComponent</b> definition. The "runtimePath" specifies a location - relative to the deployed structure of the <b>WorkbenchComponent</b> where the - contents of the referenced resource will be represented when the module is - prepared for runtime. - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - The <b>WorkbenchComponent</b> contains a list of <b>ReferencedComponent</b>s. - Each <b>ReferencedComponent</b> provides a handle that must resolve to a - <b>WorkbenchComponent</b>, a runtimePath that defines where the constructed - component will be placed within the context of the runtime - <b>WorkbenchComponent</b>, and a <b>DependencyType</b> - that can be either "consume" or "use" to indicate how the contents of - that <b>ReferencedComponent</b> should be absorbed by the <b>WorkbenchComponent</b>. - <b>ReferencedComponent</b>s may reference <b>WorkbenchComponent</b>s in - other projects and on current project's classpath (Not yet implemented). - The <b>DependencyType</b> will determine whether the contents of - the <b>ReferencedComponent</b> are absorbed as-is or archived into a *.{w|j|e}ar - file. - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - The <b>ProjectComponents</b> object provides a root container for all - <b>WorkbenchComponent</b>s defined in a given project. - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - -<b>ComponentCore</b> provides a facade to manage the underlying model for - clients. Static methods - <code>ModuleCore.getModuleCoreForRead()</code> - and - <code>ModuleCore.getModuleCoreForWrite()</code> - may be used to acquire an ModuleCore adapter, and clients are responsible - for invoking - <code>dispose()</code> - whenever they are finished using the model. - </p> -</td> -</tr> -</table> -<a href="#top">top</a><a name="constraints"></a> -<table width="100%" cellspacing="5" cellpadding="2" border="0"> -<tbody> -<tr> -<td valign="top" bgcolor="#0080c0" align="left" colspan="2"><b><font face="Arial,Helvetica" color="#ffffff">Constraints enforced by the CCM</font></b></td> -</tr> -</tbody> -</table> -<table width="500"> -<tr> -<td> -<p> - The following constraints are enforced by the model: - <ol> - -<li> - -<p> - The solution will not check dependencies for components that are - contained in the same project. To get the full benefits of - inter-component dependency checking, components must be separated - into different projects. We do not have the necessary - flexibility in constructing and scoping classpaths on a level - more granular than the project level, which would be needed - to support this functionality. - </p> - -</li> - -<li> - -<p> - The solution will not allow a single component to span more than - one project. Within that project, we will have fairly broad - flexibility to specify which resources map to which components. - Each component within a project must have its own source folder, - but a component may contain more than one source folder. Each - source folder may be contained by at most one component. Components - may reference dependent components in other projects (so a Web - Application may reference a Web Library outside of the - project that contains the Web Application). - </p> - -</li> - -<li> - -<p> - The solution will not allow more than one server target per - component (and really per-project) at a time. The ability to - switch this server target (via some action or property - setting) will continue to be possible. Users that need the - capability to develop for multiple server targets will need - to manually switch and test as necessary. - </p> - -</li> - -<li> - -<p> - Each component in a project may have its own output folder - structure automatically constructed for it. The output - structure will match the J2EE specification output structure - required for the component type (for J2EE modules). A new - builder will handle this responsibility and work - cooperatively with the Java builder to construct a - deployable, on-disk representation of the module structure. - The reference implementation will follow this pattern, but - hooks will be made available to vary this behavior. - The necessity for this on-disk structure to match a - J2EE-compliant layout is motivated by the requirement to have - in-workbench testing, so that users will not have to deal - with a deployer actually constructing a deployable module and - shipping it off to a server to test their code. This approach - is consistent with existing Ant-based approaches and - Application Servers which can run in a "debug" mode on disk. - Our value-add will be greater automation and integration with - the workbench -- particularly for incremental based support. - The specialized module builder would not be necessary if the - source was already in the appropriate J2EE specification - compliant structure. The default creation will still - encourage a single module per project, which conforms to the - correct J2EE structure. - </p> - -</li> - -<li> - -<p> - Components will be described using a simple XML format, and each - project will contain one - <I>.wtpmodules</I> - file that will describe all of the components for that project. - The level of tooling to help users create these files is yet - to be determined for WTP M4. This would be a great area for - other interested developers to suggest and provide tooling - (e.g. a Wizard or Editor) to create these files from existing - structures. A schema is provided to make it easier for - consumers that want to build their own - <I>.wtpmodules</I> - by hand to take advantage of the content assist in the XML - editor. - </p> - -</li> - -</ol> - -</p> -</td> -</tr> -</table> -<a href="#top">top</a><a name="module-core-examples"></a> -<table width="100%" cellspacing="5" cellpadding="2" border="0"> -<tbody> -<tr> -<td valign="top" bgcolor="#0080c0" align="left" colspan="2"><b><font face="Arial,Helvetica" color="#ffffff">ComponentCore API: Working with the metamodel</font></b></td> -</tr> -</tbody> -</table> -<BR> -<table width="500"> -<tr> -<td> -<p> - ComponentCore uses a handle based model much like the existing Platform - Resource model. The ComponentCore facade is not tied to any project, and - the handles that it returns may or may not exist. The complexity of - managing the underlying EMF model is handled under the cover for users. - </p> -</td> -</tr> -</table> -<table cellpadding="10" cellspacing="10"> -<tr> -<td> -<p> -<img src="../../../../../overview/componentcore_package.jpg"></p> -</td> -</tr> -<tr> -<td> -<p> -<i>Figure 2: The ComponentCore API</i> -</p> -</td> -</tr> -</table> -<a href="#top">top</a> -</body> -</html> diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/package.xml b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/package.xml deleted file mode 100644 index 3b5c004ca..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/package.xml +++ /dev/null @@ -1,331 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../" /> - <title>modulecore api overview</title> - </head> - - <body> - <abstract> - The ComponentCore API allows clients to work with the Structural - Metamodels that define abstract modules within Eclipse projects. - These metamodels are exposed through the Virtual Path API layer - (see <a href="ComponentCore.html">ComponentCore</a>). Clients - should also review the <b>org.eclipse.wst.common.componentcore.resources</b> - package. - </abstract> - - <a name="top"/> - <p> - The following document includes information on these topics: - <ul> - <li><a href="#structural-metamodel">ComponentCore Metamodel (CCM)</a> - used to understand which files should or should not be - included within a module.</li> - <li><a href="#constraints">Constraints</a> enforced by the - design</li> - <li><a href="#module-core-examples">The API entry-point</a></li> - </ul> - </p> - <a name="structural-metamodel"/> - <h2>ComponentCore Metamodel (CCM)</h2> - <BR /> - <p> - The ComponentCore Metamodel (CCM) is an EMF model that allows - the tooling to understand most project structures. Each project - has a single CCM which is stored under the project root named - <I>.wtpmodules</I> - . The XML format is defined by the - <a href="../../../../../overview/componentCore.xsd">ComponentCore schema</a>. - The following diagram is a UML representation of the - ComponentCore Metamodel. This information is published for - potential contributors of editors, but the EMF model is - not exposed directly as API, and could change in view of - changes for WTP 1.1. - </p> - <img src="../../../../../overview/componentcore_model.jpg" caption="The Component Core Metamodel" /> - <p> - Each logical component contained in the project is represented by a - <b>WorkbenchComponent</b> element. The <b>WorkbenchComponent</b> defines - information about the type of component, the resources consumed by the - module from the project, and the referenced components. The - <b>WorkbenchComponent</b> is very generic, and as modeled, does - not necessarily correspond to only J2EE artifacts. - </p> - <p> - The <b>WorkbenchComponent</b> has a - <i>name</i> - , which is the name that will be used when the runtime form of the - component is constructed. For a web application, the - <i>name</i> - might be "MyWebApplication". - </p> - <p> - The <b>WorkbenchComponent</b> may be uniquely referenced by a URI. The - fully qualified URI to any component must begin with the component - protocol ("component:"), specify a subprotocol ("resource|classpath") and - then a path to the referenced component. A <b>WorkbenchComponent</b> with the - name "MyWebApplication" defined in a project named - "MyWebModulesProject" would be referenced by the following URI: - "component:/resource/MyWebModulesProject/MyWebApplication". As a future - extension, a component referenced on the classpath of a project (perhaps - a Utility Jar or an EJB Client Jar), the URI might be something like: - "component:/classpath/MyWebModulesProject/CustomerEJBClient.jar". - </p> - <p> - The <b>WorkbenchComponent</b> has a <b>ComponentType</b>. The - <b>ComponentType</b> defines a <i>componentTypeId</i> - , which indicates the specific kind of component. The Web Tools Platform - uses the <i>componentTypeId</i> - to determine how to work with the content component of the <b>WorkbenchComponent</b> - and prepare the component for deployment. The <b>ComponentType</b> may - also define the runtime-paths of special metadata resources which are - important to the <b>WorkbenchComponent</b>. "Metadata" refers to resources - which explain the content details of the specific modules. An example of - such a file would be the "WEB-INF/web.xml" deployment descriptor for - Web Applications. - </p> - <p> - The <b>WorkbenchComponent</b> contains a list of ComponentResources. Each - <b>ComponentResource</b> has "sourcePath" and a corresponding - "runtimePath". The "sourcePath" can reference either a file or folder, - but the referenced resource must be contained in the same project as the - <b>WorkbenchComponent</b> definition. The "runtimePath" specifies a location - relative to the deployed structure of the <b>WorkbenchComponent</b> where the - contents of the referenced resource will be represented when the module is - prepared for runtime. - </p> - <p> - The <b>WorkbenchComponent</b> contains a list of <b>ReferencedComponent</b>s. - Each <b>ReferencedComponent</b> provides a handle that must resolve to a - <b>WorkbenchComponent</b>, a runtimePath that defines where the constructed - component will be placed within the context of the runtime - <b>WorkbenchComponent</b>, and a <b>DependencyType</b> - that can be either "consume" or "use" to indicate how the contents of - that <b>ReferencedComponent</b> should be absorbed by the <b>WorkbenchComponent</b>. - <b>ReferencedComponent</b>s may reference <b>WorkbenchComponent</b>s in - other projects and on current project's classpath (Not yet implemented). - The <b>DependencyType</b> will determine whether the contents of - the <b>ReferencedComponent</b> are absorbed as-is or archived into a *.{w|j|e}ar - file. - </p> - <p> - The <b>ProjectComponents</b> object provides a root container for all - <b>WorkbenchComponent</b>s defined in a given project. - </p> - <p> - <b>ComponentCore</b> provides a facade to manage the underlying model for - clients. Static methods - <code>ModuleCore.getModuleCoreForRead()</code> - and - <code>ModuleCore.getModuleCoreForWrite()</code> - may be used to acquire an ModuleCore adapter, and clients are responsible - for invoking - <code>dispose()</code> - whenever they are finished using the model. - </p> - <a href="#top">top</a> - <a name="constraints"/> - <h2>Constraints enforced by the CCM</h2> - <p> - The following constraints are enforced by the model: - <ol> - <li> - <p> - The solution will not check dependencies for components that are - contained in the same project. To get the full benefits of - inter-component dependency checking, components must be separated - into different projects. We do not have the necessary - flexibility in constructing and scoping classpaths on a level - more granular than the project level, which would be needed - to support this functionality. - </p> - </li> - <li> - <p> - The solution will not allow a single component to span more than - one project. Within that project, we will have fairly broad - flexibility to specify which resources map to which components. - Each component within a project must have its own source folder, - but a component may contain more than one source folder. Each - source folder may be contained by at most one component. Components - may reference dependent components in other projects (so a Web - Application may reference a Web Library outside of the - project that contains the Web Application). - </p> - </li> - <li> - <p> - The solution will not allow more than one server target per - component (and really per-project) at a time. The ability to - switch this server target (via some action or property - setting) will continue to be possible. Users that need the - capability to develop for multiple server targets will need - to manually switch and test as necessary. - </p> - </li> - <li> - <p> - Each component in a project may have its own output folder - structure automatically constructed for it. The output - structure will match the J2EE specification output structure - required for the component type (for J2EE modules). A new - builder will handle this responsibility and work - cooperatively with the Java builder to construct a - deployable, on-disk representation of the module structure. - The reference implementation will follow this pattern, but - hooks will be made available to vary this behavior. - The necessity for this on-disk structure to match a - J2EE-compliant layout is motivated by the requirement to have - in-workbench testing, so that users will not have to deal - with a deployer actually constructing a deployable module and - shipping it off to a server to test their code. This approach - is consistent with existing Ant-based approaches and - Application Servers which can run in a "debug" mode on disk. - Our value-add will be greater automation and integration with - the workbench -- particularly for incremental based support. - The specialized module builder would not be necessary if the - source was already in the appropriate J2EE specification - compliant structure. The default creation will still - encourage a single module per project, which conforms to the - correct J2EE structure. - </p> - </li> - <li> - <p> - Components will be described using a simple XML format, and each - project will contain one - <I>.wtpmodules</I> - file that will describe all of the components for that project. - The level of tooling to help users create these files is yet - to be determined for WTP M4. This would be a great area for - other interested developers to suggest and provide tooling - (e.g. a Wizard or Editor) to create these files from existing - structures. A schema is provided to make it easier for - consumers that want to build their own - <I>.wtpmodules</I> - by hand to take advantage of the content assist in the XML - editor. - </p> - </li> - </ol> - </p> - <a href="#top">top</a> - <a name="module-core-examples"/> - <h2>ComponentCore API: Working with the metamodel</h2> - <BR /> - <p> - ComponentCore uses a handle based model much like the existing Platform - Resource model. The ComponentCore facade is not tied to any project, and - the handles that it returns may or may not exist. The complexity of - managing the underlying EMF model is handled under the cover for users. - </p> - <img src="../../../../../overview/componentcore_package.jpg" caption="The ComponentCore API" /> - <!-- - <p> - Clients should use one of - <code>ModuleCore.getModuleCoreForRead()</code> - or - <code>ModuleCore.getModuleCoreForWrite()</code> - to acquire an instance of ModuleCore. - <codesnippet caption="Acquiring an instance of ComponentCore for read-only access"> -IProject currentProject = ... -ModuleCore moduleCoreInstance = ModuleCore.getModuleCoreForRead(currentProject); -WorkbenchComponent[] modules = moduleCoreInstance.getWorkbenchComponents(); -... work with modules ... -moduleCoreInstance.dispose(); - </codesnippet> - </p> - <p> - For clients that would like to build up their own models for a given - project, or modify the existing metamodel, the ModuleCore instance should - be acquired for write-access. - </p> - <codesnippet caption="Creating a WorkbenchComponent"> -... -import org.eclipse.emf.common.util.URI; -... - -public static void createWebAppModule(IProject aTargetProject, - IFolder aJavaSourceFolder, - IFolder aWebContentFolder, - IResource aWebAppDeploymentDescriptor, - IProgressMonitor aProgressMonitor) -{ - ModuleCore moduleCoreInstance = null; - try { - moduleCoreInstance = - ModuleCore.getModuleCoreForWrite(aTargetProject); - - /* Create a new module that will be - contained by the current ModuleCore */ - WorkbenchComponent newModule = - moduleCoreInstance.createWorkbenchComponent("MyWebModule.war"); - - /* A Java source folder that contains - the classes for the current module */ - ComponentResource javaSource = - moduleCoreInstance.createComponentResource( - aJavaSourceFolder); - javaSource.setDeployedPath( - URI.createURI("/WEB-INF/classes")); - newModule.getResources().add(javaSource); - - /* A resource folder that contains - the *.jsp, *.html, .img, ... files */ - ComponentResource webContent = - moduleCoreInstance.createComponentResource( - aWebContentFolder); - webContent.setDeployedPath(URI.createURI("/")); - newModule.getResources().add(webContent); - - /* A resource that points to a valid web.xml - file that follows the J2EE Web Deployment - Descriptor Specification - */ - ComponentResource deploymentDescriptor = - moduleCoreInstance.createComponentResource( - aWebAppDeploymentDescriptor); - deploymentDescriptor.setDeployedPath( - URI.createURI("/WEB-INF/web.xml")); - newModule.getResources().add(deploymentDescriptor); - - moduleCoreInstance.saveIfNecessary(aProgressMonitor); - } finally { - if (moduleCoreInstance != null) { - moduleCoreInstance.dispose(); - } - } -} - </codesnippet> - <p> - For clients that would like to take an existing project an add Flexible - Project Support, use the ModuleCoreNature.addModuleCoreIfNecessary() API - to prepare the project to support flexible module structures. the - existing metamodel, then acquire the ModuleCore instance for modification. - </p> - <codesnippet caption="Add Flexible Project support to a new or existing project"> -... -import org.eclipse.emf.common.util.URI; -... -public static void makeFlexible(IProject aTargetProject) { - ModuleCore moduleCoreInstance = null; - try { - ModuleCoreNature.addModuleCoreNatureIfNecessary(aTargetProject); - moduleCoreInstance = ModuleCore.getModuleCoreForWrite(aTargetProject); - ... work with moduleCoreInstance and underlying model ... - moduleCoreInstance.saveIfNecessary(aProgressMonitor); - } finally { - if (moduleCoreInstance != null) { - moduleCoreInstance.dispose(); - } - } -} - </codesnippet> - --> - <a href="#top">top</a> - </body> -</html> -
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualComponent.java deleted file mode 100644 index 7de081d5f..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualComponent.java +++ /dev/null @@ -1,238 +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.wst.common.componentcore.resources; - -import java.util.Properties; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; - -/** - * Represents a component as defined by the .component file. - * <p> - * A component is a container of virtual resources which has other features that describe the - * component including: - * - * @plannedfor 1.0 - */ -public interface IVirtualComponent extends IAdaptable { - - IPath ROOT = new Path("/"); //$NON-NLS-1$ - - /** - * Type constant (bit mask value 1) which identifies component binary status. - */ - public static final int BINARY = 0x1; - - - /** - * The name of the component must be unique within its enclosing project. - * - * @return The name of the component. - */ - String getName(); - - /** - * @return The deployed name of the component. - */ - String getDeployedName(); - - /** - * The componentTypeId is used to understand how this component should be edited and deployed. - * Examples include "jst.web" or "jst.utility". The componentTypeId can be set to any value when - * created so long as that value makes sense to the clients. Standard componentTypeIds may be - * available for common component types. - * - * @return The componentTypeId, a string based identifier that indicates the component - */ -// String getComponentTypeId(); - - - /** - * Returns reference to itself. - * <p> - * - * @return the name of the component that contains the virtual resource - */ - public IVirtualComponent getComponent(); - - - /** - * - * The componentTypeId is used to understand how this component should be edited and deployed. - * Examples include "jst.web" or "jst.utility". The componentTypeId can be set to any value when - * created so long as that value makes sense to the clients. Standard componentTypeIds may be - * available for common component types. - * - * @param aComponentTypeId - * A value which is either standard for a common component type or client-defined for - * a custom component type - */ -// void setComponentTypeId(String aComponentTypeId); - - /** - * MetaProperties are String-based name-value pairs that include information about this - * component that may be relevant to clients or the way that clients edit or deploy components. - * - * @return A by-reference instance of the properties for this component. - */ - Properties getMetaProperties(); - - /** - * Adds a single property - * @param property - * A value which is name, value pair, see ComponentcoreFactory.eINSTANCE.createProperty() - * - */ - void setMetaProperty(String name, String value); - - /** - * Adds the properties provided as a list - * @param properties - * A list of properties - */ - void setMetaProperties(Properties properties); - - /** - * MetaResources provide a loose mechanism for components that would like to list off the - * metadata-resources available in the component which can aid or expedite searching for this - * resources. - * <p> - * Clients are not required to get or set the MetaResources for a component. - * </p> - * - * @return A by-value copy of the MetaResources array - * @see #setMetaResources(IPath[]) - */ - IPath[] getMetaResources(); - - /** - * - * MetaResources provide a loose mechanism for components that would like to list off the - * metadata-resources available in the component which can aid or expedite searching for this - * resources. - * <p> - * Clients are not required to get or set the MetaResources for a component. The existing - * MetaResources will be overwritten after the call to this method. - * </p> - * - * @param theMetaResourcePaths - * An array of paths that will become the new MetaResource array. - */ - void setMetaResources(IPath[] theMetaResourcePaths); - - - /** - * Virtual components may reference other virtual components to build logical dependency trees. - * <p> - * Each virtual reference will indicate how the content of the reference will be absorbed - * by this component. Each virtual reference will always specify an enclosing component that will - * be this component. - * </p> - * @return A by-value copy of the virtual reference array - */ - IVirtualReference[] getReferences(); - /** - * Virtual components may reference other virtual components to build logical dependency trees. - * <p> - * Each virtual reference will indicate how the content of the reference will be absorbed - * by this component. Each virtual reference will always specify an enclosing component that will - * be this component. - * </p> - * @return A by-value copy of the virtual reference with given name, or null if none exist matching this name - */ - IVirtualReference getReference(String aComponentName); - - /** - * Virtual components may reference other virtual components to build logical dependency trees. - * <p> - * Each virtual reference will indicate how the content of the reference will be absorbed - * by this component. Each virtual reference will always specify an enclosing component that will - * be this component. Any references specified in the array which do not specify an enclosing - * component that matches this component will be modified to specify this virtual component. - * </p> - * <p> - * Existing virtual references will be overwritten when this method is called. - * </p> - * @param theReferences A by-value copy of the virtual reference array - */ - void setReferences(IVirtualReference[] theReferences); - - public void addReferences(IVirtualReference[] references); - - /** - * Returns true if this component is of binary type - * - * @return The binary status. - */ - boolean isBinary(); - - - /** - * Create the underlying model elements if they do not already exist. Resources - * may be created as a result of this method if the mapped path does not exist. - * - * @param updateFlags Any of IVirtualResource or IResource update flags. If a - * resource must be created, the updateFlags will be supplied to the - * resource creation operation. - * @param aMonitor - * @throws CoreException - */ - public void create(int updateFlags, IProgressMonitor aMonitor) throws CoreException; - - /** - * Returns a handle to the root folder. - * <p> - * This is a resource handle operation; neither the container - * nor the result need exist in the workspace. - * The validation check on the resource name/path is not done - * when the resource handle is constructed; rather, it is done - * automatically as the resource is created. - * </p> - * - * @param name the string name of the member folder - * @return the (handle of the) member folder - */ - public IVirtualFolder getRootFolder(); - - /** - * Returns the project which contains the component. - * <p> - * The name of the project may not (and most likely will not) be referenced in the - * runtime path of this virtual path, but will be referenced by the workspace-relative path. - * </p> - * <p> - * This is a resource handle operation; neither the resource nor the resulting project need - * exist. - * </p> - * - * @return the project handle - */ - public IProject getProject(); - - /** - * Returns whether this component is backed by an accessible Component. - */ - public boolean exists(); - - /** - * Returns the components which reference this component. This is only a one layer - * deep search algorithm. - * - * @return array of IVirtualComponents - */ - public IVirtualComponent[] getReferencingComponents(); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualContainer.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualContainer.java deleted file mode 100644 index c2411ad4a..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualContainer.java +++ /dev/null @@ -1,283 +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.wst.common.componentcore.resources; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -/** - * Represents a component as defined by the WTP Modules file. A - * virtual container represents the root of the component. - * <p> - * Virtual containers can provide handles to virtual files and - * virtual folders that it contains. - * </p> - * <p> - * To acquire a handle to a component, use the following snippet:<br> - * <code>ModuleCore.createContainer(containingProject, componentName)</code> - * which will create a handle to a virtual container contained by - * <i>containingProject</i> with the name <i>componentName</i>. If the - * a component of the given name exists, then - * {@link org.eclipse.wst.common.componentcore.resources.IVirtualResource#exists()} - * will return true. Otherwise, use {@link #create(int, IProgressMonitor)} to - * create the relevant model elements. If a client needs to add a - * mapping from a folder in the same project to root, use - * {@link #createLink(IPath, int, IProgressMonitor)} with a - * project-relative path. - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * @plannedfor 1.0 - */ -public interface IVirtualContainer extends IVirtualResource { - - - /** - * Create the underlying model elements if they do not already exist. Resources - * may be created as a result of this method if the mapped path does not exist. - * - * @param updateFlags Any of IVirtualResource or IResource update flags. If a - * resource must be created, the updateFlags will be supplied to the - * resource creation operation. - * @param aMonitor - * @throws CoreException - */ - public void create(int updateFlags, IProgressMonitor aMonitor) throws CoreException; - - - /** - * Returns whether a virtual resource of some type with the given path - * exists relative to this resource. - * The supplied path may be absolute or relative; in either case, it is - * interpreted as relative to this resource. Trailing separators are ignored. - * If the path is empty this container is checked for existence. - * - * @param path the path of the resource - * @return <code>true</code> if a resource of some type with the given path - * exists relative to this resource, and <code>false</code> otherwise - * @see IVirtualResource#exists() - */ - public boolean exists(IPath path); - - /** - * Finds and returns the member virtual resource (folder or file) - * with the given name in this container, or <code>null</code> if no such - * resource exists. - * - * - * @param name the string name of the member resource - * @return the member resource, or <code>null</code> if no such - * resource exists - */ - public IVirtualResource findMember(String name); - - /** - * Finds and returns the member resource (folder, or file) - * with the given name in this container, or <code>null</code> if - * there is no such resource. - * <p> - * If the <code>includePhantoms</code> argument is <code>false</code>, - * only a member resource with the given name that exists will be returned. - * If the <code>includePhantoms</code> argument is <code>true</code>, - * the method also returns a resource if the workspace is keeping track of a - * phantom with that name. - * </p> - * <p> - * Note that no attempt is made to exclude team-private member resources - * as with <code>members</code>. - * </p> - * - * @param name the string name of the member resource - * @param includePhantoms <code>true</code> if phantom resources are - * of interest; <code>false</code> if phantom resources are not of - * interest - * @return the member resource, or <code>null</code> if no such - * resource exists - * @see #members() - * @see IVirtualResource#isPhantom() - */ - public IVirtualResource findMember(String name, int searchFlags); - - /** - * Finds and returns the member resource identified by the given path in - * this container, or <code>null</code> if no such resource exists. - * The supplied path may be absolute or relative; in either case, it is - * interpreted as relative to this resource. Trailing separators and the path's - * device are ignored. If the path is empty this container is returned. - * - * @param path the path of the desired resource - * @return the member resource, or <code>null</code> if no such - * resource exists - */ - public IVirtualResource findMember(IPath path); - - /** - * Finds and returns the member resource identified by the given path in - * this container, or <code>null</code> if there is no such resource. - * The supplied path may be absolute or relative; in either case, it is - * interpreted as relative to this resource. Trailing separators and the path's - * device are ignored. - * If the path is empty this container is returned. - * - * @param path the path of the desired resource - * @param includePhantoms <code>true</code> if phantom resources are - * of interest; <code>false</code> if phantom resources are not of - * interest - * @return the member resource, or <code>null</code> if no such - * resource exists - * @see #members(boolean) - * @see IVirtualResource#isPhantom() - */ - public IVirtualResource findMember(IPath path, int searchFlags); - - /** - * Returns a handle to the file identified by the given path in this - * container. - * <p> - * This is a resource handle operation; neither the resource nor - * the result need exist in the workspace. - * The validation check on the resource name/path is not done - * when the resource handle is constructed; rather, it is done - * automatically as the resource is created. - * <p> - * The supplied path may be absolute or relative; in either case, it is - * interpreted as relative to this resource and is appended - * to this container's full path to form the full path of the resultant resource. - * A trailing separator is ignored. The path of the resulting resource must - * have at least two segments. - * </p> - * - * @param path the path of the member file - * @return the (handle of the) member file - * @see #getFolder(IPath) - */ - public IVirtualFile getFile(IPath path); - - /** - * Returns a handle to the folder identified by the given path in this - * container. - * <p> - * This is a resource handle operation; neither the resource nor - * the result need exist in the workspace. - * The validation check on the resource name/path is not done - * when the resource handle is constructed; rather, it is done - * automatically as the resource is created. - * <p> - * The supplied path may be absolute or relative; in either case, it is - * interpreted as relative to this resource and is appended - * to this container's full path to form the full path of the resultant resource. - * A trailing separator is ignored. The path of the resulting resource must - * have at least two segments. - * </p> - * - * @param path the path of the member folder - * @return the (handle of the) member folder - * @see #getFile(IPath) - */ - public IVirtualFolder getFolder(IPath path); - - /** - * Returns a handle to the file with the given name in this folder. - * <p> - * This is a resource handle operation; neither the resource nor - * the result need exist in the workspace. - * The validation check on the resource name/path is not done - * when the resource handle is constructed; rather, it is done - * automatically as the resource is created. - * </p> - * - * @param name the string name of the member file - * @return the (handle of the) member file - * @see #getFolder(String) - */ - public IVirtualFile getFile(String name); - - /** - * Returns a handle to the folder with the given name in this folder. - * <p> - * This is a resource handle operation; neither the container - * nor the result need exist in the workspace. - * The validation check on the resource name/path is not done - * when the resource handle is constructed; rather, it is done - * automatically as the resource is created. - * </p> - * - * @param name the string name of the member folder - * @return the (handle of the) member folder - * @see #getFile(String) - */ - public IVirtualFolder getFolder(String name); - - /** - * Returns a list of existing member resources (projects, folders and files) - * in this resource, in no particular order. - * <p> - * This is a convenience method, fully equivalent to <code>members(IVirtualResource.NONE)</code>. - * Team-private member resources are <b>not</b> included in the result. - * </p><p> - * Note that the members of a project or folder are the files and folders - * immediately contained within it. The members of the workspace root - * are the projects in the workspace. - * </p> - * - * @return an array of members of this resource - * @exception CoreException if this request fails. Reasons include: - * <ul> - * <li> This resource does not exist.</li> - * <li> This resource is a project that is not open.</li> - * </ul> - * @see #findMember(IPath) - * @see IVirtualResource#isAccessible() - */ - public IVirtualResource[] members() throws CoreException; - - /** - * Returns a list of all member resources (projects, folders and files) - * in this resource, in no particular order. - * <p> - * If the <code>INCLUDE_PHANTOMS</code> flag is not specified in the member - * flags (recommended), only member resources that exist will be returned. - * If the <code>INCLUDE_PHANTOMS</code> flag is specified, - * the result will also include any phantom member resources the - * workspace is keeping track of. - * </p><p> - * If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag is specified - * in the member flags, team private members will be included along with - * the others. If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag - * is not specified (recommended), the result will omit any team private - * member resources. - * </p> - * <p> - * If the <code>EXCLUDE_DERIVED</code> flag is not specified, derived - * resources are included. If the <code>EXCLUDE_DERIVED</code> flag is - * specified in the member flags, derived resources are not included. - * </p> - * - * @param memberFlags bit-wise or of member flag constants - * (<code>INCLUDE_PHANTOMS</code>, <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> - * and <code>EXCLUDE_DERIVED</code>) indicating which members are of interest - * @return an array of members of this resource - * @exception CoreException if this request fails. Reasons include: - * <ul> - * <li> This resource does not exist.</li> - * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and - * this resource does not exist.</li> - * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and - * this resource is a project that is not open.</li> - * </ul> - * @see IVirtualResource#exists() - * @plannedfor 2.0 - */ - public IVirtualResource[] members(int memberFlags) throws CoreException; - - public IVirtualResource[] getResources(String aResourceType); -} - diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualFile.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualFile.java deleted file mode 100644 index c5d44400d..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualFile.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.componentcore.resources; - -import org.eclipse.core.resources.IFile; -/** - * Represents a file that can be navigated through - * an abstract ("virtual") path. - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * @plannedfor 1.0 - */ -public interface IVirtualFile extends IVirtualResource { - /** - * returns the underlying IFile, returns first IFile if multiple exist. - * - * @return the underlying IFile - */ - public IFile getUnderlyingFile(); - /** - * returns the array of underlying IFiles that are mapped to the same runtime path. - * - * @return the array of underlying IFiles mapped to the runtime path - */ - public IFile[] getUnderlyingFiles(); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualFolder.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualFolder.java deleted file mode 100644 index 3519e841d..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualFolder.java +++ /dev/null @@ -1,37 +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.wst.common.componentcore.resources; - -import org.eclipse.core.resources.IContainer; -/** - * Represents a folder that can be navigated through - * an abstract ("virtual") path. - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * @plannedfor 1.0 - */ -public interface IVirtualFolder extends IVirtualContainer { - /** - * returns the underlying IFolder mapped to the runtime path, - * returns first IFolder if multiple exist. - * - * @return the underlying IFolder - */ - public IContainer getUnderlyingFolder(); - /** - * returns the underlying IFolders mapped to the runtime path. - * Multiple IFolders can be mapped to the same runtime path. - * - * @return the array of underlying IFolders - */ - public IContainer[] getUnderlyingFolders(); -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualReference.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualReference.java deleted file mode 100644 index 6ef2274a9..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualReference.java +++ /dev/null @@ -1,110 +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.wst.common.componentcore.resources; - -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.DependencyType; - -/** - * Represents a dependency between two components: EnclosingComponent->ReferencedComponent. - * <p> - * The ReferencedComponent may exist in another project or as a binary form on the classpath - * of the project. - * </p> - * @plannedfor 1.0 - */ -public interface IVirtualReference { - - /** - * Indicates that the dependency should be archived into a *.?ar format before being absorbed. - */ - int DEPENDENCY_TYPE_USES = DependencyType.USES; - /** - * Indicates that the dependency will be absorbed as is without archiving. - */ - int DEPENDENCY_TYPE_CONSUMES = DependencyType.CONSUMES; - - /** - * Creates this virtual reference in model, if it doesn't already exist. - * @param updateFlags Currently no update flags apply. - * @param aMonitor A progress monitor to track the completion of the operation - */ - public void create(int updateFlags, IProgressMonitor aMonitor); - - /** - * Returns whether this reference actual exists in the model - * @return whether this reference actual exists in the model - */ - public boolean exists(); - - /** - * The runtime path indicates where the contents of the referenced - * component will be absorbed within the context of the enclosing component. - * @param aRuntimePath A value component-relative path. - */ - public void setRuntimePath(IPath aRuntimePath); - /** - * The runtime path indicates where the contents of the referenced - * component will be absorbed within the context of the enclosing component. - * @return A value component-relative path. - */ - public IPath getRuntimePath(); - - /** - * The dependencyType indicates how the contents of the referenced component will be absorbed. - * @param aDependencyType One of DEPENDENCY_TYPE_USES or DEPENDENCY_TYPE_CONSUMES - * @see #DEPENDENCY_TYPE_CONSUMES - * @see #DEPENDENCY_TYPE_USES - */ - public void setDependencyType(int aDependencyType); - - - /** - * @return One of DEPENDENCY_TYPE_USES or DEPENDENCY_TYPE_CONSUMES - * @see #DEPENDENCY_TYPE_CONSUMES - * @see #DEPENDENCY_TYPE_USES - */ - public int getDependencyType(); - - /** - * The enclosing component contains this reference, and will absorb the contents of the referenced component - * @return The enclosing component - */ - public IVirtualComponent getEnclosingComponent(); - - /** - * The referenced component is "targeted" by the reference, and will be absorbed by the enclosing component. - * @return the referenced component. - */ - public IVirtualComponent getReferencedComponent(); - - /** - * Set the referenced component that is "targeted" by the reference and will be absorbed by the enclosing component. - * @param referencedComponent - */ - public void setReferencedComponent(IVirtualComponent referencedComponent, EObject dependentObject); - - - /** - * Get the archive name of the referenced component - * @return - */ - public String getArchiveName(); - - /** - * Set the archive name of the referenced component - * @param archiveName - */ - public void setArchiveName(String archiveName); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualResource.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualResource.java deleted file mode 100644 index eee8e16a0..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/IVirtualResource.java +++ /dev/null @@ -1,405 +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.wst.common.componentcore.resources; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; - - -/** - * <p> - * Allows clients to work with flexible project structures - * using API similar to the Eclipse Platform IResource model. - * </p> - * <p> - * IVirtualResource allows resources to be accessed through a - * abstract path referred to as a "runtime path". - * A virtual resource may represent multiple underlying resources. - * A virtual resource is contained by exactly one component. - * A resource may be represented by multiple virtual resources, which - * may be contained by one or more components. - * </p> - * <p> - * IVirtualResource allows clients to acquire - * information about the underlying resource including the name, - * and the paths which are relevant to the current resource, such - * as the {@link #getRuntimePath() runtime path}, the - * {@link #getWorkspaceRelativePath() workspace-relative path} - * of the underlying resource, and the - * {@link #getProjectRelativePath() project-relative path} - * of the underlying resource. - * </p> - * <a name="references" /> - * <p>Each IVirtualResource can represent an <b>implicit</b> reference or - * an <b>explicit</b> reference. An <b>explicit</b> reference is a formal - * mapping from some path within the file structure to a runtime path. Changing - * or removing an explicit reference only requires model modifications. An - * <b>implicit</b> reference has a root which is derived from an explicit path, - * but some fragment of the path towards the end is derived from the literal - * path within the file structure. Modifications to implicit paths may cause - * changes to structure on disk. For resource modifications that should not modify - * structures on disk, use {@link #IGNORE_UNDERLYING_RESOURCE}. - * </p> - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * @plannedfor 1.0 - */ -public interface IVirtualResource extends ISchedulingRule, IAdaptable { - - - /* - * ==================================================================== - * Constants defining resource types: There are four possible resource - * types and their type constants are in the hex range 0x10 to 0x80 - * as defined below. - * ==================================================================== - */ - - /** - * Type constant (bit mask value 16) which identifies file resources. - * - * @see IVirtualResource#getType() - * @see IVirtualFile - */ - public static final int FILE = 0x10; - - /** - * Type constant (bit mask value 32) which identifies folder resources. - * - * @see IVirtualResource#getType() - * @see IVirtualFolder - */ - public static final int FOLDER = 0x20; - - /** - * Type constant (bit mask value 64) which identifies the root resource. - * - * @see IVirtualResource#getType() - * @see IVirtualContainer - */ - public static final int COMPONENT = 0x40; - - /** - * General purpose zero-valued bit mask constant. Useful whenever you need to supply a bit mask - * with no bits set. - * <p> - * Example usage: <code> - * <pre> - * delete(IVirtualResource.NONE, null) - * </pre> - * </code> - * </p> - * - * @plannedfor 2.0 - */ - public static final int NONE = 0; - - /* - * ==================================================================== Constants for update - * flags for delete, move, copy, open, etc.: - * ==================================================================== - */ - - /** - * Update flag constant (bit mask value 256) indicating that the operation should proceed even if - * the resource is out of sync with the local file system. - * - * @plannedfor 2.0 - */ - public static final int FORCE = 0x100; - - /** - * Indicates that exclusions enumerated in the model should be ignored. (bit mask value 512) - */ - public static final int IGNORE_EXCLUSIONS = 0x200; - - /** - * Indicates that modifications should only modify the metamodel and ignore the underlying - * resources where applicable. See the - * <a href="IVirtualResource.html#references">documentation on references</a> - * for more information on why this flag is relevant. (bit mask value 1024) - */ - public static final int IGNORE_UNDERLYING_RESOURCE = 0x400; - - /** - * Create a mapping from the supplied location to the runtime path of this - * virtual resource. Model changes will occur as a result of this method, - * and potentially resource-level creations as well. - * - * @param aProjectRelativeLocation A project relative location that will be represented by the runtime path after this call - * @param updateFlags A bitmask of flags to supply to the method. - * @param monitor - * @throws CoreException - */ - public void createLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException; - - /** - * Removes the mapping, if it exists, from the supplied location to the runtime path of this - * virtual resource. Model changes will occur as a result of this method, - * and potentially resource-level creations as well. - * - * @param aProjectRelativeLocation A project relative location whose mapping to the runtime path of this object should be removed. - * @param updateFlags A bitmask of flags to supply to the method. - * @param monitor - * @throws CoreException - */ - public void removeLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException; - - - /** - * Remove the resource from the flexible structure. Removing the resource could require - * changes to the underlying metamodel or changes to the file structure. To avoid - * changes the actual disk structure, use {@link #IGNORE_UNDERLYING_RESOURCE}. - * <p> - * Update flags supplied to this method will be passed into any IResource modification - * API which is called as a result of this method's invocation. - * </p> - * @see #IGNORE_UNDERLYING_RESOURCE - * @see IResource#delete(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException; - - /** - * Compares two objects for equality; for resources, equality is defined in terms of their - * handles: same resource type, equal full paths, and identical workspaces. Resources are not - * equal to objects other than resources. - * - * @param other - * the other object - * @return an indication of whether the objects are equals - * @see #getType() - * @see #getWorkspaceRelativePath() - */ - public boolean equals(Object other); - - /** - * Returns whether this virtual resource is backed by an accessible IResource. - * <p> - * <code>IVirtualResource</code> objects are lightweight handle objects used to access - * IResources. However, having an IVirtualResource handle does not necessarily mean the - * underlying resource represented by the handle exists in the workspace, or is accessible. - * For more detailed information concerning the existence or accessibility of the underlying - * resource, {@link #getUnderlyingResource()}. - * </p> - * - * @return <code>true</code> if the underlying resource exists and is accessible, otherwise <code>false</code> - * @see org.eclipse.core.resources.IResource#exists() - * @see #getUnderlyingResource(); - */ - public boolean exists(); - - /** - * Returns the file extension portion of this virtual resource's name, or <code>null</code> if it does - * not have one. The file extension of the virtual resource will be returned, which may or may not match - * that of the underlying resource. - * <p> - * The file extension portion is defined as the string following the last period (".") character - * in the name. If there is no period in the name, the path has no file extension portion. If - * the name ends in a period, the file extension portion is the empty string. - * </p> - * <p> - * This is a resource handle operation; the resource need not exist. - * </p> - * - * @return a string file extension - * @see #getName() - */ - public String getFileExtension(); - - /** - * Returns the full, absolute path of the underlying resource relative to the workspace. - * <p> - * This is a resource handle operation; the resource need not exist. If this resource does - * exist, its path can be safely assumed to be valid. - * </p> - * - * @return the absolute path of this resource - * @see #getProjectRelativePath() - * @see IResource#getFullPath() - */ - public IPath getWorkspaceRelativePath(); - - - /** - * Returns a relative path of the underlying resource with respect to its project. - * <p> - * This is a resource handle operation; the resource need not exist. If this resource does - * exist, its path can be safely assumed to be valid. - * </p> - * <p> - * Project-relative paths are recommended over absolute paths, since the former are not affected - * if the project is renamed. - * </p> - * - * @return the relative path of this resource with respect to its project - * @see #getWorkspaceRelativePath() - * @see #getProject() - * @see IResource#getProjectRelativePath() - */ - public IPath getProjectRelativePath(); - - /** - * Returns the runtime path of this virtual resource. The runtime path - * is determined through the metamodel and represents the path that the - * underlying resource will be accessed at runtime. - * - * @return the runtime path of this virtual resource - */ - public IPath getRuntimePath(); - - /** - * Returns the name of this virtual resource. The name of a virtual resource - * is synonymous with the last segment of its runtime path. - * <p> - * This is a resource handle operation; the resource need not exist. - * </p> - * <p> - * If this resource exists, its name can be safely assumed to be valid. - * </p> - * - * @return the name of the virtual resource - * @see #getRuntimePath() - */ - public String getName(); - - /** - * Returns the name of the component that contains this virtual resource. - * <p> - * Each virtual resource is contained by at least one component. A component - * represents a logical collection of files. If the underlying resource is - * contained by multiple components, then the component name returned by - * this method will be determined by how the virtual resource was created. - * For each virtual resource, the component name will be the same as the - * component name of the parent. - * - * @return the name of the component that contains the virtual resource - */ - public IVirtualComponent getComponent(); - - /** - * Returns the virtual resource which contains this virtual resource, or <code>null</code> if it has - * no parent (that is, the virtual resource represents the root of the component). - * <p> - * The full path of the parent resource is the same as this resource's full path with the last - * segment removed. - * </p> - * <p> - * This is a resource handle operation; neither the resource nor the resulting resource need - * exist. - * </p> - * - * @return the container of the virtual resource, or <code>null</code> if this virtual resource represents the root of the component - */ - public IVirtualContainer getParent(); - - /** - * Returns the project which contains the component which contains this virtual resource. - * <p> - * The name of the project may not (and most likely will not) be referenced in the - * runtime path of this virtual path, but will be referenced by the workspace-relative path. - * </p> - * <p> - * This is a resource handle operation; neither the resource nor the resulting project need - * exist. - * </p> - * - * @return the project handle - */ - public IProject getProject(); - - /** - * Returns the type of this resource. The returned value will be one of <code>FILE</code>, - * <code>FOLDER</code>, <code>COMPONENT</code> - * <p> - * <ul> - * <li> All resources of type <code>FILE</code> implement <code>IVirtualFile</code>.</li> - * <li> All resources of type <code>FOLDER</code> implement <code>IVirtualFolder</code>.</li> - * <li> All resources of type <code>COMPONENT</code> implement <code>IVirtualContainer</code>.</li> - * </ul> - * </p> - * <p> - * This is a resource handle operation; the resource need not exist in the workspace. - * </p> - * - * @return the type of this resource - * @see #FILE - * @see #FOLDER - * @see #COMPONENT - */ - public int getType(); - - /** - * A virtual resource is a representation of one or more Eclipse Platform resources. - * <p> - * Returns the "primary" underlying resource. The resource may or may not exist. The resource - * will be contained by the project returned by {@link #getProject()}. - * </p> - * <p> - * Since a virtual resource could represent multiple resources, this method will return - * the "primary" resource. For clients that wish to take advantage of the multiple resources - * at a single path, use {@link #getUnderlyingResources()}. - * @return The primary resource that backs this virtual resource. - */ - public IResource getUnderlyingResource(); - - /** - * A virtual resource is a representation of one or more Eclipse Platform resources. - * <p> - * Returns all underlying resources. The resources may or may not exist. The resources - * will be contained by the project returned by {@link #getProject()}. - * </p> - * <p> - * Since a virtual resource could represent multiple resources, this method will return - * all underlying resources. For clients that prefer to acknowledge only one resource, - * at a single path, use {@link #getUnderlyingResource()}. - * @return All resources that back this virtual resource. - */ - public IResource[] getUnderlyingResources(); - - /** - * Returns whether this resource is accessible. For files and folders, this is equivalent to - * existing; for projects, this is equivalent to existing and being open. The workspace root is - * always accessible. - * - * @return <code>true</code> if this resource is accessible, and <code>false</code> - * otherwise - * @see #exists() - * @see IProject#isOpen() - */ - public boolean isAccessible(); - - /** - * The resourceType provides meta-information about the types of content this virtual resource may represent. Examples - * include "java", "resources", "bpel", etc. - * <p> - * The resourceType may be null, and {@link IVirtualComponent} will always return null for this method. - * </p> - * @return A client-set resourceType string - */ - public String getResourceType(); - - /** - * The resourceType provides meta-information about the types of content this virtual resource may represent. Examples - * include "java", "resources", "bpel", etc. - * <p> - * The resourceType may be null, and {@link IVirtualComponent} will always return null for this method. - * </p> - * @param A client-set resourceType string - */ - public void setResourceType(String aResourceType); - -} diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/package.html b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/package.html deleted file mode 100644 index d791ba2a3..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/package.html +++ /dev/null @@ -1,80 +0,0 @@ -<html> -<head> -<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -<link rel="stylesheet" href="../../../../..//apistyles.css" type="text/css"> -<title>modulecore resources api overview</title> -</head> -<body> -<p> - The ComponentCore Virtual Path API allows clients to navigate - logical collections of files within Eclipse projects using API - similar to the Eclipse IResource API. - </p> -<a name="top"></a><a name="virtual-path"></a> -<table width="100%" cellspacing="5" cellpadding="2" border="0"> -<tbody> -<tr> -<td valign="top" bgcolor="#0080c0" align="left" colspan="2"><b><font face="Arial,Helvetica" color="#ffffff">Virtual Path API</font></b></td> -</tr> -</tbody> -</table> -<BR> -<table width="500"> -<tr> -<td> -<p> - The Virtual Path API provides a facade to the flexible project model. - Each IVirtualResource represents a resource from the runtime component - under a virtual runtime path. Each IVirtualResource may represent one - or more Eclipse Platfrom resources located at the same runtime path. - </p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p> - Each IVirtualResource is contained by exactly one IVirtualComponent. - However, the underlying resources that are represented by the - IVirtualResource may be contained by multiple IVirtualComponents. - IVirtualComponents are contained by IFlexibleProjects. Each - IFlexibleProject may contain one or more IVirtualComponents. - </p> -</td> -</tr> -</table> -<table cellpadding="10" cellspacing="10"> -<tr> -<td> -<p> -<img src="../../../../../../overview/mapping.jpg"></p> -</td> -</tr> -<tr> -<td> -<p> -<i>Figure 1: A visual representation of a possible mapping between a Virtual structure and a Platform Resource structure.</i> -</p> -</td> -</tr> -</table> -<table cellpadding="10" cellspacing="10"> -<tr> -<td> -<p> -<img src="../../../../../../overview/virtual_path_api.jpg"></p> -</td> -</tr> -<tr> -<td> -<p> -<i>Figure 2: Virtual Path Model</i> -</p> -</td> -</tr> -</table> -<a href="#top">top</a> -</body> -</html> diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/package.xml b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/package.xml deleted file mode 100644 index 5999f55db..000000000 --- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/resources/package.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../" /> - <title>component core resources api overview</title> - </head> - - <body> - <abstract> - The ComponentCore Virtual Path API allows clients to navigate - logical collections of files within Eclipse projects using API - similar to the Eclipse IResource API. - </abstract> - - <a name="top"/> - <!-- - <p> - The following document includes information on these topics: - <ul> - <li><a href="#virtual-path">Pointer 1</a> A description</li> - </ul> - </p> - --> - <a name="virtual-path"/> - <h2>Virtual Path API</h2> - <BR /> - <p> - The Virtual Path API provides a facade to the flexible project model. - Each IVirtualResource represents a resource from the runtime component - under a virtual runtime path. Each IVirtualResource may represent one - or more Eclipse Platfrom resources located at the same runtime path. - </p> - <p> - Each IVirtualResource is contained by exactly one IVirtualComponent. - However, the underlying resources that are represented by the - IVirtualResource may be contained by multiple IVirtualComponents. - IVirtualComponents are contained by IFlexibleProjects. Each - IFlexibleProject may contain one or more IVirtualComponents. - </p> - <img src="../../../../../../overview/mapping.jpg" - caption="A visual representation of a possible mapping between a Virtual structure and a Platform Resource structure." - width="600" height="466" - /> - <img src="../../../../../../overview/virtual_path_api.jpg" caption="Virtual Path Model" /> - <!-- - <codesnippet caption="An example snippet."> -... -import org.eclipse.emf.common.util.URI; -... -public static void makeFlexible(IProject aTargetProject) { - ModuleCore moduleCoreInstance = null; - try { - ModuleCoreNature.addModuleCoreNatureIfNecessary(aTargetProject); - moduleCoreInstance = ModuleCore.getModuleCoreForWrite(aTargetProject); - ... work with moduleCoreInstance and underlying model ... - moduleCoreInstance.saveIfNecessary(aProgressMonitor); - } finally { - if (moduleCoreInstance != null) { - moduleCoreInstance.dispose(); - } - } -} - </codesnippet> - <codesnippet caption="An example snippet."> -... -import org.eclipse.emf.common.util.URI; -... -public static void makeFlexible(IProject aTargetProject) { - ModuleCore moduleCoreInstance = null; - try { - ModuleCoreNature.addModuleCoreNatureIfNecessary(aTargetProject); - moduleCoreInstance = ModuleCore.getModuleCoreForWrite(aTargetProject); - ... work with moduleCoreInstance and underlying model ... - moduleCoreInstance.saveIfNecessary(aProgressMonitor); - } finally { - if (moduleCoreInstance != null) { - moduleCoreInstance.dispose(); - } - } -} - </codesnippet> - --> - <a href="#top">top</a> - </body> -</html> -
\ No newline at end of file |