diff options
author | cbridgha | 2007-09-05 01:54:41 +0000 |
---|---|---|
committer | cbridgha | 2007-09-05 01:54:41 +0000 |
commit | f57f13b30eaf33ac1e145021c50ec2f62aba465c (patch) | |
tree | ff483c344b2836210bd551185d5455631512195b /plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal | |
parent | a8959cb8b1660fc6c53759d92c621c98ccf5fccf (diff) | |
download | webtools.javaee-200708050923.tar.gz webtools.javaee-200708050923.tar.xz webtools.javaee-200708050923.zip |
This commit was manufactured by cvs2svn to create tag 'v200708050923'.v200708050923
Diffstat (limited to 'plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal')
21 files changed, 0 insertions, 1756 deletions
diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/DelegateConfigurationElement.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/DelegateConfigurationElement.java deleted file mode 100644 index bf8bd47f9..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/DelegateConfigurationElement.java +++ /dev/null @@ -1,223 +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 - *******************************************************************************/ -/* - * Created on Dec 14, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.wst.web.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IContributor; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.InvalidRegistryObjectException; - -/** - * An object which represents the user-defined contents of an extension in a plug-in manifest. - */ -public class DelegateConfigurationElement implements IConfigurationElement { - - private final IConfigurationElement delegateElement; - private static final String DELEGATE_NAME = "delegateConfigurationElement"; //$NON-NLS-1$ - private static final String DELEGATE_NAMESPACE = "delegateConfigurationElementNamespace"; //$NON-NLS-1$ - private static final String DELEGATE_NULL_STRING = "delegateConfigurationElement: NULL"; //$NON-NLS-1$ - - public DelegateConfigurationElement(IConfigurationElement aDelegate) { - delegateElement = aDelegate; - } - - /** - * @param propertyName - * @return - * @throws org.eclipse.core.runtime.CoreException - */ - public Object createExecutableExtension(String propertyName) throws CoreException { - if (delegateElement == null) - return null; - return delegateElement.createExecutableExtension(propertyName); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (delegateElement == null) - return false; - return delegateElement.equals(obj); - } - - /** - * @param name - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getAttribute(String name) throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getAttribute(name); - } - - /** - * @param name - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getAttributeAsIs(String name) throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getAttributeAsIs(name); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String[] getAttributeNames() throws InvalidRegistryObjectException { - if (delegateElement == null) - return new String[0]; - return delegateElement.getAttributeNames(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public IConfigurationElement[] getChildren() throws InvalidRegistryObjectException { - if (delegateElement == null) - return new IConfigurationElement[0]; - return delegateElement.getChildren(); - } - - /** - * @param name - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public IConfigurationElement[] getChildren(String name) throws InvalidRegistryObjectException { - if (delegateElement == null) - return new IConfigurationElement[0]; - return delegateElement.getChildren(name); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public IExtension getDeclaringExtension() throws InvalidRegistryObjectException { - if (delegateElement == null) - throw new InvalidRegistryObjectException(); - return delegateElement.getDeclaringExtension(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getName() throws InvalidRegistryObjectException { - if (delegateElement == null) - return DELEGATE_NAME; - return delegateElement.getName(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getNamespace() throws InvalidRegistryObjectException { - if (delegateElement == null) - return DELEGATE_NAMESPACE; - return delegateElement.getNamespace(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public Object getParent() throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getParent(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getValue() throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getValue(); - } - - /** - * @return - * @throws org.eclipse.core.runtime.InvalidRegistryObjectException - */ - public String getValueAsIs() throws InvalidRegistryObjectException { - if (delegateElement == null) - return null; - return delegateElement.getValueAsIs(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - if (delegateElement == null) - return -1; - return delegateElement.hashCode(); - } - - /** - * @return - */ - public boolean isValid() { - - if (delegateElement == null) - return false; - return delegateElement.isValid(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - public String toString() { - if (delegateElement == null) - return DELEGATE_NULL_STRING; - return delegateElement.toString(); - } - - public IConfigurationElement toEquinox() { - // TODO Auto-generated method stub - return null; - } - - public IContributor getContributor() throws InvalidRegistryObjectException { - if (delegateElement == null) - throw new InvalidRegistryObjectException(); - return delegateElement.getContributor(); - } - - public String getNamespaceIdentifier() throws InvalidRegistryObjectException { - if (delegateElement == null) - return DELEGATE_NAMESPACE; - return delegateElement.getNamespaceIdentifier(); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ISimpleWebModuleConstants.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ISimpleWebModuleConstants.java deleted file mode 100644 index e58e26061..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ISimpleWebModuleConstants.java +++ /dev/null @@ -1,23 +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.web.internal; - - -public interface ISimpleWebModuleConstants -{ - public static final String PLUG_IN_ID = "org.eclipse.wst.web"; //$NON-NLS-1$ - public static final String STATIC_PROJECT_TYPE = "STATIC"; //$NON-NLS-1$ - public static final String CSS_DIRECTORY = "theme"; //$NON-NLS-1$ - public static final String INFO_DIRECTORY = "WEB-INF"; //$NON-NLS-1$ - public static final String LIBRARY_DIRECTORY = "lib"; //$NON-NLS-1$ - public static final String CLASSES_DIRECTORY = "classes"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IWSTWebPreferences.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IWSTWebPreferences.java deleted file mode 100644 index 0f4e7aab9..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IWSTWebPreferences.java +++ /dev/null @@ -1,13 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.wst.web.internal; - -public interface IWSTWebPreferences { - String PREF_STATICWEBCONTENT = "org.eclipse.jst.j2ee.preference.staticWebContentName"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ResourceHandler.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ResourceHandler.java deleted file mode 100644 index 87c27dc01..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ResourceHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.web.internal; - -import org.eclipse.osgi.util.NLS; - -public final class ResourceHandler extends NLS { - - private static final String BUNDLE_NAME = "staticwebproject";//$NON-NLS-1$ - - private ResourceHandler() { - // Do not instantiate - } - - public static String StaticWebProjectCreationWizard_Wizard_Title; - public static String StaticWebProjectWizardBasePage_Page_Description; - public static String StaticWebSettingsPropertiesPage_Web_Content_Label; - public static String StaticContextRootComposite_Context_Root_Label; - public static String StaticWebProjectWizardBasePage_Page_Title; - public static String StaticWebSettingsPropertiesPage_Not_available_for_closed_projects; - public static String TargetRuntime; - public static String NewDotDotDot; - public static String InvalidServerTarget; - public static String ConfigureSettings; - - static { - NLS.initializeMessages(BUNDLE_NAME, ResourceHandler.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WSTWebPlugin.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WSTWebPlugin.java deleted file mode 100644 index 024341573..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WSTWebPlugin.java +++ /dev/null @@ -1,68 +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.web.internal; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; - -/** - * The main plugin class to be used in the desktop. - */ -public class WSTWebPlugin extends Plugin -{ - //The shared instance. - private static WSTWebPlugin plugin; - - private WSTWebPreferences preferences; - - public static final String PLUGIN_ID = "com.ibm.etools.webtools.staticwebproject"; //$NON-NLS-1$ - public static final String VALIDATION_BUILDER_ID = ValidationPlugin.VALIDATION_BUILDER_ID; // plugin - - public static final String[] ICON_DIRS = new String[]{"icons/full/obj16", //$NON-NLS-1$ - "icons/full/ctool16", //$NON-NLS-1$ - "icons/full/wizban", //$NON-NLS-1$ - "icons", //$NON-NLS-1$ - ""}; //$NON-NLS-1$ - /** - * The constructor. - */ - public WSTWebPlugin() { - super(); - plugin = this; - } - - /** - * Returns the shared instance. - */ - public static WSTWebPlugin getDefault() - { - return plugin; - } - - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - protected void initializeDefaultPluginPreferences() { - getWSTWebPreferences().initializeDefaultPreferences(); - } - /** - * @return Returns the preferences. - */ - public WSTWebPreferences getWSTWebPreferences() { - if (this.preferences == null) - this.preferences = new WSTWebPreferences(this); - return this.preferences; - } -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WSTWebPreferences.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WSTWebPreferences.java deleted file mode 100644 index fd5256a05..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WSTWebPreferences.java +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ - -package org.eclipse.wst.web.internal; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Preferences; - -public class WSTWebPreferences { - public interface Keys { - final static String STATIC_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.staticWebContentName"; //$NON-NLS-1$ - } - public interface Values { - final static String STATIC_WEB_CONTENT = "WebContent"; //$NON-NLS-1$ - } - public interface Defaults { - final static String STATIC_WEB_CONTENT = Values.STATIC_WEB_CONTENT; - } - private Plugin owner = null; - private Preferences preferences = null; - private boolean persistOnChange = false; - - public WSTWebPreferences(Plugin owner) { - this.owner = owner; - } - protected void initializeDefaultPreferences() { - getPreferences().setDefault(Keys.STATIC_WEB_CONTENT, Defaults.STATIC_WEB_CONTENT); - } - - public String getStaticWebContentFolderName() { - return getPreferences().getString(Keys.STATIC_WEB_CONTENT); - } - - public void setStaticWebContentFolderName(String value) { - getPreferences().setValue(Keys.STATIC_WEB_CONTENT, value); - firePreferenceChanged(); - } - - public void firePreferenceChanged() { - if (isPersistOnChange()) - persist(); - } - - public void persist() { - getOwner().savePluginPreferences(); - } - - /** - * @return Returns the persistOnChange. - */ - public boolean isPersistOnChange() { - return this.persistOnChange; - } - - /** - * @param persistOnChange - * The persistOnChange to set. - */ - public void setPersistOnChange(boolean persistOnChange) { - this.persistOnChange = persistOnChange; - } - - private Preferences getPreferences() { - if (this.preferences == null) - this.preferences = getOwner().getPluginPreferences(); - return this.preferences; - } - - /** - * @return Returns the owner. - */ - private Plugin getOwner() { - return this.owner; - } -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WebPropertiesUtil.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WebPropertiesUtil.java deleted file mode 100644 index ef2498126..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WebPropertiesUtil.java +++ /dev/null @@ -1,108 +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.web.internal; - -import com.ibm.icu.util.StringTokenizer; - -public class WebPropertiesUtil { - private static final char[] BAD_CHARS = {'/', '\\', ':'}; - /** - * @param project - * org.eclipse.core.resources.IProject - */ - /** - * Returns a error message that states whether a context root is valid or not returns null if - * context root is fine - * - * @return java.lang.String - * @param contextRoot - * java.lang.String - */ - public static String validateContextRoot(String contextRoot) { - - if (contextRoot == null) - return null; - - String errorMessage = null; - - String name = contextRoot; - if (name.equals("") || name == null) { //$NON-NLS-1$ - // this was added because the error message shouldnt be shown initially. It should be - // shown only if context root field is edited to - errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title; - - //errorMessage = ProjectSupportResourceHandler.getString("Context_Root_cannot_be_empty_2"); //$NON-NLS-1$ - return errorMessage; - } - - /******************************************************************************************* - * // JZ - fix to defect 204264, "/" is valid in context root if (name.indexOf("//") != -1) { - * //$NON-NLS-1$ errorMessage = "// are invalid characters in a resource name"; return - * errorMessage; - * } - ******************************************************************************************/ - - if (name.trim().equals(name)) { - StringTokenizer stok = new StringTokenizer(name, "."); //$NON-NLS-1$ - outer : while (stok.hasMoreTokens()) { - String token = stok.nextToken(); - for (int i = 0; i < token.length(); i++) { - if (!(token.charAt(i) == '_') && !(token.charAt(i) == '-') && !(token.charAt(i) == '/') && Character.isLetterOrDigit(token.charAt(i)) == false) { - if (Character.isWhitespace(token.charAt(i))) { - //Removed because context roots can contain white space - //errorMessage = - // ResourceHandler.getString("_Context_root_cannot_conta_UI_");//$NON-NLS-1$ - // = " Context root cannot contain whitespaces." - } else { - errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title; - - //errorMessage = ProjectSupportResourceHandler.getString("The_character_is_invalid_in_a_context_root", new Object[]{(new Character(token.charAt(i))).toString()}); //$NON-NLS-1$ - break outer; - } - } - } - } - } // en/ end of if(name.trim - else - errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title; - //errorMessage = ProjectSupportResourceHandler.getString("Names_cannot_begin_or_end_with_whitespace_5"); //$NON-NLS-1$ - - return errorMessage; - } - - - /** - * Return true if the string contains any of the characters in the array. - */ - private static boolean contains(String str, char[] chars) { - for (int i = 0; i < chars.length; i++) { - if (str.indexOf(chars[i]) != -1) - return true; - } - return false; - } - - - public static String validateFolderName(String folderName) { - if (folderName.length() == 0) - return ResourceHandler.StaticWebProjectWizardBasePage_Page_Title; - - //return ProjectSupportResourceHandler.getString("Folder_name_cannot_be_empty_2"); //$NON-NLS-1$ - - if (contains(folderName, BAD_CHARS)) - return ResourceHandler.StaticWebProjectWizardBasePage_Page_Title; - - //return ProjectSupportResourceHandler.getString("Folder_name_is_not_valid", new Object[]{folderName}); //$NON-NLS-1$ - - return null; - } - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java deleted file mode 100644 index d351360d9..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java +++ /dev/null @@ -1,429 +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.web.internal.deployables; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.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.Path; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualContainer; -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.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.server.core.IModule; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.internal.ModuleFile; -import org.eclipse.wst.server.core.internal.ModuleFolder; -import org.eclipse.wst.server.core.model.IModuleFile; -import org.eclipse.wst.server.core.model.IModuleFolder; -import org.eclipse.wst.server.core.model.IModuleResource; -import org.eclipse.wst.server.core.util.ProjectModule; - -public abstract class ComponentDeployable extends ProjectModule { - - protected IVirtualComponent component = null; - protected List members = new ArrayList(); - - public ComponentDeployable(IProject project) { - this(project,ComponentCore.createComponent(project)); - } - - public ComponentDeployable(IProject project, IVirtualComponent aComponent) { - super(project); - this.component = aComponent; - } - - /** - * @see org.eclipse.jst.server.core.IJ2EEModule#isBinary() - */ - public boolean isBinary() { - if (component==null) - return false; - return component.isBinary(); - } - - /** - * Add the resources from mr to the existing resources in Module Folder mf - * @param ModuleFolder mf - * @param IModuleResource[] mr - */ - private void addMembersToModuleFolder(ModuleFolder mf, IModuleResource[] mr) { - // If the folder is null or the resources to add are null or empty, bail and return - if (mf == null || mr == null || mr.length==0) - return; - // Get the existing members in the module folder - IModuleResource[] mf_members = mf.members(); - int mf_size = 0; - // Get the length of the existing members in the module folder - if (mf_members != null) - mf_size = mf_members.length; - // Create a new array to set on the module folder which will combine the existing and - // new module resources - IModuleResource[] res = new IModuleResource[mf_size + mr.length]; - // Copy the existing members into the array if there are any - if (mf_members != null && mf_size > 0) - System.arraycopy(mf_members, 0, res, 0, mf_size); - // Copy the new members into the array - System.arraycopy(mr, 0, res, mf_size, mr.length); - // Set the new members array on the module folder - mf.setMembers(res); - } - - /** - * Returns the child modules of this module. - * - * @return org.eclipse.wst.server.core.model.IModule[] - */ - public IModule[] getChildModules() { - return getModules(); - } - - public IModule[] getModules() { - List modules = new ArrayList(); - if (component != null) { - IVirtualReference[] components = getReferences(component); - for (int i = 0; i < components.length; i++) { - IVirtualReference reference = components[i]; - if (reference != null && reference.getDependencyType()==IVirtualReference.DEPENDENCY_TYPE_USES) { - IVirtualComponent virtualComp = reference.getReferencedComponent(); - IModule module = gatherModuleReference(component, virtualComp); - if (module != null && !modules.contains(module)) - modules.add(module); - } - } - } - return (IModule[]) modules.toArray(new IModule[modules.size()]); - } - - protected IVirtualReference[] getReferences(IVirtualComponent aComponent) { - return aComponent.getReferences(); - } - - protected IModule gatherModuleReference(IVirtualComponent component, IVirtualComponent targetComponent ) { - // Handle workspace project module components - if (targetComponent != null && targetComponent.getProject()!=component.getProject()) { - if (!targetComponent.isBinary()) - return ServerUtil.getModule(targetComponent.getProject()); - } - return null; - } - - /** - * Find the module resources for a given container and path. Inserts in the java containers - * at a given path if not null. - * - * @param cont a container - * @param path the current module relative path - * @param javaPath the path where Java resources fit in the root - * @param javaCont - * @return a possibly-empty array of module resources - * @throws CoreException - */ - protected IModuleResource[] getMembers(IContainer cont, IPath path, IPath javaPath, IContainer[] javaCont) throws CoreException { - IResource[] res = cont.members(); - int size2 = res.length; - List list = new ArrayList(size2); - for (int j = 0; j < size2; j++) { - if (res[j] instanceof IContainer) { - IContainer cc = (IContainer) res[j]; - - IPath newPath = path.append(cc.getName()).makeRelative(); - // Retrieve already existing module folder if applicable - ModuleFolder mf = (ModuleFolder) getExistingModuleResource(members,newPath); - if (mf == null) { - mf = new ModuleFolder(cc, cc.getName(), path); - ModuleFolder parent = (ModuleFolder) getExistingModuleResource(members, path); - if (path.isEmpty()) - members.add(mf); - else { - if (parent == null) - parent = ensureParentExists(path, cc); - addMembersToModuleFolder(parent, new IModuleResource[] {mf}); - } - } - IModuleResource[] mr = getMembers(cc, newPath, javaPath, javaCont); - - if (javaPath != null && newPath.isPrefixOf(javaPath)) - mr = handleJavaPath(path, javaPath, newPath, javaCont, mr, cc); - - addMembersToModuleFolder(mf, mr); - - } else { - IFile f = (IFile) res[j]; - // Handle the default package case - if (path.equals(javaPath)) { - ModuleFolder mFolder = (ModuleFolder) getExistingModuleResource(members,javaPath); - IModuleFile mFile = createModuleFile(f, javaPath); - if (mFolder != null) - addMembersToModuleFolder(mFolder,new IModuleResource[]{mFile}); - else - list.add(mFile); - } else { - IModuleFile mf = createModuleFile(f, path); - list.add(mf); - } - } - } - IModuleResource[] mr = new IModuleResource[list.size()]; - list.toArray(mr); - return mr; - } - - protected IModuleFile createModuleFile(final IFile file, final IPath path) { - return new ModuleFile(file, file.getName(), path, file.getModificationStamp() + file.getLocalTimeStamp()); - } - - protected IModuleResource[] getMembers(IVirtualContainer cont, IPath path) throws CoreException { - IVirtualResource[] res = cont.members(); - int size2 = res.length; - List list = new ArrayList(size2); - for (int j = 0; j < size2; j++) { - if (res[j] instanceof IVirtualContainer) { - IVirtualContainer cc = (IVirtualContainer) res[j]; - // Retrieve already existing module folder if applicable - ModuleFolder mf = (ModuleFolder) getExistingModuleResource(members,path.append(new Path(cc.getName()).makeRelative())); - if (mf == null) { - mf = new ModuleFolder((IContainer)cc.getUnderlyingResource(), cc.getName(), path); - ModuleFolder parent = (ModuleFolder) getExistingModuleResource(members, path); - if (path.isEmpty()) - members.add(mf); - else { - if (parent == null) - parent = ensureParentExists(path, (IContainer)cc.getUnderlyingResource()); - addMembersToModuleFolder(parent, new IModuleResource[] {mf}); - } - } - IModuleResource[] mr = getMembers(cc, path.append(cc.getName())); - addMembersToModuleFolder(mf, mr); - } else { - IFile f = (IFile) res[j].getUnderlyingResource(); - IModuleFile mf = null; - if (shouldAddComponentFile(f)) { - mf = createModuleFile(f, path); - list.add(mf); - } - } - } - IModuleResource[] mr = new IModuleResource[list.size()]; - list.toArray(mr); - return mr; - } - - protected ModuleFolder ensureParentExists(IPath path, IContainer cc) { - ModuleFolder parent = (ModuleFolder) getExistingModuleResource(members, path); - if (parent == null) { - String folderName = path.lastSegment(); - IPath folderPath = Path.EMPTY; - if (path.segmentCount()>1) - folderPath = path.removeLastSegments(1); - parent = new ModuleFolder(cc, folderName, folderPath); - if (path.segmentCount()>1) - addMembersToModuleFolder(ensureParentExists(path.removeLastSegments(1),cc), new IModuleResource[] {parent}); - else - members.add(parent); - } - return parent; - } - - /** - * This method is meant to be overridden by subclasses. Return whether or not to add this file - * to the members list. - * - * @param file - * @return boolean should add file? - */ - protected boolean shouldAddComponentFile(IFile file) { - return true; - } - - /** - * Check the current cache to see if we already have an existing module resource for - * the given path. - * @param aList - * @param path - * @return an existing moduleResource from the cached result - */ - - protected IModuleResource getExistingModuleResource(List aList, IPath path) { - // If the list is empty, return null - if (aList==null || aList.isEmpty() || path == null) - return null; - // Otherwise recursively check to see if given resource matches current resource or if it is a child - String[] pathSegments = path.segments(); - IModuleResource moduleResource = null; - - if(pathSegments.length == 0) - return null; - for (Iterator iter = aList.iterator(); iter.hasNext();) { - moduleResource = (IModuleResource) iter.next(); - String[] moduleSegments = moduleResource.getModuleRelativePath().segments(); - // If the last segment in passed in path equals the module resource name - // and segment count is the same and the path segments start with the module path segments - // then we have a match and we return the existing moduleResource - if (pathSegments[pathSegments.length - 1].equals(moduleResource.getName()) && - (moduleSegments.length + 1) == pathSegments.length && - startsWith(moduleSegments, pathSegments)) - return moduleResource; - - // Otherwise, if it is a folder, check its children for the existing resource path - // but only check if the beginning segments are a match - if(moduleResource instanceof IModuleFolder && - startsWith(moduleSegments, pathSegments) && pathSegments.length > moduleSegments.length && - moduleResource.getName().equals(pathSegments[moduleSegments.length > 0 ? moduleSegments.length : 0])) - if (((IModuleFolder)moduleResource).members()!=null) - return getExistingModuleResource(Arrays.asList(((IModuleFolder)moduleResource).members()),path); - } - return null; - } - - /** - * - * @param beginningSegments - * @param testSegments - * @return True if beginningSegments[i] == testSegments[i] for all 0<=i<beginningSegments[i] - */ - private boolean startsWith(String[] beginningSegments, String[] testSegments) { - for(int i=0; i < beginningSegments.length; i++) { - if(!beginningSegments[i].equals(testSegments[i])) - return false; - } - return true; - } - - protected IModuleResource[] handleJavaPath(IPath path, IPath javaPath, IPath curPath, IContainer[] javaCont, IModuleResource[] mr, IContainer cc) throws CoreException { - //subclasses may override - return new IModuleResource[]{}; - } - - public IModuleResource[] members() throws CoreException { - members.clear(); - IVirtualComponent vc = ComponentCore.createComponent(getProject()); - if (vc != null) { - IVirtualFolder vFolder = vc.getRootFolder(); - IModuleResource[] mr = getMembers(vFolder, Path.EMPTY); - int size = mr.length; - for (int j = 0; j < size; j++) { - members.add(mr[j]); - } - addUtilMembers(vc); - } - - IModuleResource[] mr = new IModuleResource[members.size()]; - members.toArray(mr); - return mr; - } - - protected boolean shouldIncludeUtilityComponent(IVirtualComponent virtualComp, IVirtualReference[] components, ArtifactEdit edit) { - return virtualComp != null && virtualComp.isBinary() && virtualComp.getProject()==component.getProject(); - } - - protected void addUtilMembers(IVirtualComponent vc) { - ArtifactEdit edit = null; - try { - edit = getComponentArtifactEditForRead(); - IVirtualReference[] components = vc.getReferences(); - for (int i = 0; i < components.length; i++) { - IVirtualReference reference = components[i]; - IVirtualComponent virtualComp = reference.getReferencedComponent(); - if (shouldIncludeUtilityComponent(virtualComp,components,edit)) { - addUtilMember(vc, reference, reference.getRuntimePath()); - } - } - } finally { - if (edit!=null) - edit.dispose(); - } - } - - protected void addUtilMember(IVirtualComponent parent, IVirtualReference reference, IPath runtimePath) { - IModuleFile mf = null; - final String archiveName = reference.getArchiveName(); - final IVirtualComponent virtualComp = reference.getReferencedComponent(); - final IPath archivePath = ((VirtualArchiveComponent)virtualComp).getWorkspaceRelativePath(); - if (archivePath != null) { //In Workspace - IFile utilFile = ResourcesPlugin.getWorkspace().getRoot().getFile(archivePath); - String name = null != archiveName ? archiveName : utilFile.getName(); - mf = new ModuleFile(utilFile, name, runtimePath.makeRelative()); - } else { - File extFile = ((VirtualArchiveComponent)virtualComp).getUnderlyingDiskFile(); - String name = null != archiveName ? archiveName : extFile.getName(); - mf = new ModuleFile(extFile, name, runtimePath.makeRelative()); - } - if (mf == null) { - return; - } - IModuleResource moduleParent = getExistingModuleResource(members, mf.getModuleRelativePath()); - if (moduleParent != null && moduleParent instanceof ModuleFolder) { - addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[]{mf}); - } else { - if (mf.getModuleRelativePath().isEmpty()) { - members.add(mf); - } else { - if (moduleParent == null) { - moduleParent = ensureParentExists(mf.getModuleRelativePath(), (IContainer)parent.getRootFolder().getUnderlyingResource()); - } - addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[] {mf}); - } - } - } - - protected ArtifactEdit getComponentArtifactEditForRead() { - return null; - } - - protected static 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; - } - - /** - * Returns the root folders for the resources in this module. - * - * @return a possibly-empty array of resource folders - */ - public IContainer[] getResourceFolders() { - IVirtualComponent vc = ComponentCore.createComponent(getProject()); - if (vc != null) { - IVirtualFolder vFolder = vc.getRootFolder(); - if (vFolder != null) - return vFolder.getUnderlyingFolders(); - } - return new IContainer[]{}; - } - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/IStaticWebModuleArtifact.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/IStaticWebModuleArtifact.java deleted file mode 100644 index 7fd5bfb59..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/IStaticWebModuleArtifact.java +++ /dev/null @@ -1,14 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ - -package org.eclipse.wst.web.internal.deployables; - -public interface IStaticWebModuleArtifact { - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployable.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployable.java deleted file mode 100644 index 98720770b..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployable.java +++ /dev/null @@ -1,68 +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.web.internal.deployables; - -import java.util.Properties; - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -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.server.core.IModule; -import org.eclipse.wst.server.core.util.IStaticWeb; - -public class StaticWebDeployable extends ComponentDeployable implements IStaticWeb { - - public StaticWebDeployable(IProject project, IVirtualComponent component) { - super(project); - } - - public String getContextRoot() { - Properties props = component.getMetaProperties(); - if(props.containsKey("context-root")) //$NON-NLS-1$ - return props.getProperty("context-root"); //$NON-NLS-1$ - return component.getName(); - } - - public String getURI(IModule module) { - IVirtualComponent comp = ComponentCore.createComponent(module.getProject()); - String aURI = null; - if (comp !=null) { - if (!comp.isBinary() && isProjectOfType(module.getProject(),IModuleConstants.WST_WEB_MODULE)) { - IVirtualReference ref = component.getReference(comp.getName()); - aURI = ref.getRuntimePath().append(comp.getName()+".war").toString(); //$NON-NLS-1$ - } - } - - if (aURI !=null && aURI.length()>1 && aURI.startsWith("/")) //$NON-NLS-1$ - aURI = aURI.substring(1); - return aURI; - } - - public String getVersion() { - IFacetedProject facetedProject = null; - try { - facetedProject = ProjectFacetsManager.create(component.getProject()); - if (facetedProject !=null && ProjectFacetsManager.isProjectFacetDefined(IModuleConstants.WST_WEB_MODULE)) { - IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(IModuleConstants.WST_WEB_MODULE); - return facetedProject.getInstalledVersion(projectFacet).getVersionString(); - } - } catch (Exception e) { - //Ignore - } - return "1.0"; //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableFactory.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableFactory.java deleted file mode 100644 index e6e0474bf..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableFactory.java +++ /dev/null @@ -1,134 +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.web.internal.deployables; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -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.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleDelegate; -import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate; - -public class StaticWebDeployableFactory extends ProjectModuleFactoryDelegate { - private static final String ID = "org.eclipse.wst.web.internal.deployables.static"; //$NON-NLS-1$ - protected ArrayList moduleDelegates = new ArrayList(); - - /* - * @see DeployableProjectFactoryDelegate#getFactoryID() - */ - public static String getFactoryId() { - return ID; - } - protected IModule[] createModules(ModuleCoreNature nature) { - IProject project = nature.getProject(); - try { - IVirtualComponent comp = ComponentCore.createComponent(project); - return createModuleDelegates(comp); - } catch (Exception e) { - Logger.getLogger().write(e); - } - return null; - } - /** - * Returns true if the project represents a deployable project of this type. - * - * @param project - * org.eclipse.core.resources.IProject - * @return boolean - */ - protected boolean isValidModule(IProject project) { - try { - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - if (facetedProject == null) - return false; - IProjectFacet webFacet = ProjectFacetsManager.getProjectFacet(IModuleConstants.WST_WEB_MODULE); - return facetedProject.hasProjectFacet(webFacet); - } catch (Exception e) { - return false; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModuleDelegate(org.eclipse.wst.server.core.IModule) - */ - public ModuleDelegate getModuleDelegate(IModule module) { - for (Iterator iter = moduleDelegates.iterator(); iter.hasNext();) { - ModuleDelegate element = (ModuleDelegate) iter.next(); - if (module == element.getModule()) - return element; - } - return null; - - } - - protected IModule[] createModules(IProject project) { - try { - ModuleCoreNature nature = (ModuleCoreNature) project.getNature(IModuleConstants.MODULE_NATURE_ID); - if (nature != null) - return createModules(nature); - } catch (CoreException e) { - Logger.getLogger().write(e); - } - return null; - } - - protected IModule[] createModuleDelegates(IVirtualComponent component) throws CoreException { - StaticWebDeployable moduleDelegate = null; - IModule module = null; - try { - if(isValidModule(component.getProject())) { - moduleDelegate = new StaticWebDeployable(component.getProject(),component); - module = createModule(component.getName(), component.getName(), IModuleConstants.WST_WEB_MODULE, moduleDelegate.getVersion(), moduleDelegate.getProject()); - moduleDelegate.initialize(module); - } - } catch (Exception e) { - Logger.getLogger().write(e); - } finally { - if (module != null) { - if (getModuleDelegate(module) == null) - moduleDelegates.add(moduleDelegate); - } - } - if (module == null) - return null; - return new IModule[] {module}; - } - - /** - * Returns the list of resources that the module should listen to - * for state changes. The paths should be project relative paths. - * Subclasses can override this method to provide the paths. - * - * @return a possibly empty array of paths - */ - protected IPath[] getListenerPaths() { - return new IPath[] { - new Path(".project"), // nature //$NON-NLS-1$ - new Path(StructureEdit.MODULE_META_FILE_NAME), // component - new Path(".settings/org.eclipse.wst.common.project.facet.core.xml") // facets //$NON-NLS-1$ - }; - } -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapter.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapter.java deleted file mode 100644 index f29938eb6..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ - -package org.eclipse.wst.web.internal.deployables; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate; - -public class StaticWebDeployableObjectAdapter extends ModuleArtifactAdapterDelegate implements IAdapterFactory - -{ - - public StaticWebDeployableObjectAdapter() { - super(); - } - - public Object getAdapter(Object adaptableObject, Class adapterType) { - return null; - } - - public Class[] getAdapterList() { - return new Class[]{IStaticWebModuleArtifact.class}; - } - - public IModuleArtifact getModuleArtifact(Object obj) { - return StaticWebDeployableObjectAdapterUtil.getModuleObject(obj); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapterUtil.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapterUtil.java deleted file mode 100644 index f179163d0..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapterUtil.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.web.internal.deployables; - -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.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -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.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.util.WebResource; - -public class StaticWebDeployableObjectAdapterUtil { - - private final static String[] extensionsToExclude = new String[]{"sql", "xmi"}; //$NON-NLS-1$ //$NON-NLS-2$ - static String INFO_DIRECTORY = "WEB-INF"; //$NON-NLS-1$ - - public static IModuleArtifact getModuleObject(Object obj) { - IResource resource = null; - if (obj instanceof IResource) - resource = (IResource) obj; - else if (obj instanceof IAdaptable) - resource = (IResource) ((IAdaptable) obj).getAdapter(IResource.class); - - if (resource == null) - return null; - - if (resource instanceof IProject) { - IProject project = (IProject) resource; - if (hasInterestedComponents(project)) - return new WebResource(getModule(project), new Path("")); //$NON-NLS-1$ - return null; - } - - IProject project = ProjectUtilities.getProject(resource); - if (project != null && !hasInterestedComponents(project)) - return null; - - IVirtualComponent comp = ComponentCore.createComponent(project); - // determine path - IPath rootPath = comp.getRootFolder().getProjectRelativePath(); - IPath resourcePath = resource.getProjectRelativePath(); - - // Check to make sure the resource is under the webApplication directory - if (resourcePath.matchingFirstSegments(rootPath) != rootPath.segmentCount()) - return null; - - // Do not allow resource under the web-inf directory - resourcePath = resourcePath.removeFirstSegments(rootPath.segmentCount()); - if (resourcePath.segmentCount() > 1 && resourcePath.segment(0).equals(INFO_DIRECTORY)) - return null; - - if (shouldExclude(resource)) - return null; - - // return Web resource type - return new WebResource(getModule(project), resourcePath); - - } - - /** - * Method shouldExclude. - * - * @param resource - * @return boolean - */ - private static boolean shouldExclude(IResource resource) { - String fileExt = resource.getFileExtension(); - - // Exclude files of certain extensions - for (int i = 0; i < extensionsToExclude.length; i++) { - String extension = extensionsToExclude[i]; - if (extension.equalsIgnoreCase(fileExt)) - return true; - } - return false; - } - - protected static IModule getModule(IProject project) { - if (hasInterestedComponents(project)) - return ServerUtil.getModule(project); - return null; - } - - protected static boolean hasInterestedComponents(IProject project) { - return isProjectOfType(project, IModuleConstants.WST_WEB_MODULE); - } - - protected static 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; - } -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/ILibModule.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/ILibModule.java deleted file mode 100644 index 9a0954e06..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/ILibModule.java +++ /dev/null @@ -1,30 +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.web.internal.operation; - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface/method/field - * - * @deprecated - * - */ -public interface ILibModule extends DoNotUseMeThisWillBeDeletedPost15{ - String getJarName(); - - String getProjectName(); - - String getURI(); - - IProject getProject(); -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/ISimpleWebModuleCreationDataModelProperties.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/ISimpleWebModuleCreationDataModelProperties.java deleted file mode 100644 index acd55ff2c..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/ISimpleWebModuleCreationDataModelProperties.java +++ /dev/null @@ -1,30 +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.web.internal.operation; - -import org.eclipse.wst.common.componentcore.datamodel.properties.IComponentCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - */ -public interface ISimpleWebModuleCreationDataModelProperties extends IComponentCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15 { - - /** - * Optional, type String, the user defined name of web contents folder - */ - public static final String WEBCONTENT_FOLDER = "IWebComponentCreationDataModelProperties.WEBCONTENT_FOLDER"; //$NON-NLS-1$ - - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IWebProjectPropertiesUpdateDataModelProperties.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IWebProjectPropertiesUpdateDataModelProperties.java deleted file mode 100644 index fdc78bed0..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IWebProjectPropertiesUpdateDataModelProperties.java +++ /dev/null @@ -1,20 +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.web.internal.operation; - - - -public interface IWebProjectPropertiesUpdateDataModelProperties { - - public static final String PROJECT = "IWebProjectPropertiesUpdateDataModelProperties.PROJECT"; //$NON-NLS-1$ - public static final String CONTEXT_ROOT = "IWebProjectPropertiesUpdateDataModelProperties.CONTEXT_ROOT"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/LibModule.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/LibModule.java deleted file mode 100644 index 0a555a723..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/LibModule.java +++ /dev/null @@ -1,78 +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.web.internal.operation; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.web.internal.ISimpleWebModuleConstants; -import org.eclipse.wst.web.internal.WSTWebPlugin; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface/method/field - * - * @deprecated - * - */ -public class LibModule implements ILibModule, DoNotUseMeThisWillBeDeletedPost15 { - protected static final IPath LIB_PATH = new Path(ISimpleWebModuleConstants.INFO_DIRECTORY).append(ISimpleWebModuleConstants.LIBRARY_DIRECTORY); - - private String jarName; - private String projectName; - - public LibModule(String jarName, String projectName) { - this.jarName = jarName; - this.projectName = projectName; - } - - /* - * @see ILibModule#getJarName() - */ - public String getJarName() { - return jarName; - } - - /* - * @see ILibModule#getProjectName() - */ - public String getProjectName() { - return projectName; - } - - /* - * @see ILibModule#getProject() - */ - public IProject getProject() { - return (IProject) WSTWebPlugin.getWorkspace().getRoot().findMember(projectName); - } - - /** - * @see ILibModule#getURI() - */ - public String getURI() { - return IPath.SEPARATOR + LIB_PATH.append(getJarName()).toString(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (obj == null || !(obj instanceof ILibModule)) { - return false; - } - ILibModule module = (ILibModule) obj; - return getJarName().equals(module.getJarName()) && getProjectName().equals(module.getProjectName()) && getURI().equals(module.getURI()) && getProject().equals(module.getProject()); - } - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationDataModelProvider.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationDataModelProvider.java deleted file mode 100644 index 7d1bcd956..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationDataModelProvider.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.web.internal.operation; - -import java.util.List; -import java.util.Set; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.wst.common.componentcore.datamodel.FlexibleProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationProperties; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - */ -public class SimpleWebModuleCreationDataModelProvider extends ComponentCreationDataModelProvider implements ISimpleWebModuleCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15{ - - public SimpleWebModuleCreationDataModelProvider() { - super(); - } - - public void init() { - super.init(); - } - - public IDataModelOperation getDefaultOperation() { - return new StaticWebModuleCreationFacetOperation(model); - } - - protected EClass getComponentType() { - // TODO Auto-generated method stub - return null; - } - - protected Integer getDefaultComponentVersion() { - // TODO Auto-generated method stub - return null; - } - - protected String getComponentExtension() { - return ".war"; //$NON-NLS-1$ - } - - protected void initProjectCreationModel() { - IDataModel dm = DataModelFactory.createDataModel(new FlexibleProjectCreationDataModelProvider()); - model.addNestedModel(NESTED_PROJECT_CREATION_DM, dm); - model.setProperty(LOCATION, dm.getProperty(IProjectCreationProperties.PROJECT_LOCATION)); - } - - protected List getProperties() { - // TODO Auto-generated method stub - return null; - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(WEBCONTENT_FOLDER); - return propertyNames; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(WEBCONTENT_FOLDER)) - return "WebContent"; //$NON-NLS-1$ - return super.getDefaultProperty(propertyName); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean result = super.propertySet(propertyName, propertyValue); - if (propertyName.equals(PROJECT_NAME)) - setProperty(COMPONENT_NAME,propertyValue); - return result; - } - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/StaticWebModuleCreationFacetOperation.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/StaticWebModuleCreationFacetOperation.java deleted file mode 100644 index 4259673a2..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/StaticWebModuleCreationFacetOperation.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.web.internal.operation; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IComponentCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.project.facet.ISimpleWebFacetInstallDataModelProperties; -import org.eclipse.wst.project.facet.SimpleWebFacetInstallDataModelProvider; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - */ -public class StaticWebModuleCreationFacetOperation extends AbstractDataModelOperation implements DoNotUseMeThisWillBeDeletedPost15 { - - public StaticWebModuleCreationFacetOperation(IDataModel dataModel) { - super(dataModel); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) { - - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - String projectName = model.getStringProperty(IComponentCreationDataModelProperties.PROJECT_NAME); - - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projectName); - - FacetDataModelMap map = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - map.add(setupWebInstallAction()); - - IStatus stat = OK_STATUS; - try { - stat = dm.getDefaultOperation().execute(monitor, info); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - return stat; - } - - protected IDataModel setupWebInstallAction() { - String versionStr = "1.0"; //$NON-NLS-1$ - IDataModel webFacetInstallDataModel = DataModelFactory.createDataModel(new SimpleWebFacetInstallDataModelProvider()); - webFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, model.getStringProperty(IComponentCreationDataModelProperties.PROJECT_NAME)); - webFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, versionStr); - webFacetInstallDataModel.setProperty(ISimpleWebFacetInstallDataModelProperties.CONTENT_DIR, model.getStringProperty(ISimpleWebModuleCreationDataModelProperties.WEBCONTENT_FOLDER)); - - return webFacetInstallDataModel; - } -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebProjectPropertiesUpdateDataModelProvider.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebProjectPropertiesUpdateDataModelProvider.java deleted file mode 100644 index 9f9287b3f..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebProjectPropertiesUpdateDataModelProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.eclipse.wst.web.internal.operation; - -/******************************************************************************* - * Copyright (c) 2003, 2004, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -import java.util.Set; - -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class WebProjectPropertiesUpdateDataModelProvider - extends AbstractDataModelProvider - implements IWebProjectPropertiesUpdateDataModelProperties{ - - public WebProjectPropertiesUpdateDataModelProvider(){ - super(); - } - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(PROJECT); - names.add(CONTEXT_ROOT); - return names; - } - - public IDataModelOperation getDefaultOperation() { - return new WebProjectPropertiesUpdateOperation(model); - } - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebProjectPropertiesUpdateOperation.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebProjectPropertiesUpdateOperation.java deleted file mode 100644 index f56011808..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebProjectPropertiesUpdateOperation.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.eclipse.wst.web.internal.operation; - -/******************************************************************************* - * Copyright (c) 2003, 2004, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -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.internal.util.ComponentUtilities; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - - - -/** - * @version 1.0 - * @author - */ -public class WebProjectPropertiesUpdateOperation - extends AbstractDataModelOperation - implements IWebProjectPropertiesUpdateDataModelProperties{ - - - public WebProjectPropertiesUpdateOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - IProject project = (IProject)model.getProperty( IWebProjectPropertiesUpdateDataModelProperties.PROJECT ); - String contextRoot = model.getStringProperty( IWebProjectPropertiesUpdateDataModelProperties.CONTEXT_ROOT ); - if (contextRoot != null) { - ComponentUtilities.setServerContextRoot(project, contextRoot); - } - return OK_STATUS; - } - -} |