diff options
author | cbridgha | 2005-05-18 23:11:28 +0000 |
---|---|---|
committer | cbridgha | 2005-05-18 23:11:28 +0000 |
commit | 08bd5b116ab8d104f7e10f99cab36138b816c0cf (patch) | |
tree | 478a2573d3944057cd49a07ac116eac1d13df1c9 /plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal | |
parent | d68dc36dddf09e655260f68e2b6374a16bb1ae61 (diff) | |
download | webtools.javaee-N20050519.tar.gz webtools.javaee-N20050519.tar.xz webtools.javaee-N20050519.zip |
This commit was manufactured by cvs2svn to create tag 'N20050519'.N20050519
Diffstat (limited to 'plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal')
23 files changed, 0 insertions, 2605 deletions
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 f2afbb883..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ISimpleWebModuleConstants.java +++ /dev/null @@ -1,17 +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 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$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ISimpleWebNatureConstants.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ISimpleWebNatureConstants.java deleted file mode 100644 index 85035d415..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ISimpleWebNatureConstants.java +++ /dev/null @@ -1,28 +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.IPath; -import org.eclipse.core.runtime.Path; - -public interface ISimpleWebNatureConstants { - java.lang.String STATIC_CONTEXT_ROOT = "/"; //$NON-NLS-1$ - String STATIC_NATURE_ID = "org.eclipse.wst.web" + ".StaticWebNature"; //$NON-NLS-1$ //$NON-NLS-2$ - int STATIC_WEB_PROJECT = 0; - - String CSS_DIRECTORY = "theme"; //$NON-NLS-1$ - String INFO_DIRECTORY = "WEB-INF"; //$NON-NLS-1$ - String LIBRARY_DIRECTORY = "lib"; //$NON-NLS-1$ - String WEB_MODULE_DIRECTORY_V4 = "webApplication";//$NON-NLS-1$ - String WEBSETTINGS_FILE_NAME = ".j2ee"; //$NON-NLS-1$ - String WEB_MODULE_DIRECTORY_ = "Web Content";//$NON-NLS-1$ - IPath WEB_MODULE_PATH_V4 = new Path(WEB_MODULE_DIRECTORY_V4); - IPath WEB_MODULE_PATH_ = new Path(WEB_MODULE_DIRECTORY_); -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IStaticWebNatureConstants.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IStaticWebNatureConstants.java deleted file mode 100644 index 506ddd80d..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IStaticWebNatureConstants.java +++ /dev/null @@ -1,22 +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 IStaticWebNatureConstants { - java.lang.String STATIC_CONTEXT_ROOT = "/"; //$NON-NLS-1$ - String STATIC_NATURE_ID = "org.eclipse.jst.j2ee.web" + ".StaticWebNature"; //$NON-NLS-1$ //$NON-NLS-2$ - int STATIC_WEB_PROJECT = 0; - - String CSS_DIRECTORY = "theme"; //$NON-NLS-1$ - String INFO_DIRECTORY = "WEB-INF"; //$NON-NLS-1$ - String LIBRARY_DIRECTORY = "lib"; //$NON-NLS-1$ - String WEB_MODULE_DIRECTORY_V4 = "webApplication";//$NON-NLS-1$ - String WEBSETTINGS_FILE_NAME = ".websettings"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IStaticWebProjectConstants.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IStaticWebProjectConstants.java deleted file mode 100644 index ad1ffe9bd..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/IStaticWebProjectConstants.java +++ /dev/null @@ -1,17 +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 IStaticWebProjectConstants -{ - 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$ -}
\ No newline at end of file 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 439098116..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/ResourceHandler.java +++ /dev/null @@ -1,38 +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 java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class ResourceHandler -{ - private static final String BUNDLE_NAME = "staticwebproject";//$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private ResourceHandler() { - //Default constructor - } - - public static String getString(String key) - { - // TODO Auto-generated method stub - try - { - return RESOURCE_BUNDLE.getString(key); - } - catch( MissingResourceException e ) - { - return '!' + key + '!'; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/SimpleWebNatureRuntimeUtilities.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/SimpleWebNatureRuntimeUtilities.java deleted file mode 100644 index 5b5f40e41..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/SimpleWebNatureRuntimeUtilities.java +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.wst.web.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.web.internal.operation.IStaticWebNature; -import org.eclipse.wst.web.internal.operation.StaticWebNatureRuntime; - -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; - - -public class SimpleWebNatureRuntimeUtilities { - /** - * WebNatureRuntimeHelper constructor comment. - */ - public SimpleWebNatureRuntimeUtilities() { - super(); - } - - /** - * Adds a nauture to a project - */ - protected static void addNatureToProject(IProject proj, String natureId) throws CoreException { - ProjectUtilities.addNatureToProject(proj, natureId); - } - - /** - * Creation date: (10/22/2001 2:17:25 PM) - * - * @return org.eclipse.jst.j2ee.internal.internal.internal.web.operations.IBaseWebNature - */ - public static IStaticWebNature getRuntime(IProject project) { - if (project == null) - return null; - try { - IStaticWebNature nature = null; - if (project.hasNature(ISimpleWebNatureConstants.STATIC_NATURE_ID)) - nature = (IStaticWebNature) project.getNature(ISimpleWebNatureConstants.STATIC_NATURE_ID); - return nature; - } catch (CoreException e) { - return null; - } - } - - /** - * Return the J2EE Web Nature for the given project. If the the project does not have a J2EE Web - * Nature, then return null. - * - * @param project - * The project to get the nature from - * @return IJ2EEWebNature The J2EE Web Nature - */ - public static StaticWebNatureRuntime getStaticRuntime(IProject project) { - IStaticWebNature nature = getRuntime(project); - if (nature != null) { - if (nature.isStatic()) - return (StaticWebNatureRuntime) nature; - } - return null; - } - - /** - * Return whether or not the project has a runtime created on it. - * - * @return boolean - * @param project - * com.ibm.itp.core.api.resources.IProject - */ - public static boolean hasStaticRuntime(IProject project) { - if (project == null || !project.exists()) { - return false; - } - try { - return project.hasNature(ISimpleWebNatureConstants.STATIC_NATURE_ID); - } catch (CoreException e) { - return false; - } - } - - public static String getDefaultStaticWebContentName() { - return WSTWebPlugin.getDefault().getWSTWebPreferences().getStaticWebContentFolderName(); - } - - public static String getContextRootFromWebProject(IProject project) { - - // get uri from web app display name, and get context root from web nature - IStaticWebNature nature = SimpleWebNatureRuntimeUtilities.getRuntime(project); - String contextRoot = ""; //$NON-NLS-1$ - contextRoot = nature.getContextRoot(); - - // WebEditModel webEditModel = null; - // try { - // webEditModel = (nature.isStatic()) - // ? null - // : - // ((J2EEWebNatureRuntime)nature).getWebAppEditModelForRead(WebNatureRuntimeUtilities.this); - // contextRoot = nature.getContextRoot(); - // } catch (Exception e) { - // e.printStackTrace(); - // } - // finally { - // if (webEditModel != null) - // webEditModel.releaseAccess(WebNatureRuntimeUtilities.this); - // } - return contextRoot; - } - -}
\ 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 df141bdcc..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WSTWebPlugin.java +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ - -package org.eclipse.wst.web.internal; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; -import org.osgi.framework.Bundle; - -/** - * The main plugin class to be used in the desktop. - */ -public class WSTWebPlugin extends AbstractUIPlugin -{ - //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; - } - /** - * This gets a .gif from the icons folder. - */ - public ImageDescriptor getImageDescriptor(String key) { - ImageDescriptor imageDescriptor = null; - URL gifImageURL = getImageURL(key, getBundle()); - if (gifImageURL != null) - imageDescriptor = ImageDescriptor.createFromURL(gifImageURL); - return imageDescriptor; - } - /** - * This gets a .gif from the icons folder. - */ - public static URL getImageURL(String key, Bundle bundle) { - String gif = "/" + key + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$ - IPath path = null; - for (int i = 0; i < ICON_DIRS.length; i++) { - path = new Path(ICON_DIRS[i]).append(gif); - if (bundle.getEntry(path.toString()) == null) - continue; - try { - return new URL(bundle.getEntry("/"), path.toString()); - } catch (MalformedURLException exception) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning("Load_Image_Error_"); //$NON-NLS-1$ - exception.printStackTrace(); - continue; - } - } - return null; - } - - 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; - } -}
\ No newline at end of file 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 7a3cc4303..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/WebPropertiesUtil.java +++ /dev/null @@ -1,106 +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 java.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.getString("StaticWebProjectWizardBasePage.Page_Title"); //$NON-NLS-1$ - - //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.getString("StaticWebProjectWizardBasePage.Page_Title"); //$NON-NLS-1$ - - //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.getString("StaticWebProjectWizardBasePage.Page_Title"); //$NON-NLS-1$ - //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.getString("StaticWebProjectWizardBasePage.Page_Title"); //$NON-NLS-1$ - - //return ProjectSupportResourceHandler.getString("Folder_name_cannot_be_empty_2"); //$NON-NLS-1$ - - if (contains(folderName, BAD_CHARS)) - return ResourceHandler.getString("StaticWebProjectWizardBasePage.Page_Title"); //$NON-NLS-1$ - - //return ProjectSupportResourceHandler.getString("Folder_name_is_not_valid", new Object[]{folderName}); //$NON-NLS-1$ - - return null; - } - -}
\ No newline at end of file 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 49ee452b4..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/IStaticWebModuleArtifact.java +++ /dev/null @@ -1,6 +0,0 @@ -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 d319eb5c2..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployable.java +++ /dev/null @@ -1,119 +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.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.util.IStaticWeb; -import org.eclipse.wst.server.core.util.ProjectModule; -import org.eclipse.wst.web.internal.ISimpleWebNatureConstants; -import org.eclipse.wst.web.internal.SimpleWebNatureRuntimeUtilities; -import org.eclipse.wst.web.internal.operation.IStaticWebNature; - -public class StaticWebDeployable extends ProjectModule implements IStaticWeb { - - public StaticWebDeployable(IProject project) { - super(project); - setWebNature(getStaticWebNature()); - } - - /** - * TODO Changed setModule to setProject to react to changes in IStaticWebNature. Verify if this change is correct. - * @param staticWebNature - */ - private void setWebNature(IStaticWebNature nature) { - nature.setProject(getProject()); - } - - public String getFactoryId() { - return "org.eclipse.jst.j2ee.internal.internal.internal.web.deployables.static"; //$NON-NLS-1$ - } - - /** - * Returns true if this deployable currently exists, and false if it has been deleted or moved - * and is no longer represented by this deployable. - * - * @return boolean - */ - public boolean exists() { - if (getProject() == null || !getProject().exists()) - return false; - try { - return (this.project.hasNature(ISimpleWebNatureConstants.STATIC_NATURE_ID)); - } catch (Exception e) { - //e.printStackTrace(); - } - return false; - } - - protected IStaticWebNature getStaticWebNature() { - return SimpleWebNatureRuntimeUtilities.getStaticRuntime(this.project); - } - - public String getContextRoot() { - IStaticWebNature nature = getStaticWebNature(); - if (nature != null) - return nature.getContextRoot(); - return null; - } - - /* - * (non-Javadoc) - * - * @see com.ibm.wtp.server.core.util.ProjectModule#getRootFolder() - */ - public IPath getRootFolder() { - // TODO Auto-generated method stub - return getStaticWebNature().getRootPublishableFolder().getProjectRelativePath(); - } - - public String getType() { - return "web.static"; //$NON-NLS-1$ - } - - public String getVersion() { - return "1.0"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModule#validate(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus validate(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModule#getModuleType() - */ - public IModuleType getModuleType() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModule#getChildModules(org.eclipse.core.runtime.IProgressMonitor) - */ - public IModule[] getChildModules(IProgressMonitor monitor) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file 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 5c2148406..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableFactory.java +++ /dev/null @@ -1,113 +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 java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleDelegate; -import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate; -import org.eclipse.wst.web.internal.ISimpleWebNatureConstants; -import org.eclipse.wst.web.internal.operation.IBaseWebNature; - -public class StaticWebDeployableFactory extends ProjectModuleFactoryDelegate { - private static final String ID = "org.eclipse.jst.j2ee.internal.web.deployables.static"; //$NON-NLS-1$ - protected ArrayList moduleDelegates = new ArrayList(); - - /* - * @see DeployableProjectFactoryDelegate#getFactoryID() - */ - public String getFactoryId() { - return ID; - } - - /** - * 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) { - return false; - } - - /** - * Creates the deployable project for the given project. - * - * @param project - * org.eclipse.core.resources.IProject - * @return com.ibm.etools.server.core.model.IDeployableProject - */ - protected IModule createModule(IProject project) { - try { - IModule deployable = null; - StaticWebDeployable projectModule = null; - IBaseWebNature nature = (IBaseWebNature) project.getNature(ISimpleWebNatureConstants.STATIC_NATURE_ID); - deployable = nature.getModule(); - if (deployable == null) { - projectModule = new StaticWebDeployable(nature.getProject()); - deployable = createModule(projectModule.getId(), projectModule.getName(), projectModule.getType(), projectModule.getVersion(), projectModule.getProject()); - nature.setModule(deployable); - projectModule.initialize(deployable); - //deployable = projectModule.getModule(); - } - moduleDelegates.add(projectModule); - return deployable; - } catch (Exception e) { - //Ignore - } - return null; - } - - /* - * (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; - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModules() - */ - public IModule[] getModules() { - if (projects == null || projects.isEmpty()) - cacheModules(); - int i = 0; - Iterator modules = projects.values().iterator(); - IModule[] modulesArray = new IModule[projects.values().size()]; - while (modules.hasNext()) { - IModule element = (IModule) modules.next(); - modulesArray[i++] = element; - - } - return modulesArray; - - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate#createModules(org.eclipse.core.resources.IProject) - */ - protected IModule[] createModules(IProject project) { - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file 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 e514f80f2..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapter.java +++ /dev/null @@ -1,26 +0,0 @@ -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 852b617aa..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/StaticWebDeployableObjectAdapterUtil.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Created on Feb 21, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.wst.web.internal.deployables; - -import java.util.Arrays; -import java.util.Iterator; - -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.jst.j2ee.internal.project.IWebNatureConstants; -//import org.eclipse.jst.j2ee.internal.web.operations.WebNatureRuntimeUtilities; - -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; -import org.eclipse.wst.web.internal.operation.IBaseWebNature; -import org.eclipse.wst.web.internal.operation.StaticWebNatureRuntime; - -public class StaticWebDeployableObjectAdapterUtil { - - private final static String[] extensionsToExclude = new String[]{"sql", "xmi"}; //$NON-NLS-1$ //$NON-NLS-2$ - static String J2EE_NATURE_ID = "org.eclipse.jst.j2ee.web.WebNature"; //$NON-NLS-1$ - static String INFO_DIRECTORY = "WEB-INF"; //$NON-NLS-1$ - public static IBaseWebNature getRuntime(IProject project) { - if (project == null) - return null; - try { - IBaseWebNature nature; - if (project.hasNature(J2EE_NATURE_ID)) - nature = (IBaseWebNature) project.getNature(J2EE_NATURE_ID); - else - nature = (IBaseWebNature) project.getNature("org.eclipse.wst.web.StaticWebNature"); - return nature; - } catch (CoreException e) { - return null; - } - } - - 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; - - // find deployable - IBaseWebNature webNature = getRuntime(resource.getProject()); - if (webNature == null || !(webNature instanceof StaticWebNatureRuntime)) - return null; - - if (resource instanceof IProject) - return new WebResource(getModule(webNature), new Path("")); //$NON-NLS-1$ - - // determine path - IPath rootPath = webNature.getRootPublishableFolder().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(webNature), 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(IBaseWebNature nature) { - IModule deployable = nature.getModule(); - if (deployable != null) - return deployable; - - IProject project = nature.getProject(); - Iterator iterator = Arrays.asList(ServerUtil.getModules("web.static")).iterator(); //$NON-NLS-1$ //$NON-NLS-2$ - while (iterator.hasNext()) { - deployable = (IModule) iterator.next(); - if (deployable instanceof IModule) { - if (((IModule) deployable).getProject().equals(project)) - return deployable; - } - } - return null; - } - - -} diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IBaseWebNature.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IBaseWebNature.java deleted file mode 100644 index 9679a2e86..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IBaseWebNature.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Created on Dec 2, 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.operation; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.wst.server.core.IModule; - -/** - * @author dfholt - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public interface IBaseWebNature extends IProjectNature { - /** - * Insert the method's description here. Creation date: (10/31/2001 2:27:17 PM) - * - * @param path - * @param s - * java.lang.String - */ - void createFile(IPath path, String s) throws org.eclipse.core.runtime.CoreException; - - /** - * Insert the method's description here. Creation date: (10/16/2001 1:42:50 PM) - * - * @return java.lang.String - */ - String getContextRoot(); - - - /** - * This is a proxy method to enable invoking getModuleServerRoot() through the IBaseWebNature - * interface. The method can't be defined directly on the interface since it's implemented by - * AbstractJavaMOFNatureRuntime - * - * Creation date: (10/23/2001 2:24:52 PM) - * - * @return org.eclipse.core.resources.IContainer - */ - IContainer getRootPublishableFolder(); - - /** - * @return String - */ - String getModuleServerRootName(); - - void setModuleServerRootName(String name) throws CoreException; - - /** - * @return IContainer - */ - IContainer getModuleServerRoot(); - - /** - * @return org.eclipse.core.runtime.IPath - */ - IPath getWebSettingsPath(); - - /** - * Creation date: (10/30/2001 5:30:42 PM) - * - * @return boolean - * @deprecated - */ - int getWebNatureType(); - - /** - * Insert the method's description here. Creation date: (10/30/2001 5:30:10 PM) - * - * @param type - * boolean - * @deprecated - */ - void setWebNatureType(int type) throws CoreException; - - /** - * Return true if J2EE nature. - * - * @return boolean - */ - boolean isJ2EE(); - - /** - * Return true if Static nature. - * - * @return boolean - */ - boolean isStatic(); - - /** - * Return the deployable object for use by the server tooling - */ - IModule getModule(); - /** - * Insert the method's description here. Creation date: (10/23/2001 5:50:15 PM) - * - * @return org.eclipse.core.runtime.IPath - */ - IPath getWebModulePath(); - /** - * @return org.eclipse.core.runtime.IPath - */ - IPath getBasicWebModulePath(); - /** - * Set the deployable object for use by the server tooling - */ - void setModule(IModule module); - - void setContextRoot(String contextRoot) throws CoreException; - - void setFeatureIds(String[] featureIds) throws CoreException; - - String[] getFeatureIds(); -} 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 2d3d1bc6b..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/ILibModule.java +++ /dev/null @@ -1,21 +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.operation; - -import org.eclipse.core.resources.IProject; - -public interface ILibModule { - String getJarName(); - - String getProjectName(); - - String getURI(); - - IProject getProject(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IStaticWebNature.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IStaticWebNature.java deleted file mode 100644 index 76e7eca11..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/IStaticWebNature.java +++ /dev/null @@ -1,20 +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.operation; - - - -/** - * The IWebNature defines the web related behaviour of a project. - */ -public interface IStaticWebNature extends IBaseWebNature { - //Default -}
\ No newline at end of file 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 47198046e..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/LibModule.java +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ -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.web.internal.ISimpleWebNatureConstants; -import org.eclipse.wst.web.internal.WSTWebPlugin; - - -public class LibModule implements ILibModule { - protected static final IPath LIB_PATH = new Path(ISimpleWebNatureConstants.INFO_DIRECTORY).append(ISimpleWebNatureConstants.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()); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationDataModel.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationDataModel.java deleted file mode 100644 index e9ca279cd..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationDataModel.java +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ - -package org.eclipse.wst.web.internal.operation; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation; -import org.eclipse.wst.web.internal.ISimpleWebNatureConstants; - -public class SimpleWebModuleCreationDataModel extends ProjectCreationDataModel -{ - /* - * required (automatically set) for the Features page to determine which - * features to provide. Type "int" set to - * IWebNatureConstants.STATIC_WEB_PROJECT - */ - public SimpleWebModuleCreationDataModel createStaticWebProjectCreationDataModel( - String projectName) - { - SimpleWebModuleCreationDataModel model = (SimpleWebModuleCreationDataModel) super - .createProjectCreationDataModel(projectName); - model.addStaticWebNature(); - //setIntProperty(WebProjectFeaturesDataModel.WEB_PROJECT_TYPE, IWebNatureConstants.STATIC_WEB_PROJECT); - - return model; - } - - public SimpleWebModuleCreationDataModel() - { - super(); - addStaticWebNature(); - //setIntProperty(WebProjectFeaturesDataModel.WEB_PROJECT_TYPE,IWebNatureConstants.STATIC_WEB_PROJECT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.operation.ProjectCreationDataModel#initValidBaseProperties() - */ - protected void initValidBaseProperties() - { - super.initValidBaseProperties(); - //addValidBaseProperty(WebProjectFeaturesDataModel.WEB_PROJECT_TYPE); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.operation.ProjectCreationDataModel#getDefaultOperation() - */ - public WTPOperation getDefaultOperation() - { - return new SimpleWebModuleCreationOperation(this); - } - - protected final void addStaticWebNature() - { - String[] natures = (String[]) getProperty(PROJECT_NATURES); - String[] newNatures; - - if( natures == null ) - { - newNatures = new String[1]; - newNatures[0] = ISimpleWebNatureConstants.STATIC_NATURE_ID; - } - else - { - newNatures = new String[natures.length + 1]; - System.arraycopy(natures, 0, newNatures, 0, natures.length); - newNatures[natures.length] = ISimpleWebNatureConstants.STATIC_NATURE_ID; - } - - setProperty(PROJECT_NATURES, newNatures); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.operation.ProjectCreationDataModel#doValidateProperty(java.lang.String) - */ - protected IStatus doValidateProperty(String propertyName) - { - /*if( propertyName.equals(WebProjectFeaturesDataModel.WEB_PROJECT_TYPE) ) - { - return OK_STATUS; - }*/ - return super.doValidateProperty(propertyName); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.operation.WTPOperationDataModel#getTargetProject() - */ - public IProject getTargetProject() - { - return ProjectCreationDataModel.getProjectHandleFromProjectName(getStringProperty(PROJECT_NAME)); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationOperation.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationOperation.java deleted file mode 100644 index c71ec5f8d..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/SimpleWebModuleCreationOperation.java +++ /dev/null @@ -1,77 +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.operation; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationOperation; -import org.eclipse.wst.web.internal.ISimpleWebNatureConstants; -import org.eclipse.wst.web.internal.WSTWebPlugin; - -public class SimpleWebModuleCreationOperation extends ProjectCreationOperation -{ - /** - * @param dataModel - */ - public SimpleWebModuleCreationOperation(ProjectCreationDataModel dataModel) - { - super(dataModel); - } - - protected void execute(IProgressMonitor monitor) throws CoreException, - InvocationTargetException, InterruptedException - { - super.execute(monitor); - - SimpleWebModuleCreationDataModel dataModel = (SimpleWebModuleCreationDataModel) operationDataModel; - IProject project = dataModel.getProject(); - - IFolder webContentFolder = project - .getFolder(getWebContentFolderPreference()); - - if( !webContentFolder.exists() ) - webContentFolder.create(true, true, null); - - IFolder cssFolder = project.getFolder(webContentFolder - .getProjectRelativePath().append( - ISimpleWebNatureConstants.CSS_DIRECTORY)); - - if( !cssFolder.exists() ) cssFolder.create(true, true, null); - - //createWebSettings(project); - - if( monitor.isCanceled() ) throw new OperationCanceledException(); - } - - //To do: WebSettings do not exist now -// private void createWebSettings(IProject project) throws CoreException -// { -// WebSettings webSettings = new WebSettings(project); -// webSettings.setContextRoot(project.getName()); -// webSettings.setWebContentName(getWebContentFolderPreference()); -// // webSettings -// // .setProjectType(IStaticWebProjectConstants.STATIC_PROJECT_TYPE); -// -// webSettings.write(); -// } - - private String getWebContentFolderPreference() - { - //TODO implement - String webContentFolder = WSTWebPlugin.getDefault().getWSTWebPreferences().getStaticWebContentFolderName(); - return webContentFolder; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/StaticWebNatureRuntime.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/StaticWebNatureRuntime.java deleted file mode 100644 index db3bb51c6..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/StaticWebNatureRuntime.java +++ /dev/null @@ -1,652 +0,0 @@ -package org.eclipse.wst.web.internal.operation; - -/* - * Licensed Material - Property of IBM (C) Copyright IBM Corp. 2001, 2002 - All Rights Reserved. US - * Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP - * Schedule Contract with IBM Corp. - */ - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import org.eclipse.core.resources.ICommand; -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.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.web.internal.ISimpleWebNatureConstants; -import org.eclipse.wst.web.internal.WSTWebPlugin; - -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; - -/* - * Licensed Materials - Property of IBM, WebSphere Studio Workbench (c) Copyright IBM Corp 2000 - */ -public class StaticWebNatureRuntime implements IStaticWebNature { - static protected String PROJECTTYPE_STATIC_VALUE = "STATIC"; //$NON-NLS-1$ - static protected String PROJECTTYPE_J2EE_VALUE = "J2EE"; //$NON-NLS-1$ - - // Version number may not change with every release, - // only when changes necessitate a new version number - public static int CURRENT_VERSION = 500; - - public static int instanceCount = 1; - public int instanceStamp = 0; - protected String contextRoot = null; - protected String[] featureIds = null; - protected int fVersion = -1; - - //protected WebSettings fWebSettings; - - - protected IModule module; - protected IProject project; - -// private static final String LINKS_BUILDER_ID = "com.ibm.etools.webtools.additions.linksbuilder"; //$NON-NLS-1$ - - /** - * WebNatureRuntime constructor comment. - */ - public StaticWebNatureRuntime() { - super(); - instanceStamp = instanceCount; - instanceCount++; - - class WebSettingsModifier implements IResourceChangeListener, IResourceDeltaVisitor { - - public void resourceChanged(IResourceChangeEvent event) { - if (event.getSource() instanceof IWorkspace) { - IResourceDelta delta = event.getDelta(); - switch (event.getType()) { - case IResourceChangeEvent.PRE_BUILD : - if (delta != null) { - try { - delta.accept(this); - } catch (CoreException e) { - //Ignore - } - } - break; - } - } - } - - public boolean visit(IResourceDelta delta) throws CoreException { - if (delta != null) { - // get target IResource - final IResource resource = delta.getResource(); - if (resource != null) { - if (resource.getType() == IResource.FILE) { - // If the websettings file is being modified, reset all the cached - // values - // in the nature - IFile file = (IFile) resource; - if ((file.getName().equals(ISimpleWebNatureConstants.WEBSETTINGS_FILE_NAME)) && (resource.getProject().getName().equals(getProject().getName()))) { - resetWebSettings(); - } - } - } - return true; - } - return false; - } - - } - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.addResourceChangeListener(new WebSettingsModifier(), IResourceChangeEvent.PRE_BUILD); - - } - - /* - * Do nothing with a cvs ignore file for web projects, till a better solution is found from OTI - */ - - public void addCVSIgnoreFile() { - //Do nothing - } - - /** - * Adds a builder to the build spec for the given project. - */ - protected void addToFrontOfBuildSpec(String builderID) throws CoreException { - IProjectDescription description = getProject().getDescription(); - ICommand[] commands = description.getBuildSpec(); - boolean found = false; - for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(builderID)) { - found = true; - break; - } - } - if (!found) { - ICommand command = description.newCommand(); - command.setBuilderName(builderID); - ICommand[] newCommands = new ICommand[commands.length + 1]; - System.arraycopy(commands, 0, newCommands, 1, commands.length); - newCommands[0] = command; - IProjectDescription desc = getProject().getDescription(); - desc.setBuildSpec(newCommands); - getProject().setDescription(desc, null); - } - } - - /** - * Create a default file for the user given the name (directory relative to the project) and the - * default contents for the file. - * - * @param newFilePath - - * IPath - * @param newFileContents - - * String - */ - public void createFile(IPath newFilePath, String newFileContents) throws CoreException { - - IPath projectPath = project.getFullPath(); - IWorkspace workspace = WSTWebPlugin.getWorkspace(); - - createFolder(newFilePath.removeLastSegments(1).toString()); - - IFile outputFile = workspace.getRoot().getFile(projectPath.append(newFilePath)); - outputFile.refreshLocal(IResource.DEPTH_INFINITE, null); - - InputStream inputStream = new ByteArrayInputStream(newFileContents.getBytes()); - if (!(outputFile.exists())) - outputFile.create(inputStream, true, null); - } - - /** - * Create the folders for the project we have just created. - * - * @exception com.ibm.itp.core.api.resources.CoreException - * The exception description. - */ - protected void createFolders() throws CoreException { - // Create the WEB_MODULE directory - createFolder(getBasicWebModulePath()); - } - - /** - * Create a new nature runtime from the project info - */ - // public static StaticWebNatureRuntime createRuntime(WebProjectInfo info) throws CoreException - // { - // IProject project = info.getProject(); - // if (!hasRuntime(project)) { - // addNatureToProject(project, ISimpleWebNatureConstants.STATIC_NATURE_ID); - // StaticWebNatureRuntime runtime - // =(StaticWebNatureRuntime)WebNatureRuntimeUtilities.getRuntime(project); - // runtime.initializeFromInfo(info); - // return runtime; - // } - // return getRuntime(project); - // } - /** - * Removes this nature from the project. - * - * @see IProjectNature#deconfigure - */ - public void deconfigure() throws CoreException { - // super.deconfigure(); - // removeFromBuildSpec(J2EEPlugin.LINKS_BUILDER_ID); - } - - /* - * Returns the context root that the server is configured with (also called the web app path). - * This is the path that the war is placed on within the deployed server. This path must be - * included as the first segment of a doc relative path specification within an html file. - */ - public String getContextRoot() { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead - if (contextRoot == null) { -// WebSettings settings = getWebSettings(); -// contextRoot = settings.getContextRoot(); -// if (contextRoot == null) -// contextRoot = getProject().getName(); - } - return contextRoot; - } - -// protected WebSettings getWebSettings() { -// if (fWebSettings == null) { -// fWebSettings = new WebSettings(getProject()); -// } -// return fWebSettings; -// } - - /* - * Returns the root that the server runs off of. For projects created in v4, this is - * webApplication. For projects created in v5.0, this is Web Content. For projects created in - * v5.0.1 and later, this is configurable per project by the user. - */ - public IContainer getModuleServerRoot() { - return getProject().getFolder(getModuleServerRootName()); - } - - - /* - * Returns the name of the module server root directory. For projects created in v4, this is - * webApplication. For projects created in v5.0, this is Web Content. For projects created in - * v5.0.1 and later, this is configurable per project by the user. - */ - public String getModuleServerRootName() { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// String name = getWebSettings().getWebContentName(); -// if (name != null) -// return name; - - int version = getVersion(); - // If created in V5 or beyond - if (version != -1 && version >= 500) - return ISimpleWebNatureConstants.WEB_MODULE_DIRECTORY_; - - return ISimpleWebNatureConstants.WEB_MODULE_DIRECTORY_V4; - } - - - public void setModuleServerRootName(String name) throws CoreException { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// getWebSettings().setWebContentName(name); -// getWebSettings().write(); - } - - /** - * Return the root location for loading mof resources; defaults to the source folder, subclasses - * may override - */ - public IContainer getEMFRoot() { - return getModuleServerRoot(); - } - - /** - * Return the nature's ID. - */ - public String getNatureID() { - return ISimpleWebNatureConstants.STATIC_NATURE_ID; - } - - /** - * Return the ID of the plugin that this nature is contained within. - */ - protected String getPluginID() { - return WSTWebPlugin.PLUGIN_ID; - } - /** - * Insert the method's description here. Creation date: (10/30/2001 11:12:41 PM) - * - * @return org.eclipse.core.resources.IContainer - */ - public IContainer getRootPublishableFolder() { - return getModuleServerRoot(); - } - - /** - * Get a WebNatureRuntime that corresponds to the supplied project. - * - * @return com.ibm.itp.wt.IWebNature - * @param project - * com.ibm.itp.core.api.resources.IProject - */ - public static StaticWebNatureRuntime getRuntime(IProject project) { - try { - StaticWebNatureRuntime a = (StaticWebNatureRuntime) project.getNature(ISimpleWebNatureConstants.STATIC_NATURE_ID); - return a; - } catch (CoreException e) { - return null; - } - } - - - public IPath getBasicWebModulePath() { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// WebSettings webSettings = getWebSettings(); -// String name = webSettings.getWebContentName(); - String name = null; - if (name == null) { - int version = getVersion(); - // If created in V5 or beyond - if (version != -1 && version >= 500) - return ISimpleWebNatureConstants.WEB_MODULE_PATH_; - - return ISimpleWebNatureConstants.WEB_MODULE_PATH_V4; - } - return new Path(name); - } - - - public IPath getWebModulePath() { - return getProjectPath().append(getBasicWebModulePath()); - } - - - /** - * Insert the method's description here. Creation date: (10/30/2001 5:25:06 PM) - * - * @return boolean - * @deprecated - */ - public int getWebNatureType() { - - return ISimpleWebNatureConstants.STATIC_WEB_PROJECT; - } - - - /* - * Return the current version number. - */ - public static int getCurrentVersion() { - return CURRENT_VERSION; - } - - - /* - * Return the version number stored in the web settings file. The version number is used to - * determine when the web project was created (i.e., under what product version). The current - * version number does not necessarily change with each product version -- it's only changed - * when it becomes necessary to distinguish a new version from a prior version. - */ - public int getVersion() { - - if (fVersion == -1) { - try { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// String versionString = getWebSettings().getVersion(); - String versionString = null; - if (versionString != null) - fVersion = Integer.parseInt(versionString); - } catch (NumberFormatException e) { - //Ignore - } - } - return fVersion; - } - - - public IPath getWebSettingsPath() { - return getProjectPath().append(ISimpleWebNatureConstants.WEBSETTINGS_FILE_NAME); - } - - /** - * Return whether or not the project has a runtime created on it. - * - * @return boolean - * @param project - * com.ibm.itp.core.api.resources.IProject - */ - public static boolean hasRuntime(IProject project) { - try { - return project.hasNature(ISimpleWebNatureConstants.STATIC_NATURE_ID); - } catch (CoreException e) { - return false; - } - } - - /** - * Insert the method's description here. Creation date: (10/31/2001 5:32:12 PM) - * - * @param info - * com.ibm.iwt.webproject.WebProjectInfo - * @exception org.eclipse.core.runtime.CoreException - * The exception description. - */ -/* public void initializeFromInfo(WebProjectInfo info) throws org.eclipse.core.runtime.CoreException { - int natureType = info.getWebProjectType(); - - WebSettings webSettings = getWebSettings(); - webSettings.setProjectType(convertNatureTypeToString(natureType)); - webSettings.setWebContentName(info.getWebContentName()); - webSettings.write(); - - createFolders(); - // super.initializeFromInfo(info); - }*/ - - /** - * Insert the method's description here. Creation date: (11/1/2001 2:25:22 PM) - * - * @param builderID - * java.lang.String - * @exception org.eclipse.core.runtime.CoreException - * The exception description. - */ - protected void removeFromBuildSpec(String builderID) throws org.eclipse.core.runtime.CoreException { - IProjectDescription description = getProject().getDescription(); - ICommand[] commands = description.getBuildSpec(); - boolean found = false; - for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(builderID)) { - found = true; - break; - } - } - if (!found) { - ICommand command = description.newCommand(); - command.setBuilderName(builderID); - ICommand[] newCommands = new ICommand[commands.length + 1]; - System.arraycopy(commands, 0, newCommands, 1, commands.length); - newCommands[0] = command; - IProjectDescription desc = getProject().getDescription(); - desc.setBuildSpec(newCommands); - getProject().setDescription(desc, null); - } - - } - - protected void resetWebSettings() { -// fWebSettings = null; - contextRoot = null; - - } - - - public void contributeToNature(EMFWorkbenchContext aNature) { - // if (emfNature == aNature) return; - // super.contributeToNature(aNature); - // WorkbenchURIConverter converter = (WorkbenchURIConverter) - // aNature.getContext().getURIConverter(); - // converter.addInputContainer(getProject()); - } - - protected String convertNatureTypeToString(int type) { - if (type == ISimpleWebNatureConstants.STATIC_WEB_PROJECT) - return PROJECTTYPE_STATIC_VALUE; - - return PROJECTTYPE_J2EE_VALUE; - } - - /** - * Set the web nature's type to either Static (ISimpleWebNatureConstants.STATIC_WEB_NATURE) or J2EE - * (ISimpleWebNatureConstants.J2EE_WEB_NATURE) - * - * @param newIsStaticWebProject - * boolean - * @deprecated - */ - public void setWebNatureType(int natureType) throws CoreException { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// getWebSettings().setProjectType(convertNatureTypeToString(natureType)); -// getWebSettings().write(); - - } - - - public String[] getFeatureIds() { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// WebSettings settings = getWebSettings(); -// featureIds = settings.getFeatureIds(); - if (featureIds == null) - featureIds = new String[0]; - - return featureIds; - } - - public void setFeatureIds(String[] featureIds) throws CoreException { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// WebSettings webSettings = getWebSettings(); -// webSettings.setFeatureIds(featureIds); -// webSettings.write(); - } - - /** - * Configures the project with this nature. - * - * @see IProjectNature#configure() - */ - public void primConfigure() throws CoreException { - // super.primConfigure(); - - // this order is depended upon (see RATLC00855322) - addToFrontOfBuildSpec(WSTWebPlugin.VALIDATION_BUILDER_ID); -// addToFrontOfBuildSpec(LINKS_BUILDER_ID); - } - - public void setContextRoot(String newContextRoot) throws CoreException { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// getWebSettings().setContextRoot(newContextRoot); -// getWebSettings().write(); - contextRoot = newContextRoot; - } - - public void removeFeatureId(String featureId) throws CoreException { -// To do : Needs rework for flexibile project ModuleCore.getFirstArtifactEditForRead -// WebSettings webSettings = getWebSettings(); -// webSettings.removeFeatureId(featureId); -// webSettings.write(); - } - - - /** - * Configures the project with this nature. This is called by <code>IProject.addNature</code> - * and should not be called directly by clients. The nature extension id is added to the list of - * natures on the project by <code>IProject.addNature</code>, and need not be added here. - * - * All subtypes must call super. - * - * @exception CoreException - * if this method fails. - */ - public void configure() throws org.eclipse.core.runtime.CoreException { - primConfigure(); - - } - - /** - * Gets the deployable. - * - * @return Returns a IDeployable - */ - public IModule getModule() { - return module; - } - - /** - * Sets the deployable. - * - * @param deployable - * The deployable to set - */ - public void setModule(IModule module) { - this.module = module; - } - - /** - * Returns the project to which this project nature applies. - * - * @return the project handle - */ - public org.eclipse.core.resources.IProject getProject() { - return project; - } - - /** - * Sets the project to which this nature applies. Used when instantiating this project nature - * runtime. This is called by <code>IProject.addNature</code> and should not be called - * directly by clients. - * - * @param project - * the project to which this nature applies - */ - public void setProject(org.eclipse.core.resources.IProject newProject) { - project = newProject; - //need to be called here since getNature and createNature will not call it - try { - configure(); - } catch (CoreException e) { - //Ignore - } - } - - /** - * Create a folder relative to the project based on aProjectRelativePathString. - * - * @exception com.ibm.itp.core.api.resources.CoreException - * The exception description. - */ - public IFolder createFolder(String aProjectRelativePathString) throws CoreException { - if (aProjectRelativePathString != null && aProjectRelativePathString.length() > 0) - return createFolder(new Path(aProjectRelativePathString)); - return null; - } - - /** - * Create a folder relative to the project based on aProjectRelativePathString. - * - * @exception com.ibm.itp.core.api.resources.CoreException - * The exception description. - */ - public IFolder createFolder(IPath aProjectRelativePath) throws CoreException { - if (aProjectRelativePath != null && !aProjectRelativePath.isEmpty()) { - IFolder folder = getWorkspace().getRoot().getFolder(getProjectPath().append(aProjectRelativePath)); - if (!folder.exists()) - folder.create(true, true, null); - return folder; - } - return null; - } - - /** - * Adds a nauture to a project - */ - protected static void addNatureToProject(IProject proj, String natureId) throws CoreException { - ProjectUtilities.addNatureToProject(proj, natureId); - } - - /** - * Return the full path of the project. - */ - protected IPath getProjectPath() { - return getProject().getFullPath(); - } - - public IWorkspace getWorkspace() { - return getProject().getWorkspace(); - } - - - /** - * @see IBaseWebNature#isJ2EE() - */ - public boolean isJ2EE() { - return false; - } - - /** - * @see IBaseWebNature#isStatic() - */ - public boolean isStatic() { - return true; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebSettings.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebSettings.java deleted file mode 100644 index 071d9e92f..000000000 --- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/operation/WebSettings.java +++ /dev/null @@ -1,609 +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.operation; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.web.internal.ISimpleWebNatureConstants; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - - -public class WebSettings{ - protected IFile fSettingsFile; - protected IProject fProject; - protected Document fDomDocument; - // Version number may not change with every release, - // only when changes necessitate a new version number - public static String CURRENT_VERSION = "600"; //$NON-NLS-1$ - public static String VERSION_V4 = "400"; //$NON-NLS-1$ - public static final String ELEMENT_WORKSPACE_VERSION = "version"; //$NON-NLS-1$ - - - static final String ELEMENT_WEBSETTINGS = "j2eesettings"; //$NON-NLS-1$ - static final String ELEMENT_PROJECTTYPE = "project-type"; //$NON-NLS-1$ - static final String ELEMENT_CONTEXTROOT = "context-root"; //$NON-NLS-1$ - static final String ELEMENT_WEBCONTENT = "webcontent"; //$NON-NLS-1$ - static final String ELEMENT_JSPLEVEL = "jsp-level"; //$NON-NLS-1$ - static final String ELEMENT_LIBMODULES = "lib-modules"; //$NON-NLS-1$ - static final String ELEMENT_LIBMODULE = "lib-module"; //$NON-NLS-1$ - static final String ELEMENT_LIBMODULE_JAR = "jar"; //$NON-NLS-1$ - static final String ELEMENT_LIBMODULE_PROJECT = "project"; //$NON-NLS-1$ - static final String ELEMENT_FEATURES = "features"; //$NON-NLS-1$ - static final String ELEMENT_FEATURE = "feature"; //$NON-NLS-1$ - static final String ELEMENT_FEATUREID = "feature-id"; //$NON-NLS-1$ - - static final ILibModule[] EMPTY_LIBMODULES = new ILibModule[0]; - static final String[] EMPTY_FEATURES = new String[0]; - static boolean validWebSettings = true; - - public WebSettings(IProject project) { - fProject = project; - //this.nature = nature; - if (getDOMDocument() == null) { - try { - createNewDocument(); - } catch (CoreException e) { - //Ignore - } catch (IOException e) { - //Ignore - } - } - } - - public WebSettings(IProject project, IFile webSettings) { - fProject = project; - //this.nature = nature; - if (getDOMDocument(webSettings) == null) { - validWebSettings = false; - } - } - - protected IFile getSettingsFile() { - if (fSettingsFile == null) { - fSettingsFile = fProject.getFile(ISimpleWebNatureConstants.WEBSETTINGS_FILE_NAME); - } - return fSettingsFile; - } - - public String getContextRoot() { - return getValue(ELEMENT_CONTEXTROOT); - } - - public String getJSPLevel() { - return getValue(ELEMENT_JSPLEVEL); - } - - public String getWebContentName() { - return getValue(ELEMENT_WEBCONTENT); - } - - public ILibModule[] getLibModules() { - Element root = getRootElement(); - if (root == null) - return EMPTY_LIBMODULES; - - Element libModuleNode = findChildNode(root, ELEMENT_LIBMODULES); - if (libModuleNode == null) - return EMPTY_LIBMODULES; - - NodeList children = libModuleNode.getChildNodes(); - ArrayList results = new ArrayList(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - ILibModule libModule = getLibModule(node); - if (libModule != null) { - results.add(libModule); - } - } - - return (ILibModule[]) results.toArray(new ILibModule[results.size()]); - } - - protected ILibModule getLibModule(Node node) { - if (!node.getNodeName().equalsIgnoreCase(ELEMENT_LIBMODULE)) - return null; - String jarName = getNodeValue((Element) node, ELEMENT_LIBMODULE_JAR); - String projectName = getNodeValue((Element) node, ELEMENT_LIBMODULE_PROJECT); - - ILibModule libModule = new LibModule(jarName, projectName); - return libModule; - } - - public String[] getFeatureIds() { - Element root = getRootElement(); - if (root == null) - return EMPTY_FEATURES; - - Element featuresNode = findChildNode(root, ELEMENT_FEATURES); - if (featuresNode == null) - return EMPTY_FEATURES; - - NodeList children = featuresNode.getChildNodes(); - ArrayList results = new ArrayList(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - String featureId = getFeatureId(node); - if (featureId != null) { - results.add(featureId); - } - } - - return (String[]) results.toArray(new String[results.size()]); - } - - protected String getFeatureId(Node node) { - if (!node.getNodeName().equalsIgnoreCase(ELEMENT_FEATURE)) - return null; - String id = getNodeValue((Element) node, ELEMENT_FEATUREID); - - return id; - } - - public String getProjectType() { - return getValue(ELEMENT_PROJECTTYPE); - } - - public String getCurrentVersion() { - // The following change is needed when the websettings file is - // deleted from a version 4 workspace Checking for webapplication - // folder - Otherwise, new projects will not work. - IContainer webmoduleFolder = fProject.getFolder(ISimpleWebNatureConstants.WEB_MODULE_DIRECTORY_V4); - IFolder webinfFolder = ((IFolder) webmoduleFolder).getFolder(ISimpleWebNatureConstants.INFO_DIRECTORY); - if (webinfFolder.exists()) { - return VERSION_V4; - } - - return CURRENT_VERSION; - } - - protected String getValue(String settingName) { - Element root = getRootElement(); - if (root == null) - return null; - return getNodeValue(root, settingName); - } - - protected void createNewDocument() throws CoreException, IOException { - StringWriter writer = new StringWriter(); - writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$ - writer.write("\n"); //$NON-NLS-1$ - writer.write("<j2eesettings version=\""); //$NON-NLS-1$ - writer.write(getCurrentVersion()); - writer.write("\">");//$NON-NLS-1$ - writer.write("\n"); //$NON-NLS-1$ - writer.write("</j2eesettings>"); //$NON-NLS-1$ - writer.write("\n"); //$NON-NLS-1$ - - InputStream sourceStream = new ByteArrayInputStream(writer.toString().getBytes("UTF8")); //$NON-NLS-1$ - IFile webSettingsFile = getSettingsFile(); - if (webSettingsFile.exists()) - webSettingsFile.setContents(sourceStream, true, true, null); - else - webSettingsFile.create(sourceStream, true, null); - read(); - } - - public void setContextRoot(String contextRoot) { - setValue(ELEMENT_CONTEXTROOT, contextRoot); - } - - public void setJSPLevel(String jspLevel) { - setValue(ELEMENT_JSPLEVEL, jspLevel); - } - - public void setWebContentName(String name) { - String defaultName = getWebContentName(); - if (defaultName == null || defaultName.length() == 0 || !name.equals(defaultName)) - setValue(ELEMENT_WEBCONTENT, name); - } - - public void setProjectType(String projectType) { - setValue(ELEMENT_PROJECTTYPE, projectType); - } - - public void setLibModules(ILibModule[] libModules) { - Document doc = getOrCreateDocument(); - Node libModulesNode = findOrCreateChildNode(doc.getDocumentElement(), ELEMENT_LIBMODULES); - Node firstChild = null; - - // Remove all of the children. - while ((firstChild = libModulesNode.getFirstChild()) != null) - libModulesNode.removeChild(firstChild); - - // Add new children. - for (int i = 0; i < libModules.length; i++) { - ILibModule iLibModule = libModules[i]; - if (iLibModule != null) - addLibModule(libModulesNode, iLibModule); - } - } - - protected void addLibModule(Node libModulesNode, ILibModule libModule) { - Document doc = getDOMDocument(); - Element libModuleNode = doc.createElement(ELEMENT_LIBMODULE); - libModulesNode.appendChild(libModuleNode); - setValue(libModuleNode, ELEMENT_LIBMODULE_JAR, libModule.getJarName()); - setValue(libModuleNode, ELEMENT_LIBMODULE_PROJECT, libModule.getProjectName()); - } - - public void setFeatureIds(String[] featureIds) { - Document doc = getOrCreateDocument(); - Node featuresNode = findOrCreateChildNode(doc.getDocumentElement(), ELEMENT_FEATURES); - - // Add new children. - for (int i = 0; i < featureIds.length; i++) { - String sFeatureId = featureIds[i]; - if (sFeatureId != null) - addFeatureId(featuresNode, sFeatureId); - } - } - - protected void addFeatureId(Node featuresNode, String featureId) { - Document doc = getDOMDocument(); - Element featureNode = doc.createElement(ELEMENT_FEATURE); - featuresNode.appendChild(featureNode); - setValue(featureNode, ELEMENT_FEATUREID, featureId); - } - - public boolean isValidWebSettings() { - return validWebSettings; - } - - public void removeFeatureId(String removeId) { - Element root = getRootElement(); - if (root != null) { - Element featuresNode = findChildNode(root, ELEMENT_FEATURES); - if (featuresNode != null) { - NodeList children = featuresNode.getChildNodes(); - ArrayList results = new ArrayList(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - String featureId = getFeatureId(node); - if (featureId != null) { - // determine if in the list to remove - if (!(featureId.equals(removeId))) - results.add(featureId); - } - } - // Remove all of the children. - Node firstChild = null; - while ((firstChild = featuresNode.getFirstChild()) != null) - featuresNode.removeChild(firstChild); - if (results.size() > 0) { - String[] updateFeatureIds = (String[]) results.toArray(new String[results.size()]); - // Add new children. - for (int i = 0; i < results.size(); i++) { - String sFeatureId = updateFeatureIds[i]; - if (sFeatureId != null) - addFeatureId(featuresNode, sFeatureId); - } - } - } - } - } - - public String getRootNodeName() { - return ELEMENT_WEBSETTINGS; - } - protected Node findOrCreateChildNode(Element root, String nodeName) { - Node node = findChildNode(root, nodeName); - if (node == null) { - // If the element does not exist yet, create one. - node = getDOMDocument().createElement(nodeName); - root.appendChild(node); - } - return node; - } - protected Element findChildNode(Element parent, String nodeName) { - NodeList list = parent.getChildNodes(); - int length = list.getLength(); - for (int i = 0; i < length; ++i) { - Node curNode = list.item(i); - if (curNode.getNodeType() == Node.ELEMENT_NODE) { - Element curElement = (Element) curNode; - if (curElement.getNodeName().equalsIgnoreCase(nodeName)) - return curElement; - } - } - return null; - } - protected Element getRootElement() { - Document doc = getDOMDocument(); - if (doc == null) - return null; - - Element root = doc.getDocumentElement(); - if (root == null) - return null; - if (!root.getNodeName().equalsIgnoreCase(getRootNodeName())) - return null; - return root; - } - - protected Document getOrCreateDocument() { - Document doc = getDOMDocument(); - if (doc == null) { - try { - createNewDocument(); - doc = getDOMDocument(); - } catch (CoreException e) { - //Ignore - } catch (IOException e) { - //Ignore - } - } - return doc; - } - public static String getWebContentDirectory(InputStream inputStream) { - InputStreamReader fileStream = null; - try { - fileStream = new InputStreamReader(inputStream, "utf-8"); //$NON-NLS-1$ - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document fDomDocument = parser.parse(new InputSource(fileStream)); - Element root = fDomDocument.getDocumentElement(); - if (root.getNodeName().equalsIgnoreCase(ELEMENT_WEBSETTINGS)) { - NodeList list = root.getChildNodes(); - for (int i = 0, length = list.getLength(); i < length; i++) { - Node node = list.item(i); - if (node.getNodeName().equals(ELEMENT_WEBCONTENT)) { - NodeList childNodes = node.getChildNodes(); - for (int j = 0, childLength = childNodes.getLength(); j < childLength; j++) { - Node curNode = childNodes.item(j); - if (curNode.getNodeType() == Node.TEXT_NODE) { - return curNode.getNodeValue(); - } - } - return null; - } - } - } - } catch (UnsupportedEncodingException e) { - //Ignore - } catch (ParserConfigurationException e) { - //Ignore - } catch (FactoryConfigurationError e) { - //Ignore - } catch (SAXException e) { - //Ignore - } catch (IOException e) { - //Ignore - } catch (Exception e) { - //Ignore - } finally { - if (fileStream != null) - try { - fileStream.close(); - } catch (IOException e1) { - //Ignore - } - } - return null; - } - protected Document getDOMDocument() { - if (fDomDocument == null) { - try { - read(); - } catch (IOException e) { - //Ignore - } - } - return fDomDocument; - } - - // Version of getDomDocument for use by import - protected Document getDOMDocument(IFile webSettings) { - if (fDomDocument == null) { - try { - read(webSettings); - } catch (IOException e) { - //Ignore - } - } - return fDomDocument; - } - protected void read() throws IOException { - // This following was changed for Defect 212723 The Util StringReader - // was changed to the InputStreamReader MAY - IFile settingsFile = getSettingsFile(); - InputStream inputStream = null; - InputStreamReader fileStream = null; - if (settingsFile.exists()) { - try { - ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - - // JZ: fix to defect 240171 - inputStream = settingsFile.getContents(true); - fileStream = new InputStreamReader(inputStream, "utf-8"); //$NON-NLS-1$ - - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - fDomDocument = parser.parse(new InputSource(fileStream)); - } finally { - Thread.currentThread().setContextClassLoader(prevClassLoader); - } - /* } catch (JavaModelException e) { - throw new IOException("file.badFormat"); //$NON-NLS-1$ -*/ } catch (CoreException e) { - throw new IOException("file.badFormat"); //$NON-NLS-1$ - } catch (SAXException e) { - throw new IOException("file.badFormat"); //$NON-NLS-1$ - } catch (ParserConfigurationException e) { - throw new IOException("file.badFormat"); //$NON-NLS-1$ - } finally { - if (fileStream != null) - fileStream.close(); - } - } - } - - - // Version of read for use by import - protected void read(IFile settings) throws IOException { - // This following was changed for Defect 212723 The Util StringReader - // was changed to the InputStreamReader MAY - IFile settingsFile = settings; - - InputStream inputStream = null; - InputStreamReader fileStream = null; - if (settingsFile != null) { - try { - ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - inputStream = settingsFile.getContents(); - fileStream = new InputStreamReader(inputStream, "utf-8"); //$NON-NLS-1$ - - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - fDomDocument = parser.parse(new InputSource(fileStream)); - } finally { - Thread.currentThread().setContextClassLoader(prevClassLoader); - } - - } catch (SAXException e) { - throw new IOException("file.badFormat"); //$NON-NLS-1$ - } catch (ParserConfigurationException e) { - throw new IOException("file.badFormat"); //$NON-NLS-1$ - } catch (CoreException ce) { - ce.printStackTrace(); - } finally { - if (fileStream != null) - fileStream.close(); - } - } - } - protected void setValue(String nodeName, String value) { - Document doc = getOrCreateDocument(); - setValue(doc.getDocumentElement(), nodeName, value); - } - protected void setValue(Element root, String nodeName, String value) { - Node node = findOrCreateChildNode(root, nodeName); - - NodeList childNodes = node.getChildNodes(); - - if (childNodes.getLength() == 0) { - Text newText = getDOMDocument().createTextNode(value); - node.appendChild(newText); - root.appendChild(node); - } else { - for (int i = 0; i < childNodes.getLength(); i++) { - Node curNode = childNodes.item(i); - if (curNode.getNodeType() == Node.TEXT_NODE) - curNode.setNodeValue(value); - } - } - } - - protected String getNodeValue(Element parent, String nodeName) { - if (parent != null) { - Element node = findChildNode(parent, nodeName); - if (node != null) - return getChildText(node); - } - return null; - } - - protected String getChildText(Element node) { - NodeList list = node.getChildNodes(); - int length = list.getLength(); - for (int i = 0; i < length; ++i) { - Node curNode = list.item(i); - if (curNode.getNodeType() == Node.TEXT_NODE) { - return curNode.getNodeValue(); - } - } - return null; - } - public void setVersion(String version) { - Document doc = getDOMDocument(); - if (doc == null) - return; - - Element root = doc.getDocumentElement(); - if (root == null) - return; - - if (!root.getNodeName().equalsIgnoreCase(getRootNodeName())) - return; - - root.setAttribute(ELEMENT_WORKSPACE_VERSION, version); //$NON-NLS-1$ - } - public void write() throws CoreException { - if (fDomDocument == null) - return; - - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - - try { - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ - transformer.transform(new DOMSource(fDomDocument.getDocumentElement()), new StreamResult(outStream)); - } catch (TransformerConfigurationException e) { - Logger.getLogger().logError(e); - } catch (TransformerFactoryConfigurationError e) { - Logger.getLogger().logError(e); - } catch (TransformerException e) { - Logger.getLogger().logError(e); - } - - InputStream sourceStream = new ByteArrayInputStream(outStream.toByteArray()); - - IFile settingsFile = getSettingsFile(); - if (settingsFile.exists()) - settingsFile.setContents(sourceStream, true, true, null); - else - settingsFile.create(sourceStream, true, null); - } - public String getVersion() { - Document doc = getDOMDocument(); - if (doc == null) - return null; - - Element root = doc.getDocumentElement(); - if (root == null) - return null; - if (!root.getNodeName().equalsIgnoreCase(getRootNodeName())) - return null; - - return root.getAttribute(ELEMENT_WORKSPACE_VERSION); //$NON-NLS-1$ - } -}
\ No newline at end of file |