diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.core/src/org')
283 files changed, 0 insertions, 40399 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/IJSFCoreConstants.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/IJSFCoreConstants.java deleted file mode 100644 index 7e2d9c84b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/IJSFCoreConstants.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core; - -/** - * JSF Core framework constants - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public final class IJSFCoreConstants -{ - /** - * The global id for the JSF facet - * TODO: align with extensioin point through plugin.properties - */ - public static final String JSF_CORE_FACET_ID = "jst.jsf"; //$NON-NLS-1$ - /** - * The facet version for a JSF 1.0 project - * TODO: align with extensioin point through plugin.properties - */ - public final static String FACET_VERSION_1_0 = "1.0"; //$NON-NLS-1$ - /** - * The constant id for a JSF 1.0 project - */ - public final static String JSF_VERSION_1_0 = FACET_VERSION_1_0; - /** - * The facet version for a JSF 1.1 project - * TODO: align with extensioin point through plugin.properties - */ - public final static String FACET_VERSION_1_1 = "1.1"; //$NON-NLS-1$ - /** - * The constant id for a JSF 1.1 project - */ - public final static String JSF_VERSION_1_1 = FACET_VERSION_1_1; - /** - * The facet version for a JSF 1.2 project - * TODO: align with extensioin point through plugin.properties - */ - public final static String FACET_VERSION_1_2 = "1.2";//$NON-NLS-1$ - /** - * The constant id for a JSF 1.2 project - */ - public final static String JSF_VERSION_1_2 = FACET_VERSION_1_2; - - private IJSFCoreConstants() - { - // no instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/IJSFPreferenceModel.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/IJSFPreferenceModel.java deleted file mode 100644 index 13af43b10..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/IJSFPreferenceModel.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman - initial implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal; - -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.eclipse.jface.preference.IPreferenceStore; - -/** - * Defines a generic JSF preferences model - * - * @author cbateman - * - */ -public interface IJSFPreferenceModel -{ - /** - * Loads the object from the preference store provided - * - * @param prefStore - */ - public void load(IPreferenceStore prefStore); - - /** - * Copies the object into the preference store but DOES NOT SAVE IT - * - * @param prefStore - */ - public void commit(IPreferenceStore prefStore); - - /** - * Reverts the model to it's defaults. Does not commit to pref store. - */ - public void setDefaults(); - - /** - * @param context - * @param key - * @return the preference value in context with using key as the id - */ - public Object getValueByKey(final IScopeContext context, final String key); - - /** - * @param context - * @param key - * @return the preference value in context using key as the id and drawing - * it directly from the preference store - */ - public Object getStoredValueByKey(final IScopeContext context, final String key); - - /** - * Set the preference value indicated by key in context to value. May - * throw ClassCastException if value is not the type expected for the key - * @param context - * @param key - * @param value - * @return the old value - */ - public Object setValueByKey(final IScopeContext context, final String key, final Object value); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFCorePlugin.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFCorePlugin.java deleted file mode 100644 index d93286e00..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFCorePlugin.java +++ /dev/null @@ -1,312 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - * Ian Trimble - JSFLibraryRegistry work - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jst.jsf.designtime.context.AbstractDTExternalContextFactory; -import org.eclipse.jst.jsf.designtime.el.AbstractDTMethodResolver; -import org.eclipse.jst.jsf.designtime.el.AbstractDTPropertyResolver; -import org.eclipse.jst.jsf.designtime.el.AbstractDTVariableResolver; -import org.eclipse.ui.preferences.ScopedPreferenceStore; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -/** - * JSF Core plugin. - * - * @author Gerry Kessler - Oracle, Ian Trimble - Oracle - */ -public class JSFCorePlugin extends WTPPlugin { - /** - * The plugin id - */ - public static final String PLUGIN_ID = "org.eclipse.jst.jsf.core";//org.eclipse.jst.jsf.core.internal.JSFCorePlugin"; //$NON-NLS-1$ - - // The shared instance. - private static JSFCorePlugin plugin; - - private IPreferenceStore preferenceStore; - - /** - * The constructor. - */ - public JSFCorePlugin() { - plugin = this; - } - - /** - * This method is called upon plug-in activation - * @param context - * @throws Exception - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - * @param context - * @throws Exception - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - } - - /** - * Returns the shared instance. - * @return the shared instance - */ - public static JSFCorePlugin getDefault() { - return plugin; - } - - /** - * @param e - * @param msg - */ - public static void log(final Exception e, final String msg) { - final ILog log = getDefault().getLog(); - - log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e)); - } - - /** - * Logs using the default ILog implementation provided by getLog(). - * - * @param severity Severity (IStatus constant) of log entry - * @param message Human-readable message describing log entry - * @param ex Throwable instance (can be null) - */ - public static void log(int severity, String message, Throwable ex) { - getDefault().getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, message, ex)); - } - - /** - * Logs using the default ILog implementation provided by getLog(). - * - * @param severity Severity (IStatus constant) of log entry - * @param message Human-readable message describing log entry - */ - public static void log(int severity, String message) { - log(severity, message, null); - } - - /** - * Logs a message for this plugin - * - * @param message - * @param t - */ - public static void log(String message, Throwable t) - { - ILog log = plugin.getLog(); - log.log( - new Status( - IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, message, t)); - } - - public String getPluginID() { - return PLUGIN_ID; - } - - /** - * @return all registered symbol source providers - */ - public synchronized static Map<String, AbstractDTVariableResolver> getVariableResolvers() - { - if (_registeredVariableResolvers == null) - { - registerVariableResolverProviders(); - if (_registeredVariableResolvers == null) - { - throw new AssertionError("registerProviders failed"); //$NON-NLS-1$ - } - } - return Collections.unmodifiableMap(_registeredVariableResolvers); - } - - private static Map<String, AbstractDTVariableResolver> _registeredVariableResolvers; - private final static String VARIABLE_RESOLVER_EXT_POINT_NAME = "variableresolver"; //$NON-NLS-1$ - - private static void registerVariableResolverProviders() - { - _registeredVariableResolvers = new HashMap(); - loadRegisteredExtensions(VARIABLE_RESOLVER_EXT_POINT_NAME, - _registeredVariableResolvers, - VARIABLE_RESOLVER_EXT_POINT_NAME); - } - - /** - * @return a map of all registered property resolvers by id - */ - public synchronized static Map<String, AbstractDTPropertyResolver> getPropertyResolvers() - { - if (_registeredPropertyResolvers == null) - { - registerPropertyResolverProviders(); - if (_registeredPropertyResolvers == null) - { - throw new AssertionError("registerProviders failed"); //$NON-NLS-1$ - } - } - return Collections.unmodifiableMap(_registeredPropertyResolvers); - } - - private static Map<String, AbstractDTPropertyResolver> _registeredPropertyResolvers; - private final static String PROPERTY_RESOLVER_EXT_POINT_NAME = - "propertyresolver"; //$NON-NLS-1$ - - private static void registerPropertyResolverProviders() - { - _registeredPropertyResolvers = new HashMap(); - loadRegisteredExtensions(PROPERTY_RESOLVER_EXT_POINT_NAME, - _registeredPropertyResolvers, - PROPERTY_RESOLVER_EXT_POINT_NAME); - } - - - /** - * @return a map of all registered method resolvers by id - */ - public synchronized static Map<String, AbstractDTMethodResolver> getMethodResolvers() - { - if (_registeredMethodResolvers == null) - { - registerMethodResolverProviders(); - if (_registeredMethodResolvers == null) - { - throw new AssertionError("registerProviders failed"); //$NON-NLS-1$ - } - } - return Collections.unmodifiableMap(_registeredMethodResolvers); - } - - private static Map<String, AbstractDTMethodResolver> _registeredMethodResolvers; - private final static String METHOD_RESOLVER_EXT_POINT_NAME = - "methodresolver"; //$NON-NLS-1$ - - private static void registerMethodResolverProviders() - { - _registeredMethodResolvers = new HashMap(); - loadRegisteredExtensions(METHOD_RESOLVER_EXT_POINT_NAME, - _registeredMethodResolvers, - METHOD_RESOLVER_EXT_POINT_NAME); - - } - - /** - * @return a map of all registered external context providers by id - */ - public synchronized static Map<String, AbstractDTExternalContextFactory> getExternalContextProviders() - { - if (_registeredExternalContextProviders == null) - { - registerExternalContextProviders(); - if (_registeredExternalContextProviders == null) - { - throw new AssertionError("registerProviders failed"); //$NON-NLS-1$ - } - } - return Collections.unmodifiableMap(_registeredExternalContextProviders); - } - - private static Map<String, AbstractDTExternalContextFactory> _registeredExternalContextProviders; - private final static String EXTERNAL_CONTEXT_EXT_POINT_NAME = - "externalcontext"; //$NON-NLS-1$ - - private static void registerExternalContextProviders() - { - _registeredExternalContextProviders = new HashMap(); - loadRegisteredExtensions(EXTERNAL_CONTEXT_EXT_POINT_NAME, - _registeredExternalContextProviders, - EXTERNAL_CONTEXT_EXT_POINT_NAME); - } - - private static <ResolverProvider> void loadRegisteredExtensions(final String extName, - final Map<String, ResolverProvider> registry, - final String elementName) - { - final IExtensionPoint point = Platform.getExtensionRegistry(). - getExtensionPoint(plugin.getBundle().getSymbolicName(), - extName); - final IExtension[] extensions = point.getExtensions(); - - for (int i = 0; i < extensions.length; i++) - { - final IExtension extension = extensions[i]; - final IConfigurationElement[] elements = - extension.getConfigurationElements(); - final String bundleId = extension.getContributor().getName(); - - for (int j = 0; j < elements.length; j++) - { - final IConfigurationElement element = elements[j]; - if (elementName.equals(element.getName()) - && element.getAttribute("class") != null //$NON-NLS-1$ - && element.getAttribute("id") != null) //$NON-NLS-1$ - { - final String factoryClassName = element.getAttribute("class"); //$NON-NLS-1$ - final String id = element.getAttribute("id"); //$NON-NLS-1$ - final Bundle bundle = Platform.getBundle(bundleId); - - if (bundle != null) - { - try - { - final Class factoryClass = - bundle.loadClass(factoryClassName); - - final Object variableResolver= - factoryClass.newInstance(); - - registry.put(id, (ResolverProvider) variableResolver); - } - catch (Exception e) - { - final ILog logger_ = getDefault().getLog(); - logger_.log(new Status(IStatus.ERROR, plugin.getBundle() - .getSymbolicName(), 0, - "Error loading resolver provider extension point",e)); //$NON-NLS-1$ - } - } - } - } - } - } - - /** - * @return the preference store for this bundle - * TODO: this is copied from AbstractUIPlugin; need to upgrade to new IPreferencesService - */ - public IPreferenceStore getPreferenceStore() { - // Create the preference store lazily. - if ( this.preferenceStore == null) { - this.preferenceStore = new ScopedPreferenceStore(new InstanceScope(),getBundle().getSymbolicName()); - - } - return this.preferenceStore; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFLibrariesContainerInitializer.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFLibrariesContainerInitializer.java deleted file mode 100644 index d8d443c0f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFLibrariesContainerInitializer.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.ClasspathContainerInitializer; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper; - -/** - * Initialize JSF Libraries as classpath containers - */ -public class JSFLibrariesContainerInitializer extends - ClasspathContainerInitializer { - - private static final String MISSING_LIBRARY = Messages.JSFLibrariesContainerInitializer_missing_library; - - /** - * Constructor - */ - public JSFLibrariesContainerInitializer() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public void initialize(IPath containerPath, IJavaProject project) throws CoreException { - if (isJSFLibraryContainer(containerPath)) { - String libId= containerPath.lastSegment(); - - JSFLibrary ref= JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getJSFLibraryByID(libId); - if (ref != null) { - JSFLibraryClasspathContainer container= new JSFLibraryClasspathContainer(ref); - JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null); - } - } - } - - private boolean isJSFLibraryContainer(IPath path) { - return path != null && path.segmentCount() == 2 && JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID.equals(path.segment(0)); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#canUpdateClasspathContainer(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { - return isJSFLibraryContainer(containerPath); - } - - /** - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getDescription(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public String getDescription(IPath containerPath, IJavaProject project) { - if (isJSFLibraryContainer(containerPath)) { - String id = containerPath.lastSegment(); - JSFLibrary libref = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getJSFLibraryByID(id); - String displayText = id; - - if (libref == null){ - displayText = displayText + " " + MISSING_LIBRARY; //$NON-NLS-1$ - } - - return displayText; - } - return super.getDescription(containerPath, project); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - public Object getComparisonID(IPath containerPath, IJavaProject project) { - return containerPath; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFLibraryClasspathContainer.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFLibraryClasspathContainer.java deleted file mode 100644 index ab3d50c0c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFLibraryClasspathContainer.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper; - - -/** - * JSF Library classpath container - */ -public class JSFLibraryClasspathContainer implements IClasspathContainer { - private static final String NON_IMPL_DESC = Messages.JSFLibraryClasspathContainer_NON_IMPL_LIBRARY; - private static final String IMPL_DESC = Messages.JSFLibraryClasspathContainer_IMPL_LIBRARY; - - private JSFLibrary lib; - - /** - * @param lib - */ - public JSFLibraryClasspathContainer(JSFLibrary lib) { - this.lib = lib; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries() - */ - public IClasspathEntry[] getClasspathEntries() { - return JSFLibraryRegistryUtil.getInstance().getClasspathEntries(lib); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getDescription() - */ - public String getDescription() { - StringBuffer buf = new StringBuffer(lib.getLabel()); - buf.append(" "); //$NON-NLS-1$ - if (lib.isImplementation()) - buf.append(IMPL_DESC); - else - buf.append(NON_IMPL_DESC); - - return buf.toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getKind() - */ - public int getKind() { - return IClasspathContainer.K_APPLICATION; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IClasspathContainer#getPath() - */ - public IPath getPath() { - return new Path(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID).append(this.lib.getID()); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFRegistryVersionInfo.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFRegistryVersionInfo.java deleted file mode 100644 index 19fa69644..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/JSFRegistryVersionInfo.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal; - -import org.osgi.framework.Version; - -/** - * A value object the describes the current and expected state of the JSF Library - * Registry - * - * @author cbateman - * - */ -final class JSFRegistryVersionInfo -{ - private Version _curVersion; // the version of the current registry on disk - private Version _expectedVersion; // the expected or required version of the registry - - JSFRegistryVersionInfo(Version oldVersion, Version expectedVersion) - { - super(); - _curVersion = oldVersion; - _expectedVersion = expectedVersion; - } - - /** - * @return the version of the registry found in the current workspace - */ - public Version getCurVersion() { - return _curVersion; - } - - /** - * @return the version of the registry that is expected - */ - public Version getExpectedVersion() { - return _expectedVersion; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java deleted file mode 100644 index a98eafd94..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - * Ian Trimble - changed to work correctly with org.eclipse.osgi.util.NLS - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * String resource handler. - * - * @author Gerry Kessler - Oracle, Ian Trimble - Oracle - */ -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.core.internal.messages"; //$NON-NLS-1$ - - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ClientImplValidationMsg; - - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_DupeJarValidation; - - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_INITIAL_VALIDATION_IMPL_TYPE; - - - /** - * see messages.properties - */ - public static String JSFLibCfgDialogSettingData_Sticky_Component_Lib_Not_Exist; - - /** - * see messages.properties - */ - public static String JSFLibrariesContainerInitializer_missing_library; - - /** - * see messages.properties - */ - public static String JSFLibraryClasspathContainer_IMPL_LIBRARY; - - /** - * see messages.properties - */ - public static String JSFLibraryClasspathContainer_NON_IMPL_LIBRARY; - - /** - * see messages.properties - */ - public static String JSFLibraryConfigModel_Null_Data_Source; - - /** - * see messages.properties - */ - public static String JSFLibraryConfigPersistData_SAVED_COMPLIB_NOT_FOUND; - - /** - * see messages.properties - */ - public static String JSFLibraryConfigPersistData_SAVED_IMPLLIB_NOT_FOUND; - - /** - * see messages.properties - */ - public static String JSFLibraryRegistry_ErrorCreatingURL; - /** - * see messages.properties - */ - public static String JSFLibraryRegistry_NoLoadCreatingNew; - /** - * see messages.properties - */ - public static String JSFLibraryRegistry_ErrorSaving; - /** - * see messages.properties - */ - public static String JSFLibraryRegistry_DEFAULT_IMPL_LABEL; - /** - * see messages.properties - */ - public static String JSFLibraryRegistry_ErrorLoadingFromExtPt; - - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateServletName; - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateJSFImpl; - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateConfigFileEmpty; - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateConfigFilePath; - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateConfigFileRelative1; - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateConfigFileRelative2; - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateConfigFileXML; - /** - * see messages.properties - */ - public static String JSFFacetInstallDataModelProvider_ValidateConfigFileSlashes; - - /** - * see messages.properties - */ - public static String ArchiveFileImpl_CannotCopyFile; - /** - * see messages.properties - */ - public static String ArchiveFileImpl_CannotCloseFile; - /** - * see messages.properties - */ - public static String ArchiveFileImpl_CannotLocatePluginRelativeFile; - - /** - * see messages.properties - */ - public static String JSFUtils_MissingJAR; - - /** - * see messages.properties - */ - public static String PluginProvidedJSFLibraryCreationHelper_ErrorCreating; - /** - * see messages.properties - */ - public static String PluginProvidedJSFLibraryCreationHelper_ErrorMultipleDefinition; - - /** - * see messages.properties - */ - public static String JSFUtils_ErrorCreatingConfigFile; - /** - * see messages.properties - */ - public static String JSFUtils_ErrorClosingConfigFile; - - /** - * see messages.properties - */ - public static String JSFAppConfigUtils_ErrorOpeningJarFile; - - /** - * see messages.properties - */ - public static String JARFileJSFAppConfigProvider_ErrorLoadingModel; - - /** - * see messages.properties - */ - public static String J2EEModuleDependencyDelegate_UpdatingJ2EEModuleDependencies; - /** - * see messages.properties - */ - public static String J2EEModuleDependencyDelegate_UpdatingJ2EEModuleDependenciesForProject; - - /** - * see messages.properties - */ - public static String JSFRegistryMigration05_to_10_title; - /** - * see messages.properties - */ - public static String JSFRegistryMigration05_to_10_message; - - /** - * see messages.properties - */ - public static String JSFRegistryMigration05_to_10_customMessage; - - - /** - * see messages.properties - */ - public static String JSFRegistryMigrationCannot05_to_10_title; - /** - * see messages.properties - */ - public static String JSFRegistryMigrationCannot05_to_10_message; - - /** - * see messages.properties - */ - public static String JSFRegistryMigrationCannot05_to_10_customMessage; - - - /** - * see messages.properties - */ - public static String RegistryMigrationStartupHandler_Dialog_Abort_And_Exit_Migration; - - /** - * see messages.properties - */ - public static String RegistryMigrationStartupHandler_Dialog_Confirm_Migration; - - /** - * see messages.properties - */ - public static String RegistryMigrationStartupHandler_Error_committing_migration; - - /** - * see messages.properties - */ - public static String RegistryMigrationStartupHandler_Error_Rolling_Back_Migration; - - /** - * see messages.properties - */ - public static String RegistryMigrationStartupHandler_Launch_Migration_Doc_On_Confirm; - - static { - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/RegistryUpgradeCommitHandler.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/RegistryUpgradeCommitHandler.java deleted file mode 100644 index 8e3f0f711..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/RegistryUpgradeCommitHandler.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.JSFLibraryRegistryUpgradeUtil; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.UpgradeStatus; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.browser.IWorkbenchBrowserSupport; - -/** - * Commits registry migration - * @author cbateman - * - */ -public class RegistryUpgradeCommitHandler -{ - - /** - * handle migration - */ - public static void commitMigrationIfNecessary() - { - JSFLibraryRegistryUpgradeUtil upgradeUtil = - JSFLibraryRegistryUpgradeUtil.getInstance(); - - UpgradeStatus status = upgradeUtil.getUpgradeStatus(); - - if (status.getSeverity() == IStatus.OK) - { - if (status.isUpgradeOccurred()) - { - handle05_to_10(status); - } - } - else - { - handleErrorInMigration(status); - } - } - - private static void handle05_to_10(UpgradeStatus status) - { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Handle05_to_10_migration(status)); - } - - private static void handleErrorInMigration(UpgradeStatus status) - { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() - { - public void run() - { - final Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); - MessageDialog.openError(shell, "Serious Error Encountered!", "An unrecoverable error occurred while trying to migrate your JSF Library Registry to a newer version. This may cause your library references to be broken in your JSF projects."); - } - }); - } - - private static class Handle05_to_10_migration implements Runnable - { - private final UpgradeStatus _status; - - Handle05_to_10_migration(UpgradeStatus status) - { - _status = status; - } - - public void run() - { - // no prompting necessary. just commit. - doConfirmed(false); - } - - private void doConfirmed(boolean userWantsMigrationDocLaunch) { - // delete V1 registry, leave backup file - IStatus result = _status.commit(); - - if (result.getSeverity() != IStatus.OK) - { - final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - MessageDialog.openError(shell, Messages.RegistryMigrationStartupHandler_Error_committing_migration, result.getMessage()); - } - - // if user confirmed, launch migration doc - if (userWantsMigrationDocLaunch) - try { - IWorkbenchBrowserSupport browserSupport = - PlatformUI.getWorkbench().getBrowserSupport(); - URL url = new URL("http://wiki.eclipse.org/index.php/JSF_Library_Migration"); //$NON-NLS-1$ - browserSupport.createBrowser("JSFMigrationDoc").openURL(url); //$NON-NLS-1$ - } catch (PartInitException e) { - JSFCorePlugin.log(e,"Error handling migration"); //$NON-NLS-1$ - } catch (MalformedURLException e) { - JSFCorePlugin.log(e,"Error handling migration"); //$NON-NLS-1$ - } - } - -// private void doAbortAndExit() -// { -// // rollback -// IStatus result = _status.rollback(); -// -// if (result.getSeverity() != IStatus.OK) -// { -// final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); -// MessageDialog.openError(shell, Messages.RegistryMigrationStartupHandler_Error_Rolling_Back_Migration, result.getMessage()); -// } -// // close workbench -// PlatformUI.getWorkbench().close(); -// } -// } -// -// private static class ConfirmDialog extends MessageDialogWithToggle -// { -// final static int CONFIRMED = 0; -// final static int ABORT_AND_EXIT = 1; -// -// /** -// * @param parentShell -// * @param dialogTitle -// * @param dialogMessage -// */ -// public ConfirmDialog(Shell parentShell, String dialogTitle, -// String dialogMessage) { -// super(parentShell -// , dialogTitle -// , null -// , dialogMessage -// , WARNING -// , new String[] { Messages.RegistryMigrationStartupHandler_Dialog_Confirm_Migration, Messages.RegistryMigrationStartupHandler_Dialog_Abort_And_Exit_Migration } -// , ABORT_AND_EXIT -// , Messages.RegistryMigrationStartupHandler_Launch_Migration_Doc_On_Confirm, true); -// } -// -// /** -// * Override so that the button ids line up with the constants -// * expected -// * @param parent -// */ -// protected void createButtonsForButtonBar(Composite parent) { -// final String[] buttonLabels = getButtonLabels(); -// final Button[] buttons = new Button[buttonLabels.length]; -// final int defaultButtonIndex = getDefaultButtonIndex(); -// -// for (int i = 0; i < buttonLabels.length; i++) { -// String label = buttonLabels[i]; -// Button button = createButton(parent, i, label, -// defaultButtonIndex == i); -// buttons[i] = button; -// -// } -// setButtons(buttons); -// } -// - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java deleted file mode 100644 index c2f965e3f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.contentassist.el; - -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTAddExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTAndExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTChoiceExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTEqualityExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTFunctionInvocation; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTLiteral; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTMultiplyExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTOrExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTRelationalExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTUnaryExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTValue; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTValuePrefix; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTValueSuffix; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserConstants; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserVisitor; -import org.eclipse.jst.jsp.core.internal.java.jspel.ParseException; -import org.eclipse.jst.jsp.core.internal.java.jspel.SimpleNode; -import org.eclipse.jst.jsp.core.internal.java.jspel.Token; - -/** - * Consumes an EL expression and converts into a completion prefix - * - * @author cbateman - * - */ -public final class ContentAssistParser -{ - /** - * @param relativePosition -- 1-based position in elText (first position is 1) - * @param elText - * @return a content assist strategy for the given position and el expression - * or null if one cannot be determined - */ - public static ContentAssistStrategy getPrefix(final int relativePosition, final String elText) - { - if (elText == null) - { - return null; - } - else if ("".equals(elText.trim())) - { - return new IdCompletionStrategy("", ""); - } - - final java.io.StringReader reader = new java.io.StringReader(elText); - final JSPELParser parser = new JSPELParser(reader); - - try - { - final ASTExpression expr = parser.Expression(); - final PrefixVisitor visitor = new PrefixVisitor(relativePosition, elText); - expr.jjtAccept(visitor, null); - return visitor.getPrefix(); - } - catch (ParseException pe) - { - // TODO: handle parser by using current and expected tokens - } - - return null; - } - - private static class PrefixVisitor implements JSPELParserVisitor - { - private final int _relativePos; - private final String _fullText; - - private String _curPrefix; // = null; initialized as tree is visited - private int _prefixType; - private boolean _prefixResolved; // = false; set to true when the prefix is resolved - private String _proposalStart = ""; - - PrefixVisitor(final int relativePos, final String fullText) - { - _relativePos = relativePos; - _fullText = fullText; - } - - /** - * @return the prefix if resolved or null if not resolved - */ - public ContentAssistStrategy getPrefix() - { - if (_prefixResolved) - { - switch(_prefixType) - { - case ContentAssistStrategy.PREFIX_TYPE_DOT_COMPLETION: - return new FunctionCompletionStrategy(_curPrefix, _proposalStart); - - case ContentAssistStrategy.PREFIX_TYPE_ID_COMPLETION: - return new IdCompletionStrategy(_curPrefix, _proposalStart); - - case ContentAssistStrategy.PREFIX_TYPE_EMPTY_EXPRESSION: - return new IdCompletionStrategy("", _proposalStart); - - default: - // do nothing; fall-through to return null - } - } - - return null; - } - - public Object visit(ASTAddExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTAndExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTChoiceExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTEqualityExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTFunctionInvocation node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTLiteral node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTMultiplyExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTOrExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTRelationalExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTUnaryExpression node, Object data) - { - return node.childrenAccept(this, data); - } - - public Object visit(ASTValue node, Object data) - { - // we're only in this value expr if it contains the cursor - if (testContainsCursor(node)) - { - return node.childrenAccept(this, data); - } - - return null; - } - - public Object visit(ASTValuePrefix node, Object data) - { - // for now, only concern ourselves with simple (identifier) prefixes - if (!_prefixResolved - && node.jjtGetNumChildren() == 0 - && node.getFirstToken().kind == JSPELParserConstants.IDENTIFIER) - { - _curPrefix = node.getFirstToken().image; - - if (testContainsCursor(node)) - { - // if the cursor is on this id, we don't need to visit - // further since we know both the prefix -- the id -- and - // the type -- it's an id completion - _prefixType = ContentAssistStrategy.PREFIX_TYPE_ID_COMPLETION; - int proposalLength = _relativePos - node.getFirstToken().beginColumn; - _proposalStart = node.getFirstToken().image.substring(0, proposalLength); - _prefixResolved = true; - } - } - return node.childrenAccept(this, data); - } - - public Object visit(ASTValueSuffix node, Object data) - { - // for now, only deal with the simple .id suffix - Token lastToken = node.getLastToken(); - if (node.jjtGetNumChildren() == 0) - { - if (!_prefixResolved - && node.getFirstToken().kind == JSPELParserConstants.DOT) - { - if (lastToken.kind == JSPELParserConstants.IDENTIFIER) - { - if (testContainsCursor(node)) - { - _prefixType = ContentAssistStrategy.PREFIX_TYPE_DOT_COMPLETION; - int proposalStartLength = _relativePos - lastToken.beginColumn; - if (proposalStartLength < 0) { // Cursor after firstToken start but before lastToken start? - proposalStartLength = 0; - } - _proposalStart = lastToken.image.substring(0, proposalStartLength); - _prefixResolved = true; - } - // only include this suffix on the path if the cursor is - // further to the right. Thus for x.^y we get a prefix "x" - // and for x.y.^z we get "x.y" since this the part we must - // resolve the prefix for - else - { - _curPrefix += node.getFirstToken().image + lastToken.image; - } - } - else if (lastToken == node.getFirstToken()) - { - if (testCursorImmediatelyAfter(node)) - { - _prefixType = ContentAssistStrategy.PREFIX_TYPE_DOT_COMPLETION; - _prefixResolved = true; - } - } - } - - return null; - } - - if (node.getFirstToken().kind == JSPELParserConstants.LBRACKET) - { - // try to support ca inside the brackets - node.childrenAccept(this, data); - } - - Object retValue = node.childrenAccept(this, data); - - if (!_prefixResolved) - { - // if we haven't resolved the prefix yet, then we need - // to append this suffix value - _curPrefix += _fullText.substring(node.getFirstToken().beginColumn-1, node.getLastToken().endColumn); - } - - return retValue; - } - - public Object visit(SimpleNode node, Object data) - { - return node.childrenAccept(this, data); - } - - private boolean testCursorImmediatelyAfter(SimpleNode node) - { - return node.getLastToken().endColumn == _relativePos-1; - } - - /** - * "Containing a cursor" here is deemed to mean that current cursor - * position as indicated by _relativePos, is either directly before, on or - * directly after an expression. For example, in a Value expression like - * - * x x x . y y y . z z z - * ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ - * 1 2 3 4 5 6 7 8 9 0 1 2 - * - * Position's 1-4 are on xxx, 5-8 are on yyy and 9-12 are on zzz - * - * @param node - * @return true if the node "contains the cursor" (see above) - */ - private boolean testContainsCursor(SimpleNode node) - { - return (node.getFirstToken().beginColumn <= _relativePos - && node.getLastToken().endColumn+1 >= _relativePos); - - } - } - - private ContentAssistParser() - { - // utility class; not instantiable - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistStrategy.java deleted file mode 100644 index c1582cf89..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistStrategy.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.core.internal.contentassist.el; - -import java.util.List; - -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; - -/** - * Encapsulates an EL content assist completion prefix - * - * @author cbateman - * - */ -public abstract class ContentAssistStrategy -{ - /** - * ContentAssistStrategy type for a dot content assist completion - */ - public final static int PREFIX_TYPE_DOT_COMPLETION = 0; - /** - * ContentAssistStrategy type for an id content assist completion - */ - public final static int PREFIX_TYPE_ID_COMPLETION = 1; - /** - * Completions for an empty expression - */ - public final static int PREFIX_TYPE_EMPTY_EXPRESSION = 2; - - private final int type; - private final String value; - private final String proposalStart; - - /** - * @param type - * @param value - * @param proposalStart - */ - public ContentAssistStrategy(final int type, final String value, final String proposalStart) - { - super(); - this.type = type; - this.value = value; - this.proposalStart = proposalStart; - } - - /** - * @return the type of this completion prefix as defined by - * one of the PREFIX_TYPE constants - */ - public final int getType() - { - return type; - } - - /** - * @return the token which this prefix is for - */ - public final String getValue() - { - return value; - } - - /** - * @param context - * @return the list of proposals for this strategy. Contents of the list - * must be of type ICompletionProposal - */ - public abstract List getProposals(IStructuredDocumentContext context); - - /** - * @return the part of the proposal which was already typed when user invoked autocomplete - */ - public String getProposalStart() { - return proposalStart; - } - - /** - * @param completionList - * @param proposal - */ - protected void addProposalsMatchingProposalStart(final List completionList, final ICompletionProposal[] proposal) { - final String start = getProposalStart(); - for (int j = 0; j < proposal.length; j++) { - final String proposalString = proposal[j].getDisplayString(); - //TODO Should use "real" proposal replacement instead of displayString: - if (proposalString.length() >= start.length() && - proposalString.substring(0, start.length()).equalsIgnoreCase(start)) - { - completionList.add(proposal[j]); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java deleted file mode 100644 index 77803d9c1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java +++ /dev/null @@ -1,358 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.core.internal.contentassist.el; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextResolver; -import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ITextRegionContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.symbol.IInstanceSymbol; -import org.eclipse.jst.jsf.context.symbol.IMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.provider.IContentProposalProvider; -import org.eclipse.jst.jsf.context.symbol.provider.ProposalCreationFactoryAdapter; -import org.eclipse.jst.jsf.context.symbol.provider.IContentProposalProvider.IProposalCreationFactory; -import org.eclipse.jst.jsf.designtime.resolver.ISymbolContextResolver; -import org.eclipse.jst.jsf.designtime.resolver.StructuredDocumentSymbolResolverFactory; -import org.eclipse.jst.jsf.metadataprocessors.MetaDataEnabledProcessingFactory; -import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts; -import org.eclipse.swt.graphics.Image; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * A completion strategy for function completions like: - * - * v a r . - * ^ - * - * @author cbateman - * - */ -public class FunctionCompletionStrategy extends ContentAssistStrategy -{ - /** - * @param value - * @param proposalStart - */ - public FunctionCompletionStrategy(String value, String proposalStart) - { - super(ContentAssistStrategy.PREFIX_TYPE_DOT_COMPLETION, value, proposalStart); - } - - public List getProposals(IStructuredDocumentContext context) - { - final List completionList = new ArrayList(); - - String[] ids = getValue().split("\\."); - - // if no suffixes, only one id - if (ids.length < 1) - { - ids = new String[] {getValue()}; - } - - final ISymbolContextResolver symbolResolver = - StructuredDocumentSymbolResolverFactory.getInstance(). - getSymbolContextResolver(context); - - ISymbol symbol = null; - - if (symbolResolver != null) - { - symbol = symbolResolver.getVariable(ids[0]); - } - - if (symbol instanceof IInstanceSymbol - && ((IInstanceSymbol)symbol).isTypeResolved()) - { - int curSuffixIdx = 1; - - while - (curSuffixIdx < ids.length - && symbol != null) - { - - final ISymbol[] properties = - symbolResolver.getProperties(symbol); - - // set symbol to null because hasn't been found yet - symbol = null; - - SEARCH_SYMBOL_NAME:for - (int i = 0; i < properties.length; i++) - { - final ISymbol element = properties[i]; - - if (ids[curSuffixIdx].equals(element.getName())) - { - symbol = element; - break SEARCH_SYMBOL_NAME; - } - } - curSuffixIdx++; - } - - // if we get a completion symbol, get it's proposals - if (symbol instanceof IObjectSymbol) - { - final List expectedMethodBindings = new ArrayList(); - ISymbol[] suffixes = getSymbols((IObjectSymbol) symbol, - context, - symbolResolver, - expectedMethodBindings); - - final ComposedAdapterFactory factory = - new ComposedAdapterFactory( - ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - final IProposalCreationFactory creationInfo = - new MyProposalFactory(context, getProposalStart().length(), - expectedMethodBindings); - - for (int i = 0; i < suffixes.length; i++) - { - final ISymbol propSymbol = suffixes[i]; - final Object provider = - factory.adapt(propSymbol, IContentProposalProvider.class); - - if (provider instanceof IContentProposalProvider) - { - final ICompletionProposal[] proposal = - ((IContentProposalProvider) provider). - getProposals(propSymbol, creationInfo); - if (proposal != null) - { - addProposalsMatchingProposalStart(completionList, - proposal); - } - } - } - } - } - - return completionList; - } - - private ISymbol[] getSymbols(IObjectSymbol symbol, - IStructuredDocumentContext context, - ISymbolContextResolver symbolResolver, - List expectedMethodBindings) - { - List symbols = new ArrayList(); - - if (isMethodBindingExpected(context, expectedMethodBindings)) - { - symbols.addAll(Arrays.asList( - symbolResolver.getMethods(symbol))); - } - - symbols.addAll(Arrays.asList(symbolResolver.getProperties(symbol))); - - return (ISymbol[]) symbols.toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - - private boolean isMethodBindingExpected(IStructuredDocumentContext context, - List expectedBindings) - { - boolean isMBExpected = false; // assume false until we find it true - - final IDOMContextResolver domResolver = - IStructuredDocumentContextResolverFactory.INSTANCE. - getDOMContextResolver(context); - - final Node curNode = domResolver.getNode(); - - if (curNode instanceof Attr) - { - final Attr attr = (Attr) curNode; - final Element element = attr.getOwnerElement(); - - final ITaglibContextResolver taglibResolver = - IStructuredDocumentContextResolverFactory.INSTANCE. - getTaglibContextResolver(context); - - final String uri = taglibResolver.getTagURIForNodeName(element); - - final List elVals = - MetaDataEnabledProcessingFactory.getInstance() - .getAttributeValueRuntimeTypeFeatureProcessors - (IValidELValues.class, context, uri, - element.getLocalName(), attr.getLocalName()); - - for (final Iterator it = elVals.iterator(); it.hasNext();) - { - final IValidELValues validValues = (IValidELValues) it.next(); - - try - { - CompositeType type = validValues.getExpectedRuntimeType(); - if (type != null - && type.getAssignmentTypeMask() - == IAssignable.ASSIGNMENT_TYPE_NONE) - { - isMBExpected = true; - expectedBindings.addAll( - Arrays.asList( - validValues. - getExpectedRuntimeType(). - getSignatures())); - } - } - catch (ELIsNotValidException e) - { - // do nothing - } - } - } - - // default condition is no method binding - return isMBExpected; - } - - private static class MyProposalFactory extends ProposalCreationFactoryAdapter - { - private final static int DEFAULT_RELEVANCE = 1; - - private final static int HIGH_RELEVANCE = 2; - private final static int NORMAL_RELEVANCE = 1; - private final static int LOW_RELEVANCE = 0; - - private final List _expectedMethodBindings; - private final IStructuredDocumentContext _context; - - /** - * @param context - * @param replacementLength - * @param expectedMethodBindings - */ - public MyProposalFactory(IStructuredDocumentContext context, int replacementLength, - List expectedMethodBindings) { - /*TODO I changed the meaning of "replacementLength" from "number of chars AFTER cursor to be - * replaced" to "number of chars BEFORE cursor to be replaced. Since "replacementLength" - * has always been 0 (constructor is only called by FunctionCompletionStrategy.getProposals()), - * this should not change anything, but I don't know if there have been different plans - * for "replacementLength". - * TODO Maybe this change should be done in the super class instead? - */ - super(context.getDocumentPosition() - replacementLength, replacementLength); - _context = context; - _expectedMethodBindings = expectedMethodBindings; - } - - public ICompletionProposal createProposal(String replacementText, - String displayText, - String additionalText, - Image displayImage, - Object target) - { - int replacementOffset = _replacementOffset; - int replacementLength = _replacementLength; - - // TODO: I regard this as a bit of hack, but until we write our - // proposal implementation, it's basically the only way I can - // see to do this - // if it's an array, we must check if we need to replace a - // preceding '.' - if (replacementText.startsWith("[")) - { - ITextRegionContextResolver textResolver = - IStructuredDocumentContextResolverFactory.INSTANCE.getTextRegionResolver(_context); - - if (textResolver.getRegionType().equals(DOMJSPRegionContexts.JSP_VBL_CLOSE)) - { - textResolver = - IStructuredDocumentContextResolverFactory. - INSTANCE.getTextRegionResolver(textResolver.getPreviousContext()); - } - - String regionText = textResolver.getRegionText(); - int regionStart = textResolver.getStartOffset(); - - if (DOMJSPRegionContexts.JSP_VBL_CONTENT.equals(textResolver.getRegionType()) - && regionText != null - && regionStart != -1 - && regionStart < _context.getDocumentPosition()) - { - int relativeOffset = _context.getDocumentPosition() - regionStart - 1; - - if (regionText.charAt(relativeOffset) == '.') - { - // we must replace a length of 1 (the dot) - // at an offset on prior - replacementOffset--; - replacementLength = 1; - } - } - } - - return createDefaultProposal(replacementText, - replacementOffset, - replacementLength, - replacementText.length(), - displayImage, - displayText, - null, - additionalText, - getRelevance(target, DEFAULT_RELEVANCE)); - } - - private int getRelevance(final Object target, final int defaultRelevance) - { - // if method bindings are expected, then list exact signature - // matches top most. Still list non-matching methods, but put - // them at the bottom - if (_expectedMethodBindings.size() > 0) - { - if (target instanceof IMethodSymbol) - { - final IMethodSymbol methodSymbol = (IMethodSymbol) target; - - for (final Iterator it = _expectedMethodBindings.iterator(); - it.hasNext();) - { - final String methodType = (String) it.next(); - - // we have a match, so push to the top - if (methodType.equals(methodSymbol.getSignature())) - { - return HIGH_RELEVANCE; - } - } - - // if we get out of the loop, then this method doesn't - // match the expected signature - return LOW_RELEVANCE; - } - - // non-method targets have normal relevance when mb expected - return NORMAL_RELEVANCE; - } - - // otherwise, simply return the default for all - return defaultRelevance; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/IdCompletionStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/IdCompletionStrategy.java deleted file mode 100644 index 83ccf55ef..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/IdCompletionStrategy.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.contentassist.el; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.symbol.ERuntimeSource; -import org.eclipse.jst.jsf.context.symbol.IInstanceSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.provider.IContentProposalProvider; -import org.eclipse.jst.jsf.context.symbol.provider.ProposalCreationFactoryAdapter; -import org.eclipse.jst.jsf.context.symbol.provider.IContentProposalProvider.IProposalCreationFactory; -import org.eclipse.jst.jsf.designtime.resolver.ISymbolContextResolver; -import org.eclipse.jst.jsf.designtime.resolver.StructuredDocumentSymbolResolverFactory; -import org.eclipse.swt.graphics.Image; - -/** - * A strategy for getting completions for EL id completions like: - * - * var - * ^ - * - * @author cbateman - * - */ -class IdCompletionStrategy extends ContentAssistStrategy -{ - - /** - * Construct a strategy for completing an ID completion - * - * @param prefixValue - * @param proposalStart - the part of the proposal which was already typed when user invoked autocomplete - */ - public IdCompletionStrategy(final String prefixValue, String proposalStart) - { - super(ContentAssistStrategy.PREFIX_TYPE_ID_COMPLETION, prefixValue, proposalStart); - } - - /** - * @see org.eclipse.jst.jsf.core.internal.contentassist.el.ContentAssistStrategy#getProposals(org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext) - */ - public List getProposals(IStructuredDocumentContext context) - { - final List completionList = new ArrayList(); - final IWorkspaceContextResolver workspaceResolver = - IStructuredDocumentContextResolverFactory.INSTANCE. - getWorkspaceContextResolver(context); - - final IFile iFile = (IFile) workspaceResolver.getResource(); - - ISymbol[] symbols = null; - - if (iFile != null) - { - final ISymbolContextResolver symbolResolver = - StructuredDocumentSymbolResolverFactory.getInstance(). - getSymbolContextResolver(context); - - symbols = symbolResolver.getAllVariables(); - } - - final ComposedAdapterFactory factory = - new ComposedAdapterFactory(ComposedAdapterFactory. - Descriptor.Registry.INSTANCE); - - final IProposalCreationFactory creationInfo = - new MyProposalFactory(context.getDocumentPosition(), getProposalStart().length()); - - for (int i = 0; symbols != null && i < symbols.length; i++) - { - final ISymbol symbol = symbols[i]; - - final Object adapter = - factory.adapt(symbol, IContentProposalProvider.class); - - if (adapter instanceof IContentProposalProvider) - { - final IContentProposalProvider provider = - (IContentProposalProvider) adapter; - final ICompletionProposal[] proposal = - provider.getProposals(symbol, creationInfo); - if (proposal != null) - { - addProposalsMatchingProposalStart(completionList, proposal); - } - } - } - - return completionList; - } - - private static class MyProposalFactory extends ProposalCreationFactoryAdapter - { - private final static int HIGH_RELEVANCE = 2; - private final static int NORMAL_RELEVANCE = 1; - private final static int LOW_RELEVANCE = 0; - - /** - * @param replacementOffset - * @param replacementLength - */ - public MyProposalFactory(int replacementOffset, int replacementLength) - { - /*TODO I changed the meaning of "replacementLength" from "number of chars AFTER cursor to be - * replaced" to "number of chars BEFORE cursor to be replaced. Since "replacementLength" - * has always been 0 (constructor is only called by IdCompletionStrategy.getProposals()), - * this should not change anything, but I don't know if there have been different plans - * for "replacementLength". - * TODO Maybe this change should be done in the super class instead? - */ - super(replacementOffset - replacementLength, replacementLength); - } - - public ICompletionProposal createProposal(final String replacementText, - final String displayText, - final String additionalText, - final Image displayImage, - final Object targetObject) - { - return createDefaultProposal(replacementText, _replacementOffset, - _replacementLength, - replacementText.length(), displayImage, - displayText, null, additionalText, - getRelevance(targetObject)); - } - - private int getRelevance(Object target) - { - // put tag vars at top, followed by beans, then implicits and other - if (target instanceof IInstanceSymbol) - { - final IInstanceSymbol symbol = (IInstanceSymbol) target; - - switch (symbol.getRuntimeSource().getValue()) - { - case ERuntimeSource.TAG_INSTANTIATED_SYMBOL: - return HIGH_RELEVANCE; - case ERuntimeSource.MANAGED_BEAN_SYMBOL: - return NORMAL_RELEVANCE; - case ERuntimeSource.BUILT_IN_SYMBOL: - case ERuntimeSource.OTHER: - return LOW_RELEVANCE; - } - } - - // if none of the above, return low relevance - return LOW_RELEVANCE; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigDialogSettingData.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigDialogSettingData.java deleted file mode 100644 index 93086db36..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigDialogSettingData.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Justin Chen - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties; -import org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE; - -/** - * To construct implementation library and component libraries from sticky values - * in DialogSettings as saved libraries. - * - * @author Justin Chen - Oracle - */ -public class JSFLibraryConfigDialogSettingData implements JSFLibraryConfiglModelSource { - /** - * Delimintor for parsing a persistent property string. - */ - final protected static String SEPARATOR =":"; //$NON-NLS-1$ - - final private JSFLibraryRegistryUtil jsfLibReg; - final private boolean dftImplLibDeployFlag; - private String[] savedCompLibs; - private JSFLibraryInternalReference selJSFLibImpl; // lazy initialized - private List selJSFLibComp; // lazy initialized - - private IMPLEMENTATION_TYPE implType; - - - /** - * Constructor where implementation type was chosen to be CLIENT_SUPPLIED. Created for backwards compatibilty when server supplied was not an option. - * @param implLibDeployFlag - * @param compLibs - */ - public JSFLibraryConfigDialogSettingData(boolean implLibDeployFlag, String[] compLibs) { - this(IMPLEMENTATION_TYPE.CLIENT_SUPPLIED, implLibDeployFlag, compLibs); - } - - /** - * Constructor - * @param implType {@link IMPLEMENTATION_TYPE} - * @param implLibDeployFlag String valid options are "true" or "false" - * @param compLibs String[] saved component library settings in string array - * - public JSFLibraryConfigDialogSettingData(String implLibDeployFlag, String[] compLibs) { - this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); - this.dftImplLibDeployFlag = implLibDeployFlag; - this.savedCompLibs = compLibs; - - // Verify and log a message if a saved component library no longer exists. - verifySavedLibAvailability(); - } - */ - public JSFLibraryConfigDialogSettingData(IMPLEMENTATION_TYPE implType, boolean implLibDeployFlag, String[] compLibs) { - - this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); - this.dftImplLibDeployFlag = implLibDeployFlag; - this.savedCompLibs = compLibs; - this.implType = implType; - - // Verify and log a message if a saved component library no longer exists. - verifySavedLibAvailability(); - } - - /** - * There is no saved JSFImplLibrary per se if initializing from DialogSettings - * since default implementation library is always selected and only the - * deployment flag is saved. - * - * A null is returned when there is no default - * implementation library in registry. - * - * @return selJSFLibImpl JSFLibraryInternalReference return default implementation library with updated deployment flag - */ - public JSFLibraryInternalReference getJSFImplementationLibrary() { - if (selJSFLibImpl == null) { - // To instanciate a JSFLibraryReferenceUserDefined object from default impl lib as the saved library. - JSFLibraryInternalReference dftImplLib = jsfLibReg.getDefaultJSFImplementationLibrary(); - if (dftImplLib != null) { - selJSFLibImpl = new JSFLibraryInternalReference(dftImplLib.getLibrary(), - true, // selected - dftImplLibDeployFlag); - } - } - return selJSFLibImpl; - } - - /** - * Return the list of saved component libraries and their deployment settings. - * - * @return selJSFLibComp List - */ - public List getJSFComponentLibraries() { - if (selJSFLibComp == null) { - selJSFLibComp = new ArrayList(); - - if (savedCompLibs != null && savedCompLibs.length > 0) { - JSFLibraryInternalReference lib = null; - String item; - String[] attributes; - String id; - boolean deploy = false; - - for (int i = 0; i < savedCompLibs.length; i++) { - item = savedCompLibs[i]; - attributes = item.split(SEPARATOR); - - id = attributes[0]; - deploy = Boolean.valueOf(attributes[1]).booleanValue(); - - lib = jsfLibReg.getJSFLibraryReferencebyID(id); - if (lib != null) { - selJSFLibComp.add(new JSFLibraryInternalReference(lib.getLibrary(), true, deploy)); - } /*else { - // already logged if a saved component library is no longer available. - }*/ - } - } - } - return selJSFLibComp; - } - - /** - * Only need to verify component library availability from sticky settings. - */ - private void verifySavedLibAvailability() { - List validLibs = new ArrayList(); - if (savedCompLibs != null && savedCompLibs.length > 0) { - String item = null; - String[] attributes; - boolean invalidRefs = false; - for (int i = 0; i < savedCompLibs.length; i++) { - item = savedCompLibs[i]; - attributes = item.split(SEPARATOR); - - if (jsfLibReg.getJSFLibraryReferencebyID(attributes[0]) != null) { - validLibs.add(item); - } else { - invalidRefs = true; -// JSFCorePlugin.log(IStatus.INFO, Messages.JSFLibCfgDialogSettingData_Sticky_Component_Lib_Not_Exist); - } - } - if (invalidRefs){ - String [] validCompLibs = (String[])validLibs.toArray(new String[validLibs.size()]); - if (validCompLibs.length > 0) - System.arraycopy(validCompLibs, 0, savedCompLibs, 0, validCompLibs.length); - else - savedCompLibs = new String[]{}; - } - } - - - } - - /** - * @return {@link IMPLEMENTATION_TYPE} - */ - public IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE getImplementationType(){ - return implType; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModel.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModel.java deleted file mode 100644 index 63213534b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModel.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Oracle - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE; - -/** - * Model for the custom control <b>JSFLibraryConfigControl</b>. - * A JSFLibraryConfigModel object is initialized from a source and updated with - * selected implementation and component libraries when selections are changed. - * - * @author Justin Chen - Oracle - */ -public class JSFLibraryConfigModel { - final private JSFLibraryConfiglModelSource data; - final private JSFLibraryRegistryUtil jsfLibReg; - private List colJSFImplLib; - private List colJSFCompLib; - - /** - * Private constructor. - * @param data - */ - private JSFLibraryConfigModel(JSFLibraryConfiglModelSource data) { - this.data = data; - this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); - } - - /** - * @return IMPLEMENTATION_TYPE - */ - public IMPLEMENTATION_TYPE getImplementationType() { - return data.getImplementationType(); - } - /** - * Return JSF implementation libraries. - * - * This list is initialized from JSF library registry and updated with persistent configuration data. - * - * @return List - * see also org.eclipse.jst.jsf.ui.properties.IJSFLibraryDecoratorProvider#getProjectJSFImplementationLibraries() - */ - public List getJSFImplementationLibraries() { - if (colJSFImplLib == null) { - /* To initialze an implementation library list from registry - * and then update the list with saved implementation library. - */ - colJSFImplLib = jsfLibReg.getJSFImplementationLibraries(); -// colJSFImplLib.add(JSFLibraryRegistryUtil.getInstance().getServerSuppliedJSFLibrary()); - JSFLibraryInternalReference targetLib = data.getJSFImplementationLibrary(); - if (targetLib == null) { - // no saved implementation, get default implementation library - targetLib = jsfLibReg.getDefaultJSFImplementationLibrary(); - } - if (targetLib != null) { - JSFLibraryInternalReference srcLib = jsfLibReg.getJSFLibraryReferencebyID(targetLib.getID()); - if (srcLib != null) { - srcLib.setSelected(true); - srcLib.setToBeDeployed(targetLib.isCheckedToBeDeployed()); - } - } - } - return colJSFImplLib; - } - - /** - * Return JSF component libraries. - * - * This list is initialized from JSF library registry and updated with persistent - * configuration data. - * - * @return List - * see also org.eclipse.jst.jsf.ui.properties.IJSFLibraryDecoratorProvider#getProjectJSFComponentLibraries() - */ - public List getJSFComponentLibraries() { - if (colJSFCompLib == null) { - /* To initialize a component library list from registry and then - * update list with saved component libraries. - */ - colJSFCompLib = jsfLibReg.getJSFComponentLibraries(); - Iterator it = data.getJSFComponentLibraries().iterator(); - JSFLibraryInternalReference targetItem = null; - JSFLibraryInternalReference srcItem = null; - while (it.hasNext()) { - targetItem = (JSFLibraryInternalReference) it.next(); - srcItem = jsfLibReg.getJSFLibraryReferencebyID(targetItem.getID()); - if (srcItem != null) { - srcItem.setSelected(true); - srcItem.setToBeDeployed(targetItem.isCheckedToBeDeployed()); - } - } - } - return colJSFCompLib; - } - - /** - * Return the selected JSF implementation library currently. - * A null is returned if none is selected. - * - * @return JSFLibraryInternalReference - */ - public JSFLibraryInternalReference getCurrentJSFImplementationLibrarySelection() { - Iterator it = getJSFImplementationLibraries().iterator(); - JSFLibraryInternalReference crtItem = null; - while (it.hasNext()) { - crtItem = (JSFLibraryInternalReference) it.next(); - if (crtItem.isSelected()) { - return crtItem; - } - } - return null; - } - - /** - * Return the selected JSF component libraries currently. - * An empty list is returned when no component libraries are selected. - * - * @return list List - */ - public List getCurrentJSFComponentLibrarySelection() { - List list = new ArrayList(); - - Iterator it = getJSFComponentLibraries().iterator(); - JSFLibraryInternalReference crtItem = null; - while (it.hasNext()) { - crtItem = (JSFLibraryInternalReference) it.next(); - if (crtItem.isSelected()) { - list.add(crtItem); - } - } - return list; - } - - /** - * Returned a saved implementation library which was persisted as - * DialogSettings or as project properties. - * - * @return JSFLibraryInternalReference - */ - public JSFLibraryInternalReference getSavedJSFImplementationLibrary() { - return data.getJSFImplementationLibrary(); - } - - /** - * Returned saved component libraries which were persisted as - * DialogSettings or project persistent properties. - * - * @return List - */ - public List getSavedJSFComponentLibraries() { - return data.getJSFComponentLibraries(); - } - - /** - * Update the selected JSF implementation library. - * - * Note: The library parameter won't be not added into the collection - * if it does not exist already. - * - * @param library JSFLibraryInternalReference - */ - public void setCurrentJSFImplementationLibrarySelection(final JSFLibraryInternalReference library) { - if (library != null) { - Iterator it = getJSFImplementationLibraries().iterator(); - JSFLibraryInternalReference crtjsflib = null; - while (it.hasNext()) { - crtjsflib = (JSFLibraryInternalReference) it.next(); - if (crtjsflib.getID().equals(library.getID())) { - crtjsflib.setSelected(true); - crtjsflib.setToBeDeployed(library.isCheckedToBeDeployed()); - } else { - crtjsflib.setSelected(false); - } - } - } - } - - /** - * Update the JSF library component libraries selection. - * - * @param libraries List - */ - public void setCurrentJSFComponentLibrarySelection(final List libraries) { - if (libraries != null) { - /* Reset all item in component library list to unselect first. - * Then, update each item in cmponent libraries to the provided list. - */ - setJSFLibrariesSelection(getJSFComponentLibraries(), false); - - Iterator it = libraries.iterator(); - JSFLibraryInternalReference crtItem; - JSFLibraryInternalReference srcItem = null; - while (it.hasNext()) { - crtItem = (JSFLibraryInternalReference) it.next(); - srcItem = jsfLibReg.getJSFLibraryReferencebyID(crtItem.getID()); - - if (srcItem != null) { - srcItem.setSelected(true); - srcItem.setToBeDeployed(crtItem.isCheckedToBeDeployed()); - } - } - } - } - - /** - * To save current configuration of implementation and component libraries - * as project properties. - * - * @param project IProject - */ - public void saveData(final IProject project) { - // Instantiate one to make sure it is for a project. - JSFLibraryConfigProjectData data_ = new JSFLibraryConfigProjectData(project); - List implLibs = new ArrayList(); - implLibs.add(getCurrentJSFImplementationLibrarySelection()); - data_.saveData(implLibs, getCurrentJSFComponentLibrarySelection(), getImplementationType()); - } - - /** - * Set selection state to given state to each libray in the collection. - * - * @param libs List - * @param state boolean - */ - private void setJSFLibrariesSelection(final List libs, final boolean state) { - Iterator it = libs.iterator(); - JSFLibraryInternalReference crtjsflib; - while (it.hasNext()) { - crtjsflib = (JSFLibraryInternalReference) it.next(); - crtjsflib.setSelected(state); - } - } - - /** - * Factory class to create new JSFLibraryConfigModel instances - */ - public static final class JSFLibraryConfigModelFactory { - /** - * To create a new instance of JSFLibraryConfigModel object. - * A NullPointerException is raised if source is null. - * - * @param source JSFLibraryConfiglModelSource - * @return JSFLibraryConfigModel - */ - public static JSFLibraryConfigModel createInstance(final JSFLibraryConfiglModelSource source) { - if (source == null) { - throw new NullPointerException(Messages.JSFLibraryConfigModel_Null_Data_Source); - } - return new JSFLibraryConfigModel(source); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigProjectData.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigProjectData.java deleted file mode 100644 index 70d36dc0d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigProjectData.java +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Oracle - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.project.facet.JSFUtils; -import org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE; -import org.eclipse.osgi.util.NLS; - -/** - * To construct implementation library and component libraries - * from persistent project properties as saved libraries. - * - * @author Justin Chen - Oracle - */ -public class JSFLibraryConfigProjectData implements JSFLibraryConfiglModelSource { - final static String QUALIFIEDNAME = "org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigProjectData"; - /** - * Parsing delimnitor for elements in a tuple. - */ - final protected static String SPTR_TUPLE = ":"; //$NON-NLS-1$ - /** - * Parsing delimintor for tuples in a persistent property string. - */ - final protected static String EO_TUPLE = ";"; //$NON-NLS-1$ - - final private IProject project; - final private JSFLibraryRegistryUtil jsfLibReg; - private JSFLibraryInternalReference selJSFLibImpl; - private List selJSFLibComp; - - /** - * Constructor - * @param project - */ - public JSFLibraryConfigProjectData(IProject project) { - this.project = project; - this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); - - /* logging message when object is instantiated instead of at method call to - * reduce log entries. - */ - if (!isProjectFirstCreated()) { - verifySavedLibAvailability(); - } - } - - public IMPLEMENTATION_TYPE getImplementationType() { - try { - String type = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, - JSFUtils.PP_JSF_IMPLEMENTATION_TYPE)); - return IMPLEMENTATION_TYPE.getValue(type); - } catch (CoreException e) {// - } - return IMPLEMENTATION_TYPE.UNKNOWN; - } - - /** - * Return the previously selected JSF implementation library from project persistent properties. - * Return null if none exists. - * - * @return selJSFLibImpl JSFLibraryDecorator - */ - public JSFLibraryInternalReference getJSFImplementationLibrary() { - try { - if (!isProjectFirstCreated() && - selJSFLibImpl == null ) { - String strImplLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, - JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); - selJSFLibImpl = getJSFImplLibfromPersistentProperties(getTuples(strImplLibs)); - } - } catch (CoreException e) { - JSFCorePlugin.log(e, "Exception occured while returning reference to the JSF implementation library"); - } - return selJSFLibImpl; - } - - /** - * Return the selected JSF component libraries from project persistent properties. - * An empty List is returned if no JSF component libraries were saved or - * if the project is newly created. - * - * @return selJSFLibComp List - */ - public List getJSFComponentLibraries() { - try { - if (!isProjectFirstCreated()) { - if ( selJSFLibComp == null ) { - selJSFLibComp = new ArrayList(); - - String strCompLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES)); - List savedList = getTuples(strCompLibs); - - Iterator it = savedList.iterator(); - Tuple crtTuple = null; - JSFLibraryInternalReference srcItem = null; - while (it.hasNext()) { - crtTuple = (Tuple) it.next(); - - srcItem = jsfLibReg.getJSFLibraryReferencebyID(crtTuple.getID()); - if (srcItem != null) { - selJSFLibComp.add( new JSFLibraryInternalReference(srcItem.getLibrary(), - true, - crtTuple.needDeploy()) ); - } /*else { - // already logged a message for a missing library - }*/ - } - } - } else { - selJSFLibComp = new ArrayList(0); - } - } catch (CoreException e) { - JSFCorePlugin.log(e, "Exception occured while returning references to the JSF component libraries."); - } - return selJSFLibComp; - } - - /** - * To save configuration data as a project persistent properties. - * - * @param implementation - * @param component - */ - void saveData(final List implementation, final List component, final IMPLEMENTATION_TYPE implType) { - try { - ((IResource)project).setPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES), generatePersistString(implementation)); - ((IResource)project).setPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES), generatePersistString(component)); - ((IResource)project).setPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_IMPLEMENTATION_TYPE), IMPLEMENTATION_TYPE.getStringValue(implType)); - - /* Flush the selection so that they can be reconstructed from - * persistent properties when getSavedJSFImplLib and getSavedJSFCompLibs - * called next time. - */ - selJSFLibImpl = null; - selJSFLibComp = null; - - } catch (CoreException e) { - JSFCorePlugin.log(e, "Exception occured while persisting the JSF Library preferences"); - } - } - - /** - * Check if a project is just created by inspecting persistent properties - * if there is any. ? - */ - private boolean isProjectFirstCreated() { - boolean isNew = false; - try { - ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, - JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); - } catch (CoreException e) { - isNew = true; - } - return isNew; - } - - private void verifySavedLibAvailability() { - try { - String strImplLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); - String strCompLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES)); - - logMissingLib(getTuples(strImplLibs), true); - logMissingLib(getTuples(strCompLibs), false); - - } catch (CoreException e) { - JSFCorePlugin.log(e, "Exception occured while verifying saved JSF Library preferences"); - } - } - - private void logMissingLib(final List jsfLibTuples, final boolean isVerifyImpl) { - if (jsfLibReg != null) { - Iterator itTuple = jsfLibTuples.iterator(); - while(itTuple.hasNext()) { - Tuple tuple = (Tuple)itTuple.next(); - JSFLibraryInternalReference jsfLib = jsfLibReg.getJSFLibraryReferencebyID(tuple.getID()); - /* Information logged when saved JSF lib is removed from registry. - * One log entry is created for each missing library. - */ - if (jsfLib == null) { - String prjName = project.getName(); - String msg = (isVerifyImpl) ? - Messages.JSFLibraryConfigPersistData_SAVED_IMPLLIB_NOT_FOUND : - Messages.JSFLibraryConfigPersistData_SAVED_COMPLIB_NOT_FOUND; - JSFCorePlugin.log(IStatus.INFO, NLS.bind(msg, prjName)); - } - } - } - } - - private JSFLibraryInternalReference getJSFImplLibfromPersistentProperties(final List jsfLibTuples) { - if (jsfLibReg != null) { - Tuple tuple = null; - JSFLibraryInternalReference lib = null; - Iterator itTuple = jsfLibTuples.iterator(); - while(itTuple.hasNext()) { - tuple = (Tuple) itTuple.next(); - lib = jsfLibReg.getJSFLibraryReferencebyID(tuple.id); - if (lib != null) { - return new JSFLibraryInternalReference(lib.getLibrary(), - tuple.selected, - tuple.deploy); - } /*else { - // already logged a message for a missing library - }*/ - } - } - return null; - } - - private String generatePersistString(List list) { - JSFLibraryInternalReference jsfLibItem; - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < list.size(); i++) { - jsfLibItem = (JSFLibraryInternalReference)list.get(i); - sb = sb.append(jsfLibItem.generatePersistString()); - sb.append(JSFLibraryConfigProjectData.EO_TUPLE); - } - return sb.toString(); - } - - private List getTuples(String strJSFLibs) { - List list = new ArrayList(); - - if (strJSFLibs != null) { - String patternStr = JSFLibraryConfigProjectData.EO_TUPLE; - String[] fields = strJSFLibs.split(patternStr); - if (strJSFLibs.length() > 0) { - Tuple tuple; - for (int i = 0; i < fields.length; i++) { - tuple = new Tuple(fields[i]); - list.add(tuple); - } - } - } - return list; - } - - /** - * Inner class for parsing project persistent properties. - * - * To Do: Take out selected attribute since it is not needed. - * Add the library name as an attribute. - * Provide code path to migrate earlier project. - * - * NOTE: this class should no longer be used except to support - * legacy (pre-2.0M6 library registries) - */ - static class Tuple { - final private String id; - final private boolean selected; - final private boolean deploy; - - Tuple(String id, boolean selected, boolean deploy) { - this.id = id; - this.selected = selected; - this.deploy = deploy; - } - // parse tuple = ID:selected:deploy - Tuple(String tuple) { - String[] fields = tuple.split(JSFLibraryConfigProjectData.SPTR_TUPLE); - - if (fields.length >= 3) - { - this.id = fields[0]; - this.selected = Boolean.valueOf(fields[1]).booleanValue(); - this.deploy = Boolean.valueOf(fields[2]).booleanValue(); - } - else - { - throw new IllegalStateException("Library registry is corrupt"); - } - } - - String getID() { - return id; - } - - boolean isSelected() { - return selected; - } - - boolean needDeploy() { - return deploy; - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfiglModelSource.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfiglModelSource.java deleted file mode 100644 index 557583573..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfiglModelSource.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Justin Chen - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import java.util.List; - -import org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE; - -/** - * Interface for data source to instanciate a <b>JSFLibraryConfigModel</b> object. - * - * @author Justin Chen - Oracle - */ -public interface JSFLibraryConfiglModelSource { - /** - * Return a saved JSF implementation library. - * Depends on the model source, it could be sticky values from DialogSettings or - * project property values. - * - * A null could be returned when creating first web project in a new workspace. - * - * @return JSFLibraryInternalReference - */ - public JSFLibraryInternalReference getJSFImplementationLibrary(); - - /** - * Return a list of saved JSF component libraries. - * Otheriwse, return an empty list. - * - * @return List - */ - public List getJSFComponentLibraries(); - - /** - * Return type of implementation - * - * @return {@link IMPLEMENTATION_TYPE} - */ - public IMPLEMENTATION_TYPE getImplementationType(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryInternalReference.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryInternalReference.java deleted file mode 100644 index aca5bf540..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryInternalReference.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Oracle - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; - -/** - * Attach additonal attributes such as selection and deployment - * to a JSF library when it is referenced by a project. - * - * @author Justin Chen - Oracle - */ -public class JSFLibraryInternalReference { - final private JSFLibrary jsfLib; - private boolean check4Deploy; // Initialized from default in workspace - private boolean selected; // selected for project - - /** - * Constructor - * @param jsfLib JSFLibrary instance embedded inside. - * @param selected boolean true if selected, otherwise, not selected. - * @param deploy boolean true if needs to be deployed, otherwise, won't be deployed. - */ - public JSFLibraryInternalReference(JSFLibrary jsfLib, boolean selected, boolean deploy) { - this.jsfLib = jsfLib; - this.selected = selected; - this.check4Deploy = deploy; - } - - /** - * Return the embedded JSFLibrary instance. - * - * @return jsfLib JSFLibrary - */ - public JSFLibrary getLibrary() { - return jsfLib; - } - - /** - * Set the to be deployed flag. - * - * @param deploy boolean - */ - public void setToBeDeployed(final boolean deploy) { - check4Deploy = deploy; - } - - /** - * Return true if the JSF library needs to be deployed. - * Otheriwse, return false. - * - * @return boolean - */ - public boolean isCheckedToBeDeployed() { - return check4Deploy; - } - - /** - * Set the selected attribute to a JSFLibraryLibraryReference object. - * - * @param selected boolean - */ - public void setSelected(final boolean selected) { - this.selected = selected; - } - - /** - * Return true if the JSF library is referenced by a project. - * Otherwise, return false. - * - * @return selected boolean - */ - public boolean isSelected() { - return selected; - } - - /** - * To generate a string that represents the JSFLibraryLibraryReference - * object for persistence. - * - * @return String - */ - protected String generatePersistString() { - return (getID() + JSFLibraryConfigProjectData.SPTR_TUPLE + - String.valueOf(isSelected()) + JSFLibraryConfigProjectData.SPTR_TUPLE + - String.valueOf(isCheckedToBeDeployed())); - } - - /** - * Helper method to return the library ID from the embedded - * JSFLibrary instance. - * - * @return id String - */ - public String getID() { - return jsfLib.getID(); - } - - /** - * Helper method to return the library name from the embedded - * JSFLibrary instance. - * - * @return name String - */ - public String getName() { - return jsfLib.getName(); - } - - /** - * Helper method to return the label for the library from the embedded - * JSFLibrary instance. - * - * @return name String - */ - public String getLabel() { - return jsfLib.getLabel(); - } - - /** - * Return true if the embedded JSF library instance i implementation. - * Otherwise, return false. - * - * @return boolean - */ - public boolean isImplementation() { - return jsfLib.isImplementation(); - } - - /** - * Help method to return a list of Archive files from - * the embedded JSFLibrary instance. - * - * @return boolean - */ - public EList getArchiveFiles() { - return jsfLib.getArchiveFiles(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryRegistryUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryRegistryUtil.java deleted file mode 100644 index 0e3c02ac2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryRegistryUtil.java +++ /dev/null @@ -1,604 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Oracle - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.InvalidRegistryObjectException; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.JSFLibraryClasspathContainer; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.RegistryUpgradeCommitHandler; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.adapter.MaintainDefaultImplementationAdapter; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.JSFLibraryRegistryResourceFactoryImpl; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.JSFLibraryRegistryResourceImpl; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.JSFLibraryRegistryUpgradeUtil; -import org.eclipse.jst.jsf.core.internal.project.facet.JSFUtils; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper; -import org.eclipse.jst.jsf.core.jsflibraryregistry.PluginProvidedJSFLibraryCreationHelper; -import org.eclipse.jst.jsf.core.jsflibraryregistry.internal.PluginProvidedJSFLibraryCreationHelper2; - -/** - * A singleton maintains lists of implementation and component libraries - * in registry. - * - * Each item in the lists contains a workingcopy of a JSF library and - * decorates with usage information such selection and deployment. - * - * The lists are updated when there are changes in JSF library registry. - * - * @author Justin Chen, etc. - Oracle - */ -public class JSFLibraryRegistryUtil { - private static JSFLibraryRegistryUtil instance = null; - - private List implLibs = null; - private List compLibs = null; - - - // The NS URI of the JSF Library Registry's Ecore package. (Must match - // setting on package in Ecore model.) - private static final String JSF_LIBRARY_REGISTRY_NSURI = "http://www.eclipse.org/webtools/jsf/schema/jsflibraryregistry.xsd"; //$NON-NLS-1$ - - private static final String LIB_EXT_PT = "pluginProvidedJsfLibraries"; //$NON-NLS-1$ - //deprecated ext-pt - private static final String OLD_LIB_EXT_PT = "jsfLibraries"; //$NON-NLS-1$ - - // The JSF Library Registry EMF resource instance. - private static JSFLibraryRegistryResourceImpl jsfLibraryRegistryResource = null; - - //JSFLibraryRegistry singleton - private JSFLibraryRegistry jsfLibraryRegistry; - - /** - * Private constructor - */ - private JSFLibraryRegistryUtil() { - //nothing to do - } - - /** - * Return the singleton instance of JSFLibraryRegistryUtil. - * - * @return JSFLibraryRegistryUtil - */ - public synchronized static JSFLibraryRegistryUtil getInstance() { - if ( instance == null ) { - instance = new JSFLibraryRegistryUtil(); - instance.loadJSFLibraryRegistry(); - } - return instance; - } - - /** - * Convenience method to return the JSFLibraryRegistry instance. - * - * @return jsfLibReg JSFLibraryRegistry - */ - public JSFLibraryRegistry getJSFLibraryRegistry() { - return jsfLibraryRegistry; - } - - /** - * Get the default JSF implementation library instance. - * A null is returned when there is no libraries in the registry. - * - * @return JSFLibraryInternalReference - */ - public JSFLibraryInternalReference getDefaultJSFImplementationLibrary() { - JSFLibrary dftImplLib = getJSFLibraryRegistry().getDefaultImplementation(); - - return ((dftImplLib != null) ? - getJSFLibraryReferencebyID(dftImplLib.getID()) : - null); - } - - /** - * Get the working copy of JSF implementation libraries. - * The list is updated when there are changes in registry. - * - * @return List - */ - List getJSFImplementationLibraries() { - if (implLibs == null) { - implLibs = wrapJSFLibraries(getJSFLibraryRegistry().getImplJSFLibraries()); - } else { - if (implLibs.size() != getJSFLibraryRegistry().getImplJSFLibraries().size() || - isAnyLibraryChanged(implLibs)) { - implLibs.clear(); - implLibs = wrapJSFLibraries(getJSFLibraryRegistry().getImplJSFLibraries()); - } - } - return implLibs; - } - - /** - * Get the working copy of JSF component libraries. - * The list is updated when there are changes in registry. - * - * @return List - */ - List getJSFComponentLibraries() { - if (compLibs == null) { - compLibs = wrapJSFLibraries(getJSFLibraryRegistry().getNonImplJSFLibraries()); - } else { - if (compLibs.size() != getJSFLibraryRegistry().getNonImplJSFLibraries().size() || - isAnyLibraryChanged(compLibs)) { - compLibs.clear(); - compLibs = wrapJSFLibraries(getJSFLibraryRegistry().getNonImplJSFLibraries()); - } - } - return compLibs; - } - - /** - * Get the JSFLibraryDecorator object from the provided ID. - * A null is returned no library matches the ID. - * - * @param id String - * @return JSFLibraryDecorator - */ - public JSFLibraryInternalReference getJSFLibraryReferencebyID(final String id) { - Iterator it = getJSFImplementationLibraries().iterator(); - JSFLibraryInternalReference crtItem = null; - - // search implementation libraries - while(it.hasNext()) { - crtItem = (JSFLibraryInternalReference)it.next(); - if (id.equals(crtItem.getID())) { - return crtItem; - } - } - // search component libraries - it = getJSFComponentLibraries().iterator(); - while(it.hasNext()) { - crtItem = (JSFLibraryInternalReference)it.next(); - if (id.equals(crtItem.getID())) { - return crtItem; - } - } - return null; - } - - /** - * Add a JSF Library into collection for either - * JSF implementation libraries or component libraries. - * The decision is based on if a JSF library is an implementation. - * - * @param library JSFLibraryLibraryReference - */ - public void addJSFLibrary(final JSFLibraryInternalReference library) { - // Library is added only if it does not exist in registry - if (library != null && getJSFLibraryRegistry().getJSFLibraryByID(library.getID()) == null) { - // Add the library working copy into workspace registry. - JSFLibrary jsfLib = library.getLibrary(); - getJSFLibraryRegistry().addJSFLibrary(jsfLib.getWorkingCopy()); - - // Add library into the collection depends on its type. - List list = (library.isImplementation() ? - getJSFImplementationLibraries() : - getJSFComponentLibraries()); - list.add(library); - } - } - - private List wrapJSFLibraries(final EList libs) { - List list = new ArrayList(); - if (libs != null) { - JSFLibrary jsfLib; - JSFLibraryInternalReference jsfLibDctr; - - Iterator it = libs.iterator(); - while (it.hasNext()) { - jsfLib = (JSFLibrary) it.next(); - // Set unselected and undeployed initially. - jsfLibDctr = new JSFLibraryInternalReference(jsfLib, //.getWorkingCopy(), - false, - false); - list.add(jsfLibDctr); - } - } - return list; - } - - private boolean isAnyLibraryChanged(final List list) { - Iterator it = list.iterator(); - JSFLibraryInternalReference wclib = null; // working copy library - JSFLibrary lib = null; - - while(it.hasNext()) { - wclib = (JSFLibraryInternalReference)it.next(); - lib = getJSFLibraryRegistry().getJSFLibraryByID(wclib.getID()); - if (lib == null) { // removed. Hence, changed. - return true; - } - if (wclib.getArchiveFiles().size() != - lib.getArchiveFiles().size()) { // Archives changed.. - return true; - } - if (isAnyArchiveFileChanged(wclib.getArchiveFiles(), - lib.getArchiveFiles())) { // Check archive file changes. I.e., name and location - return true; - } - } - return false; - } - - private boolean isAnyArchiveFileChanged(final EList source, EList target) { - ArchiveFile arSrc = null; - Iterator it = source.iterator(); - while (it.hasNext()) { - arSrc = (ArchiveFile) it.next(); - if (!findMatchedArchive(arSrc, target)) { - return true; - } - } - return false; - } - - private boolean findMatchedArchive(ArchiveFile source, EList list) { - ArchiveFile target = null; - Iterator it = list.iterator(); - while (it.hasNext()) { - target = (ArchiveFile) it.next(); - if (target.equals(source)) { - return true; - } - } - return false; - } - - /** - * Get the classpath entries for a JSF Library - * @param lib - * @return IClasspathEntry[] - */ - public IClasspathEntry[] getClasspathEntries(JSFLibrary lib){ - //TODO: cache to optimize. probably belongs inside JSFLibrary model. - ArrayList res= new ArrayList(lib.getArchiveFiles().size()); - for (Iterator it=lib.getArchiveFiles().iterator();it.hasNext();) { - ArchiveFile jar= (ArchiveFile)it.next(); - if (jar != null && jar.exists()) { - IClasspathEntry entry = getClasspathEntry(jar); - if (entry != null) - res.add(entry); - } - } - IClasspathEntry[] entries= (IClasspathEntry[]) res.toArray(new IClasspathEntry[res.size()]); - return entries; - } - - /** - * Create IClasspathEntry for ArchiveFile - * @param jar - * @return IClasspathEntry - */ - public IClasspathEntry getClasspathEntry(ArchiveFile jar){ - IClasspathEntry entry = null; - if (jar !=null && jar.exists()){ - entry = JavaCore.newLibraryEntry(new Path(jar.getResolvedSourceLocation()), null, null);//, nu, sourceAttachRoot, accessRules, extraAttributes, false/*not exported*/); - } - return entry; - } - - /** - * Binds JSF Libraries to classpath containers when the library changes. - * - * This method will deal with library/cp container renames by removing the old classpath container and then adding. - * - * @param oldId - * @param newId - * @param removeAndAddBecauseOfRename - * @param monitor - * @throws JavaModelException - */ - public static void rebindClasspathContainerEntries(String oldId, String newId, boolean removeAndAddBecauseOfRename, IProgressMonitor monitor) throws JavaModelException { - IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); - IJavaProject[] projects= JavaCore.create(root).getJavaProjects(); - IPath containerPath= new Path(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID).append(newId); - IPath oldContainerPath = new Path(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID).append(oldId); - - JSFLibrary lib = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getJSFLibraryByID(newId); - List affectedProjects= new ArrayList(); - removeAndAddBecauseOfRename = (!oldId.equals(newId)); - // find all projects using the old container name... - for (int i= 0; i < projects.length; i++) { - IJavaProject project= projects[i]; - IClasspathEntry[] entries= project.getRawClasspath(); - for (int k= 0; k < entries.length; k++) { - IClasspathEntry curr= entries[k]; - if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { - if (oldContainerPath.equals(curr.getPath())) { - affectedProjects.add(project); - break; - } - } - } - } - - if (!affectedProjects.isEmpty()) { - IJavaProject[] affected= (IJavaProject[]) affectedProjects.toArray(new IJavaProject[affectedProjects.size()]); - IClasspathContainer[] containers= new IClasspathContainer[affected.length]; - removeAndAddBecauseOfRename = (!oldId.equals(newId)); - if (removeAndAddBecauseOfRename){//not very pretty... remove and add new container - IClasspathEntry newEntry = JavaCore.newContainerEntry(containerPath); - for (int i= 0; i < affected.length; i++) { - IJavaProject project= affected[i]; - IClasspathEntry[] entries= project.getRawClasspath(); - List keptEntries = new ArrayList(); - //keep all entries except the old one - for (int k= 0; k < entries.length; k++) { - IClasspathEntry curr= entries[k]; - if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER){ - if( ! oldContainerPath.equals(curr.getPath())) - keptEntries.add(curr); - } - else { - keptEntries.add(curr); - } - } - // add new container entry - keptEntries.add(newEntry); - setRawClasspath(project, keptEntries, monitor); - } - - } - else {//rebind - - JSFLibraryClasspathContainer container= new JSFLibraryClasspathContainer(lib); - containers[0] = container; - - JavaCore.setClasspathContainer(containerPath, affected, containers, monitor); - } - } else { - if (monitor != null) { - monitor.done(); - } - } - } - - /** - * Sets the raw classpath on a project and logs an error if it when a JavaModelException occurs - * @param project - * @param cpEntries - * @param monitor - */ - public static void setRawClasspath(IJavaProject project, List cpEntries, IProgressMonitor monitor) { - IClasspathEntry[] entries = (IClasspathEntry[])cpEntries.toArray(new IClasspathEntry[0]); - try { - project.setRawClasspath(entries, monitor); - } catch (JavaModelException e) { - JSFCorePlugin.log(e, "Unable to set classpath for: "+project.getProject().getName()); - } - } - - /** - * @param iproject - * @return true if iproject has persistent properties indicating that it may still - * be using V1 JSF Library references - */ - public static boolean doesProjectHaveV1JSFLibraries(IProject iproject) - { - if (iproject == null || !iproject.isAccessible()) - { - return false; // won't be able to get reading on a null or closed project - } - - try - { - Object compLib = iproject.getPersistentProperty(new QualifiedName(JSFLibraryConfigProjectData.QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES)); - Object implLib = iproject.getPersistentProperty(new QualifiedName(JSFLibraryConfigProjectData.QUALIFIEDNAME, JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); - - if (compLib != null || implLib != null) - { - return true; - } - } - catch(CoreException ce) - { - JSFCorePlugin.log(ce, "Error checking age of project"); - } - // by default, fall through to false - return false; - } - - /** - * Removes the persistent property from JSF projects tagged with - * V1 JSF libraries. - * @param projects - */ - public static void removeV1JSFLibraryProperty(List<IProject> projects) - { - for (final Iterator<IProject> it = projects.iterator(); it.hasNext();) - { - IProject project = it.next(); - try { - if (project.isAccessible()) - { - project.setPersistentProperty(new QualifiedName(JSFLibraryConfigProjectData.QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES), null); - project.setPersistentProperty(new QualifiedName(JSFLibraryConfigProjectData.QUALIFIEDNAME, JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES), null); - } - } catch (CoreException e) { - JSFCorePlugin.log(e, "Error removing JSF library persistent property"); - } - } - } - - /** - * Loads the JSFLibraryRegistry EMF object from plugin-specfic workspace - * settings location. - */ - private void loadJSFLibraryRegistry() { - try { - - EPackage.Registry.INSTANCE.put(JSF_LIBRARY_REGISTRY_NSURI, JSFLibraryRegistryPackageImpl.init()); - URI jsfLibRegURI = JSFLibraryRegistryUpgradeUtil.getRegistryURI(JSFLibraryRegistryUpgradeUtil.JSF_LIBRARY_REGISTRY_LATESTVERSION_URL); - JSFLibraryRegistryUpgradeUtil.getInstance().upgradeRegistryIfNecessary(JSFLibraryRegistryUpgradeUtil.LATESTVERSION); - - JSFLibraryRegistryResourceFactoryImpl resourceFactory = new JSFLibraryRegistryResourceFactoryImpl(); - jsfLibraryRegistryResource = (JSFLibraryRegistryResourceImpl)resourceFactory.createResource(jsfLibRegURI); - try { - Map options = new HashMap(); - //disable notifications during load to avoid changing stored default implementation - options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE); - jsfLibraryRegistryResource.load(options); - jsfLibraryRegistry = (JSFLibraryRegistry)jsfLibraryRegistryResource.getContents().get(0); - - loadJSFLibraryExtensions(); - loadDeprecatedJSFLibraryExtensions();//to be removed - - } catch(IOException ioe) { - //Create a new Registry instance - jsfLibraryRegistry = JSFLibraryRegistryFactory.eINSTANCE.createJSFLibraryRegistry(); - jsfLibraryRegistryResource = (JSFLibraryRegistryResourceImpl)resourceFactory.createResource(jsfLibRegURI); - jsfLibraryRegistryResource.getContents().add(jsfLibraryRegistry); - loadJSFLibraryExtensions(); - loadDeprecatedJSFLibraryExtensions();//to be removed - saveJSFLibraryRegistry(); - } - //add adapter to maintain default implementation - if (jsfLibraryRegistry != null) { - //check that a default impl is set. if not pick first one if available. - JSFLibrary defLib = jsfLibraryRegistry.getDefaultImplementation(); - if (defLib == null && jsfLibraryRegistry.getImplJSFLibraries().size() > 0){ - jsfLibraryRegistry.setDefaultImplementation((JSFLibrary)jsfLibraryRegistry.getImplJSFLibraries().get(0)); - saveJSFLibraryRegistry(); - } - jsfLibraryRegistry.eAdapters().add(MaintainDefaultImplementationAdapter.getInstance()); - - //commit - RegistryUpgradeCommitHandler.commitMigrationIfNecessary(); - } - } catch(MalformedURLException mue) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFLibraryRegistry_ErrorCreatingURL, mue); - } - } -///////////////////////////////// Load and Save JSF Library Registry //////////////////////////////////////////////// - - /** - * Creates library registry items from extension points. - */ - private void loadJSFLibraryExtensions() { - try { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(JSFCorePlugin.PLUGIN_ID, LIB_EXT_PT); - IExtension[] extensions = point.getExtensions(); - for (int i=0;i < extensions.length;i++){ - IExtension ext = extensions[i]; - for (int j=0;j < ext.getConfigurationElements().length;j++){ - PluginProvidedJSFLibraryCreationHelper2 newLibCreator = new PluginProvidedJSFLibraryCreationHelper2(ext.getConfigurationElements()[j]); - JSFLibrary newLib = newLibCreator.create(); - - /** - * Additional check on if a plug-in contributes jsflibraries is an expanded folder. - * Fix related to bug 144954. - * - * It would be ideal to check if a plug-in is distributed as a JAR - * before a JSFLibrary is created. - * - * This is a temporary solution since JARs in a JAR case is not - * supported in this release. Bug 14496. - */ - if (newLib != null) //&& isJSFLibinExpandedFolder(newLib)) - jsfLibraryRegistry.addJSFLibrary(newLib); - } - } - } catch (InvalidRegistryObjectException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFLibraryRegistry_ErrorLoadingFromExtPt, e); - } - } - - /** - * Creates deprecated library registry items from extension points. - * TO BE REMOVED - */ - private void loadDeprecatedJSFLibraryExtensions() { - try { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(JSFCorePlugin.PLUGIN_ID, OLD_LIB_EXT_PT); - IExtension[] extensions = point.getExtensions(); - for (int i=0;i < extensions.length;i++){ - IExtension ext = extensions[i]; - for (int j=0;j < ext.getConfigurationElements().length;j++){ - PluginProvidedJSFLibraryCreationHelper newLibCreator = new PluginProvidedJSFLibraryCreationHelper(ext.getConfigurationElements()[j]); - JSFLibrary newLib = newLibCreator.create(); - - /** - * Additional check on if a plug-in contributes jsflibraries is an expanded folder. - * Fix related to bug 144954. - * - * It would be ideal to check if a plug-in is distributed as a JAR - * before a JSFLibrary is created. - * - * This is a temporary solution since JARs in a JAR case is not - * supported in this release. Bug 14496. - */ - if (newLib != null ) //&& isJSFLibinExpandedFolder(newLib)) - jsfLibraryRegistry.addJSFLibrary(newLib); - } - } - } catch (InvalidRegistryObjectException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFLibraryRegistry_ErrorLoadingFromExtPt, e); - } - } - - /** - * Saves the JSFLibraryRegistry EMF object from plugin-specfic workspace - * settings location. (Called from stop(BundleContext).) - * @return true if save is successful - */ - public boolean saveJSFLibraryRegistry() { - boolean saved = false; - if (jsfLibraryRegistryResource != null) { - try { - jsfLibraryRegistryResource.save(Collections.EMPTY_MAP); - saved = true; - } catch(IOException ioe) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFLibraryRegistry_ErrorSaving, ioe); - } - } else { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFLibraryRegistry_ErrorSaving); - } - return saved; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/ArchiveFile.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/ArchiveFile.java deleted file mode 100644 index 01941eae1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/ArchiveFile.java +++ /dev/null @@ -1,221 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Archive File</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#isRelativeToWorkspace <em>Relative To Workspace</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getSourceLocation <em>Source Location</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getRelativeDestLocation <em>Relative Dest Location</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getJSFLibrary <em>JSF Library</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getArchiveFile() - * @model - * @generated - */ -public interface ArchiveFile extends EObject{ - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * Returns the value of the '<em><b>Source Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Source Location</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Source Location</em>' attribute. - * @see #setSourceLocation(String) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getArchiveFile_SourceLocation() - * @model required="true" - * @generated - */ - String getSourceLocation(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getSourceLocation <em>Source Location</em>}' attribute. - * <!-- begin-user-doc --> - * If the value passed is found to be relative to the workspace, a - * workspace-relative location is stored; to prevent this behaviour, call - * isRelativeToWorkspace(false) before calling this method. - * <!-- end-user-doc --> - * @param value the new value of the '<em>Source Location</em>' attribute. - * @see #getSourceLocation() - * @generated - */ - void setSourceLocation(String value); - - /** - * Returns the value of the '<em><b>Relative To Workspace</b></em>' attribute. - * The default value is <code>"true"</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Relative To Workspace</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Relative To Workspace</em>' attribute. - * @see #setRelativeToWorkspace(boolean) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getArchiveFile_RelativeToWorkspace() - * @model default="true" required="true" - * @generated - */ - boolean isRelativeToWorkspace(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#isRelativeToWorkspace <em>Relative To Workspace</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Relative To Workspace</em>' attribute. - * @see #isRelativeToWorkspace() - * @generated - */ - void setRelativeToWorkspace(boolean value); - - /** - * Returns the value of the '<em><b>Relative Dest Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Relative Dest Location</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Relative Dest Location</em>' attribute. - * @see #setRelativeDestLocation(String) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getArchiveFile_RelativeDestLocation() - * @model required="true" - * @generated - */ - String getRelativeDestLocation(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getRelativeDestLocation <em>Relative Dest Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Relative Dest Location</em>' attribute. - * @see #getRelativeDestLocation() - * @generated - */ - void setRelativeDestLocation(String value); - - /** - * Returns the value of the '<em><b>JSF Library</b></em>' container reference. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getArchiveFiles <em>Archive Files</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>JSF Library</em>' container reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>JSF Library</em>' container reference. - * @see #setJSFLibrary(JSFLibrary) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getArchiveFile_JSFLibrary() - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getArchiveFiles - * @model opposite="ArchiveFiles" required="true" - * @generated - */ - JSFLibrary getJSFLibrary(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getJSFLibrary <em>JSF Library</em>}' container reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>JSF Library</em>' container reference. - * @see #getJSFLibrary() - * @generated - */ - void setJSFLibrary(JSFLibrary value); - - /** - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Path</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * @return the path - * <!-- end-user-doc --> - * @model kind="operation" required="true" - * @generated - */ - String getPath(); - - /** - * <!-- begin-user-doc --> - * @return the name - * <!-- end-user-doc --> - * @model kind="operation" required="true" - * @generated - */ - String getName(); - - /** - * <!-- begin-user-doc --> - * @return true if exists - * <!-- end-user-doc --> - * @model required="true" - * @generated - */ - boolean exists(); - - /** - * <!-- begin-user-doc --> - * @param object - * @return true if equal - * <!-- end-user-doc --> - * @model required="true" objectRequired="true" - * @generated - */ - boolean equals(Object object); - - /** - * <!-- begin-user-doc --> - * @return the hashCode - * <!-- end-user-doc --> - * @model required="true" - * @generated - */ - int hashCode(); - - /** - * <!-- begin-user-doc --> - * @param baseDestLocation - * @return true if copied succeeds - * <!-- end-user-doc --> - * @model required="true" baseDestLocationRequired="true" - * @generated - */ - boolean copyTo(String baseDestLocation); - - /** - * <!-- begin-user-doc --> - * @return the resolved source location - * <!-- end-user-doc --> - * @model kind="operation" required="true" - * @generated - */ - String getResolvedSourceLocation(); - -} // ArchiveFile diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibrary.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibrary.java deleted file mode 100644 index a50d990f8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibrary.java +++ /dev/null @@ -1,236 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>JSF Library</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getID <em>ID</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getJSFVersion <em>JSF Version</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isDeployed <em>Deployed</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isImplementation <em>Implementation</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getArchiveFiles <em>Archive Files</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibrary() - * @model - * @generated - */ -public interface JSFLibrary extends EObject{ - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * Returns the value of the '<em><b>ID</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>ID</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>ID</em>' attribute. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibrary_ID() - * @model default="" transient="true" changeable="false" derived="true" - * @generated - */ - String getID(); - - /** - * Returns the value of the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Name</em>' attribute. - * @see #setName(String) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibrary_Name() - * @model required="true" - * @generated - */ - String getName(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getName <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Name</em>' attribute. - * @see #getName() - * @generated - */ - void setName(String value); - - /** - * Returns the value of the '<em><b>JSF Version</b></em>' attribute. - * The default value is <code>"UNKNOWN"</code>. - * The literals are from the enumeration {@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>JSF Version</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>JSF Version</em>' attribute. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion - * @see #setJSFVersion(JSFVersion) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibrary_JSFVersion() - * @model default="UNKNOWN" required="true" - * @generated - */ - JSFVersion getJSFVersion(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getJSFVersion <em>JSF Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>JSF Version</em>' attribute. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion - * @see #getJSFVersion() - * @generated - */ - void setJSFVersion(JSFVersion value); - - /** - * Returns the value of the '<em><b>Deployed</b></em>' attribute. - * The default value is <code>"true"</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Deployed</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Deployed</em>' attribute. - * @see #setDeployed(boolean) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibrary_Deployed() - * @model default="true" required="true" - * @generated - */ - boolean isDeployed(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isDeployed <em>Deployed</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Deployed</em>' attribute. - * @see #isDeployed() - * @generated - */ - void setDeployed(boolean value); - - /** - * Returns the value of the '<em><b>Implementation</b></em>' attribute. - * The default value is <code>"false"</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Implementation</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Implementation</em>' attribute. - * @see #setImplementation(boolean) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibrary_Implementation() - * @model default="false" required="true" - * @generated - */ - boolean isImplementation(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isImplementation <em>Implementation</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Implementation</em>' attribute. - * @see #isImplementation() - * @generated - */ - void setImplementation(boolean value); - - /** - * Returns the value of the '<em><b>Archive Files</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile}. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getJSFLibrary <em>JSF Library</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Archive Files</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Archive Files</em>' containment reference list. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibrary_ArchiveFiles() - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getJSFLibrary - * @model type="org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile" opposite="JSFLibrary" containment="true" - * @generated - */ - EList getArchiveFiles(); - - /** - * <!-- begin-user-doc --> - * @param fullPath - * @return true if fullPath contains archive file - * <!-- end-user-doc --> - * @model required="true" fullPathRequired="true" - * @generated - */ - boolean containsArchiveFile(String fullPath); - - /** - * <!-- begin-user-doc --> - * @return the working copy - * <!-- end-user-doc --> - * @model kind="operation" required="true" - * @generated - */ - JSFLibrary getWorkingCopy(); - - /** - * <!-- begin-user-doc --> - * @param otherLibrary - * <!-- end-user-doc --> - * @model otherLibraryRequired="true" - * @generated - */ - void updateValues(JSFLibrary otherLibrary); - - /** - * <!-- begin-user-doc --> - * @param baseDestLocation - * @return true if copy succeeds - * <!-- end-user-doc --> - * @model required="true" baseDestLocationRequired="true" - * @generated - */ - boolean copyTo(String baseDestLocation); - - /** - * <!-- begin-user-doc --> - * @return label - * <!-- end-user-doc --> - * @model kind="operation" required="true" - * @generated - */ - String getLabel(); - -} // JSFLibrary diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistry.java deleted file mode 100644 index 73b7057a4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistry.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.core.internal.Messages; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>JSF Library Registry</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getDefaultImplementationID <em>Default Implementation ID</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getJSFLibraries <em>JSF Libraries</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getPluginProvidedJSFLibraries <em>Plugin Provided JSF Libraries</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibraryRegistry() - * @model - * @generated - */ -public interface JSFLibraryRegistry extends EObject{ - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * Returns the value of the '<em><b>Default Implementation ID</b></em>' attribute. - * The default value is <code>""</code>. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Default Implementation ID</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Default Implementation ID</em>' attribute. - * @see #setDefaultImplementationID(String) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibraryRegistry_DefaultImplementationID() - * @model default="" - * @generated - */ - String getDefaultImplementationID(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getDefaultImplementationID <em>Default Implementation ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Default Implementation ID</em>' attribute. - * @see #getDefaultImplementationID() - * @generated - */ - void setDefaultImplementationID(String value); - - /** - *The default implementation message string - */ - public static final String DEFAULT_IMPL_LABEL = Messages.JSFLibraryRegistry_DEFAULT_IMPL_LABEL; - - /** - * Returns the value of the '<em><b>JSF Libraries</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>JSF Libraries</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>JSF Libraries</em>' containment reference list. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibraryRegistry_JSFLibraries() - * @model type="org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary" containment="true" - * @generated - */ - EList getJSFLibraries(); - - /** - * Returns the value of the '<em><b>Plugin Provided JSF Libraries</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Plugin Provided JSF Libraries</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Plugin Provided JSF Libraries</em>' containment reference list. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFLibraryRegistry_PluginProvidedJSFLibraries() - * @model type="org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary" containment="true" transient="true" - * @generated - */ - EList getPluginProvidedJSFLibraries(); - - /** - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Default Implementation</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * @return the default implementation - * <!-- end-user-doc --> - * @model kind="operation" required="true" - * @generated - */ - JSFLibrary getDefaultImplementation(); - - /** - * <!-- begin-user-doc --> - * @param implementation - * <!-- end-user-doc --> - * @model implementationRequired="true" - * @generated - */ - void setDefaultImplementation(JSFLibrary implementation); - - /** - * <!-- begin-user-doc --> - * @param ID - * @return the jsf library - * <!-- end-user-doc --> - * @model required="true" IDRequired="true" - * @generated - */ - JSFLibrary getJSFLibraryByID(String ID); - - /** - * <!-- begin-user-doc --> - * @param name - * @return the jsf libraries matching name - * <!-- end-user-doc --> - * @model required="true" many="false" nameRequired="true" - * @generated - */ - EList getJSFLibrariesByName(String name); - - /** - * <!-- begin-user-doc --> - * @return the implementation JSF libraries - * <!-- end-user-doc --> - * @model kind="operation" required="true" many="false" - * @generated - */ - EList getImplJSFLibraries(); - - /** - * <!-- begin-user-doc --> - * @return the non-implementation JSF libraries - * <!-- end-user-doc --> - * @model kind="operation" required="true" many="false" - * @generated - */ - EList getNonImplJSFLibraries(); - - /** - * <!-- begin-user-doc --> - * @return all the JSF libraries - * <!-- end-user-doc --> - * @model kind="operation" required="true" many="false" - * @generated - */ - EList getAllJSFLibraries(); - - /** - * <!-- begin-user-doc --> - * @param library - * @return true if add succeeds - * <!-- end-user-doc --> - * @model required="true" libraryRequired="true" - * @generated - */ - boolean addJSFLibrary(JSFLibrary library); - - /** - * <!-- begin-user-doc --> - * @param library - * @return true if remove succeeds - * <!-- end-user-doc --> - * @model required="true" libraryRequired="true" - * @generated - */ - boolean removeJSFLibrary(JSFLibrary library); - -} // JSFLibraryRegistry diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistryFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistryFactory.java deleted file mode 100644 index 77560bd6e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistryFactory.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry; - -import org.eclipse.emf.ecore.EFactory; - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage - * @generated - */ -public interface JSFLibraryRegistryFactory extends EFactory{ - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - JSFLibraryRegistryFactory eINSTANCE = org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryFactoryImpl.init(); - - /** - * Returns a new object of class '<em>JSF Library Registry</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>JSF Library Registry</em>'. - * @generated - */ - JSFLibraryRegistry createJSFLibraryRegistry(); - - /** - * Returns a new object of class '<em>JSF Library</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>JSF Library</em>'. - * @generated - */ - JSFLibrary createJSFLibrary(); - - /** - * Returns a new object of class '<em>Archive File</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Archive File</em>'. - * @generated - */ - ArchiveFile createArchiveFile(); - - /** - * Returns a new object of class '<em>Plugin Provided JSF Library</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Plugin Provided JSF Library</em>'. - * @generated - */ - PluginProvidedJSFLibrary createPluginProvidedJSFLibrary(); - - /** - * Returns the package supported by this factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the package supported by this factory. - * @generated - */ - JSFLibraryRegistryPackage getJSFLibraryRegistryPackage(); - -} //JSFLibraryRegistryFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistryPackage.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistryPackage.java deleted file mode 100644 index ac28f41f4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFLibraryRegistryPackage.java +++ /dev/null @@ -1,779 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -/** - * <!-- begin-user-doc --> - * The <b>Package</b> for the model. - * It contains accessors for the meta objects to represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory - * @model kind="package" - * @generated - */ -public interface JSFLibraryRegistryPackage extends EPackage{ - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The package name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNAME = "jsflibraryregistry"; - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_URI = "http://www.eclipse.org/webtools/jsf/schema/jsflibraryregistry.xsd"; - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_PREFIX = "jsflibreg"; - - /** - * The singleton instance of the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - JSFLibraryRegistryPackage eINSTANCE = org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl.init(); - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl <em>JSF Library Registry</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getJSFLibraryRegistry() - * @generated - */ - int JSF_LIBRARY_REGISTRY = 0; - - /** - * The feature id for the '<em><b>Default Implementation ID</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID = 0; - - /** - * The feature id for the '<em><b>JSF Libraries</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY_REGISTRY__JSF_LIBRARIES = 1; - - /** - * The feature id for the '<em><b>Plugin Provided JSF Libraries</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES = 2; - - /** - * The number of structural features of the '<em>JSF Library Registry</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY_REGISTRY_FEATURE_COUNT = 3; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl <em>JSF Library</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getJSFLibrary() - * @generated - */ - int JSF_LIBRARY = 1; - - /** - * The feature id for the '<em><b>ID</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY__ID = 0; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY__NAME = 1; - - /** - * The feature id for the '<em><b>JSF Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY__JSF_VERSION = 2; - - /** - * The feature id for the '<em><b>Deployed</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY__DEPLOYED = 3; - - /** - * The feature id for the '<em><b>Implementation</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY__IMPLEMENTATION = 4; - - /** - * The feature id for the '<em><b>Archive Files</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY__ARCHIVE_FILES = 5; - - /** - * The number of structural features of the '<em>JSF Library</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int JSF_LIBRARY_FEATURE_COUNT = 6; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl <em>Archive File</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getArchiveFile() - * @generated - */ - int ARCHIVE_FILE = 3; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.PluginProvidedJSFLibraryImpl <em>Plugin Provided JSF Library</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.PluginProvidedJSFLibraryImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getPluginProvidedJSFLibrary() - * @generated - */ - int PLUGIN_PROVIDED_JSF_LIBRARY = 2; - - /** - * The feature id for the '<em><b>ID</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__ID = JSF_LIBRARY__ID; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__NAME = JSF_LIBRARY__NAME; - - /** - * The feature id for the '<em><b>JSF Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__JSF_VERSION = JSF_LIBRARY__JSF_VERSION; - - /** - * The feature id for the '<em><b>Deployed</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__DEPLOYED = JSF_LIBRARY__DEPLOYED; - - /** - * The feature id for the '<em><b>Implementation</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__IMPLEMENTATION = JSF_LIBRARY__IMPLEMENTATION; - - /** - * The feature id for the '<em><b>Archive Files</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__ARCHIVE_FILES = JSF_LIBRARY__ARCHIVE_FILES; - - /** - * The feature id for the '<em><b>Plugin ID</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID = JSF_LIBRARY_FEATURE_COUNT + 0; - - /** - * The feature id for the '<em><b>Label</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY__LABEL = JSF_LIBRARY_FEATURE_COUNT + 1; - - /** - * The number of structural features of the '<em>Plugin Provided JSF Library</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int PLUGIN_PROVIDED_JSF_LIBRARY_FEATURE_COUNT = JSF_LIBRARY_FEATURE_COUNT + 2; - - /** - * The feature id for the '<em><b>Relative To Workspace</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ARCHIVE_FILE__RELATIVE_TO_WORKSPACE = 0; - - /** - * The feature id for the '<em><b>Source Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ARCHIVE_FILE__SOURCE_LOCATION = 1; - - /** - * The feature id for the '<em><b>Relative Dest Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ARCHIVE_FILE__RELATIVE_DEST_LOCATION = 2; - - /** - * The feature id for the '<em><b>JSF Library</b></em>' container reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ARCHIVE_FILE__JSF_LIBRARY = 3; - - /** - * The number of structural features of the '<em>Archive File</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ARCHIVE_FILE_FEATURE_COUNT = 4; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion <em>JSF Version</em>}' enum. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getJSFVersion() - * @generated - */ - int JSF_VERSION = 4; - - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry <em>JSF Library Registry</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>JSF Library Registry</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry - * @generated - */ - EClass getJSFLibraryRegistry(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getDefaultImplementationID <em>Default Implementation ID</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Default Implementation ID</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getDefaultImplementationID() - * @see #getJSFLibraryRegistry() - * @generated - */ - EAttribute getJSFLibraryRegistry_DefaultImplementationID(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getJSFLibraries <em>JSF Libraries</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>JSF Libraries</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getJSFLibraries() - * @see #getJSFLibraryRegistry() - * @generated - */ - EReference getJSFLibraryRegistry_JSFLibraries(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getPluginProvidedJSFLibraries <em>Plugin Provided JSF Libraries</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Plugin Provided JSF Libraries</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry#getPluginProvidedJSFLibraries() - * @see #getJSFLibraryRegistry() - * @generated - */ - EReference getJSFLibraryRegistry_PluginProvidedJSFLibraries(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary <em>JSF Library</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>JSF Library</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary - * @generated - */ - EClass getJSFLibrary(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getID <em>ID</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>ID</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getID() - * @see #getJSFLibrary() - * @generated - */ - EAttribute getJSFLibrary_ID(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getName <em>Name</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Name</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getName() - * @see #getJSFLibrary() - * @generated - */ - EAttribute getJSFLibrary_Name(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getJSFVersion <em>JSF Version</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>JSF Version</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getJSFVersion() - * @see #getJSFLibrary() - * @generated - */ - EAttribute getJSFLibrary_JSFVersion(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isDeployed <em>Deployed</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Deployed</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isDeployed() - * @see #getJSFLibrary() - * @generated - */ - EAttribute getJSFLibrary_Deployed(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isImplementation <em>Implementation</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Implementation</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#isImplementation() - * @see #getJSFLibrary() - * @generated - */ - EAttribute getJSFLibrary_Implementation(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getArchiveFiles <em>Archive Files</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Archive Files</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary#getArchiveFiles() - * @see #getJSFLibrary() - * @generated - */ - EReference getJSFLibrary_ArchiveFiles(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile <em>Archive File</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Archive File</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile - * @generated - */ - EClass getArchiveFile(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getSourceLocation <em>Source Location</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Source Location</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getSourceLocation() - * @see #getArchiveFile() - * @generated - */ - EAttribute getArchiveFile_SourceLocation(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#isRelativeToWorkspace <em>Relative To Workspace</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Relative To Workspace</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#isRelativeToWorkspace() - * @see #getArchiveFile() - * @generated - */ - EAttribute getArchiveFile_RelativeToWorkspace(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getRelativeDestLocation <em>Relative Dest Location</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Relative Dest Location</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getRelativeDestLocation() - * @see #getArchiveFile() - * @generated - */ - EAttribute getArchiveFile_RelativeDestLocation(); - - /** - * Returns the meta object for the container reference '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getJSFLibrary <em>JSF Library</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the container reference '<em>JSF Library</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile#getJSFLibrary() - * @see #getArchiveFile() - * @generated - */ - EReference getArchiveFile_JSFLibrary(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary <em>Plugin Provided JSF Library</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Plugin Provided JSF Library</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary - * @generated - */ - EClass getPluginProvidedJSFLibrary(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getPluginID <em>Plugin ID</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Plugin ID</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getPluginID() - * @see #getPluginProvidedJSFLibrary() - * @generated - */ - EAttribute getPluginProvidedJSFLibrary_PluginID(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getLabel <em>Label</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Label</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getLabel() - * @see #getPluginProvidedJSFLibrary() - * @generated - */ - EAttribute getPluginProvidedJSFLibrary_Label(); - - /** - * Returns the meta object for enum '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion <em>JSF Version</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for enum '<em>JSF Version</em>'. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion - * @generated - */ - EEnum getJSFVersion(); - - /** - * Returns the factory that creates the instances of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the factory that creates the instances of the model. - * @generated - */ - JSFLibraryRegistryFactory getJSFLibraryRegistryFactory(); - - /** - * <!-- begin-user-doc --> - * Defines literals for the meta objects that represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @generated - */ - interface Literals { - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl <em>JSF Library Registry</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getJSFLibraryRegistry() - * @generated - */ - @SuppressWarnings("hiding") - EClass JSF_LIBRARY_REGISTRY = eINSTANCE.getJSFLibraryRegistry(); - - /** - * The meta object literal for the '<em><b>Default Implementation ID</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID = eINSTANCE.getJSFLibraryRegistry_DefaultImplementationID(); - - /** - * The meta object literal for the '<em><b>JSF Libraries</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EReference JSF_LIBRARY_REGISTRY__JSF_LIBRARIES = eINSTANCE.getJSFLibraryRegistry_JSFLibraries(); - - /** - * The meta object literal for the '<em><b>Plugin Provided JSF Libraries</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EReference JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES = eINSTANCE.getJSFLibraryRegistry_PluginProvidedJSFLibraries(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl <em>JSF Library</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getJSFLibrary() - * @generated - */ - @SuppressWarnings("hiding") - EClass JSF_LIBRARY = eINSTANCE.getJSFLibrary(); - - /** - * The meta object literal for the '<em><b>ID</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute JSF_LIBRARY__ID = eINSTANCE.getJSFLibrary_ID(); - - /** - * The meta object literal for the '<em><b>Name</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute JSF_LIBRARY__NAME = eINSTANCE.getJSFLibrary_Name(); - - /** - * The meta object literal for the '<em><b>JSF Version</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute JSF_LIBRARY__JSF_VERSION = eINSTANCE.getJSFLibrary_JSFVersion(); - - /** - * The meta object literal for the '<em><b>Deployed</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute JSF_LIBRARY__DEPLOYED = eINSTANCE.getJSFLibrary_Deployed(); - - /** - * The meta object literal for the '<em><b>Implementation</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute JSF_LIBRARY__IMPLEMENTATION = eINSTANCE.getJSFLibrary_Implementation(); - - /** - * The meta object literal for the '<em><b>Archive Files</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EReference JSF_LIBRARY__ARCHIVE_FILES = eINSTANCE.getJSFLibrary_ArchiveFiles(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl <em>Archive File</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getArchiveFile() - * @generated - */ - @SuppressWarnings("hiding") - EClass ARCHIVE_FILE = eINSTANCE.getArchiveFile(); - - /** - * The meta object literal for the '<em><b>Relative To Workspace</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute ARCHIVE_FILE__RELATIVE_TO_WORKSPACE = eINSTANCE.getArchiveFile_RelativeToWorkspace(); - - /** - * The meta object literal for the '<em><b>Source Location</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute ARCHIVE_FILE__SOURCE_LOCATION = eINSTANCE.getArchiveFile_SourceLocation(); - - /** - * The meta object literal for the '<em><b>Relative Dest Location</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute ARCHIVE_FILE__RELATIVE_DEST_LOCATION = eINSTANCE.getArchiveFile_RelativeDestLocation(); - - /** - * The meta object literal for the '<em><b>JSF Library</b></em>' container reference feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EReference ARCHIVE_FILE__JSF_LIBRARY = eINSTANCE.getArchiveFile_JSFLibrary(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.PluginProvidedJSFLibraryImpl <em>Plugin Provided JSF Library</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.PluginProvidedJSFLibraryImpl - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getPluginProvidedJSFLibrary() - * @generated - */ - @SuppressWarnings("hiding") - EClass PLUGIN_PROVIDED_JSF_LIBRARY = eINSTANCE.getPluginProvidedJSFLibrary(); - - /** - * The meta object literal for the '<em><b>Plugin ID</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID = eINSTANCE.getPluginProvidedJSFLibrary_PluginID(); - - /** - * The meta object literal for the '<em><b>Label</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute PLUGIN_PROVIDED_JSF_LIBRARY__LABEL = eINSTANCE.getPluginProvidedJSFLibrary_Label(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion <em>JSF Version</em>}' enum. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl#getJSFVersion() - * @generated - */ - @SuppressWarnings("hiding") - EEnum JSF_VERSION = eINSTANCE.getJSFVersion(); - - } - -} //JSFLibraryRegistryPackage diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFVersion.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFVersion.java deleted file mode 100644 index ad9f7f67f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/JSFVersion.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.util.AbstractEnumerator; - -/** - * <!-- begin-user-doc --> - * A representation of the literals of the enumeration '<em><b>JSF Version</b></em>', - * and utility methods for working with them. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getJSFVersion() - * @model - * @generated - */ -public final class JSFVersion extends AbstractEnumerator { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The '<em><b>UNKNOWN</b></em>' literal value. - * <!-- begin-user-doc --> - * <p> - * If the meaning of '<em><b>UNKNOWN</b></em>' literal object isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @see #UNKNOWN_LITERAL - * @model - * @generated - * @ordered - */ - public static final int UNKNOWN = -1; - - /** - * The '<em><b>V1 1</b></em>' literal value. - * <!-- begin-user-doc --> - * <p> - * If the meaning of '<em><b>V1 1</b></em>' literal object isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @see #V1_1_LITERAL - * @model name="v1_1" - * @generated - * @ordered - */ - public static final int V1_1 = 1; - - /** - * The '<em><b>V1 2</b></em>' literal value. - * <!-- begin-user-doc --> - * <p> - * If the meaning of '<em><b>V1 2</b></em>' literal object isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @see #V1_2_LITERAL - * @model name="v1_2" - * @generated - * @ordered - */ - public static final int V1_2 = 2; - - /** - * The '<em><b>UNKNOWN</b></em>' literal object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #UNKNOWN - * @generated - * @ordered - */ - public static final JSFVersion UNKNOWN_LITERAL = new JSFVersion(UNKNOWN, "UNKNOWN", "UNKNOWN"); - - /** - * The '<em><b>V1 1</b></em>' literal object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #V1_1 - * @generated - * @ordered - */ - public static final JSFVersion V1_1_LITERAL = new JSFVersion(V1_1, "v1_1", "v1_1"); - - /** - * The '<em><b>V1 2</b></em>' literal object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #V1_2 - * @generated - * @ordered - */ - public static final JSFVersion V1_2_LITERAL = new JSFVersion(V1_2, "v1_2", "v1_2"); - - /** - * An array of all the '<em><b>JSF Version</b></em>' enumerators. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static final JSFVersion[] VALUES_ARRAY = - new JSFVersion[] { - UNKNOWN_LITERAL, - V1_1_LITERAL, - V1_2_LITERAL, - }; - - /** - * A public read-only list of all the '<em><b>JSF Version</b></em>' enumerators. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); - - /** - * Returns the '<em><b>JSF Version</b></em>' literal with the specified literal value. - * <!-- begin-user-doc --> - * @param literal value - * @return the JSF version for name value - * <!-- end-user-doc --> - * @generated - */ - public static JSFVersion get(String literal) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - JSFVersion result = VALUES_ARRAY[i]; - if (result.toString().equals(literal)) { - return result; - } - } - return null; - } - - /** - * Returns the '<em><b>JSF Version</b></em>' literal with the specified name. - * <!-- begin-user-doc --> - * @param name - * @return JSFVersion - * <!-- end-user-doc --> - * @generated - */ - public static JSFVersion getByName(String name) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - JSFVersion result = VALUES_ARRAY[i]; - if (result.getName().equals(name)) { - return result; - } - } - return null; - } - - /** - * Returns the '<em><b>JSF Version</b></em>' literal with the specified integer value. - * <!-- begin-user-doc --> - * @param value - * @return the JSFVersion for the integer 'value' - * <!-- end-user-doc --> - * @generated - */ - public static JSFVersion get(int value) { - switch (value) { - case UNKNOWN: return UNKNOWN_LITERAL; - case V1_1: return V1_1_LITERAL; - case V1_2: return V1_2_LITERAL; - } - return null; - } - - /** - * Only this class can construct instances. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private JSFVersion(int value, String name, String literal) { - super(value, name, literal); - } - - /** - * Returns the '<em><b>JSF Version</b></em>' literal with the specified - * name like the get(String) method does, but will return UNKNOWN instead - * of null if the name is not recognized. - * <!-- begin-user-doc --> - * @param name - * @return the JSFVersion - * <!-- end-user-doc --> - * @generated NOT - */ - public static JSFVersion getJSFVersion(String name) { - JSFVersion version = get(name); - if (version == null) { - version = UNKNOWN_LITERAL; - } - return version; - } - -} //JSFVersion diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/PluginProvidedJSFLibrary.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/PluginProvidedJSFLibrary.java deleted file mode 100644 index 89722da0b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/PluginProvidedJSFLibrary.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry; - - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Plugin Provided JSF Library</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getPluginID <em>Plugin ID</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getLabel <em>Label</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getPluginProvidedJSFLibrary() - * @model - * @generated - */ -public interface PluginProvidedJSFLibrary extends JSFLibrary{ - /** - * Separator between plugin id and JSF Library name - */ - public static final String ID_SEPARATOR = "$$"; - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * Returns the value of the '<em><b>Plugin ID</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Plugin ID</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Plugin ID</em>' attribute. - * @see #setPluginID(String) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getPluginProvidedJSFLibrary_PluginID() - * @model required="true" - * @generated - */ - String getPluginID(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getPluginID <em>Plugin ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Plugin ID</em>' attribute. - * @see #getPluginID() - * @generated - */ - void setPluginID(String value); - - /** - * Returns the value of the '<em><b>Label</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Label</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Label</em>' attribute. - * @see #setLabel(String) - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#getPluginProvidedJSFLibrary_Label() - * @model required="true" - * @generated - */ - String getLabel(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary#getLabel <em>Label</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Label</em>' attribute. - * @see #getLabel() - * @generated - */ - void setLabel(String value); - -} // PluginProvidedJSFLibrary diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/adapter/MaintainDefaultImplementationAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/adapter/MaintainDefaultImplementationAdapter.java deleted file mode 100644 index 6f6ff667c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/adapter/MaintainDefaultImplementationAdapter.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.adapter; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; - -/** - * EMF adapter that attempts to always maintain a default implementation - * JSFLibrary upon addition and removal of JSFLibrary instances and upon - * changing of a JSFLibrary instance's implementation property. - * - * @author Ian Trimble - Oracle - */ -public class MaintainDefaultImplementationAdapter extends AdapterImpl { - - private static MaintainDefaultImplementationAdapter INSTANCE = - new MaintainDefaultImplementationAdapter(); - - /** - * Gets the single instance of this adapter. - * - * @return The single instance of this adapter. - */ - public static MaintainDefaultImplementationAdapter getInstance() { - return INSTANCE; - } - - /** - * Called to notify this adapter that a change has occured. - * - * @param notification EMF Notification instance - */ - public void notifyChanged(Notification notification) { - Object objNotifier = notification.getNotifier(); - if (objNotifier instanceof JSFLibraryRegistry) { - int eventType = notification.getEventType(); - switch (eventType) { - case Notification.ADD: - Object objNewValue = notification.getNewValue(); - if (objNewValue instanceof JSFLibrary) { - libraryAdded((JSFLibrary)objNewValue); - } - break; - case Notification.REMOVE: - Object objOldValue = notification.getOldValue(); - if (objOldValue instanceof JSFLibrary) { - libraryRemoved((JSFLibrary)objOldValue); - } - break; - } - } else if (objNotifier instanceof JSFLibrary) { - if (notification.getFeatureID(JSFLibrary.class) == JSFLibraryRegistryPackage.JSF_LIBRARY__IMPLEMENTATION) { - implementationFlagSet((JSFLibrary)objNotifier); - } - } - } - - /** - * Checks if the library added is an implementation and, if so, makes it - * the default implementation if it is the only implementation. - * - * @param library JSFLibrary instance - */ - protected void libraryAdded(JSFLibrary library) { - if (library != null && library.isImplementation()) { - JSFLibraryRegistry jsfLibReg = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry(); - EList impls = jsfLibReg.getImplJSFLibraries(); - if (impls.size() == 1) { - jsfLibReg.setDefaultImplementation(library); - } - } - } - - /** - * Checks if the library removed is the default implementation and, if so, - * makes the first remaining implementation the new default or nulls out - * the default implementation if no other implementation remains. - * - * @param library JSFLibrary instance - */ - protected void libraryRemoved(JSFLibrary library) { - if (library != null && library.isImplementation()) { - JSFLibraryRegistry jsfLibReg = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry(); - JSFLibrary defaultImpl = jsfLibReg.getDefaultImplementation(); - if (defaultImpl == null || library.getID().equals(defaultImpl.getID())) { - setNewDefaultImplementation(); - } - } - } - - /** - * Checks if the implementation flag of the JSFLibrary has been changed - * such that it is now eligible to become the default implementation or - * such that it is no longer eligible as the default implementation and - * sets the default implementation appropriately. Note that the passed - * JSFLibrary instance must have been added to the model before calling - * this method for it to have any effect. - * - * @param library JSFLibrary instance - */ - protected void implementationFlagSet(JSFLibrary library) { - JSFLibraryRegistry jsfLibReg = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry(); - if (jsfLibReg != null) { - JSFLibrary defaultImpl = jsfLibReg.getDefaultImplementation(); - if ( - library.isImplementation() && - defaultImpl == null - ) { - jsfLibReg.setDefaultImplementation(library); - } else if ( - !library.isImplementation() && - (defaultImpl != null && library.getID() == defaultImpl.getID()) - ) { - setNewDefaultImplementation(); - } - } - } - - /** - * Sets the first available JSFLibrary marked as an implementation as the - * default implementation or sets the default implementation to null if no - * JSFLibrary is marked as an implementation. - */ - protected void setNewDefaultImplementation() { - JSFLibraryRegistry jsfLibReg = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry(); - EList impls = jsfLibReg.getImplJSFLibraries(); - if (impls.size() > 0) { - jsfLibReg.setDefaultImplementation((JSFLibrary)impls.get(0)); - } else { - jsfLibReg.setDefaultImplementation(null); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/ArchiveFileImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/ArchiveFileImpl.java deleted file mode 100644 index a0c940702..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/ArchiveFileImpl.java +++ /dev/null @@ -1,705 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; -import org.eclipse.osgi.util.NLS; -import org.osgi.framework.Bundle; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Archive File</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl#isRelativeToWorkspace <em>Relative To Workspace</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl#getSourceLocation <em>Source Location</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl#getRelativeDestLocation <em>Relative Dest Location</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.ArchiveFileImpl#getJSFLibrary <em>JSF Library</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ArchiveFileImpl extends EObjectImpl implements ArchiveFile { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The default value of the '{@link #isRelativeToWorkspace() <em>Relative To Workspace</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isRelativeToWorkspace() - * @generated - * @ordered - */ - protected static final boolean RELATIVE_TO_WORKSPACE_EDEFAULT = true; - - /** - * The cached value of the '{@link #isRelativeToWorkspace() <em>Relative To Workspace</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isRelativeToWorkspace() - * @generated - * @ordered - */ - protected boolean relativeToWorkspace = RELATIVE_TO_WORKSPACE_EDEFAULT; - - /** - * The default value of the '{@link #getSourceLocation() <em>Source Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceLocation() - * @generated - * @ordered - */ - protected static final String SOURCE_LOCATION_EDEFAULT = null; - - /** - * The cached value of the '{@link #getSourceLocation() <em>Source Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceLocation() - * @generated - * @ordered - */ - protected String sourceLocation = SOURCE_LOCATION_EDEFAULT; - - /** - * The default value of the '{@link #getRelativeDestLocation() <em>Relative Dest Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRelativeDestLocation() - * @generated - * @ordered - */ - protected static final String RELATIVE_DEST_LOCATION_EDEFAULT = null; - - /** - * The cached value of the '{@link #getRelativeDestLocation() <em>Relative Dest Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRelativeDestLocation() - * @generated - * @ordered - */ - protected String relativeDestLocation = RELATIVE_DEST_LOCATION_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ArchiveFileImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * @return the static eClass - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return JSFLibraryRegistryPackage.Literals.ARCHIVE_FILE; - } - - /** - * <!-- begin-user-doc --> - * @return the source location - * <!-- end-user-doc --> - * @generated - */ - public String getSourceLocation() { - return sourceLocation; - } - - /** - * <!-- begin-user-doc --> - * Enhanced to not only set the location but also to attempt to determine - * if the location passed is relative to the current workspace. If so, only - * the relative location is stored. If not, the full location as passed is - * stored and the relativeToWorkspace property is set to false. To override - * this behaviour and set the absolute location as passed regardless, call - * setRelativeToWorkspace(false) BEFORE calling this method. - * - * @param newSourceLocation - * - * <!-- end-user-doc --> - * @generated NOT - */ - public void setSourceLocation(String newSourceLocation) { - String oldSourceLocation = sourceLocation; - if (relativeToWorkspace) { - IWorkspaceRoot workspaceRoot = getWorkspaceRoot(); - if (workspaceRoot != null) { - IPath wsRootPath = workspaceRoot.getLocation(); - IPath srcPath = new Path(newSourceLocation); - if (workspaceRoot.findMember(srcPath) != null) { - sourceLocation = newSourceLocation; - } else if (wsRootPath.isPrefixOf(srcPath)) { - int segmentsMatched = wsRootPath.matchingFirstSegments(srcPath); - srcPath = srcPath.removeFirstSegments(segmentsMatched).setDevice(null); - sourceLocation = srcPath.toOSString(); - } else { - sourceLocation = newSourceLocation; - relativeToWorkspace = false; - } - } - } else { - sourceLocation = newSourceLocation; - } - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.ARCHIVE_FILE__SOURCE_LOCATION, oldSourceLocation, sourceLocation)); - } - - /** - * <!-- begin-user-doc --> - * @return true if file is relative to workspace - * <!-- end-user-doc --> - * @generated - */ - public boolean isRelativeToWorkspace() { - return relativeToWorkspace; - } - - /** - * <!-- begin-user-doc --> - * To override workspace-relative recognition behaviour, be sure to call - * this method with a false value BEFORE calling setLocation(String). - * @param newRelativeToWorkspace - * <!-- end-user-doc --> - * @generated - */ - public void setRelativeToWorkspace(boolean newRelativeToWorkspace) { - boolean oldRelativeToWorkspace = relativeToWorkspace; - relativeToWorkspace = newRelativeToWorkspace; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_TO_WORKSPACE, oldRelativeToWorkspace, relativeToWorkspace)); - } - - /** - * <!-- begin-user-doc --> - * @return the relative destination location - * <!-- end-user-doc --> - * @generated - */ - public String getRelativeDestLocation() { - return relativeDestLocation; - } - - /** - * <!-- begin-user-doc --> - * @param newRelativeDestLocation - * <!-- end-user-doc --> - * @generated - */ - public void setRelativeDestLocation(String newRelativeDestLocation) { - String oldRelativeDestLocation = relativeDestLocation; - relativeDestLocation = newRelativeDestLocation; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_DEST_LOCATION, oldRelativeDestLocation, relativeDestLocation)); - } - - /** - * <!-- begin-user-doc --> - * @return the jsf library instance - * <!-- end-user-doc --> - * @generated - */ - public JSFLibrary getJSFLibrary() { - if (eContainerFeatureID != JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY) return null; - return (JSFLibrary)eContainer(); - } - - /** - * <!-- begin-user-doc --> - * @param newJSFLibrary - * @param msgs - * @return NotificationChain - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain basicSetJSFLibrary(JSFLibrary newJSFLibrary, NotificationChain msgs) { - msgs = eBasicSetContainer((InternalEObject)newJSFLibrary, JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY, msgs); - return msgs; - } - - /** - * <!-- begin-user-doc --> - * @param newJSFLibrary - * <!-- end-user-doc --> - * @generated - */ - public void setJSFLibrary(JSFLibrary newJSFLibrary) { - if (newJSFLibrary != eInternalContainer() || (eContainerFeatureID != JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY && newJSFLibrary != null)) { - if (EcoreUtil.isAncestor(this, newJSFLibrary)) - throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); - NotificationChain msgs = null; - if (eInternalContainer() != null) - msgs = eBasicRemoveFromContainer(msgs); - if (newJSFLibrary != null) - msgs = ((InternalEObject)newJSFLibrary).eInverseAdd(this, JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES, JSFLibrary.class, msgs); - msgs = basicSetJSFLibrary(newJSFLibrary, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY, newJSFLibrary, newJSFLibrary)); - } - - /** - * <!-- begin-user-doc --> - * @return the path - * <!-- end-user-doc --> - * @generated NOT - */ - public String getPath() { - String path = null; - String resolvedSourceLocation = getResolvedSourceLocation(); - if (resolvedSourceLocation != null) { - int iPos = resolvedSourceLocation.lastIndexOf('/'); - if (iPos < 0) { - iPos = resolvedSourceLocation.lastIndexOf('\\'); - } - if (iPos < 1) { - path = ""; //$NON-NLS-1$ - } else { - path = resolvedSourceLocation.substring(0, iPos); - } - } - return path; - } - - /** - * <!-- begin-user-doc --> - * @return the name - * <!-- end-user-doc --> - * @generated NOT - */ - public String getName() { - String name = null; - String resolvedSourceLocation = getResolvedSourceLocation(); - if (resolvedSourceLocation != null) { - int iPos = resolvedSourceLocation.lastIndexOf('/'); - if (iPos < 0) { - iPos = resolvedSourceLocation.lastIndexOf('\\'); - } - if (iPos < 0 || iPos == resolvedSourceLocation.length() - 1) { - name = resolvedSourceLocation; - } else { - name = resolvedSourceLocation.substring(iPos + 1); - } - } - return name; - } - - /** - * <!-- begin-user-doc --> - * @return true if the archive file exists in the bundle - * <!-- end-user-doc --> - * @generated NOT - */ - public boolean exists() { - boolean exists = false; - if (getJSFLibrary() instanceof PluginProvidedJSFLibrary) { - Bundle bundle = getBundle(); - if (bundle != null) { - exists = bundle.getEntry(sourceLocation) != null; - } - } else { - String resolvedSourceLocation = getResolvedSourceLocation(); - if (resolvedSourceLocation != null) { - exists = new File(resolvedSourceLocation).exists(); - } - } - return exists; - } - - /** - * <!-- begin-user-doc --> - * @param object - * @return true if equal - * <!-- end-user-doc --> - * @generated NOT - */ - public boolean equals(Object object) { - boolean equal = false; - if (object != null && object instanceof ArchiveFile) { - String resolvedSourceLocation = getResolvedSourceLocation(); - String objResolvedSourceLocation = ((ArchiveFile)object).getResolvedSourceLocation(); - if (resolvedSourceLocation == null && objResolvedSourceLocation == null) { - equal = true; - } else if (resolvedSourceLocation != null) { - equal = resolvedSourceLocation.equals(objResolvedSourceLocation); - } - } - return equal; - } - - /** - * <!-- begin-user-doc --> - * @return a the resolved source location hash or 0 if it is null - * <!-- end-user-doc --> - * @generated NOT - */ - public int hashCode() { - return getResolvedSourceLocation() != null ? getResolvedSourceLocation().hashCode() : 0; - } - - /** - * <!-- begin-user-doc --> - * @param baseDestLocation - * @return true if the copy is successful - * <!-- end-user-doc --> - * @generated NOT - */ - public boolean copyTo(String baseDestLocation) { - boolean copied = false; - InputStream in = null; - OutputStream out = null; - IPath outPath = new Path(baseDestLocation); - if (relativeDestLocation != null) { - outPath = outPath.append(relativeDestLocation); - } - outPath = outPath.append(getName()); - try { - if (!outPath.toFile().exists()) { - out = new FileOutputStream(outPath.toOSString()); - } else { - return copied; - } - if (getJSFLibrary() instanceof PluginProvidedJSFLibrary) { - Bundle bundle = getBundle(); - URL inURL = bundle.getEntry(sourceLocation); - if (inURL != null) { - in = inURL.openStream(); - } else { - JSFCorePlugin.log( - IStatus.ERROR, - NLS.bind(Messages.ArchiveFileImpl_CannotLocatePluginRelativeFile, - sourceLocation)); - return copied; - } - } else { - in = new FileInputStream(getResolvedSourceLocation()); - } - byte[] buf = new byte[1024]; - int len = 0; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - copied = true; - } catch(FileNotFoundException fnfe) { - JSFCorePlugin.log(IStatus.ERROR, Messages.ArchiveFileImpl_CannotCopyFile, fnfe); - } catch(IOException ioe) { - JSFCorePlugin.log(IStatus.ERROR, Messages.ArchiveFileImpl_CannotCopyFile, ioe); - } finally { - try { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } catch(IOException ioe) { - JSFCorePlugin.log(IStatus.WARNING, Messages.ArchiveFileImpl_CannotCloseFile, ioe); - } - } - return copied; - } - - /** - * <!-- begin-user-doc --> - * @return the resolved source location - * <!-- end-user-doc --> - * @generated NOT - */ - public String getResolvedSourceLocation() { - String resolvedSourceLocation = null; - /** - * The implementation to support PluginProvidedJSFLibrary assume the following. - * 1. Plugin provided JSF library needs to be distributed as an expanded folder. - * 2. JARs for plugin provided JSF library need to reside inside the folder mentioned in item 1 above. - * 3. Each JAR needs to specify a relative path for the folder mentioned in item 1 above. - * - * Fix for bug 144954. - */ - if (getJSFLibrary() instanceof PluginProvidedJSFLibrary) { - Bundle bundle = getBundle(); - if (bundle != null) { - //resolvedSourceLocation = appendSeparator(bundleLocation) + sourceLocation; - try { - Path srcPath = new Path(sourceLocation); - URL fileURL = FileLocator.find(bundle, srcPath, null); - if (fileURL != null){ - URL url = FileLocator.resolve(fileURL); - resolvedSourceLocation = url.getPath(); - } - else - resolvedSourceLocation = sourceLocation; - } catch (IOException e) { - resolvedSourceLocation = sourceLocation; - } - } else { - resolvedSourceLocation = sourceLocation; - } - } else { - if (isRelativeToWorkspace()) { - IWorkspaceRoot workspaceRoot = getWorkspaceRoot(); - if (workspaceRoot != null) { - String workspaceLocation = workspaceRoot.getLocation().toOSString(); - if (workspaceLocation != null) { - resolvedSourceLocation = appendSeparator(workspaceLocation) + sourceLocation; - } else { - resolvedSourceLocation = sourceLocation; - } - } else { - resolvedSourceLocation = sourceLocation; - } - } else { - resolvedSourceLocation = sourceLocation; - } - } - return resolvedSourceLocation; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY: - if (eInternalContainer() != null) - msgs = eBasicRemoveFromContainer(msgs); - return basicSetJSFLibrary((JSFLibrary)otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY: - return basicSetJSFLibrary(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * @param msgs - * @return NotificationChain - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { - switch (eContainerFeatureID) { - case JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY: - return eInternalContainer().eInverseRemove(this, JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES, JSFLibrary.class, msgs); - } - return super.eBasicRemoveFromContainerFeature(msgs); - } - - /** - * <!-- begin-user-doc --> - * @param featureID - * @param resolve - * @param coreType - * @return - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_TO_WORKSPACE: - return isRelativeToWorkspace() ? Boolean.TRUE : Boolean.FALSE; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__SOURCE_LOCATION: - return getSourceLocation(); - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_DEST_LOCATION: - return getRelativeDestLocation(); - case JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY: - return getJSFLibrary(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * @param featureID - * @param newValue - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_TO_WORKSPACE: - setRelativeToWorkspace(((Boolean)newValue).booleanValue()); - return; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__SOURCE_LOCATION: - setSourceLocation((String)newValue); - return; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_DEST_LOCATION: - setRelativeDestLocation((String)newValue); - return; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY: - setJSFLibrary((JSFLibrary)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_TO_WORKSPACE: - setRelativeToWorkspace(RELATIVE_TO_WORKSPACE_EDEFAULT); - return; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__SOURCE_LOCATION: - setSourceLocation(SOURCE_LOCATION_EDEFAULT); - return; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_DEST_LOCATION: - setRelativeDestLocation(RELATIVE_DEST_LOCATION_EDEFAULT); - return; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY: - setJSFLibrary((JSFLibrary)null); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_TO_WORKSPACE: - return relativeToWorkspace != RELATIVE_TO_WORKSPACE_EDEFAULT; - case JSFLibraryRegistryPackage.ARCHIVE_FILE__SOURCE_LOCATION: - return SOURCE_LOCATION_EDEFAULT == null ? sourceLocation != null : !SOURCE_LOCATION_EDEFAULT.equals(sourceLocation); - case JSFLibraryRegistryPackage.ARCHIVE_FILE__RELATIVE_DEST_LOCATION: - return RELATIVE_DEST_LOCATION_EDEFAULT == null ? relativeDestLocation != null : !RELATIVE_DEST_LOCATION_EDEFAULT.equals(relativeDestLocation); - case JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY: - return getJSFLibrary() != null; - } - return super.eIsSet(featureID); - } - - /** - * Gets the Bundle instance by parent PluginProvidedJSFLibrary instance's - * pluginID property, if and only if the parent JSFLibrary instance IS a - * PluginProvidedJSFLibrary, else returns null. - * @return Bundle instance, or null if not located or applicable - */ - protected Bundle getBundle() { - Bundle bundle = null; - if (getJSFLibrary() instanceof PluginProvidedJSFLibrary) { - String pluginID = ((PluginProvidedJSFLibrary)getJSFLibrary()).getPluginID(); - if (pluginID != null) { - bundle = Platform.getBundle(pluginID); - } - } - return bundle; - } - - /** - * Gets the IWorkspaceRoot instance. - * @return IWorkspaceRoot instance - */ - protected IWorkspaceRoot getWorkspaceRoot() { - IWorkspaceRoot workspaceRoot = null; - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - if (workspace != null) { - workspaceRoot = workspace.getRoot(); - } - return workspaceRoot; - } - - /** - * @param path - * @return the the path string with invalid path separators correctly fixed - */ - protected String appendSeparator(String path) { - String newPath = null; - if (!path.endsWith("\\") && !path.endsWith("/")) { //$NON-NLS-1$ //$NON-NLS-2$ - newPath = path + System.getProperty("file.separator"); //$NON-NLS-1$ - } else { - newPath = path; - } - return newPath; - } - - /** - * <!-- begin-user-doc --> - * @return the string representation of this archive file - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (RelativeToWorkspace: "); - result.append(relativeToWorkspace); - result.append(", SourceLocation: "); - result.append(sourceLocation); - result.append(", RelativeDestLocation: "); - result.append(relativeDestLocation); - result.append(')'); - return result.toString(); - } - -} //ArchiveFileImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryImpl.java deleted file mode 100644 index 2187da7ba..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryImpl.java +++ /dev/null @@ -1,557 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.adapter.MaintainDefaultImplementationAdapter; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>JSF Library</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl#getID <em>ID</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl#getJSFVersion <em>JSF Version</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl#isDeployed <em>Deployed</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl#isImplementation <em>Implementation</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl#getArchiveFiles <em>Archive Files</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class JSFLibraryImpl extends EObjectImpl implements JSFLibrary { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The default value of the '{@link #getID() <em>ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getID() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getID() <em>ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getID() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The default value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - - /** - * The default value of the '{@link #getJSFVersion() <em>JSF Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getJSFVersion() - * @generated - * @ordered - */ - protected static final JSFVersion JSF_VERSION_EDEFAULT = JSFVersion.UNKNOWN_LITERAL; - - /** - * The cached value of the '{@link #getJSFVersion() <em>JSF Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getJSFVersion() - * @generated - * @ordered - */ - protected JSFVersion jsfVersion = JSF_VERSION_EDEFAULT; - - /** - * The default value of the '{@link #isDeployed() <em>Deployed</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isDeployed() - * @generated - * @ordered - */ - protected static final boolean DEPLOYED_EDEFAULT = true; - - /** - * The cached value of the '{@link #isDeployed() <em>Deployed</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isDeployed() - * @generated - * @ordered - */ - protected boolean deployed = DEPLOYED_EDEFAULT; - - /** - * The default value of the '{@link #isImplementation() <em>Implementation</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isImplementation() - * @generated - * @ordered - */ - protected static final boolean IMPLEMENTATION_EDEFAULT = false; - - /** - * The cached value of the '{@link #isImplementation() <em>Implementation</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isImplementation() - * @generated - * @ordered - */ - protected boolean implementation = IMPLEMENTATION_EDEFAULT; - - /** - * The cached value of the '{@link #getArchiveFiles() <em>Archive Files</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getArchiveFiles() - * @generated - * @ordered - */ - protected EList archiveFiles; - - /** - * <!-- begin-user-doc --> - * Enhanced to not only create an instance but also to set an initial ID - * (which can be reset later) and to add the - * MaintainDefaultImplementationAdapter to the list of adapters. - * <!-- end-user-doc --> - * @generated NOT - */ - protected JSFLibraryImpl() { - super(); -// //set initial ID; will be overwritten from XML if already persisted -// setID(String.valueOf(System.currentTimeMillis())); - //add adapter to maintain a default implementation - eAdapters().add(MaintainDefaultImplementationAdapter.getInstance()); - } - - /** - * <!-- begin-user-doc --> - * @return the static eClass - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return JSFLibraryRegistryPackage.Literals.JSF_LIBRARY; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public String getID() { - return getName(); - } - - /** - * <!-- begin-user-doc --> - * @return the name - * <!-- end-user-doc --> - * @generated - */ - public String getName() { - return name; - } - - /** - * <!-- begin-user-doc --> - * @param newName - * <!-- end-user-doc --> - * @generated - */ - public void setName(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.JSF_LIBRARY__NAME, oldName, name)); - } - - /** - * <!-- begin-user-doc --> - * @return the jsf version - * <!-- end-user-doc --> - * @generated - */ - public JSFVersion getJSFVersion() { - return jsfVersion; - } - - /** - * <!-- begin-user-doc --> - * @param newJSFVersion - * <!-- end-user-doc --> - * @generated - */ - public void setJSFVersion(JSFVersion newJSFVersion) { - JSFVersion oldJSFVersion = jsfVersion; - jsfVersion = newJSFVersion == null ? JSF_VERSION_EDEFAULT : newJSFVersion; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.JSF_LIBRARY__JSF_VERSION, oldJSFVersion, jsfVersion)); - } - - /** - * <!-- begin-user-doc --> - * @return true if library is to be deployed - * <!-- end-user-doc --> - * @generated - */ - public boolean isDeployed() { - return deployed; - } - - /** - * <!-- begin-user-doc --> - * @param newDeployed - * <!-- end-user-doc --> - * @generated - */ - public void setDeployed(boolean newDeployed) { - boolean oldDeployed = deployed; - deployed = newDeployed; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.JSF_LIBRARY__DEPLOYED, oldDeployed, deployed)); - } - - /** - * <!-- begin-user-doc --> - * @return true if implementation - * <!-- end-user-doc --> - * @generated - */ - public boolean isImplementation() { - return implementation; - } - - /** - * <!-- begin-user-doc --> - * @param newImplementation - * <!-- end-user-doc --> - * @generated - */ - public void setImplementation(boolean newImplementation) { - boolean oldImplementation = implementation; - implementation = newImplementation; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.JSF_LIBRARY__IMPLEMENTATION, oldImplementation, implementation)); - } - - /** - * <!-- begin-user-doc --> - * @return the list of archive files - * <!-- end-user-doc --> - * @generated - */ - public EList getArchiveFiles() { - if (archiveFiles == null) { - archiveFiles = new EObjectContainmentWithInverseEList(ArchiveFile.class, this, JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES, JSFLibraryRegistryPackage.ARCHIVE_FILE__JSF_LIBRARY); - } - return archiveFiles; - } - - /** - * <!-- begin-user-doc --> - * @param fullPath - * @return the true if the fullPath contains an archive file - * <!-- end-user-doc --> - * @generated NOT - */ - public boolean containsArchiveFile(String fullPath) { - boolean contains = false; - if (fullPath != null) { - Iterator itArchiveFiles = getArchiveFiles().iterator(); - while (itArchiveFiles.hasNext()) { - ArchiveFile archiveFile = (ArchiveFile)itArchiveFiles.next(); - if (fullPath.equals(archiveFile.getResolvedSourceLocation())) { - contains = true; - break; - } - } - } - return contains; - } - - /** - * <!-- begin-user-doc --> - * @return the working copy - * <!-- end-user-doc --> - * @generated NOT - */ - public JSFLibrary getWorkingCopy() { - JSFLibrary workingCopyLib = JSFLibraryRegistryFactory.eINSTANCE.createJSFLibrary(); -// workingCopyLib.setID(getID()); - workingCopyLib.setName(getName()); - workingCopyLib.setJSFVersion(getJSFVersion()); - workingCopyLib.setDeployed(isDeployed()); - workingCopyLib.setImplementation(isImplementation()); - Iterator itArchiveFiles = getArchiveFiles().iterator(); - while (itArchiveFiles.hasNext()) { - ArchiveFile srcArchiveFile = (ArchiveFile)itArchiveFiles.next(); - ArchiveFile destArchiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile(); - destArchiveFile.setRelativeToWorkspace(srcArchiveFile.isRelativeToWorkspace()); - destArchiveFile.setSourceLocation(srcArchiveFile.getSourceLocation()); - destArchiveFile.setRelativeDestLocation(srcArchiveFile.getRelativeDestLocation()); - workingCopyLib.getArchiveFiles().add(destArchiveFile); - } - return workingCopyLib; - } - - /** - * <!-- begin-user-doc --> - * @param otherLibrary - * <!-- end-user-doc --> - * @generated NOT - */ - public void updateValues(JSFLibrary otherLibrary) { - if (otherLibrary != null) { -// setID(otherLibrary.getID()); - setName(otherLibrary.getName()); - setJSFVersion(otherLibrary.getJSFVersion()); - setDeployed(otherLibrary.isDeployed()); - setImplementation(otherLibrary.isImplementation()); - Iterator itArchiveFiles = otherLibrary.getArchiveFiles().iterator(); - getArchiveFiles().clear(); - while (itArchiveFiles.hasNext()) { - ArchiveFile srcArchiveFile = (ArchiveFile)itArchiveFiles.next(); - ArchiveFile destArchiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile(); - destArchiveFile.setRelativeToWorkspace(srcArchiveFile.isRelativeToWorkspace()); - destArchiveFile.setSourceLocation(srcArchiveFile.getSourceLocation()); - destArchiveFile.setRelativeDestLocation(srcArchiveFile.getRelativeDestLocation()); - getArchiveFiles().add(destArchiveFile); - } - } - } - - /** - * <!-- begin-user-doc --> - * @param baseDestLocation - * @return the base destination location - * <!-- end-user-doc --> - * @generated NOT - */ - public boolean copyTo(String baseDestLocation) { - boolean allCopied = true; - Iterator itFiles = getArchiveFiles().iterator(); - while (itFiles.hasNext()) { - ArchiveFile archiveFile = (ArchiveFile)itFiles.next(); - boolean copied = archiveFile.copyTo(baseDestLocation); - allCopied = allCopied && copied; - } - return allCopied; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public String getLabel() { - return getName(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES: - return ((InternalEList)getArchiveFiles()).basicAdd(otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES: - return ((InternalEList)getArchiveFiles()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY__ID: - return getID(); - case JSFLibraryRegistryPackage.JSF_LIBRARY__NAME: - return getName(); - case JSFLibraryRegistryPackage.JSF_LIBRARY__JSF_VERSION: - return getJSFVersion(); - case JSFLibraryRegistryPackage.JSF_LIBRARY__DEPLOYED: - return isDeployed() ? Boolean.TRUE : Boolean.FALSE; - case JSFLibraryRegistryPackage.JSF_LIBRARY__IMPLEMENTATION: - return isImplementation() ? Boolean.TRUE : Boolean.FALSE; - case JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES: - return getArchiveFiles(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY__NAME: - setName((String)newValue); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__JSF_VERSION: - setJSFVersion((JSFVersion)newValue); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__DEPLOYED: - setDeployed(((Boolean)newValue).booleanValue()); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__IMPLEMENTATION: - setImplementation(((Boolean)newValue).booleanValue()); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES: - getArchiveFiles().clear(); - getArchiveFiles().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY__NAME: - setName(NAME_EDEFAULT); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__JSF_VERSION: - setJSFVersion(JSF_VERSION_EDEFAULT); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__DEPLOYED: - setDeployed(DEPLOYED_EDEFAULT); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__IMPLEMENTATION: - setImplementation(IMPLEMENTATION_EDEFAULT); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES: - getArchiveFiles().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case JSFLibraryRegistryPackage.JSF_LIBRARY__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); - case JSFLibraryRegistryPackage.JSF_LIBRARY__JSF_VERSION: - return jsfVersion != JSF_VERSION_EDEFAULT; - case JSFLibraryRegistryPackage.JSF_LIBRARY__DEPLOYED: - return deployed != DEPLOYED_EDEFAULT; - case JSFLibraryRegistryPackage.JSF_LIBRARY__IMPLEMENTATION: - return implementation != IMPLEMENTATION_EDEFAULT; - case JSFLibraryRegistryPackage.JSF_LIBRARY__ARCHIVE_FILES: - return archiveFiles != null && !archiveFiles.isEmpty(); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * @return the string representation - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (ID: "); - result.append(id); - result.append(", Name: "); - result.append(name); - result.append(", JSFVersion: "); - result.append(jsfVersion); - result.append(", Deployed: "); - result.append(deployed); - result.append(", Implementation: "); - result.append(implementation); - result.append(')'); - return result.toString(); - } - -} //JSFLibraryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryFactoryImpl.java deleted file mode 100644 index 0b4846ab7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryFactoryImpl.java +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EFactoryImpl; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * <!-- end-user-doc --> - * @generated - */ -public class JSFLibraryRegistryFactoryImpl extends EFactoryImpl implements JSFLibraryRegistryFactory { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * @return the initialized factory - * <!-- end-user-doc --> - * @generated - */ - public static JSFLibraryRegistryFactory init() { - try { - JSFLibraryRegistryFactory theJSFLibraryRegistryFactory = (JSFLibraryRegistryFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/webtools/jsf/schema/jsflibraryregistry.xsd"); - if (theJSFLibraryRegistryFactory != null) { - return theJSFLibraryRegistryFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new JSFLibraryRegistryFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistryFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * @param eClass - * @return the static eclass - * <!-- end-user-doc --> - * @generated - */ - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY: return createJSFLibraryRegistry(); - case JSFLibraryRegistryPackage.JSF_LIBRARY: return createJSFLibrary(); - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY: return createPluginProvidedJSFLibrary(); - case JSFLibraryRegistryPackage.ARCHIVE_FILE: return createArchiveFile(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * @param eDataType - * @param initialValue - * @return an instance of eDataType for initialValue - * <!-- end-user-doc --> - * @generated - */ - public Object createFromString(EDataType eDataType, String initialValue) { - switch (eDataType.getClassifierID()) { - case JSFLibraryRegistryPackage.JSF_VERSION: - return createJSFVersionFromString(eDataType, initialValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * @param eDataType - * @param instanceValue - * @return the string created from instanceValue from eDataType - * <!-- end-user-doc --> - * @generated - */ - public String convertToString(EDataType eDataType, Object instanceValue) { - switch (eDataType.getClassifierID()) { - case JSFLibraryRegistryPackage.JSF_VERSION: - return convertJSFVersionToString(eDataType, instanceValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * @return the jsf library registry - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistry createJSFLibraryRegistry() { - JSFLibraryRegistryImpl jsfLibraryRegistry = new JSFLibraryRegistryImpl(); - return jsfLibraryRegistry; - } - - /** - * <!-- begin-user-doc --> - * @return the jsf library - * <!-- end-user-doc --> - * @generated - */ - public JSFLibrary createJSFLibrary() { - JSFLibraryImpl jsfLibrary = new JSFLibraryImpl(); - return jsfLibrary; - } - - /** - * <!-- begin-user-doc --> - * @return the archive file - * <!-- end-user-doc --> - * @generated - */ - public ArchiveFile createArchiveFile() { - ArchiveFileImpl archiveFile = new ArchiveFileImpl(); - return archiveFile; - } - - /** - * <!-- begin-user-doc --> - * @return the plugin provided JSF library - * <!-- end-user-doc --> - * @generated - */ - public PluginProvidedJSFLibrary createPluginProvidedJSFLibrary() { - PluginProvidedJSFLibraryImpl pluginProvidedJSFLibrary = new PluginProvidedJSFLibraryImpl(); - return pluginProvidedJSFLibrary; - } - - /** - * <!-- begin-user-doc --> - * @param eDataType - * @param initialValue - * @return the jsfVersion the dataType - * <!-- end-user-doc --> - * @generated - */ - public JSFVersion createJSFVersionFromString(EDataType eDataType, String initialValue) { - JSFVersion result = JSFVersion.get(initialValue); - if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); - return result; - } - - /** - * <!-- begin-user-doc --> - * @param eDataType - * @param instanceValue - * @return the string version of the data type - * <!-- end-user-doc --> - * @generated - */ - public String convertJSFVersionToString(EDataType eDataType, Object instanceValue) { - return instanceValue == null ? null : instanceValue.toString(); - } - - /** - * <!-- begin-user-doc --> - * @return the registry package - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistryPackage getJSFLibraryRegistryPackage() { - return (JSFLibraryRegistryPackage)getEPackage(); - } - - /** - * <!-- begin-user-doc --> - * @return the package - * <!-- end-user-doc --> - * @deprecated - * @generated - */ - public static JSFLibraryRegistryPackage getPackage() { - return JSFLibraryRegistryPackage.eINSTANCE; - } - -} //JSFLibraryRegistryFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryImpl.java deleted file mode 100644 index 6d2964fcd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryImpl.java +++ /dev/null @@ -1,433 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>JSF Library Registry</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl#getDefaultImplementationID <em>Default Implementation ID</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl#getJSFLibraries <em>JSF Libraries</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl#getPluginProvidedJSFLibraries <em>Plugin Provided JSF Libraries</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class JSFLibraryRegistryImpl extends EObjectImpl implements JSFLibraryRegistry { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The default value of the '{@link #getDefaultImplementationID() <em>Default Implementation ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDefaultImplementationID() - * @generated - * @ordered - */ - protected static final String DEFAULT_IMPLEMENTATION_ID_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getDefaultImplementationID() <em>Default Implementation ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDefaultImplementationID() - * @generated - * @ordered - */ - protected String defaultImplementationID = DEFAULT_IMPLEMENTATION_ID_EDEFAULT; - - /** - * The cached value of the '{@link #getJSFLibraries() <em>JSF Libraries</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getJSFLibraries() - * @generated - * @ordered - */ - protected EList jsfLibraries; - - /** - * The cached value of the '{@link #getPluginProvidedJSFLibraries() <em>Plugin Provided JSF Libraries</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPluginProvidedJSFLibraries() - * @generated - * @ordered - */ - protected EList pluginProvidedJSFLibraries; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected JSFLibraryRegistryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * @return the static eClass - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return JSFLibraryRegistryPackage.Literals.JSF_LIBRARY_REGISTRY; - } - - /** - * <!-- begin-user-doc --> - * @return the default implementation id - * <!-- end-user-doc --> - * @generated - */ - public String getDefaultImplementationID() { - return defaultImplementationID; - } - - /** - * <!-- begin-user-doc --> - * @param newDefaultImplementationID - * <!-- end-user-doc --> - * @generated - */ - public void setDefaultImplementationID(String newDefaultImplementationID) { - String oldDefaultImplementationID = defaultImplementationID; - defaultImplementationID = newDefaultImplementationID; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID, oldDefaultImplementationID, defaultImplementationID)); - } - - /** - * <!-- begin-user-doc --> - * @return the list of jsf libraries - * <!-- end-user-doc --> - * @generated - */ - public EList getJSFLibraries() { - if (jsfLibraries == null) { - jsfLibraries = new EObjectContainmentEList(JSFLibrary.class, this, JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__JSF_LIBRARIES); - } - return jsfLibraries; - } - - /** - * <!-- begin-user-doc --> - * @return the list of plugin provided JSF libraries - * <!-- end-user-doc --> - * @generated - */ - public EList getPluginProvidedJSFLibraries() { - if (pluginProvidedJSFLibraries == null) { - pluginProvidedJSFLibraries = new EObjectContainmentEList(PluginProvidedJSFLibrary.class, this, JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES); - } - return pluginProvidedJSFLibraries; - } - - /** - * <!-- begin-user-doc --> - * @return the default implemention JSF library - * <!-- end-user-doc --> - * @generated NOT - */ - public JSFLibrary getDefaultImplementation() { - return getJSFLibraryByID(getDefaultImplementationID()); - } - - /** - * <!-- begin-user-doc --> - * @param implementation - * <!-- end-user-doc --> - * @generated NOT - */ - public void setDefaultImplementation(JSFLibrary implementation) { - if (implementation != null) { - setDefaultImplementationID(implementation.getID()); - } else { - setDefaultImplementationID(null); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__JSF_LIBRARIES: - return ((InternalEList)getJSFLibraries()).basicRemove(otherEnd, msgs); - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES: - return ((InternalEList)getPluginProvidedJSFLibraries()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID: - return getDefaultImplementationID(); - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__JSF_LIBRARIES: - return getJSFLibraries(); - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES: - return getPluginProvidedJSFLibraries(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID: - setDefaultImplementationID((String)newValue); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__JSF_LIBRARIES: - getJSFLibraries().clear(); - getJSFLibraries().addAll((Collection)newValue); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES: - getPluginProvidedJSFLibraries().clear(); - getPluginProvidedJSFLibraries().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID: - setDefaultImplementationID(DEFAULT_IMPLEMENTATION_ID_EDEFAULT); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__JSF_LIBRARIES: - getJSFLibraries().clear(); - return; - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES: - getPluginProvidedJSFLibraries().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID: - return DEFAULT_IMPLEMENTATION_ID_EDEFAULT == null ? defaultImplementationID != null : !DEFAULT_IMPLEMENTATION_ID_EDEFAULT.equals(defaultImplementationID); - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__JSF_LIBRARIES: - return jsfLibraries != null && !jsfLibraries.isEmpty(); - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES: - return pluginProvidedJSFLibraries != null && !pluginProvidedJSFLibraries.isEmpty(); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * @param ID - * @return the jsf library of ID or null if none - * <!-- end-user-doc --> - * @generated NOT - */ - public JSFLibrary getJSFLibraryByID(String ID) { - JSFLibrary library = null; - if (ID != null) { - Iterator itLibs = getAllJSFLibraries().iterator(); - while (itLibs.hasNext()) { - JSFLibrary curLib = (JSFLibrary)itLibs.next(); - if (ID.equals(curLib.getID())) { - library = curLib; - break; - } - } - } - return library; - } - - /** - * <!-- begin-user-doc --> - * @param name - * @return the list of libraries named 'name' - * <!-- end-user-doc --> - * @generated NOT - */ - public EList getJSFLibrariesByName(String name) { - EList libraries = new BasicEList(); - if (name != null) { - Iterator itLibs = getAllJSFLibraries().iterator(); - while(itLibs.hasNext()) { - JSFLibrary curLib = (JSFLibrary)itLibs.next(); - if (name.equals(curLib.getName())) { - libraries.add(curLib); - } - } - } - return libraries; - } - - /** - * <!-- begin-user-doc --> - * This is a convenience method to return an EList of JSFLibrary instances - * that are marked as JSF implementations; while all instances are valid - * references, the returned EList should not be used for additions and/or - * removals of instances (use the EList returned by getJSFLibraries()). - * @return the list of implemention jsf libraries - * <!-- end-user-doc --> - * @generated NOT - */ - public EList getImplJSFLibraries() { - EList implementations = new BasicEList(); - Iterator itLibs = getAllJSFLibraries().iterator(); - while (itLibs.hasNext()) { - JSFLibrary lib = (JSFLibrary)itLibs.next(); - if (lib.isImplementation()) { - implementations.add(lib); - } - } - return implementations; - } - - /** - * <!-- begin-user-doc --> - * This is a convenience method to return an EList of JSFLibrary instances - * that are not marked as JSF implementations; while all instances are - * valid references, the returned EList should not be used for additions - * and/or removals of instances (use the EList returned by - * getJSFLibraries()). - * @return the non-implemention JSF libraries - * <!-- end-user-doc --> - * @generated NOT - */ - public EList getNonImplJSFLibraries() { - EList nonImplementations = new BasicEList(); - Iterator itLibs = getAllJSFLibraries().iterator(); - while (itLibs.hasNext()) { - JSFLibrary lib = (JSFLibrary)itLibs.next(); - if (!lib.isImplementation()) { - nonImplementations.add(lib); - } - } - return nonImplementations; - } - - /** - * <!-- begin-user-doc --> - * This is a convenience method to return an EList of JSFLibrary instances - * and PluginProvidedJSFLibrary instances; while all instances are valid - * references, the returned EList should not be used for additions and/or - * removals of instances (use the EList returned by getJSFLibraries()). - * @return all JSF libraries - * <!-- end-user-doc --> - * @generated NOT - */ - public EList getAllJSFLibraries() { - EList allLibs = new BasicEList(); - allLibs.addAll(getJSFLibraries()); - allLibs.addAll(getPluginProvidedJSFLibraries()); - return allLibs; - } - - /** - * <!-- begin-user-doc --> - * @param library - * @return true if library is successfully added - * <!-- end-user-doc --> - * @generated NOT - */ - public boolean addJSFLibrary(JSFLibrary library) { - boolean added = false; - if (library instanceof PluginProvidedJSFLibrary) { - added = getPluginProvidedJSFLibraries().add(library); - } else { - added = getJSFLibraries().add(library); - } - return added; - } - - /** - * <!-- begin-user-doc --> - * @param library - * @return true if library is successfully removed - * <!-- end-user-doc --> - * @generated NOT - */ - public boolean removeJSFLibrary(JSFLibrary library) { - boolean removed = false; - if (library instanceof PluginProvidedJSFLibrary) { - removed = getPluginProvidedJSFLibraries().remove(library); - } else { - removed = getJSFLibraries().remove(library); - } - return removed; - } - - /** - * <!-- begin-user-doc --> - * @return the string representation - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (DefaultImplementationID: "); - result.append(defaultImplementationID); - result.append(')'); - return result.toString(); - } - - -} //JSFLibraryRegistryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryPackageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryPackageImpl.java deleted file mode 100644 index 0532ca94f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/JSFLibraryRegistryPackageImpl.java +++ /dev/null @@ -1,514 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; - - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Package</b>. - * <!-- end-user-doc --> - * @generated - */ -public class JSFLibraryRegistryPackageImpl extends EPackageImpl implements JSFLibraryRegistryPackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass jsfLibraryRegistryEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass jsfLibraryEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass archiveFileEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass pluginProvidedJSFLibraryEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EEnum jsfVersionEEnum = null; - - /** - * Creates an instance of the model <b>Package</b>, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - * <p>Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage#eNS_URI - * @see #init() - * @generated - */ - private JSFLibraryRegistryPackageImpl() { - super(eNS_URI, JSFLibraryRegistryFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this - * model, and for any others upon which it depends. Simple - * dependencies are satisfied by calling this method on all - * dependent packages before doing anything else. This method drives - * initialization for interdependent packages directly, in parallel - * with this package, itself. - * <p>Of this package and its interdependencies, all packages which - * have not yet been registered by their URI values are first created - * and registered. The packages are then initialized in two steps: - * meta-model objects for all of the packages are created before any - * are initialized, since one package's meta-model objects may refer to - * those of another. - * <p>Invocation of this method will not affect any packages that have - * already been initialized. - * <!-- begin-user-doc --> - * @return the JSF library registry package - * <!-- end-user-doc --> - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static JSFLibraryRegistryPackage init() { - if (isInited) return (JSFLibraryRegistryPackage)EPackage.Registry.INSTANCE.getEPackage(JSFLibraryRegistryPackage.eNS_URI); - - // Obtain or create and register package - JSFLibraryRegistryPackageImpl theJSFLibraryRegistryPackage = (JSFLibraryRegistryPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof JSFLibraryRegistryPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new JSFLibraryRegistryPackageImpl()); - - isInited = true; - - // Create package meta-data objects - theJSFLibraryRegistryPackage.createPackageContents(); - - // Initialize created meta-data - theJSFLibraryRegistryPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theJSFLibraryRegistryPackage.freeze(); - - return theJSFLibraryRegistryPackage; - } - - /** - * <!-- begin-user-doc --> - * @return the eclass - * <!-- end-user-doc --> - * @generated - */ - public EClass getJSFLibraryRegistry() { - return jsfLibraryRegistryEClass; - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getJSFLibraryRegistry_DefaultImplementationID() { - return (EAttribute)jsfLibraryRegistryEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * @return the ereference - * <!-- end-user-doc --> - * @generated - */ - public EReference getJSFLibraryRegistry_JSFLibraries() { - return (EReference)jsfLibraryRegistryEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * @return the ereference - * <!-- end-user-doc --> - * @generated - */ - public EReference getJSFLibraryRegistry_PluginProvidedJSFLibraries() { - return (EReference)jsfLibraryRegistryEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * @return the eclass - * <!-- end-user-doc --> - * @generated - */ - public EClass getJSFLibrary() { - return jsfLibraryEClass; - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getJSFLibrary_ID() { - return (EAttribute)jsfLibraryEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getJSFLibrary_Name() { - return (EAttribute)jsfLibraryEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getJSFLibrary_JSFVersion() { - return (EAttribute)jsfLibraryEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getJSFLibrary_Deployed() { - return (EAttribute)jsfLibraryEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getJSFLibrary_Implementation() { - return (EAttribute)jsfLibraryEClass.getEStructuralFeatures().get(4); - } - - /** - * <!-- begin-user-doc --> - * @return the ereference - * <!-- end-user-doc --> - * @generated - */ - public EReference getJSFLibrary_ArchiveFiles() { - return (EReference)jsfLibraryEClass.getEStructuralFeatures().get(5); - } - - /** - * <!-- begin-user-doc --> - * @return the eclass - * <!-- end-user-doc --> - * @generated - */ - public EClass getArchiveFile() { - return archiveFileEClass; - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getArchiveFile_SourceLocation() { - return (EAttribute)archiveFileEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getArchiveFile_RelativeToWorkspace() { - return (EAttribute)archiveFileEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getArchiveFile_RelativeDestLocation() { - return (EAttribute)archiveFileEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * @return the ereference - * <!-- end-user-doc --> - * @generated - */ - public EReference getArchiveFile_JSFLibrary() { - return (EReference)archiveFileEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * @return the eclass - * <!-- end-user-doc --> - * @generated - */ - public EClass getPluginProvidedJSFLibrary() { - return pluginProvidedJSFLibraryEClass; - } - - /** - * <!-- begin-user-doc --> - * @return the eattribute - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getPluginProvidedJSFLibrary_PluginID() { - return (EAttribute)pluginProvidedJSFLibraryEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getPluginProvidedJSFLibrary_Label() { - return (EAttribute)pluginProvidedJSFLibraryEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * @return the eenum - * <!-- end-user-doc --> - * @generated - */ - public EEnum getJSFVersion() { - return jsfVersionEEnum; - } - - /** - * <!-- begin-user-doc --> - * @return the jsf library registry factory - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistryFactory getJSFLibraryRegistryFactory() { - return (JSFLibraryRegistryFactory)getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - jsfLibraryRegistryEClass = createEClass(JSF_LIBRARY_REGISTRY); - createEAttribute(jsfLibraryRegistryEClass, JSF_LIBRARY_REGISTRY__DEFAULT_IMPLEMENTATION_ID); - createEReference(jsfLibraryRegistryEClass, JSF_LIBRARY_REGISTRY__JSF_LIBRARIES); - createEReference(jsfLibraryRegistryEClass, JSF_LIBRARY_REGISTRY__PLUGIN_PROVIDED_JSF_LIBRARIES); - - jsfLibraryEClass = createEClass(JSF_LIBRARY); - createEAttribute(jsfLibraryEClass, JSF_LIBRARY__ID); - createEAttribute(jsfLibraryEClass, JSF_LIBRARY__NAME); - createEAttribute(jsfLibraryEClass, JSF_LIBRARY__JSF_VERSION); - createEAttribute(jsfLibraryEClass, JSF_LIBRARY__DEPLOYED); - createEAttribute(jsfLibraryEClass, JSF_LIBRARY__IMPLEMENTATION); - createEReference(jsfLibraryEClass, JSF_LIBRARY__ARCHIVE_FILES); - - pluginProvidedJSFLibraryEClass = createEClass(PLUGIN_PROVIDED_JSF_LIBRARY); - createEAttribute(pluginProvidedJSFLibraryEClass, PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID); - createEAttribute(pluginProvidedJSFLibraryEClass, PLUGIN_PROVIDED_JSF_LIBRARY__LABEL); - - archiveFileEClass = createEClass(ARCHIVE_FILE); - createEAttribute(archiveFileEClass, ARCHIVE_FILE__RELATIVE_TO_WORKSPACE); - createEAttribute(archiveFileEClass, ARCHIVE_FILE__SOURCE_LOCATION); - createEAttribute(archiveFileEClass, ARCHIVE_FILE__RELATIVE_DEST_LOCATION); - createEReference(archiveFileEClass, ARCHIVE_FILE__JSF_LIBRARY); - - // Create enums - jsfVersionEEnum = createEEnum(JSF_VERSION); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Add supertypes to classes - pluginProvidedJSFLibraryEClass.getESuperTypes().add(this.getJSFLibrary()); - - // Initialize classes and features; add operations and parameters - initEClass(jsfLibraryRegistryEClass, JSFLibraryRegistry.class, "JSFLibraryRegistry", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getJSFLibraryRegistry_DefaultImplementationID(), ecorePackage.getEString(), "DefaultImplementationID", "", 0, 1, JSFLibraryRegistry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getJSFLibraryRegistry_JSFLibraries(), this.getJSFLibrary(), null, "JSFLibraries", null, 0, -1, JSFLibraryRegistry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getJSFLibraryRegistry_PluginProvidedJSFLibraries(), this.getPluginProvidedJSFLibrary(), null, "PluginProvidedJSFLibraries", null, 0, -1, JSFLibraryRegistry.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - EOperation op = addEOperation(jsfLibraryRegistryEClass, this.getJSFLibrary(), "getJSFLibraryByID", 1, 1); - addEParameter(op, ecorePackage.getEString(), "ID", 1, 1); - - op = addEOperation(jsfLibraryRegistryEClass, ecorePackage.getEEList(), "getJSFLibrariesByName", 1, 1); - addEParameter(op, ecorePackage.getEString(), "name", 1, 1); - - addEOperation(jsfLibraryRegistryEClass, ecorePackage.getEEList(), "getImplJSFLibraries", 1, 1); - - addEOperation(jsfLibraryRegistryEClass, ecorePackage.getEEList(), "getNonImplJSFLibraries", 1, 1); - - addEOperation(jsfLibraryRegistryEClass, ecorePackage.getEEList(), "getAllJSFLibraries", 1, 1); - - op = addEOperation(jsfLibraryRegistryEClass, ecorePackage.getEBoolean(), "addJSFLibrary", 1, 1); - addEParameter(op, this.getJSFLibrary(), "library", 1, 1); - - op = addEOperation(jsfLibraryRegistryEClass, ecorePackage.getEBoolean(), "removeJSFLibrary", 1, 1); - addEParameter(op, this.getJSFLibrary(), "library", 1, 1); - - addEOperation(jsfLibraryRegistryEClass, this.getJSFLibrary(), "getDefaultImplementation", 1, 1); - - op = addEOperation(jsfLibraryRegistryEClass, null, "setDefaultImplementation"); - addEParameter(op, this.getJSFLibrary(), "implementation", 1, 1); - - initEClass(jsfLibraryEClass, JSFLibrary.class, "JSFLibrary", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getJSFLibrary_ID(), ecorePackage.getEString(), "ID", "", 0, 1, JSFLibrary.class, IS_TRANSIENT, !IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); - initEAttribute(getJSFLibrary_Name(), ecorePackage.getEString(), "Name", null, 1, 1, JSFLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getJSFLibrary_JSFVersion(), this.getJSFVersion(), "JSFVersion", "UNKNOWN", 1, 1, JSFLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getJSFLibrary_Deployed(), ecorePackage.getEBoolean(), "Deployed", "true", 1, 1, JSFLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getJSFLibrary_Implementation(), ecorePackage.getEBoolean(), "Implementation", "false", 1, 1, JSFLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getJSFLibrary_ArchiveFiles(), this.getArchiveFile(), this.getArchiveFile_JSFLibrary(), "ArchiveFiles", null, 0, -1, JSFLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - op = addEOperation(jsfLibraryEClass, ecorePackage.getEBoolean(), "containsArchiveFile", 1, 1); - addEParameter(op, ecorePackage.getEString(), "fullPath", 1, 1); - - addEOperation(jsfLibraryEClass, this.getJSFLibrary(), "getWorkingCopy", 1, 1); - - op = addEOperation(jsfLibraryEClass, null, "updateValues"); - addEParameter(op, this.getJSFLibrary(), "otherLibrary", 1, 1); - - op = addEOperation(jsfLibraryEClass, ecorePackage.getEBoolean(), "copyTo", 1, 1); - addEParameter(op, ecorePackage.getEString(), "baseDestLocation", 1, 1); - - addEOperation(jsfLibraryEClass, ecorePackage.getEString(), "getLabel", 1, 1); - - initEClass(pluginProvidedJSFLibraryEClass, PluginProvidedJSFLibrary.class, "PluginProvidedJSFLibrary", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getPluginProvidedJSFLibrary_PluginID(), ecorePackage.getEString(), "pluginID", null, 1, 1, PluginProvidedJSFLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getPluginProvidedJSFLibrary_Label(), ecorePackage.getEString(), "Label", null, 1, 1, PluginProvidedJSFLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(archiveFileEClass, ArchiveFile.class, "ArchiveFile", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getArchiveFile_RelativeToWorkspace(), ecorePackage.getEBoolean(), "RelativeToWorkspace", "true", 1, 1, ArchiveFile.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getArchiveFile_SourceLocation(), ecorePackage.getEString(), "SourceLocation", null, 1, 1, ArchiveFile.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getArchiveFile_RelativeDestLocation(), ecorePackage.getEString(), "RelativeDestLocation", null, 1, 1, ArchiveFile.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getArchiveFile_JSFLibrary(), this.getJSFLibrary(), this.getJSFLibrary_ArchiveFiles(), "JSFLibrary", null, 1, 1, ArchiveFile.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - addEOperation(archiveFileEClass, ecorePackage.getEString(), "getName", 1, 1); - - addEOperation(archiveFileEClass, ecorePackage.getEString(), "getPath", 1, 1); - - addEOperation(archiveFileEClass, ecorePackage.getEBoolean(), "exists", 1, 1); - - op = addEOperation(archiveFileEClass, ecorePackage.getEBoolean(), "equals", 1, 1); - addEParameter(op, ecorePackage.getEJavaObject(), "object", 1, 1); - - addEOperation(archiveFileEClass, ecorePackage.getEInt(), "hashCode", 1, 1); - - op = addEOperation(archiveFileEClass, ecorePackage.getEBoolean(), "copyTo", 1, 1); - addEParameter(op, ecorePackage.getEString(), "baseDestLocation", 1, 1); - - addEOperation(archiveFileEClass, ecorePackage.getEString(), "getResolvedSourceLocation", 1, 1); - - // Initialize enums and add enum literals - initEEnum(jsfVersionEEnum, JSFVersion.class, "JSFVersion"); - addEEnumLiteral(jsfVersionEEnum, JSFVersion.UNKNOWN_LITERAL); - addEEnumLiteral(jsfVersionEEnum, JSFVersion.V1_1_LITERAL); - addEEnumLiteral(jsfVersionEEnum, JSFVersion.V1_2_LITERAL); - - // Create resource - createResource(eNS_URI); - } - -} //JSFLibraryRegistryPackageImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/PluginProvidedJSFLibraryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/PluginProvidedJSFLibraryImpl.java deleted file mode 100644 index a7b1e37e1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/impl/PluginProvidedJSFLibraryImpl.java +++ /dev/null @@ -1,271 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl; - -import java.util.Iterator; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Plugin Provided JSF Library</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.PluginProvidedJSFLibraryImpl#getPluginID <em>Plugin ID</em>}</li> - * <li>{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.PluginProvidedJSFLibraryImpl#getLabel <em>Label</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class PluginProvidedJSFLibraryImpl extends JSFLibraryImpl implements PluginProvidedJSFLibrary { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The default value of the '{@link #getPluginID() <em>Plugin ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPluginID() - * @generated - * @ordered - */ - protected static final String PLUGIN_ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getPluginID() <em>Plugin ID</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPluginID() - * @generated - * @ordered - */ - protected String pluginID = PLUGIN_ID_EDEFAULT; - - /** - * The default value of the '{@link #getLabel() <em>Label</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLabel() - * @generated - * @ordered - */ - protected static final String LABEL_EDEFAULT = null; - - /** - * The cached value of the '{@link #getLabel() <em>Label</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLabel() - * @generated - * @ordered - */ - protected String label = LABEL_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected PluginProvidedJSFLibraryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * @return the static eclass - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return JSFLibraryRegistryPackage.Literals.PLUGIN_PROVIDED_JSF_LIBRARY; - } - - /** - * <!-- begin-user-doc --> - * @return the plugin id - * <!-- end-user-doc --> - * @generated - */ - public String getPluginID() { - return pluginID; - } - - /** - * <!-- begin-user-doc --> - * @param newPluginID - * <!-- end-user-doc --> - * @generated - */ - public void setPluginID(String newPluginID) { - String oldPluginID = pluginID; - pluginID = newPluginID; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID, oldPluginID, pluginID)); - } - - /** - * <!-- begin-user-doc --> - * @return translatable label - * <!-- end-user-doc --> - * @generated NOT - */ - public String getLabel() { - if (label == null) - return super.getLabel(); - return label; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setLabel(String newLabel) { - String oldLabel = label; - label = newLabel; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__LABEL, oldLabel, label)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID: - return getPluginID(); - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__LABEL: - return getLabel(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID: - setPluginID((String)newValue); - return; - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__LABEL: - setLabel((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID: - setPluginID(PLUGIN_ID_EDEFAULT); - return; - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__LABEL: - setLabel(LABEL_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__PLUGIN_ID: - return PLUGIN_ID_EDEFAULT == null ? pluginID != null : !PLUGIN_ID_EDEFAULT.equals(pluginID); - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY__LABEL: - return LABEL_EDEFAULT == null ? label != null : !LABEL_EDEFAULT.equals(label); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public String getID() { - return getPluginID() + ID_SEPARATOR + getName(); - } - - /** - * <!-- begin-user-doc --> - * @return the working copy - * <!-- end-user-doc --> - * @generated NOT - */ - public JSFLibrary getWorkingCopy() { - PluginProvidedJSFLibrary workingCopyLib = JSFLibraryRegistryFactory.eINSTANCE.createPluginProvidedJSFLibrary(); -// workingCopyLib.setID(getID()); - workingCopyLib.setName(getName()); - if (label != null) workingCopyLib.setLabel(getLabel()); - workingCopyLib.setJSFVersion(getJSFVersion()); - workingCopyLib.setDeployed(isDeployed()); - workingCopyLib.setImplementation(isImplementation()); - workingCopyLib.setPluginID(getPluginID()); - Iterator itArchiveFiles = getArchiveFiles().iterator(); - while (itArchiveFiles.hasNext()) { - ArchiveFile srcArchiveFile = (ArchiveFile)itArchiveFiles.next(); - ArchiveFile destArchiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile(); - destArchiveFile.setRelativeToWorkspace(srcArchiveFile.isRelativeToWorkspace()); - destArchiveFile.setSourceLocation(srcArchiveFile.getSourceLocation()); - destArchiveFile.setRelativeDestLocation(srcArchiveFile.getRelativeDestLocation()); - workingCopyLib.getArchiveFiles().add(destArchiveFile); - } - return workingCopyLib; - } - - /** - * <!-- begin-user-doc --> - * @return the string representation - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (pluginID: "); - result.append(pluginID); - result.append(", Label: "); - result.append(label); - result.append(')'); - return result.toString(); - } - -} //PluginProvidedJSFLibraryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryAdapterFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryAdapterFactory.java deleted file mode 100644 index 99729806f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryAdapterFactory.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; - - -/** - * <!-- begin-user-doc --> - * The <b>Adapter Factory</b> for the model. - * It provides an adapter <code>createXXX</code> method for each class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage - * @generated - */ -public class JSFLibraryRegistryAdapterFactory extends AdapterFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The cached model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static JSFLibraryRegistryPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistryAdapterFactory() { - if (modelPackage == null) { - modelPackage = JSFLibraryRegistryPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> - * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. - * @param object - * <!-- end-user-doc --> - * @return whether this factory is applicable for the type of the object. - * @generated - */ - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch the delegates to the <code>createXXX</code> methods. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected JSFLibraryRegistrySwitch modelSwitch = - new JSFLibraryRegistrySwitch() { - public Object caseJSFLibraryRegistry(JSFLibraryRegistry object) { - return createJSFLibraryRegistryAdapter(); - } - public Object caseJSFLibrary(JSFLibrary object) { - return createJSFLibraryAdapter(); - } - public Object casePluginProvidedJSFLibrary(PluginProvidedJSFLibrary object) { - return createPluginProvidedJSFLibraryAdapter(); - } - public Object caseArchiveFile(ArchiveFile object) { - return createArchiveFileAdapter(); - } - public Object defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the <code>target</code>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param target the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ - public Adapter createAdapter(Notifier target) { - return (Adapter)modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry <em>JSF Library Registry</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry - * @generated - */ - public Adapter createJSFLibraryRegistryAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary <em>JSF Library</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary - * @generated - */ - public Adapter createJSFLibraryAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile <em>Archive File</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile - * @generated - */ - public Adapter createArchiveFileAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary <em>Plugin Provided JSF Library</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary - * @generated - */ - public Adapter createPluginProvidedJSFLibraryAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * <!-- begin-user-doc --> - * This default implementation returns null. - * <!-- end-user-doc --> - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //JSFLibraryRegistryAdapterFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryResourceFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryResourceFactoryImpl.java deleted file mode 100644 index c865f2be5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryResourceFactoryImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; - -/** - * <!-- begin-user-doc --> - * The <b>Resource Factory</b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.JSFLibraryRegistryResourceImpl - * @generated - */ -public class JSFLibraryRegistryResourceFactoryImpl extends ResourceFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * Creates an instance of the resource factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistryResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * @param uri - * @return the Resource - * <!-- end-user-doc --> - * @generated - */ - public Resource createResource(URI uri) { - Resource result = new JSFLibraryRegistryResourceImpl(uri); - return result; - } - -} //JSFLibraryRegistryResourceFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryResourceImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryResourceImpl.java deleted file mode 100644 index 1bff4c324..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryResourceImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; - -/** - * <!-- begin-user-doc --> - * The <b>Resource </b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.JSFLibraryRegistryResourceFactoryImpl - * @generated - */ -public class JSFLibraryRegistryResourceImpl extends XMLResourceImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param uri the URI of the new resource. - * @generated - */ - public JSFLibraryRegistryResourceImpl(URI uri) { - super(uri); - } - -} //JSFLibraryRegistryResourceImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistrySwitch.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistrySwitch.java deleted file mode 100644 index b8ccb5f18..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistrySwitch.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; - - -/** - * <!-- begin-user-doc --> - * The <b>Switch</b> for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the <code>caseXXX</code> method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage - * @generated - */ -public class JSFLibraryRegistrySwitch { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - /** - * The cached model package - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static JSFLibraryRegistryPackage modelPackage; - - /** - * Creates an instance of the switch. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistrySwitch() { - if (modelPackage == null) { - modelPackage = JSFLibraryRegistryPackage.eINSTANCE; - } - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - public Object doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param theEClass - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - List eSuperTypes = theEClass.getESuperTypes(); - return - eSuperTypes.isEmpty() ? - defaultCase(theEObject) : - doSwitch((EClass)eSuperTypes.get(0), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param classifierID - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case JSFLibraryRegistryPackage.JSF_LIBRARY_REGISTRY: { - JSFLibraryRegistry jsfLibraryRegistry = (JSFLibraryRegistry)theEObject; - Object result = caseJSFLibraryRegistry(jsfLibraryRegistry); - if (result == null) result = defaultCase(theEObject); - return result; - } - case JSFLibraryRegistryPackage.JSF_LIBRARY: { - JSFLibrary jsfLibrary = (JSFLibrary)theEObject; - Object result = caseJSFLibrary(jsfLibrary); - if (result == null) result = defaultCase(theEObject); - return result; - } - case JSFLibraryRegistryPackage.PLUGIN_PROVIDED_JSF_LIBRARY: { - PluginProvidedJSFLibrary pluginProvidedJSFLibrary = (PluginProvidedJSFLibrary)theEObject; - Object result = casePluginProvidedJSFLibrary(pluginProvidedJSFLibrary); - if (result == null) result = caseJSFLibrary(pluginProvidedJSFLibrary); - if (result == null) result = defaultCase(theEObject); - return result; - } - case JSFLibraryRegistryPackage.ARCHIVE_FILE: { - ArchiveFile archiveFile = (ArchiveFile)theEObject; - Object result = caseArchiveFile(archiveFile); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpretting the object as an instance of '<em>JSF Library Registry</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>JSF Library Registry</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseJSFLibraryRegistry(JSFLibraryRegistry object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>JSF Library</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>JSF Library</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseJSFLibrary(JSFLibrary object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Archive File</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Archive File</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseArchiveFile(ArchiveFile object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Plugin Provided JSF Library</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Plugin Provided JSF Library</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object casePluginProvidedJSFLibrary(PluginProvidedJSFLibrary object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>EObject</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public Object defaultCase(EObject object) { - return null; - } - -} //JSFLibraryRegistrySwitch diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryUpgradeUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryUpgradeUtil.java deleted file mode 100644 index f0862125e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryUpgradeUtil.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; - -/** - * Utility for checking for, and upgrading the JSF Library Registry when the EMF model changes. - */ -public class JSFLibraryRegistryUpgradeUtil { - static String v1Tov2UpgradeURL = "http://www.eclipse.org/JSFxxxxxxxxxxxxxxxxxxxxxx"; - - /** - * default state is OK, no upgrade - */ - private UpgradeStatus upgradeStatus; - - /** - * The workspace-relative part of the URL of the JSF Library Registry - * persistence store. (version 1) - */ - public static final String JSF_LIBRARY_REGISTRY_V1_URL = ".metadata/.plugins/org.eclipse.jst.jsf.core/JSFLibraryRegistry.xml"; //$NON-NLS-1$ - - /** - * The workspace-relative part of the URL of the JSF Library Registry - * persistence store. (version 2) - */ - public static final String JSF_LIBRARY_REGISTRY_V2_URL = ".metadata/.plugins/org.eclipse.jst.jsf.core/JSFLibraryRegistryV2.xml"; //$NON-NLS-1$ - - /** - * The LATEST VERSION of the workspace-relative part of the URL of the JSF Library Registry - * persistence store. - */ - public static final String JSF_LIBRARY_REGISTRY_LATESTVERSION_URL = JSF_LIBRARY_REGISTRY_V2_URL; - /** - * The latest version value. - */ - public static final int LATESTVERSION = 2; - - private static final int NO_VERSION = 0; - - private static JSFLibraryRegistryUpgradeUtil INSTANCE; - - /** - * @return the stateful runtime singleton - */ - public static synchronized JSFLibraryRegistryUpgradeUtil getInstance(){ - if (INSTANCE == null){ - INSTANCE = new JSFLibraryRegistryUpgradeUtil(); - } - return INSTANCE; - } - - /** - * Return the URI for the specified JSF Library Registry - * @param registryVersion - * @return URI - * @throws MalformedURLException - */ - public static URI getRegistryURI(String registryVersion) throws MalformedURLException { - URL jsfLibRegURL = new URL(Platform.getInstanceLocation().getURL(), registryVersion); - return URI.createURI(jsfLibRegURL.toString()); - } - - /** - * @param originalFile - * @return the backup file name for a file - */ - public static String getBackupFileName(final String originalFile) - { - return originalFile.concat(".bkp"); - } - - /** - * Upgrades the JSF Library registry from oldest to newest - * @param expectedVersion - */ - public void upgradeRegistryIfNecessary(int expectedVersion) { - //when adding upgrades, the upgrades should progress from oldest to newest - try - { - int curVersion = getCurVersion(); - - if (curVersion < expectedVersion && curVersion != NO_VERSION) - { - UpgradeOperation op = getUpgradeOperation(curVersion); - - if (op.canExecute()) - { - try - { - // TODO: when move to Java 5, use co-variant return - upgradeStatus = (UpgradeStatus) - op.execute(new NullProgressMonitor(), null); - upgradeStatus.setUpgradeOperation(op); - } - catch (ExecutionException e) - { - // should never happen since we control the URL's - JSFCorePlugin.log(IStatus.ERROR, "Error during loading JSF Library registry", e); - //TODO: flag failure in status - upgradeStatus = - new UpgradeStatus(IStatus.ERROR, true, "Error detected during upgrade!"); - } - } - else - { - // TODO: what if can't execute? - upgradeStatus = - new UpgradeStatus(IStatus.ERROR, false, "Error detected during upgrade!"); - } - } - else - { - // everything ok, not upgrade - upgradeStatus = new UpgradeStatus(); - } - } - catch (MalformedURLException e) { - // should never happen since we control the URL's - JSFCorePlugin.log(IStatus.ERROR, "Error during loading JSF Library registry", e); - } - } - - private int getCurVersion() throws MalformedURLException - { - // TODO: need generalized algorithm here - URI v2File = getRegistryURI(JSF_LIBRARY_REGISTRY_V2_URL); - File file = new File(v2File.toFileString()); - if (file.exists()) - { - return 2; - } - - URI v1File = getRegistryURI(JSF_LIBRARY_REGISTRY_V1_URL); - file = new File(v1File.toFileString()); - if (file.exists()) - { - return 1; - } - return NO_VERSION; - } - - /** - * @param curVersion - * @return the upgrade operation to move from curVersion to the latest - * @throws MalformedURLException - */ - protected UpgradeOperation getUpgradeOperation(int curVersion) throws MalformedURLException - { - UpgradeOperation op = new UpgradeOperation("JSF Registry Upgrade"); - switch(curVersion) - { - case 1: - op.addVersionUpgrade( - new MigrateV1toV2Operation("Upgrade v1 to v2" - ,getRegistryURI(JSF_LIBRARY_REGISTRY_V1_URL) - , getRegistryURI(JSF_LIBRARY_REGISTRY_V2_URL))); - } - - return op; - } - - - /** - * @return array of {@link UpgradeStatus}s. There can be more than one if the registry has been upgraded by more than one version. - * Will not be null. - */ - public UpgradeStatus getUpgradeStatus(){ - return this.upgradeStatus; - } - - static void deleteFile(String fileName) { - File f = new File(fileName); - if (f.exists()){ - f.delete(); - if (f.exists()) - f.deleteOnExit(); - } - } - - static void copyFile(String srcFileName, String destFileName) { - - File srcFile = new File(srcFileName); - File destFile = new File(destFileName); - FileInputStream from = null; - FileOutputStream to = null; - try { - from = new FileInputStream(srcFile); - to = new FileOutputStream(destFile); - byte[] buffer = new byte[4096]; - int bytesRead; - - while ((bytesRead = from.read(buffer)) != -1) - to.write(buffer, 0, bytesRead); // write - } catch (IOException ioe){ - JSFCorePlugin.log(ioe, "Error during file copy"); - } finally { - if (from != null) - try { - from.close(); - } catch (IOException e) { - JSFCorePlugin.log(e, "Error during file close"); - } - if (to != null) - try { - to.close(); - } catch (IOException e) { - JSFCorePlugin.log(e, "Error during file close"); - } - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryXMLProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryXMLProcessor.java deleted file mode 100644 index 5607893a5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/JSFLibraryRegistryXMLProcessor.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: JSFLibraryRegistryXMLProcessor.java,v 1.2 2007/04/04 18:50:17 cbateman Exp $ - */ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.xmi.util.XMLProcessor; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage; - -/** - * This class contains helper methods to serialize and deserialize XML documents - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class JSFLibraryRegistryXMLProcessor extends XMLProcessor { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2005 Oracle Corporation"; - - - /** - * Public constructor to instantiate the helper. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public JSFLibraryRegistryXMLProcessor() { - super((EPackage.Registry.INSTANCE)); - JSFLibraryRegistryPackage.eINSTANCE.eClass(); - } - - /** - * Register for "*" and "xml" file extensions the JSFLibraryRegistryResourceFactoryImpl factory. - * <!-- begin-user-doc --> - * @return Map of registrations - * <!-- end-user-doc --> - * @generated - */ - protected Map getRegistrations() { - if (registrations == null) { - super.getRegistrations(); - registrations.put(XML_EXTENSION, new JSFLibraryRegistryResourceFactoryImpl()); - registrations.put(STAR_EXTENSION, new JSFLibraryRegistryResourceFactoryImpl()); - } - return registrations; - } - -} //JSFLibraryRegistryXMLProcessor diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/MigrateV1toV2Operation.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/MigrateV1toV2Operation.java deleted file mode 100644 index 7ea633989..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/MigrateV1toV2Operation.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; - -class MigrateV1toV2Operation extends VersionUpgradeOperation { - - private final URI _v1Registry; - private final URI _v2Registry; - - /** - * @param label - * @param v1Registry - * @param v2Registry - */ - public MigrateV1toV2Operation(String label, URI v1Registry, URI v2Registry) { - super(label, 1, 2); - _v1Registry = v1Registry; - _v2Registry = v2Registry; - } - - public IStatus doCommit() { - JSFLibraryRegistryUpgradeUtil.deleteFile(_v1Registry.toFileString()); - return Status.OK_STATUS; - } - - public IStatus doExecute(IProgressMonitor monitor, IAdaptable info) - { - JSFLibraryRegistryUpgradeUtil.copyFile - (_v1Registry.toFileString(), JSFLibraryRegistryUpgradeUtil.getBackupFileName(_v1Registry.toFileString())); - JSFLibraryRegistryResourceFactoryImpl resourceFactory = new JSFLibraryRegistryResourceFactoryImpl(); - JSFLibraryRegistryResourceImpl res = (JSFLibraryRegistryResourceImpl)resourceFactory.createResource(_v1Registry); - try { - URI newRegURI = - JSFLibraryRegistryUpgradeUtil.getRegistryURI - (JSFLibraryRegistryUpgradeUtil.JSF_LIBRARY_REGISTRY_V2_URL); - Map options = new HashMap(); - //disable notifications during load to avoid changing stored default implementation - options.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE); - res.load(options); - //if we got this far then the registry was empty - //"upgrade" to v2 and then delete old. no point in upgrade status being sent - JSFLibraryRegistryUtil.getInstance().saveJSFLibraryRegistry(); - JSFLibraryRegistryUpgradeUtil.copyFile(_v1Registry.toFileString(), newRegURI.toFileString());//save as v2 file - JSFLibraryRegistryUpgradeUtil.deleteFile(_v1Registry.toFileString()); - - return new UpgradeStatus();//all is ok and no need to alert user - - } catch(IOException ioe) { - //this was expected... if there was actual v1 contents in the regsistry... upgrade by saving - //perform save which will lose the ID - try { - res.save(Collections.EMPTY_MAP); - //create v2 xml file - URI newRegURI = - JSFLibraryRegistryUpgradeUtil.getRegistryURI - (JSFLibraryRegistryUpgradeUtil.JSF_LIBRARY_REGISTRY_V2_URL); - JSFLibraryRegistryUpgradeUtil.copyFile(_v1Registry.toFileString(), newRegURI.toFileString()); - //delete upgraded v1 - JSFLibraryRegistryUpgradeUtil.deleteFile(_v1Registry.toFileString()); - //restore backup to v1 name - JSFLibraryRegistryUpgradeUtil.copyFile(_v1Registry.toFileString().concat(".bkp"), _v1Registry.toFileString()); - //Alert end user - return new UpgradeStatus(IStatus.OK, true, Messages.JSFRegistryMigration05_to_10_customMessage); - } catch(IOException e) { - JSFCorePlugin.log(IStatus.ERROR, "Error during repository upgrade from v1 to v2", e); - return new UpgradeStatus(IStatus.ERROR, false, - Messages.JSFRegistryMigrationCannot05_to_10_customMessage); - } - } - //return ; - } - - public IStatus doRedo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - return doExecute(monitor, info); - } - - - public boolean canUndo() { - // commit is undoable for this operation - return super.canUndo() && !hasCommitted(); - } - - public IStatus doUndo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException - { - //restore backup to v1 name - JSFLibraryRegistryUpgradeUtil.copyFile(_v1Registry.toFileString().concat(".bkp"), _v1Registry.toFileString()); - - // delete the new registry - JSFLibraryRegistryUpgradeUtil.deleteFile(_v2Registry.toFileString()); - - //and the backup - JSFLibraryRegistryUpgradeUtil.deleteFile(_v1Registry.toFileString().concat(".bkp")); - - return Status.OK_STATUS; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeOperation.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeOperation.java deleted file mode 100644 index 130a3581d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeOperation.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.AbstractOperation; -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * Encapsulates a chain of one or more version steps into a full upgrade. - * - * @author cbateman - * - */ -public class UpgradeOperation extends AbstractOperation { - - private final List/*<VersionUpgradeOperation*/ _stepOperations; - - /** - * @param label - */ - public UpgradeOperation(String label) { - super(label); - _stepOperations = new ArrayList(); - } - - /** - * Add upgrade operation to the list of operations. - * Execute, undo and redo call each operation's corresponding - * method in the order they are added to the list. - * @param operation - */ - public void addVersionUpgrade(VersionUpgradeOperation operation) - { - _stepOperations.add(operation); - } - - /** - * @param monitor - * @param info - * @return an OK status if all goes well. The status for the first op - * that fails otherwise. - * @throws ExecutionException - */ - public IStatus execute(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - - boolean upgraded = false; - - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - VersionUpgradeOperation op = (VersionUpgradeOperation) it.next(); - // TODO: move to covariant - UpgradeStatus status = (UpgradeStatus) op.execute(monitor, info); - - // fail fast - if (status.getSeverity() != IStatus.OK) - { - return status; - } - - // once an upgrade is flagged, set flag - if (status.isUpgradeOccurred()) - { - upgraded = true; - } - } - - return new UpgradeStatus(IStatus.OK, upgraded, "Upgrade succeeded"); - } - - /** - * @param monitor - * @param info - * @return an OK status if all goes well. The status for the first op - * that fails otherwise. - * @throws ExecutionException - */ - public IStatus redo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - VersionUpgradeOperation op = (VersionUpgradeOperation) it.next(); - IStatus status = op.redo(monitor, info); - - // fail fast - if (status.getSeverity() != IStatus.OK) - { - return status; - } - } - - return new UpgradeStatus(IStatus.OK, true, "Upgrade succeeded"); - } - - /** - * @param monitor - * @param info - * @return an OK status if all goes well. The status for the first op - * that fails otherwise. - * @throws ExecutionException - */ - public IStatus undo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - VersionUpgradeOperation op = (VersionUpgradeOperation) it.next(); - IStatus status = op.undo(monitor, info); - - // fail fast - if (status.getSeverity() != IStatus.OK) - { - return status; - } - } - - return Status.OK_STATUS; - } - - /** - * @return an OK status if all goes well. The status for the first op - * that fails otherwise. - * @throws ExecutionException - */ - public IStatus commit() throws ExecutionException - { - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - VersionUpgradeOperation op = (VersionUpgradeOperation) it.next(); - - if (op.canCommit()) - { - IStatus status = op.commit(); - - // fail fast - if (status.getSeverity() != IStatus.OK) - { - return status; - } - } - } - - return Status.OK_STATUS; - } - - public boolean canExecute() - { - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - IUndoableOperation op = (IUndoableOperation) it.next(); - - // fail fast - if (!op.canExecute()) - { - return false; - } - } - - return true; - } - - public boolean canRedo() { - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - IUndoableOperation op = (IUndoableOperation) it.next(); - - // fail fast - if (!op.canRedo()) - { - return false; - } - } - - return true; - } - - public boolean canUndo() { - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - IUndoableOperation op = (IUndoableOperation) it.next(); - - // fail fast - if (!op.canUndo()) - { - return false; - } - } - - return true; - } - - public void dispose() - { - for (final Iterator it = _stepOperations.iterator(); it.hasNext();) - { - IUndoableOperation op = (IUndoableOperation) it.next(); - op.dispose(); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeStatus.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeStatus.java deleted file mode 100644 index 4a75a1d83..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/UpgradeStatus.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; - -/** - * Communicates the status of the JSF Library Registry - * - */ -public class UpgradeStatus extends Status -{ - private final boolean upgradeOccurred; - private UpgradeOperation upgradeOperation; - - /** - * All-is-well UpgradeStatus constructor - */ - public UpgradeStatus(){ - super(IStatus.OK, JSFCorePlugin.getDefault().getPluginID(), "OK"); - this.upgradeOccurred = false; - } - - /** - * Constructor when registry upgrade has occured or there is a problem during upgrade - * @param severity - * @param upgradeOccurred flag - * @param message - * - */ - public UpgradeStatus(int severity, boolean upgradeOccurred, String message){ - super(severity, JSFCorePlugin.getDefault().getPluginID(), message); - this.upgradeOccurred = upgradeOccurred; - } - - /** - * @return true if a registry upgrade occurred - */ - public boolean isUpgradeOccurred() { - return upgradeOccurred; - } - - /** - * @return the operation used to do the upgrade. - */ - protected UpgradeOperation getUpgradeOperation() { - return upgradeOperation; - } - - void setUpgradeOperation(UpgradeOperation upgradeOperation) - { - this.upgradeOperation = upgradeOperation; - } - - /** - * Commits any upgrade that has occurred - * @return the result of the commit - */ - public IStatus commit() - { - if (upgradeOperation != null) - { - try - { - return upgradeOperation.commit(); - } - catch (ExecutionException e) - { - return new Status(IStatus.ERROR, JSFCorePlugin.getDefault().getPluginID(), "Error committing status", e); - } - } - return Status.OK_STATUS; - } - - /** - * @return the result of rolling back any changes - */ - public IStatus rollback() - { - if (upgradeOperation != null) - { - try - { - return upgradeOperation.undo(new NullProgressMonitor(), null); - } - catch (ExecutionException e) - { - return new Status(IStatus.ERROR, JSFCorePlugin.getDefault().getPluginID(), "Error committing status", e); - } - } - return Status.OK_STATUS; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/VersionUpgradeOperation.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/VersionUpgradeOperation.java deleted file mode 100644 index bd8f1c288..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryregistry/util/VersionUpgradeOperation.java +++ /dev/null @@ -1,236 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.AbstractOperation; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; - -/** - * Implements a single step (vX -> v(X+1)) version upgrade as an - * Eclipse operation. Adds an additional "commit" abstract method. This - * can be called after execute in situations where further actions require - * user approval etc. See the javadocs for the method, it contains important - * API rules - * - * @author cbateman - * - */ -public abstract class VersionUpgradeOperation extends AbstractOperation -{ - /** - * the version being upgraded from - */ - protected final int _oldVersion; - /** - * the version being upgraded to - */ - protected final int _newVersion; - - private boolean _hasExecuted; - private boolean _hasCommitted; - private boolean _hasCleanState = true; - - /** - * @param label - * @param oldVersion - * @param newVersion - */ - public VersionUpgradeOperation(String label, int oldVersion, int newVersion) { - super(label); - _oldVersion = oldVersion; - _newVersion = newVersion; - } - - /** - * Allows selected functionality to be called after execute is called. - * Commit must conform to following contract: - * - * 1) should do nothing if execute() has not been called. - * 2) must do nothing if canCommit == false - * 3) once executed, undo should undo commit() first, then execute() - * 4) once undone, redo should call commit only if it was called before undo() - * @return must conform to same contract as execute() - * @throws ExecutionException - * - */ - public final IStatus commit() throws ExecutionException - { - if (canCommit()) - { - IStatus result = doCommit(); - if (result.getSeverity() == IStatus.OK) - { - _hasCommitted = true; - } - else - { - _hasCommitted = false; - _hasCleanState = false; - } - return result; - } - throw new ExecutionException("Cannot execute"); - } - - /** - * @return the result of the actual commit - * @throws ExecutionException - */ - protected abstract IStatus doCommit() throws ExecutionException; - - /** - * @return true if the operation can be committed - */ - public boolean canCommit() - { - return _hasExecuted && !_hasCommitted && _hasCleanState; - } - - public final IStatus execute(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException - { - if (canExecute()) - { - IStatus result = doExecute(monitor, info); - if (result.getSeverity() == IStatus.OK) - { - _hasExecuted = true; - } - else - { - _hasExecuted = false; - _hasCleanState = false; - } - return result; - } - throw new ExecutionException("Cannot execute"); - } - - /** - * @param monitor - * @param info - * @return the status of the real execution - * @throws ExecutionException - */ - protected abstract IStatus doExecute(IProgressMonitor monitor, IAdaptable info)throws ExecutionException; - - public final IStatus redo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - if (canRedo()) - { - IStatus result = doRedo(monitor, info); - if (result.getSeverity() == IStatus.OK) - { - _hasExecuted = true; - } - else - { - _hasExecuted = false; - _hasCleanState = false; - } - return result; - } - throw new ExecutionException("Cannot redo"); - } - - /** - * @param monitor - * @param info - * @return the status of the real redo - * @throws ExecutionException - */ - protected abstract IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException; - - public final IStatus undo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - if (canUndo()) - { - IStatus result = doUndo(monitor, info); - if (result.getSeverity() == IStatus.OK) - { - _hasExecuted = false; - } - else - { - _hasExecuted = true; - _hasCleanState = false; - } - return result; - } - throw new ExecutionException("Cannot redo"); - } - - /** - * @param monitor - * @param info - * @return the status of the real redo - * @throws ExecutionException - */ - protected abstract IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException; - - public boolean canExecute() { - return !_hasExecuted && _hasCleanState; - } - - public boolean canRedo() { - return canExecute(); - } - - public boolean canUndo() { - return _hasExecuted && _hasCleanState; - } - - /** - * @param executed - */ - protected void setHasExecuted(boolean executed) { - _hasExecuted = executed; - } - - /** - * @param committed - */ - protected void setHasCommitted(boolean committed) { - _hasCommitted = committed; - } - - /** - * @param cleanState - */ - protected void setHasCleanState(boolean cleanState) { - _hasCleanState = cleanState; - } - - /** - * @return true if has executed - */ - protected boolean hasExecuted() { - return _hasExecuted; - } - - /** - * @return true if has committed - */ - protected boolean hasCommitted() { - return _hasCommitted; - } - - /** - * @return true if has clean state - */ - protected boolean hasCleanState() { - return _hasCleanState; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/launch/JSFFileURL.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/launch/JSFFileURL.java deleted file mode 100644 index 5db092d00..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/launch/JSFFileURL.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.launch; - -import java.util.Iterator; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.internal.web.jfaces.extension.FileURL; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.ServletMapping; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.core.internal.project.facet.JSFUtils11; -import org.eclipse.jst.jsf.core.internal.project.facet.JSFUtils12; - -/** - * Extends the FileURL extension-point so that a JSF JSP page - * can have it's URL mapped to the Faces Servlet using the servlet-mapping - * specified in the web.xml file - * - * @author Gerry Kessler - Oracle - * - */ -public class JSFFileURL implements FileURL { - - /** - * If this is a JSP page, this will return a URL using the first valid servlet-mapping to the Faces Servlet - * if found. If the faces servlet is not defined in the web.xml or there is no servlet-mapping, this will return null. - * - * The resource's file extension is compared with the javax.faces.DEFAULT_SUFFIX context-param if set. If the same, then - * extension mapping will be used if found in the web.xml. If not set, "jsp" default is assumed. If resource does not have the default - * file extension, then it must have either: jsp,jspx, or jsf file extensions in order to be considered for launch. - * - * This will not guarentee a page to be run. The user will still need a properly configured server with valid URL mappings and - * context-params. - * - * TODO: We could detect and insert or just warn for context-params and url mappings to run. However, this would better detected during a JSF App validation step. - * - * @see org.eclipse.jst.j2ee.internal.web.jfaces.extension.FileURL#getFileURL(org.eclipse.core.resources.IResource, org.eclipse.core.runtime.IPath) - */ - public IPath getFileURL(IResource resource, IPath existingURL) { - - //is this is a Faces Project with a Faces Servlet? - //we will not check to see if facet is installed. - // check to see if this resource is a JSF page (currently always true) and then, - //if servlet is present, we will change the url based on first mapping found - IModelProvider provider = ModelProviderManager.getModelProvider(resource.getProject()); - Object webAppObj = provider.getModelObject(); - if (webAppObj != null){ - //methods below returning the path are identical except for the APIs required - if (JSFUtils12.isWebApp25(webAppObj)){ - return getJavaEEFileURLPath(webAppObj, resource, existingURL); - } - else if (JSFUtils11.isWebApp24(webAppObj) || JSFUtils11.isWebApp23(webAppObj)) { - return getJ2EEFileURLPath(webAppObj, resource, existingURL); - } - } - return null; - } - - private IPath getJ2EEFileURLPath(Object webAppObj, IResource resource, - IPath existingURL) { - WebApp webApp = (WebApp)webAppObj; - if (webApp != null){ - Servlet servlet = JSFUtils11.findJSFServlet(webApp); - if (servlet == null)//if no faces servlet, do nothing - return null; - - //if not a JSF page, do nothing - if (!isJSFPage(resource)) - return null; - - String defaultSuffix = JSFUtils11.getDefaultSuffix(webApp); - //is the resource using default_suffix - boolean canUseExtensionMapping = resource.getFileExtension().equalsIgnoreCase(defaultSuffix); - - //if not using default extension and is not a known file extension, then we will abort - if (! canUseExtensionMapping && ! isValidKnownExtension(resource.getFileExtension())) - return null; - - Iterator mappings = servlet.getMappings().iterator(); - ServletMapping map = null; - String foundFileExtension = null; - while (mappings.hasNext()){ - map = (ServletMapping)mappings.next(); - - foundFileExtension = JSFUtils11.getFileExtensionFromMap(map); - if (foundFileExtension != null && canUseExtensionMapping) { - return existingURL.removeFileExtension().addFileExtension(foundFileExtension); - } - - String foundPrefixMapping = JSFUtils11.getPrefixMapping(map); - if (foundPrefixMapping != null){ - return new Path(foundPrefixMapping).append(existingURL); - } - - } - - if (! canUseExtensionMapping && foundFileExtension != null){ - //we could prompt user that this may not work... - //for now we will return the extension mapping - return existingURL.removeFileExtension().addFileExtension(foundFileExtension); - } - - //we could, at this point, add a url mapping to the faces servlet, or prompt user that it may be a good idea to add one... ;- - } - return null; - } - - private IPath getJavaEEFileURLPath(Object webAppObj, IResource resource, - IPath existingURL) { - org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp )webAppObj; - if (webApp != null){ - org.eclipse.jst.javaee.web.Servlet servlet = JSFUtils12.findJSFServlet(webApp); - if (servlet == null)//if no faces servlet, do nothing - return null; - - //if not a JSF page, do nothing - if (!isJSFPage(resource)) - return null; - - String defaultSuffix = JSFUtils12.getDefaultSuffix(webApp); - //is the resource using default_suffix - boolean canUseExtensionMapping = resource.getFileExtension().equalsIgnoreCase(defaultSuffix); - - //if not using default extension and is not a known file extension, then we will abort - if (! canUseExtensionMapping && ! isValidKnownExtension(resource.getFileExtension())) - return null; - - Iterator mappings = webApp.getServletMappings().iterator(); - org.eclipse.jst.javaee.web.ServletMapping map = null; - String foundFileExtension = null; - while (mappings.hasNext()){ - map = (org.eclipse.jst.javaee.web.ServletMapping)mappings.next(); - if (map.getServletName().equals(servlet.getServletName())){ - foundFileExtension = JSFUtils12.getFileExtensionFromMap(map); - if (foundFileExtension != null && canUseExtensionMapping) { - return existingURL.removeFileExtension().addFileExtension(foundFileExtension); - } - - String foundPrefixMapping = JSFUtils12.getPrefixMapping(map); - if (foundPrefixMapping != null){ - return new Path(foundPrefixMapping).append(existingURL); - } - } - } - - if (! canUseExtensionMapping && foundFileExtension != null){ - //we could prompt user that this may not work... - //for now we will return the extension mapping - return existingURL.removeFileExtension().addFileExtension(foundFileExtension); - } - - //we could, at this point, add a url mapping to the faces servlet, or prompt user that it may be a good idea to add one... ;- - } - - return null; - } - - private boolean isValidKnownExtension(String fileExtension) { - if (( fileExtension.equalsIgnoreCase("jsp") || //$NON-NLS-1$ - fileExtension.equalsIgnoreCase("jspx") || //$NON-NLS-1$ - fileExtension.equalsIgnoreCase("jsf"))) //$NON-NLS-1$ - return true; - - return false; - } - - - private boolean isJSFPage(IResource resource) { - // currently always return true. - // need to find quick way of determining whether this is a JSF JSP Page - return true; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties deleted file mode 100644 index 4f8ac773b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties +++ /dev/null @@ -1,75 +0,0 @@ -############################################################################### -# Copyright (c) 2005 Oracle Corporation. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Gerry Kessler - initial API and implementation -# Ian Trimble - change key names for use with org.eclipse.osgi.util.NLS -############################################################################### -JSFLibraryRegistry_ErrorCreatingURL=Error creating URL for JSF Library Registry -JSFLibraryRegistry_NoLoadCreatingNew=Could not load JSF Library Registry; creating new registry -JSFLibraryRegistry_ErrorSaving=Error saving JSF Library Registry -JSFLibraryRegistry_DEFAULT_IMPL_LABEL=<Default> -JSFLibraryConfigModel_Null_Data_Source=Data Source is not provided. -JSFLibraryRegistry_ErrorLoadingFromExtPt=Error while loading JSF Libaries from extension points -JSFLibraryClasspathContainer_IMPL_LIBRARY=[JSF Library - implementation] - -JSFFacetInstallDataModelProvider_ValidateServletName=Specify a servlet name to use -JSFLibraryConfigPersistData_SAVED_IMPLLIB_NOT_FOUND=Saved JSF implementation library in {0} is unavailable in JSF Library Registry -JSFLibraryConfigPersistData_SAVED_COMPLIB_NOT_FOUND=Saved JSF component library in {0} is unavailable in JSF Library Registry -JSFLibraryClasspathContainer_NON_IMPL_LIBRARY=[JSF Library] -JSFLibrariesContainerInitializer_missing_library=[missing JSF Library] -JSFFacetInstallDataModelProvider_ValidateJSFImpl=A JSF implementation library has not been chosen -JSFFacetInstallDataModelProvider_DupeJarValidation=Duplicated jar on classpath: {0} -JSFFacetInstallDataModelProvider_ValidateConfigFilePath=The configuration file path is not valid -JSFFacetInstallDataModelProvider_ValidateConfigFileEmpty=Specify a valid name and location for JSF configuration file -JSFFacetInstallDataModelProvider_ClientImplValidationMsg=JSF Implementation library must be specified. -JSFFacetInstallDataModelProvider_ValidateConfigFileRelative1=Configuration file must be specified relative to the project's {0} folder -JSFFacetInstallDataModelProvider_ValidateConfigFileRelative2=Configuration file must be located in the project's {0} folder -JSFFacetInstallDataModelProvider_INITIAL_VALIDATION_IMPL_TYPE=Select an implementation library. If a server supplied library is chosen , the chosen server adapter must be capable of providing the JSF Implementation jars, or the application will not validate or compile. -JSFFacetInstallDataModelProvider_ValidateConfigFileXML=JSF configuration file must be an XML file -JSFFacetInstallDataModelProvider_ValidateConfigFileSlashes=Configuration file path must not contain "\\"s. Use "/" instead. -JSFLibCfgDialogSettingData_Sticky_Component_Lib_Not_Exist=A sticky component library selection no longer exists. - -ArchiveFileImpl_CannotCopyFile=Cannot copy file -ArchiveFileImpl_CannotCloseFile=Cannot close file -ArchiveFileImpl_CannotLocatePluginRelativeFile=Cannot locate plugin-relative file "{0}" - -PluginProvidedJSFLibraryCreationHelper_ErrorCreating=Unable to create JSF Library: {0} -PluginProvidedJSFLibraryCreationHelper_ErrorMultipleDefinition={0} defined multiple times in {1} - -JSFUtils_ErrorCreatingConfigFile=Error creating config file -JSFUtils_ErrorClosingConfigFile=Error closing config file - -JSFAppConfigUtils_ErrorOpeningJarFile=Error opening JarFile "{0}" - -JARFileJSFAppConfigProvider_ErrorLoadingModel=Error loading model for file "{0}" -JSFUtils_MissingJAR= Missing JSF Library Jar: {0} in {1} - -J2EEModuleDependencyDelegate_UpdatingJ2EEModuleDependencies=Updating J2EE Module Dependencies -J2EEModuleDependencyDelegate_UpdatingJ2EEModuleDependenciesForProject=Updating J2EE Module Dependencies for project "{0}" - -JSFRegistryMigration05_to_10_title=User Intervention Required -JSFRegistryMigration05_to_10_message=IMPORTANT! Please read below: -JSFRegistryMigration05_to_10_customMessage=You have loaded a workspace created with a previous \ -version of JSF Tools.\nYour JSF Library Registry is out of date and needs to be migrated forward to continue.\n\ -If you choose to proceed, be aware of the following consequences:\n\ -\n\ -1) Projects in this workspace will need to be manually migrated by you to work in this version of JSF Tools.\n\ -2) Once migrated, this workspace will no longer work in older versions of JSF Tools.\n\ -\n\ -If this is not what you want, exit immediately and your workspace will still load in older versions. - -JSFRegistryMigrationCannot05_to_10_title=Error During Registry Upgrade -JSFRegistryMigrationCannot05_to_10_message=IMPORTANT! Please read below: -JSFRegistryMigrationCannot05_to_10_customMessage=You a loaded a workspace created with a previous \ -version of JSF Tools.\nYour JSF Library Registry is out of date and needs to be migrated forward to continue.\n\ -However, the existing registry has a problem and cannot be upgraded. -RegistryMigrationStartupHandler_Error_committing_migration=Error committing migration\! -RegistryMigrationStartupHandler_Error_Rolling_Back_Migration=Error rolling back migration\! -RegistryMigrationStartupHandler_Dialog_Confirm_Migration=Confirm -RegistryMigrationStartupHandler_Dialog_Abort_And_Exit_Migration=Abort and Exit -RegistryMigrationStartupHandler_Launch_Migration_Doc_On_Confirm=Launch Migration Doc on Confirm diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/AbstractJSFFacetInstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/AbstractJSFFacetInstallDelegate.java deleted file mode 100644 index 42523a219..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/AbstractJSFFacetInstallDelegate.java +++ /dev/null @@ -1,207 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * Abstract JSF Facet Install Delegate for WTP faceted web projects. - * - * Uses <code>com.eclispe.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider<code> for model - * <li> concrete delegat creates JSF configuration file if not present - * <li> concrete delegate updates web app for: servlet, servlet-mapping and context-params - * <li> adds implementation jars to WEB-INF/lib if user requests - * - * @see org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider - */ -public abstract class AbstractJSFFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, - final Object cfg, final IProgressMonitor monitor) - - throws CoreException - - { - - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - IDataModel config = null; - - if (cfg != null) { - config = (IDataModel) cfg; - } else { - //FIXME: how would we hit this??? -// config = new JSFFacetInstallConfig(); -// config.setJsfImplID(jsfImplID); - } - - // Create JSF Libs as classpath containers and set WTP dependencies as required - createClasspathEntries(project, config, monitor); - - // Create config file - createConfigFile(project, fv, config, monitor); - - // Update web model - createServletAndModifyWebXML(project, config, monitor); - - if (monitor != null) { - monitor.worked(1); - } - - } finally { - if (monitor != null) { - monitor.done(); - } - } - } - - /** - * Adds the JSF Library references specified in the wizard to the project as classpath containers. - * Marks the containers as J2EE module dependencies as required - * - * @param project - * @param config - * @param monitor - */ - protected void createClasspathEntries(IProject project, IDataModel config, IProgressMonitor monitor) { - IJavaProject javaProject = JavaCore.create(project); - List cpEntries = new ArrayList(); - try { - for (int i=0;i<javaProject.getRawClasspath().length;i++){ - cpEntries.add(javaProject.getRawClasspath()[i]); - } - } catch (JavaModelException e) { - JSFCorePlugin.log(e, "Unable to read classpath"); //$NON-NLS-1$ - } - - IPath path, cp = null; - IClasspathEntry entry = null; - JSFLibraryInternalReference libref = null; - - //Implementation - if (config.getProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE_PROPERTY_NAME) - == IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE.CLIENT_SUPPLIED){ - cp = new Path(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID); - libref = (JSFLibraryInternalReference)config.getProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION); - path = cp.append(new Path(libref.getID())); - entry = getNewCPEntry(path, libref); - cpEntries.add(entry); - } - - JSFLibraryInternalReference[] compLibs = (JSFLibraryInternalReference[])config.getProperty(IJSFFacetInstallDataModelProperties.COMPONENT_LIBRARIES); - for (int i=0;i<compLibs.length;i++){ - libref = compLibs[i]; - cp = new Path(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID); - path = cp.append(new Path(libref.getID())); - entry = getNewCPEntry(path, libref); - if (entry != null) - cpEntries.add(entry); - } - - JSFLibraryRegistryUtil.setRawClasspath(javaProject, cpEntries, monitor); - } - - /** - * @param path - * @param lib - * @return creates new IClasspathEntry with WTP dependency attribute set, if required - */ - protected IClasspathEntry getNewCPEntry(IPath path, JSFLibraryInternalReference lib) { - - IClasspathEntry entry = null; - if (lib.isCheckedToBeDeployed()){ - IClasspathAttribute depAttrib = JavaCore.newClasspathAttribute(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY, - ClasspathDependencyUtil.getDefaultRuntimePath(true).toString()); - entry = JavaCore.newContainerEntry(path,null, new IClasspathAttribute[]{depAttrib}, true); - } - else { - entry = JavaCore.newContainerEntry(path); - } - - return entry; - } - - - /** - * Create the faces configuration file - * @param project - * @param fv - * @param config - * @param monitor - */ - protected abstract void createConfigFile(final IProject project, - final IProjectFacetVersion fv, final IDataModel config, - IProgressMonitor monitor) ; - - /** - * Create servlet and URL mappings and update the webapp - * @param project - * @param config - * @param monitor - */ - protected abstract void createServletAndModifyWebXML(IProject project, - final IDataModel config, IProgressMonitor monitor); - - - /** - * @param config - * @return list of URL patterns from the datamodel - */ - protected List getServletMappings(IDataModel config) { - List mappings = new ArrayList(); - String[] patterns = (String[])config.getProperty(IJSFFacetInstallDataModelProperties.SERVLET_URL_PATTERNS); - for (int i = 0; i < patterns.length; i++) { - String pattern = patterns[i]; - mappings.add(pattern); - } - - return mappings; - } - - /** - * @param project - * @param jsfConfigPath - * @return absolute IPath to jsfConfig - */ - protected IPath resolveConfigPath(IProject project, String jsfConfigPath) { - return ComponentCore.createComponent(project).getRootFolder() - .getUnderlyingFolder().getRawLocation().append( - new Path(jsfConfigPath)); - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/AbstractJSFFacetUninstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/AbstractJSFFacetUninstallDelegate.java deleted file mode 100644 index 603ace13c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/AbstractJSFFacetUninstallDelegate.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * Abstract JSF Facet Uninstall Delegate for WTP faceted projects. - * - * <li> concrete class should remove JSF servlet, servlet-mappings and context-params - * <li> leaves JSF configuration files on disk - * <li> removes JSF classpath containers - * - * @author Gerry Kessler - Oracle - * @since M1 - */ -public abstract class AbstractJSFFacetUninstallDelegate implements IDelegate { - - public void execute(IProject project, IProjectFacetVersion fv, - Object config, IProgressMonitor monitor) throws CoreException { - { - - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - - // Remove JSF Libraries - removeJSFLibaries(project, monitor); - - // remove servlet stuff from web.xml - uninstallJSFReferencesFromWebApp(project, monitor); - - if (monitor != null) { - monitor.worked(1); - } - } finally { - if (monitor != null) { - monitor.done(); - } - } - } - } - - /** - * Removes JSF Lib CP Containers from project - * @param project - * @param monitor - */ - protected void removeJSFLibaries(IProject project, IProgressMonitor monitor) { - final IJavaProject jproj = JavaCore.create(project); - List keptEntries = new ArrayList(); - try { - IClasspathEntry[] entries = jproj.getRawClasspath(); - keptEntries = new ArrayList(); - for (int i=0;i<entries.length;i++){ - IClasspathEntry entry = entries[i]; - if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && - ! entry.getPath().segment(0) - .equals(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID)) - keptEntries.add(entry); - } - } catch (JavaModelException e) { - JSFCorePlugin.log(e, "Cannot get classpath entries to remove JSF Libraries for: "+project.getName()); //$NON-NLS-1$ - } - - if (keptEntries.size() > 0){ - try { - jproj.setRawClasspath((IClasspathEntry[])keptEntries.toArray(new IClasspathEntry[0]), monitor); - } catch (JavaModelException e) { - JSFCorePlugin.log(e, "Exception occured while removing JSF Libraries during JSF Facet uninstall"); //$NON-NLS-1$ - } - } - - - } - - /** - * Uninstall JSF references: servlet, - * @param project - * @param monitor - */ - protected abstract void uninstallJSFReferencesFromWebApp(IProject project, - IProgressMonitor monitor); - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/IJSFFacetInstallDataModelProperties.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/IJSFFacetInstallDataModelProperties.java deleted file mode 100644 index ad03d4701..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/IJSFFacetInstallDataModelProperties.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.project.facet; - -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetInstallDataModelProperties; - -/** - * Defines properties used by the JSF facet install data model. - * - * @author Gerry Kessler - Oracle - */ -public interface IJSFFacetInstallDataModelProperties extends - IFacetInstallDataModelProperties { - - /** - * TODO: - */ - public static final String IMPLEMENTATION_TYPE_PROPERTY_NAME = "IJSFFacetInstallDataModelProperties.IMPLEMENTATION_TYPE_PROPERTY_NAME"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String IMPLEMENTATION = "IJSFFacetInstallDataModelProperties.IMPLEMENTATION"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String DEPLOY_IMPLEMENTATION = "IJSFFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String CONFIG_PATH = "IJSFFacetInstallDataModelProperties.CONFIG_PATH"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String SERVLET_NAME = "IJSFFacetInstallDataModelProperties.SERVLET_NAME"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String SERVLET_CLASSNAME = "IJSFFacetInstallDataModelProperties.SERVLET_CLASSNAME"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String SERVLET_URL_PATTERNS = "IJSFFacetInstallDataModelProperties.SERVLET_URL_PATTERNS"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String WEBCONTENT_DIR = "IJSFFacetInstallDataModelProperties.WEBCONTENT_DIR"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String DEFAULT_IMPLEMENTATION_LIBRARY = "IJSFFacetInstallDataModelProperties.DEFAULT_IMPLEMENTATION_LIBRARY"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String IMPLEMENTATION_LIBRARIES = "IJSFFacetInstallDataModelProperties.IMPLEMENTATION_LIBRARIES"; //$NON-NLS-1$ - - /** - * TODO: - */ - public static final String COMPONENT_LIBRARIES = "IJSFFacetInstallDataModelProperties.COMPONENT_LIBRARIES"; //$NON-NLS-1$ - - /** - * Enumeration of implementation types - */ - public enum IMPLEMENTATION_TYPE { - - /** - * Unknown - */ - UNKNOWN, - /** - * Server supplied - */ - SERVER_SUPPLIED, - /** - * Client supplied - */ - CLIENT_SUPPLIED; - - /** - * @param type - * @return String value - */ - public static String getStringValue(final IMPLEMENTATION_TYPE type){ - if (type == null) - return "UNKNOWN"; //$NON-NLS-1$ - if (type == SERVER_SUPPLIED) - return "SERVER_SUPPLIED";//$NON-NLS-1$ - if (type == CLIENT_SUPPLIED) - return "CLIENT_SUPPLIED";//$NON-NLS-1$ - return "UNKNOWN"; //$NON-NLS-1$ - } - - /** - * @param type - * @return IMPLEMENTATION_TYPE - */ - public static IMPLEMENTATION_TYPE getValue(final String type){ - if (type == null) - return UNKNOWN; - if (type.equals("SERVER_SUPPLIED"))//$NON-NLS-1$ - return SERVER_SUPPLIED; - if (type.equals("CLIENT_SUPPLIED"))//$NON-NLS-1$ - return CLIENT_SUPPLIED; - return UNKNOWN; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java deleted file mode 100644 index 1c7b7db85..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java +++ /dev/null @@ -1,388 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew; - -/** - * Provides a data model used by the JSF facet install. - * - * @author Gerry Kessler - Oracle - */ -public class JSFFacetInstallDataModelProvider extends - FacetInstallDataModelProvider implements - IJSFFacetInstallDataModelProperties { - - private String errorMessage; - - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(IMPLEMENTATION_TYPE_PROPERTY_NAME); - names.add(IMPLEMENTATION); - names.add(DEPLOY_IMPLEMENTATION); - names.add(CONFIG_PATH); - names.add(SERVLET_NAME); - names.add(SERVLET_CLASSNAME); - names.add(SERVLET_URL_PATTERNS); - names.add(WEBCONTENT_DIR); - - names.add(IMPLEMENTATION_LIBRARIES); - names.add(COMPONENT_LIBRARIES); - names.add(DEFAULT_IMPLEMENTATION_LIBRARY); - - return names; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(IMPLEMENTATION_TYPE_PROPERTY_NAME)){ - return IMPLEMENTATION_TYPE.UNKNOWN; - } - else if (propertyName.equals(IMPLEMENTATION)) { - if (JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry() == null) - return null; - return getDefaultImplementationLibrary();//JSFCorePlugin.getDefault().getJSFLibraryRegistry().getDefaultImplementation(); - } else if (propertyName.equals(DEPLOY_IMPLEMENTATION)) { - return Boolean.TRUE; - } else if (propertyName.equals(CONFIG_PATH)) { - return JSFUtils.JSF_DEFAULT_CONFIG_PATH; - } else if (propertyName.equals(SERVLET_NAME)) { - return JSFUtils.JSF_DEFAULT_SERVLET_NAME; - } else if (propertyName.equals(SERVLET_CLASSNAME)) { - return JSFUtils.JSF_SERVLET_CLASS; - } else if (propertyName.equals(SERVLET_URL_PATTERNS)) { - return new String[] {JSFUtils.JSF_DEFAULT_URL_MAPPING }; - } else if (propertyName.equals(FACET_ID)) { - return IJSFCoreConstants.JSF_CORE_FACET_ID; - } else if (propertyName.equals(WEBCONTENT_DIR)){ - return "WebContent"; //not sure I need this //$NON-NLS-1$ - } else if (propertyName.equals(COMPONENT_LIBRARIES)) { - return new JSFLibraryInternalReference[0]; - } else if (propertyName.equals(IMPLEMENTATION_LIBRARIES)) { - return getDefaultJSFImplementationLibraries(); - } else if (propertyName.equals(DEFAULT_IMPLEMENTATION_LIBRARY)) { - return getDefaultImplementationLibrary(); - } - return super.getDefaultProperty(propertyName); - } - - public IStatus validate(String name) { - errorMessage = null; - if (name.equals(IMPLEMENTATION_TYPE_PROPERTY_NAME)) { - if (getProperty(IMPLEMENTATION_TYPE_PROPERTY_NAME) == IMPLEMENTATION_TYPE.UNKNOWN) { - return createErrorStatus(Messages.JSFFacetInstallDataModelProvider_INITIAL_VALIDATION_IMPL_TYPE); - } - } - else if (name.equals(IMPLEMENTATION)) { - if (getProperty(IMPLEMENTATION_TYPE_PROPERTY_NAME) == IMPLEMENTATION_TYPE.CLIENT_SUPPLIED) { - JSFLibraryInternalReference lib = (JSFLibraryInternalReference)getProperty(IMPLEMENTATION); - IStatus status = validateImpl(lib.getLibrary()); - if (!OK_STATUS.equals(status)) - return status; - - return validateClasspath(); - } - } else if (name.equals(CONFIG_PATH)) { - return validateConfigLocation(getStringProperty(CONFIG_PATH)); - } else if (name.equals(SERVLET_NAME)) { - return validateServletName(getStringProperty(SERVLET_NAME)); - } - else if (name.equals(COMPONENT_LIBRARIES)) { - return validateClasspath(); - } - return super.validate(name); - } - - private IStatus createErrorStatus(String msg) { - return new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, msg); - } - - private IStatus validateServletName(String servletName) { - if (servletName == null || servletName.trim().length() == 0) { - errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateServletName; - return createErrorStatus(errorMessage); - } - - return OK_STATUS; - } - - private IStatus validateImpl(JSFLibrary impl) { - if (impl == null) { - errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateJSFImpl; - } - if (errorMessage != null) { - return createErrorStatus(errorMessage); - } - return OK_STATUS; - } - - private IStatus validateConfigLocation(String text) { - if (text == null || text.trim().equals("")) { //$NON-NLS-1$ - errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileEmpty; - return createErrorStatus(errorMessage); - } - text = text.trim(); - - if (getProjectPath() == null) //this circumstance occurs on page init - return OK_STATUS; - - IPath fullPath = getProjectPath().append(text); - IPath passedPath = new Path(text); - if (!fullPath.isValidPath(text)){ - errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFilePath; - return createErrorStatus(errorMessage); - } - - //FIXME: check for valid file path also [passedPath.toFile().isFile()] - if (text.toLowerCase().lastIndexOf(".xml") != text.length() - 4) { //$NON-NLS-1$ - errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileXML; - return createErrorStatus(errorMessage); - } - - if (text.lastIndexOf("\\") >= 0){ //$NON-NLS-1$ - errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileSlashes; - return createErrorStatus(errorMessage); - } -// if (1 == 1){ -// //FIXME!!!! -// //until i can figure out how to get WebContent dir from the WebApp config, -// //skip validation here -// return OK_STATUS; -// } - if (passedPath.getDevice() != null) { - errorMessage = NLS.bind( - Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileRelative1, - getWebContentFolderName()); - return createErrorStatus(errorMessage); - } - IPath webContentFolder = getWebContentFolder(); - IPath setPath = webContentFolder.append(passedPath); - if (!getWebContentFolder().isPrefixOf(setPath)) { - errorMessage = NLS.bind( - Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileRelative2, - getWebContentFolderName()); - return createErrorStatus(errorMessage); - } - - return OK_STATUS; - } - - private IStatus validateClasspath(){ - Set jars = new HashSet(); - if (doesProjectExist()){ - //validate actual classpath by loading jars from cp - try { - IClasspathEntry[] entries = getJavaProject().getResolvedClasspath(true); - for (int i=0;i<entries.length;i++){ - IClasspathEntry entry = entries[i]; - if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY){ - jars.add(entry.getPath().makeAbsolute().toString()); - } - } - } catch (JavaModelException e) { - // FIXME: what should we do in this case? - JSFCorePlugin.log(e, "Error searching class path"); //$NON-NLS-1$ - } - } - //else as we do not have a javaProject yet, all we can do is validate that there is no duplicate jars (absolute path) - - IStatus status = null; - - JSFLibraryInternalReference ref = null; - if (getProperty(IMPLEMENTATION_TYPE_PROPERTY_NAME) == IMPLEMENTATION_TYPE.CLIENT_SUPPLIED) { - ref = ((JSFLibraryInternalReference)getProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION)); - if (ref != null){ - status = checkForDupeArchiveFiles(jars, ((JSFLibraryInternalReference)getProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION)).getLibrary()); - if (!OK_STATUS.equals(status)){ - return status; - } - } else { - return createErrorStatus(Messages.JSFFacetInstallDataModelProvider_ClientImplValidationMsg); - } - } - - JSFLibraryInternalReference[] compLibs = (JSFLibraryInternalReference[]) getProperty(IJSFFacetInstallDataModelProperties.COMPONENT_LIBRARIES); - if (compLibs != null){ - for (int i=0;i<compLibs.length;i++){ - JSFLibrary lib = compLibs[i].getLibrary(); - status = checkForDupeArchiveFiles(jars, lib); - if (!OK_STATUS.equals(status)){ - return status; - } - } - } - return OK_STATUS; - } - - private IJavaProject getJavaProject() { - IProject proj = getProject(); - if (proj != null) - return JavaCore.create(proj); - return null; - } - - private IProject getProject(){ - String projName = (String)getProperty(FACET_PROJECT_NAME); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName); - return project; - } - - private boolean doesProjectExist() { - IProject project = getProject(); - return (project != null) && project.exists(); - } - - private IStatus checkForDupeArchiveFiles(Set jars, - JSFLibrary aJSFLib) { - if (aJSFLib == null) - return OK_STATUS; - - for (Iterator it=aJSFLib.getArchiveFiles().iterator();it.hasNext();){ - ArchiveFile jar = (ArchiveFile)it.next(); - if (jars.contains(jar.getResolvedSourceLocation())){ - return createErrorStatus(NLS.bind(Messages.JSFFacetInstallDataModelProvider_DupeJarValidation,jar.getResolvedSourceLocation())); - } - jars.add(jar.getResolvedSourceLocation()); - } - return OK_STATUS; - } - - private IPath getProjectPath() { - String projName = (String)getProperty(FACET_PROJECT_NAME); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName); - if (project.exists()){ - return project.getLocation(); - } - - IDataModel projModel = (IDataModel)getProperty(MASTER_PROJECT_DM); - if (projModel.getBooleanProperty(IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION)){ - return new Path(projModel.getStringProperty(IProjectCreationPropertiesNew.PROJECT_LOCATION)).append(projName); - } - - return new Path(projModel.getStringProperty(IProjectCreationPropertiesNew.USER_DEFINED_LOCATION)).append(projName); - } - - private IPath getWebContentFolder() { - //One can get here 2 ways: - //if web app exists and user is adding a facet, or - // if creating a new web app. - - IPath webContentPath = null; - String projName = model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME); - IProject proj = ResourcesPlugin.getWorkspace().getRoot() - .getProject(projName); - - String webFolder = getWebContentFolderName(); - if (proj.exists()) { - - webContentPath = ComponentCore.createComponent(proj).getRootFolder() - .getUnderlyingFolder().getRawLocation(); - } - else { - - if (webFolder == null){ - //we got problems... should not happen - return proj.getFullPath(); - } - webContentPath = proj.getFullPath().append(webFolder); - - } - return webContentPath; - } - - private String getWebContentFolderName() { - String projName = (String)getProperty(FACET_PROJECT_NAME); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName); - if (project.exists()){ - IPath webContentPath = ComponentCore.createComponent(project).getRootFolder() - .getUnderlyingFolder().getProjectRelativePath(); - - return webContentPath.toString(); - } - - IDataModel projModel = (IDataModel)getProperty(MASTER_PROJECT_DM); - FacetDataModelMap dmMap = (FacetDataModelMap)projModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - IDataModel webFacet = dmMap.getFacetDataModel("jst.web"); //$NON-NLS-1$ - return webFacet.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER ); - } - -// private String getStringPropertyValueRecursively(final IDataModel amodel, final String propName){ -// if (hasProperty(amodel, propName)) -// return amodel.getStringProperty(propName); -// for (Iterator it=amodel.getNestedModels().iterator();it.hasNext();){ -// IDataModel nestedModel = (IDataModel)it.next(); -// String propvalue = getStringPropertyValueRecursively(nestedModel, propName); -// if(propvalue != null) -// return propvalue; -// } -// return null; -// } -// private boolean hasProperty(IDataModel model, String propertyName) { -// for (Iterator it= model.getAllProperties().iterator();it.hasNext();){ -// String prop = (String)it.next(); -//// System.out.println(prop); -// if (propertyName.equals(prop)) -// return true; -// } -// return false; -// } - - private List getDefaultJSFImplementationLibraries() { - List list = new ArrayList(); - if (JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry() != null) { - JSFLibrary jsfLib = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getDefaultImplementation(); - if (jsfLib != null){ - JSFLibraryInternalReference prjJSFLib = new JSFLibraryInternalReference(jsfLib, true, true); - list.add(prjJSFLib); - } - } - return list; - } - - private JSFLibraryInternalReference getDefaultImplementationLibrary() { - if (JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry() != null) { - JSFLibrary jsfLib = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getDefaultImplementation(); - return new JSFLibraryInternalReference(jsfLib, true, true); - } - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJ2EEFacetInstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJ2EEFacetInstallDelegate.java deleted file mode 100644 index a24f56156..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJ2EEFacetInstallDelegate.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * JSF v1.1 Facet Install Delegate for WTP faceted web projects. - * - * Uses <code>com.eclispe.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider<code> for model - * <li> creates JSF configuration file if not present - * <li> updates web.xml for: servlet, servlet-mapping and context-param - * <li> adds implementation jars to WEB-INF/lib if user requests - * - * @see org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider - * @author Gerry Kessler - Oracle - * @since M1 - */ -public class JSFJ2EEFacetInstallDelegate extends AbstractJSFFacetInstallDelegate { - - - protected void createConfigFile(final IProject project, - final IProjectFacetVersion fv, final IDataModel config, - IProgressMonitor monitor) { - - - final IPath configPath = resolveConfigPath(project, config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)); - try { - // do not overwrite if the file exists - if (!configPath.toFile().exists()) { - IWorkspaceRunnable op = new IWorkspaceRunnable(){ - - public void run(IProgressMonitor monitor_inner) - throws CoreException{ - JSFUtils11.createConfigFile(fv.getVersionString(), - configPath); - project.refreshLocal(IResource.DEPTH_INFINITE, monitor_inner); - } - - }; - op.run(monitor); - } - } catch (CoreException e) { - JSFCorePlugin.log(e, "Exception occured while creating faces-config.xml"); //$NON-NLS-1$ - } - - } - - protected void createServletAndModifyWebXML(IProject project, - final IDataModel config, IProgressMonitor monitor) { - -// IModelProvider provider = ModelProviderManager.getModelProvider(project); -// Object webAppObj = provider.getModelObject(); -// if (webAppObj == null){ -// JSFCorePlugin.log(IStatus.ERROR, project.getName()+": unable to configure web module for JavaServer Faces"); -// return; -// } -// -// if (webAppObj instanceof WebApp) { -// WebApp webApp = (WebApp)webAppObj; - WebArtifactEdit webEdit = null; - try { - webEdit = WebArtifactEdit.getWebArtifactEditForWrite(project); - WebApp webApp = webEdit.getWebApp(); - // create or update servlet ref - Servlet servlet = JSFUtils11.findJSFServlet(webApp);// check to see - // if already - // present - if (servlet != null) { - // remove old mappings - JSFUtils11.removeURLMappings(webApp, servlet); - } - - servlet = JSFUtils11 - .createOrUpdateServletRef(webApp, config, servlet); - - // init mappings - List listOfMappings = getServletMappings(config); - JSFUtils11.setUpURLMappings(webApp, listOfMappings, servlet); - - // setup context params - setupContextParams(webApp, config); - } finally { - if (webEdit != null) { - webEdit.saveIfNecessary(monitor); - webEdit.dispose(); - } - } - - - } - - private void setupContextParams(WebApp webApp, IDataModel config) { - if (webApp.getVersionID() == J2EEVersionConstants.WEB_2_3_ID)//shouldn't have to do it this way, but that's the way it goes 119442 - JSFUtils11.setupConfigFileContextParamForV2_3(webApp, config); - else - JSFUtils11.setupConfigFileContextParamForV2_4(webApp, config); - } -} - - diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJ2EEFacetUninstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJ2EEFacetUninstallDelegate.java deleted file mode 100644 index c72292098..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJ2EEFacetUninstallDelegate.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.common.ParamValue; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.webapplication.ContextParam; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; - -/** - * JSF v1.1 Facet Uninstall Delegate for WTP faceted projects. - * - * <li> removes JSF servlet, servlet-mappings and context-params - * <li> leaves JSF configuration files on disk - * <li> removes JSF classpath containers - * - * @author Gerry Kessler - Oracle - */ -public class JSFJ2EEFacetUninstallDelegate extends AbstractJSFFacetUninstallDelegate { - - - protected void uninstallJSFReferencesFromWebApp(IProject project, - IProgressMonitor monitor) { - WebArtifactEdit artifactEdit = JSFUtils11 - .getWebArtifactEditForWrite(project); - WebApp webApp = artifactEdit.getWebApp(); - - try { - Servlet servlet = JSFUtils11.findJSFServlet(webApp); - if (servlet == null) - return; - - // remove faces url mappings - removeJSFURLMappings(webApp, servlet); - // remove context params - removeJSFContextParams(webApp, servlet); - // remove servlet - removeJSFServlet(webApp, servlet); - - } finally { - if (artifactEdit != null) { - artifactEdit.saveIfNecessary(monitor); - artifactEdit.dispose(); - } - } - - } - - private void removeJSFURLMappings(WebApp webApp, Servlet servlet) { - while (webApp.getServletMapping(servlet) != null) { - webApp.getServletMappings().remove( - webApp.getServletMapping(servlet)); - } - } - - private void removeJSFContextParams(WebApp webApp, Servlet servlet) { - if (webApp.getVersionID() == J2EEVersionConstants.WEB_2_3_ID){ - Iterator it = webApp.getContexts().iterator(); - while (it.hasNext()) { - ContextParam cp = (ContextParam) it.next(); - if (cp.getParamName().equals(JSFUtils.JSF_CONFIG_CONTEXT_PARAM)) { - webApp.getContexts().remove(cp); - break; - } - } - } - else {//could check for 2_4 version here. - //hoping that the API gets fixed so I don't need to do any of this version checking - Iterator it = webApp.getContextParams().iterator(); - while (it.hasNext()) { - ParamValue cp = (ParamValue) it.next(); - if (cp.getName().equals(JSFUtils.JSF_CONFIG_CONTEXT_PARAM)) { - webApp.getContextParams().remove(cp); - break; - } - } - } - } - - private void removeJSFServlet(WebApp webApp, Servlet servlet) { - webApp.getServlets().remove(servlet); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJavaEEFacetInstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJavaEEFacetInstallDelegate.java deleted file mode 100644 index 695cdcf78..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJavaEEFacetInstallDelegate.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * JSF v1.2 Facet Install Delegate for WTP faceted web projects. - * - * Uses <code>com.eclispe.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider<code> for model - * <li> creates JSF configuration file if not present - * <li> updates web.xml for: servlet, servlet-mapping and context-param - * <li> adds implementation jars to WEB-INF/lib if user requests - * - * @see org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider - * @author Gerry Kessler - Oracle - * @since 1.0 - */ -public class JSFJavaEEFacetInstallDelegate extends AbstractJSFFacetInstallDelegate { - - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.project.facet.AbstractJSFFacetInstallDelegate#createConfigFile(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, org.eclipse.wst.common.frameworks.datamodel.IDataModel, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void createConfigFile(final IProject project, - final IProjectFacetVersion fv, final IDataModel config, - IProgressMonitor monitor) { - - - final IPath configPath = resolveConfigPath(project, config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)); - try { - // do not overwrite if the file exists - if (!configPath.toFile().exists()) { - IWorkspaceRunnable op = new IWorkspaceRunnable(){ - - public void run(IProgressMonitor monitor_inner) - throws CoreException{ - JSFUtils12.createConfigFile(fv.getVersionString(), - configPath); - project.refreshLocal(IResource.DEPTH_INFINITE, monitor_inner); - } - - }; - op.run(monitor); - } - } catch (CoreException e) { - JSFCorePlugin.log(e, "Exception occured while creating faces-config.xml");//$NON-NLS-1$ - } - - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.project.facet.AbstractJSFFacetInstallDelegate#createServletAndModifyWebXML(org.eclipse.core.resources.IProject, org.eclipse.wst.common.frameworks.datamodel.IDataModel, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void createServletAndModifyWebXML(IProject project, - final IDataModel config, IProgressMonitor monitor) { - - IModelProvider provider = ModelProviderManager.getModelProvider(project); - Object webAppObj = provider.getModelObject(); - if (webAppObj == null){ - JSFCorePlugin.log(IStatus.ERROR, project.getName()+": unable to configure web module for JavaServer Faces"); //$NON-NLS-1$ - return; - } - - if (JSFUtils12.isWebApp25(webAppObj)) { - final WebApp webApp = (WebApp)webAppObj; - provider.modify(new UpdateWebXMLFor25(webApp, config), new Path("WEB-INF").append("web.xml")); //$NON-NLS-1$ //$NON-NLS-2$ - } - else { - // - } - - } - - private class UpdateWebXMLFor25 implements Runnable { - private WebApp webApp; - private IDataModel config; - - UpdateWebXMLFor25(WebApp webApp, IDataModel config){ - this.webApp = webApp; - this.config = config; - } - - public void run() { - - // create or update servlet ref - Servlet servlet = JSFUtils12.findJSFServlet(webApp);// check to see - // if already - // present - if (servlet != null) { - // remove old mappings - JSFUtils12.removeURLMappings(webApp, servlet); - } - - servlet = JSFUtils12 - .createOrUpdateServletRef(webApp, config, servlet); - - // init mappings - List listOfMappings = getServletMappings(config); - JSFUtils12.setUpURLMappings(webApp, listOfMappings, servlet); - - // setup context params - JSFUtils12.setupConfigFileContextParamForV2_5(webApp, config); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJavaEEFacetUninstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJavaEEFacetUninstallDelegate.java deleted file mode 100644 index d8f675d95..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFJavaEEFacetUninstallDelegate.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.core.ParamValue; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.WebApp; - -/** - * JSF v1.2 Facet Uninstall Delegate for WTP faceted projects. - * - * <li> removes JSF servlet, servlet-mappings and context-params - * - */ -public class JSFJavaEEFacetUninstallDelegate extends AbstractJSFFacetUninstallDelegate { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.project.facet.AbstractJSFFacetUninstallDelegate#uninstallJSFReferencesFromWebApp(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void uninstallJSFReferencesFromWebApp(IProject project, - IProgressMonitor monitor) { - - IModelProvider provider = ModelProviderManager.getModelProvider(project); - Object webAppObj = provider.getModelObject(); - if (webAppObj != null && JSFUtils12.isWebApp25(webAppObj)){ - WebApp webApp = (WebApp)webAppObj; - Servlet servlet = JSFUtils12.findJSFServlet(webApp); - if (servlet == null) - return; - - provider.modify(new RemoveJSFFromWebAppOperation(webApp, servlet), new Path("WEB-INF").append("web.xml")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - } - - private void removeJSFContextParams(WebApp webApp, Servlet servlet) { - Iterator it = webApp.getContextParams().iterator(); - while (it.hasNext()) { - ParamValue cp = (ParamValue) it.next(); - if (cp.getParamName().equals(JSFUtils.JSF_CONFIG_CONTEXT_PARAM)) { - webApp.getContextParams().remove(cp); - break; - } - } - } - - private void removeJSFServlet(WebApp webApp, Servlet servlet) { - webApp.getServlets().remove(servlet); - } - - class RemoveJSFFromWebAppOperation implements Runnable { - private WebApp webApp; - private Servlet servlet; - - RemoveJSFFromWebAppOperation(WebApp webApp, Servlet servlet){ - this.webApp = webApp; - this.servlet = servlet; - } - - public void run() { - // remove faces url mappings - JSFUtils12.removeURLMappings(webApp, servlet); - // remove context params - removeJSFContextParams(webApp, servlet); - // remove servlet - removeJSFServlet(webApp, servlet); - - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java deleted file mode 100644 index 9d8df2b04..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * - */ -public class JSFUtils { - /** - * The default name for the Faces servlet - */ - public static final String JSF_DEFAULT_SERVLET_NAME = "Faces Servlet"; //$NON-NLS-1$ - /** - * The default name of the Faces servlet class - */ - public static final String JSF_SERVLET_CLASS = "javax.faces.webapp.FacesServlet"; //$NON-NLS-1$ - /** - * The name of the context parameter used for JSF configuration files - */ - public static final String JSF_CONFIG_CONTEXT_PARAM = "javax.faces.CONFIG_FILES"; //$NON-NLS-1$ - - /** - * The name of the context parameter used for defining the default JSP file extension - */ - public static final String JSF_DEFAULT_SUFFIX_CONTEXT_PARAM = "javax.faces.DEFAULT_SUFFIX"; //$NON-NLS-1$ - - /** - * The path to the default application configuration file - */ - public static final String JSF_DEFAULT_CONFIG_PATH = "/WEB-INF/faces-config.xml"; //$NON-NLS-1$ - - /** - * Default URL mapping to faces servlet - */ - public static final String JSF_DEFAULT_URL_MAPPING = "/faces/*"; //$NON-NLS-1$ - - /** - * the key for implementation libraries in persistent properties - * TODO: should encapsulate the property somewhere and hide the constant - */ - public static final String PP_JSF_IMPLEMENTATION_LIBRARIES = "jsf.implementation.libraries"; //$NON-NLS-1$ - /** - * the key for component libraries in persistent properties - * TODO: should encapsulate the property somewhere and hide the constant - */ - public static final String PP_JSF_COMPONENT_LIBRARIES = "jsf.component.libraries"; //$NON-NLS-1$ - /** - * the key for implementation type in persistent properties - * TODO: should encapsulate the property somewhere and hide the constant - */ - public static final String PP_JSF_IMPLEMENTATION_TYPE = "jsf.implementation.type"; //$NON-NLS-1$ - /** - * Construct an array that hold paths for all JARs in a JSF library. - * However, archive files that no longer exist are filtered out. - * - * @param jsfLib - * @param logMissingJar true to log an error for each invalid JAR. - * @return elements - */ - public static IPath[] getJARPathforJSFLibwFilterMissingJars(JSFLibrary jsfLib, boolean logMissingJar) { - EList archiveFiles = jsfLib.getArchiveFiles(); - int numJars = numberofValidJar(archiveFiles); - IPath[] elements = new IPath[numJars]; - ArchiveFile ar = null; - int idxValidJar = 0; - for (int i= 0; i < archiveFiles.size(); i++) { - ar = (ArchiveFile)archiveFiles.get(i); - if ( !ar.exists() ) { - if (logMissingJar) { - logErroronMissingJAR(jsfLib, ar); - } - } else { - elements[idxValidJar] = new Path(((ArchiveFile)archiveFiles.get(i)).getResolvedSourceLocation()).makeAbsolute(); - idxValidJar++; - } - } - return elements; - } - - /** - * Construct an array that hold paths for all JARs in a JSF library. - * - * @param jsfLib - * @param logMissingJar true to log an error for each invalid JAR. - * @return elements - */ - public static IPath[] getJARPathforJSFLib(JSFLibrary jsfLib, boolean logMissingJar) { - EList archiveFiles = jsfLib.getArchiveFiles(); - int numJars = archiveFiles.size(); - IPath[] elements = new IPath[numJars]; - ArchiveFile ar = null; - for (int i= 0; i < numJars; i++) { - ar = (ArchiveFile)archiveFiles.get(i); - if ( !ar.exists() && logMissingJar ) { - logErroronMissingJAR(jsfLib, ar); - } - elements[i] = new Path(((ArchiveFile)archiveFiles.get(i)).getResolvedSourceLocation()).makeAbsolute(); - } - return elements; - } - - private static int numberofValidJar(EList archiveFiles) { - int total = 0; - final Iterator it = archiveFiles.iterator(); - ArchiveFile ar = null; - while(it.hasNext()) { - ar = (ArchiveFile) it.next(); - if (ar.exists()) { - total++; - } - } - return total; - } - - private static void logErroronMissingJAR(JSFLibrary jsfLib, ArchiveFile ar) { - String msg = NLS.bind(Messages.JSFUtils_MissingJAR, - ar.getName(), - jsfLib.getLabel()); - JSFCorePlugin.log(IStatus.ERROR, msg); - } - - - /** - * @param config - * @return servlet display name to use from wizard data model - */ - protected static String getDisplayName(IDataModel config) { - String displayName = config.getStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME); - if (displayName.equals("")) //$NON-NLS-1$ - displayName = JSF_DEFAULT_SERVLET_NAME; - return displayName; - } - - /** - * @param config - * @return servlet display name to use from wizard data model - */ - protected static String getServletClassname(IDataModel config) { - String className = config.getStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_CLASSNAME); - if (className.equals("")) //$NON-NLS-1$ - className = JSF_SERVLET_CLASS; - return className; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils11.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils11.java deleted file mode 100644 index 4e432f589..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils11.java +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.common.CommonFactory; -import org.eclipse.jst.j2ee.common.ParamValue; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.webapplication.ContextParam; -import org.eclipse.jst.j2ee.webapplication.JSPType; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.ServletMapping; -import org.eclipse.jst.j2ee.webapplication.ServletType; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * Utility file for JSF model v1.1 - * - * @author Gerry Kessler - Oracle - */ -public class JSFUtils11 extends JSFUtils { - - /** - * Convenience method for getting writeable WebApp model - * @param project - * @return WebArtifactEdit - */ - public static WebArtifactEdit getWebArtifactEditForWrite(IProject project) { - return WebArtifactEdit.getWebArtifactEditForWrite(project); - } - - /** - * Convenience method for getting read-only WebApp model - * @param project - * @return WebArtifactEdit - */ - public static WebArtifactEdit getWebArtifactEditForRead(IProject project) { - return WebArtifactEdit.getWebArtifactEditForRead(project); - } - - /** - * @param webApp as Object - * @return Servlet - the JSF Servlet for the specified WebApp or null if not present - */ - public static Servlet findJSFServlet(Object webApp) { - Iterator it = null; - if (webApp == null) - return null; - else if (webApp instanceof WebApp) - it = ((WebApp)webApp).getServlets().iterator(); - else if (webApp instanceof org.eclipse.jst.javaee.web.WebApp) - it = ((org.eclipse.jst.javaee.web.WebApp)webApp).getServlets().iterator(); - else - return null; - - while (it.hasNext()) { - Servlet servlet = (Servlet) it.next(); - if (servlet.getWebType().isServletType()) { - if (((ServletType) servlet.getWebType()).getClassName().equals( - JSF_SERVLET_CLASS)) { - return servlet; - } - } else if (servlet.getWebType().isJspType()) { - if (((JSPType) servlet.getWebType()).getJspFile().equals( - JSF_SERVLET_CLASS)) { - return servlet; - } - } - } - - // if we get to here then we have finished the loop - // without finding the servlet we're looking for - return null; - } - - /** - * Creates a stubbed JSF configuration file for specified JSF version and path - * @param jsfVersion - * @param configPath - */ - public static void createConfigFile(String jsfVersion, IPath configPath) { - FileOutputStream os = null; - PrintWriter pw = null; - final String QUOTE = new String(new char[] { '"' }); - try { - IPath dirPath = configPath.removeLastSegments(1); - dirPath.toFile().mkdirs(); - File file = configPath.toFile(); - file.createNewFile(); - os = new FileOutputStream(file); - pw = new PrintWriter(os); - pw.write("<?xml version=" + QUOTE + "1.0" + QUOTE + " encoding=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + QUOTE + "UTF-8" + QUOTE + "?>\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ - - if (jsfVersion.equals(IJSFCoreConstants.FACET_VERSION_1_1)) - { - pw.write("<!DOCTYPE faces-config PUBLIC\n"); //$NON-NLS-1$ - pw - .write(" " //$NON-NLS-1$ - + QUOTE - + "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" //$NON-NLS-1$ - + QUOTE + "\n"); //$NON-NLS-1$ - pw.write(" " + QUOTE //$NON-NLS-1$ - + "http://java.sun.com/dtd/web-facesconfig_1_1.dtd" //$NON-NLS-1$ - + QUOTE + ">\n\n"); //$NON-NLS-1$ - - pw.write("<faces-config>\n\n"); //$NON-NLS-1$ - pw.write("</faces-config>\n"); //$NON-NLS-1$ - } - - pw.close(); - pw = null; - } catch (FileNotFoundException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorCreatingConfigFile, e); - } catch (IOException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorCreatingConfigFile, e); - } finally { - if (pw != null) - pw.close(); - if (os != null) { - try { - os.close(); - } catch (IOException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorClosingConfigFile, e); - } - } - } - } - - /** - * Creates servlet reference in WebApp if not present or updates servlet name if found - * using the passed configuration. - * - * @param webApp - * @param config - * @param servlet - * @return Servlet servlet - if passed servlet was null, will return created servlet - */ - public static Servlet createOrUpdateServletRef(WebApp webApp, - IDataModel config, Servlet servlet) { - - String displayName = getDisplayName(config); - String className = getServletClassname(config); - - if (servlet == null){ - // Create the servlet instance and set up the parameters from data - // model - servlet = WebapplicationFactory.eINSTANCE.createServlet(); - servlet.setServletName(displayName); - - ServletType servletType = WebapplicationFactory.eINSTANCE - .createServletType(); - servletType.setClassName(className); - servlet.setWebType(servletType); - servlet.setLoadOnStartup(new Integer(1)); - // Add the servlet to the web application model - webApp.getServlets().add(servlet); - } else { - // update - servlet.setServletName(displayName); - servlet.setLoadOnStartup(new Integer(1)); - } - return servlet; - } - - /** - * @param webApp as Object - * @return true if webApp instanceof org.eclipse.jst.javaee.web.WebApp - */ - public static boolean isWebApp25(Object webApp) { - if (webApp instanceof org.eclipse.jst.javaee.web.WebApp) - return true; - return false; - } - - /** - * Creates servlet-mappings for the servlet - * - * @param webApp - * @param urlMappingList - list of string values to be used in url-pattern for servlet-mapping - * @param servlet - */ - public static void setUpURLMappings(WebApp webApp, List urlMappingList, - Servlet servlet) { - // Add mappings - Iterator it = urlMappingList.iterator(); - while (it.hasNext()) { - String pattern = (String) it.next(); - ServletMapping mapping = WebapplicationFactory.eINSTANCE - .createServletMapping(); - mapping.setServlet(servlet); - mapping.setName(servlet.getServletName()); - mapping.setUrlPattern(pattern); - webApp.getServletMappings().add(mapping); - } - } - - - /** - * Removes servlet-mappings for servlet using servlet-name. - * @param webApp - * @param servlet - */ - public static void removeURLMappings(WebApp webApp, Servlet servlet) { - List mappings = webApp.getServletMappings(); - String servletName = servlet.getServletName(); - if (servletName != null) { - for (int i=mappings.size()-1;i>=0;--i){ - ServletMapping mapping = (ServletMapping)mappings.get(i); - if (mapping.getServlet().getServletName() - .equals(servletName)) { - mappings.remove(mapping); - } - } - } - } - - /** - * Creates or updates config file context-param in v 2.3 WebApp if non default configuration file is specified. - * @param webApp - * @param config - */ - public static void setupConfigFileContextParamForV2_3(WebApp webApp, - IDataModel config) { - // if not default name and location, then add context param - ContextParam cp = null; - ContextParam foundCP = null; - boolean found = false; - if (!config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH).equals(JSF_DEFAULT_CONFIG_PATH)) { - // check to see if present - Iterator it = webApp.getContexts().iterator(); - while (it.hasNext()) { - cp = (ContextParam) it.next(); - if (cp.getParamName().equals(JSF_CONFIG_CONTEXT_PARAM)) { - foundCP = cp; - found = true; - } - } - if (!found) { - cp = WebapplicationFactory.eINSTANCE.createContextParam(); - cp.setParamName(JSF_CONFIG_CONTEXT_PARAM); - cp.setParamValue(config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)); - webApp.getContexts().add(cp); - } else { - cp = foundCP; - if (cp.getParamValue().indexOf(config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)) < 0) { - String curVal = cp.getParamValue(); - String val = config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH); - if (curVal != null || !curVal.trim().equals("")) { //$NON-NLS-1$ - val = curVal + ",\n" + val; //$NON-NLS-1$ - } - cp.setParamValue(val); - } - } - } - } - /** - * Creates or updates config file context-param in v2.4 WebApp if non default configuration file is specified. - * @param webApp - * @param config - */ - public static void setupConfigFileContextParamForV2_4(WebApp webApp, - IDataModel config) { - // if not default name and location, then add context param - ParamValue foundCP = null; - ParamValue cp = null; - boolean found = false; - if (!config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH).equals(JSF_DEFAULT_CONFIG_PATH)) { - // check to see if present - Iterator it = webApp.getContextParams().iterator(); - while (it.hasNext()) { - cp = (ParamValue) it.next(); - if (cp.getName().equals(JSF_CONFIG_CONTEXT_PARAM)) { - foundCP = cp; - found = true; - } - } - if (!found) { - ParamValue pv = CommonFactory.eINSTANCE.createParamValue(); - pv.setName(JSF_CONFIG_CONTEXT_PARAM); - pv.setValue(config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)); - webApp.getContextParams().add(pv); - } else { - cp = foundCP; - if (cp.getValue().indexOf(config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)) < 0) { - String curVal = cp.getValue(); - String val = config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH); - if (curVal != null || !curVal.trim().equals("")) { //$NON-NLS-1$ - val = curVal + ",\n" + val; //$NON-NLS-1$ - } - cp.setValue(val); - } - } - } - } - - /** - * @param webAppObj as Object - * @return true if webApp instanceof org.eclipse.jst.j2ee.web.WebApp and versionID == 24 - */ - public static boolean isWebApp24(Object webAppObj) { - if (webAppObj instanceof WebApp && - ((WebApp)webAppObj).getVersionID() == 24) - return true; - return false; - } - - /** - * @param webAppObj as Object - * @return true if webApp instanceof org.eclipse.jst.j2ee.web.WebApp and versionID == 23 - */ - public static boolean isWebApp23(Object webAppObj) { - if (webAppObj instanceof WebApp && - ((WebApp)webAppObj).getVersionID() == 23) - return true; - return false; - } - - /** - * @param webApp - * @return the default file extension from the context param. Default is "jsp" if no context param. - */ - public static String getDefaultSuffix(WebApp webApp) { - String defaultSuffix = "jsp"; //$NON-NLS-1$ - for (Iterator it = webApp.getContexts().iterator();it.hasNext();) { - ContextParam cp = (ContextParam) it.next(); - if (cp.getParamName().equals(JSF_DEFAULT_SUFFIX_CONTEXT_PARAM)){ - String defSuffix = cp.getParamValue(); - if (defSuffix.startsWith(".")) //$NON-NLS-1$ - defSuffix = defSuffix.substring(1); - - return defSuffix; - } - } - return defaultSuffix; - } - - /** - * @param map - * @return prefix mapping. may return null. - */ - public static String getPrefixMapping(ServletMapping map) { - IPath extPath = new Path(map.getUrlPattern()); - if (extPath != null){ - String ext = extPath.getFileExtension(); - if (ext == null){ - String lastSeg = extPath.lastSegment(); - if (lastSeg.equals("*")) //$NON-NLS-1$ - { - return extPath.removeLastSegments(1).toString(); - } - - return extPath.toString(); - } - } - return null; - } - - /** - * @param map - * @return extension from map. Will return null if file extension not found in url patterns. - */ - public static String getFileExtensionFromMap(ServletMapping map) { - IPath extPath = new Path(map.getUrlPattern()); - if (extPath != null){ - String ext = extPath.getFileExtension(); - if (ext != null && !ext.equals("")) //$NON-NLS-1$ - return ext; - } - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils12.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils12.java deleted file mode 100644 index 5915622d0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils12.java +++ /dev/null @@ -1,309 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.core.internal.project.facet; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.javaee.core.JavaeeFactory; -import org.eclipse.jst.javaee.core.ParamValue; -import org.eclipse.jst.javaee.core.UrlPatternType; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.ServletMapping; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.javaee.web.WebAppVersionType; -import org.eclipse.jst.javaee.web.WebFactory; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * Utility file for JSF v1.2 model - * - * @author Gerry Kessler - Oracle - */ -public class JSFUtils12 extends JSFUtils{ - - /** - * @param webApp - * @return Servlet - the JSF Servlet for the specified WebApp or null if not present - */ - public static Servlet findJSFServlet(WebApp webApp) { - - Iterator it = webApp.getServlets().iterator(); - - while (it.hasNext()) { - Servlet servlet = (Servlet) it.next(); - if (servlet.getServletClass().equals (JSF_SERVLET_CLASS)) { - return servlet; - } - } - - // if we get to here then we have finished the loop - // without finding the servlet we're looking for - return null; - } - - /** - * Creates a stubbed JSF v1.2 configuration file for specified JSF version and path - * @param jsfVersion - * @param configPath - */ - public static void createConfigFile(String jsfVersion, IPath configPath) { - FileOutputStream os = null; - PrintWriter pw = null; - final String QUOTE = new String(new char[] { '"' }); - try { - IPath dirPath = configPath.removeLastSegments(1); - dirPath.toFile().mkdirs(); - File file = configPath.toFile(); - file.createNewFile(); - os = new FileOutputStream(file); - pw = new PrintWriter(os); - pw.write("<?xml version=" + QUOTE + "1.0" + QUOTE + " encoding=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + QUOTE + "UTF-8" + QUOTE + "?>\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ - - if (jsfVersion.equals(IJSFCoreConstants.FACET_VERSION_1_2)) - { - pw.write("<faces-config\n"); //$NON-NLS-1$ - pw.write(" " + "xmlns=" + QUOTE //$NON-NLS-1$ //$NON-NLS-2$ - + "http://java.sun.com/xml/ns/javaee" + QUOTE + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - pw.write(" " + "xmlns:xsi=" + QUOTE //$NON-NLS-1$ //$NON-NLS-2$ - + "http://www.w3.org/2001/XMLSchema-instance" + QUOTE //$NON-NLS-1$ - + "\n"); //$NON-NLS-1$ - pw - .write(" " //$NON-NLS-1$ - + "xsi:schemaLocation=" //$NON-NLS-1$ - + QUOTE - + "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd" //$NON-NLS-1$ - + QUOTE + "\n"); //$NON-NLS-1$ - pw.write(" " + "version=" + QUOTE + "1.2" + QUOTE + ">\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - pw.write("</faces-config>\n"); //$NON-NLS-1$ - } - - pw.close(); - pw = null; - } catch (FileNotFoundException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorCreatingConfigFile, e); - } catch (IOException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorCreatingConfigFile, e); - } finally { - if (pw != null) - pw.close(); - if (os != null) { - try { - os.close(); - } catch (IOException e) { - JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorClosingConfigFile, e); - } - } - } - } - - - /** - * Creates servlet reference in WebApp if not present or updates servlet name if found - * using the passed configuration. - * - * @param webApp - * @param config - * @param servlet - * @return Servlet servlet - if passed servlet was null, will return created servlet - */ - public static Servlet createOrUpdateServletRef(WebApp webApp, - IDataModel config, org.eclipse.jst.javaee.web.Servlet servlet) { - - String displayName = getDisplayName(config); - String className = getServletClassname(config); - - if (servlet == null){ - // Create the servlet instance and set up the parameters from data - // model - servlet = WebFactory.eINSTANCE.createServlet(); - servlet.setServletName(displayName); - servlet.setServletClass(className); - servlet.setLoadOnStartup(new Integer(1)); - // Add the servlet to the web application model - webApp.getServlets().add(servlet); - - } else { - // update - servlet.setServletName(displayName); - servlet.setLoadOnStartup(new Integer(1)); - } - return servlet; - } - - /** - * @param webAppObj as Object - * @return true if webApp instanceof org.eclipse.jst.javaee.web.WebApp and WebAppVersionType._25 - */ - public static boolean isWebApp25(Object webAppObj) { - if (webAppObj instanceof WebApp && - ((WebApp)webAppObj).getVersion() == WebAppVersionType._25_LITERAL) - return true; - return false; - } - - /** - * Creates servlet-mappings for the servlet for 2.5 WebModules or greated - * - * @param webApp - * @param urlMappingList - list of string values to be used in url-pattern for servlet-mapping - * @param servlet - */ - public static void setUpURLMappings(WebApp webApp, List urlMappingList, - Servlet servlet) { - - if (urlMappingList.size() > 0) { - ServletMapping mapping = WebFactory.eINSTANCE.createServletMapping(); - mapping.setServletName(servlet.getServletName()); - webApp.getServletMappings().add(mapping); - // Add patterns - Iterator it = urlMappingList.iterator(); - while (it.hasNext()) { - String pattern = (String) it.next(); - UrlPatternType urlPattern = JavaeeFactory.eINSTANCE.createUrlPatternType(); - urlPattern.setValue(pattern); - mapping.getUrlPatterns().add(urlPattern); - } - } - } - - /** - * Removes servlet-mappings for servlet using servlet-name for >= 2.5 WebModules. - * @param webApp - * @param servlet - */ - public static void removeURLMappings(WebApp webApp, Servlet servlet) { - List mappings = webApp.getServletMappings(); - String servletName = servlet.getServletName(); - if (servletName != null) { - for (int i=mappings.size()-1;i>=0;--i){ - ServletMapping mapping = (ServletMapping)mappings.get(i); - if (mapping.getServletName() - .equals(servletName)) { - mappings.remove(mapping); - } - } - } - } - - /** - * Creates or updates config file context-param in v2.5 WebApp if non default configuration file is specified. - * @param webApp - * @param config - */ - public static void setupConfigFileContextParamForV2_5(org.eclipse.jst.javaee.web.WebApp webApp, - IDataModel config) { - // if not default name and location, then add context param - ParamValue foundCP = null; - ParamValue cp = null; - boolean found = false; - if (!config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH).equals(JSF_DEFAULT_CONFIG_PATH)) { - // check to see if present - Iterator it = webApp.getContextParams().iterator(); - while (it.hasNext()) { - cp = (org.eclipse.jst.javaee.core.ParamValue) it.next(); - if (cp.getParamName().equals(JSF_CONFIG_CONTEXT_PARAM)) { - foundCP = cp; - found = true; - } - } - if (!found) { - ParamValue pv = JavaeeFactory.eINSTANCE.createParamValue(); - pv.setParamName(JSF_CONFIG_CONTEXT_PARAM); - pv.setParamValue(config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)); - webApp.getContextParams().add(pv); - } else { - cp = foundCP; - if (cp.getParamValue().indexOf(config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH)) < 0) { - String curVal = cp.getParamValue(); - String val = config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH); - if (curVal != null || !curVal.trim().equals("")) { //$NON-NLS-1$ - val = curVal + ",\n" + val; //$NON-NLS-1$ - } - cp.setParamValue(val); - } - } - } - } - - /** - * @param webApp - * @return the default file extension from the context param. Default is "jsp" if no context param - */ - public static String getDefaultSuffix(WebApp webApp) { - String defaultSuffix = "jsp"; //$NON-NLS-1$ - for (Iterator it = webApp.getContextParams().iterator();it.hasNext();) { - ParamValue cp = (ParamValue) it.next(); - if (cp.getParamName().equals(JSF_DEFAULT_SUFFIX_CONTEXT_PARAM)){ - String defSuffix = cp.getParamValue(); - if (defSuffix.startsWith(".")) //$NON-NLS-1$ - defSuffix = defSuffix.substring(1); - - return defSuffix; - } - } - return defaultSuffix; - } - - /** - * @param map - * @return prefix mapping - */ - public static String getPrefixMapping(ServletMapping map) { - List urls = map.getUrlPatterns(); - for (Iterator it=urls.iterator();it.hasNext();){ - IPath extPath = new Path(((UrlPatternType)it.next()).getValue()); - if (extPath != null){ - String ext = extPath.getFileExtension(); - if (ext == null){ - String lastSeg = extPath.lastSegment(); - if (lastSeg.equals("*")) //$NON-NLS-1$ - { - return extPath.removeLastSegments(1).toString(); - } - - return extPath.toString(); - } - } - } - return null; - } - - /** - * @param map - * @return extension from map. Will return null if file extension not found in url patterns. - */ - public static String getFileExtensionFromMap(ServletMapping map) { - List urls = map.getUrlPatterns(); - for (Iterator it=urls.iterator();it.hasNext();){ - IPath extPath = new Path(((UrlPatternType)it.next()).getValue()); - if (extPath != null){ - String ext = extPath.getFileExtension(); - if (ext != null && !ext.equals("")) //$NON-NLS-1$ - return ext; - } - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java deleted file mode 100644 index 43e8bbbb7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.tld; - -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration; -import org.eclipse.wst.html.core.internal.contentmodel.HTMLElementDeclaration; -import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; -import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMNodeWrapper; -import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter; -import org.w3c.dom.Element; - -/** - * Utility class to content model related information. - * - * @author mengbo - */ -public final class CMUtil { - /** - * If the element is a custom tag, get the URI of it. If the element is a - * standard JSP tag, return null. If is not jsp tag, then return null - * @param decl - * - * @return the tag uri as a string - */ - public static String getTagURI(CMElementDeclaration decl) { - if (decl instanceof CMNodeWrapper) { - decl = (CMElementDeclaration) ((CMNodeWrapper) decl) - .getOriginNode(); - } - if (decl instanceof TLDElementDeclaration) { - CMDocument doc = ((TLDElementDeclaration) decl).getOwnerDocument(); - if (doc instanceof TLDDocument) { - return ((TLDDocument) doc).getUri(); - } - } - return null; - } - - /** - * Test whether this is the JSP core tag. - * - * @param decl - * @return true if decl is a jsp element declaration - */ - public static boolean isJSP(CMElementDeclaration decl) { - if (!decl.supports(HTMLCMProperties.IS_JSP)) { - return false; - } - Boolean b = (Boolean) decl.getProperty(HTMLCMProperties.IS_JSP); - return b.booleanValue(); - } - - /** - * @param decl - * @return true if the element declartion is a non-JSP html element - */ - public static boolean isHTML(CMElementDeclaration decl) { - if (!isJSP(decl) && (decl instanceof HTMLElementDeclaration)) { - return true; - } - return false; - } - - /** - * get element declaration of specified element - * - * @param element - * @return null if can't get it. - */ - public static CMElementDeclaration getElementDeclaration(Element element) { - if (element == null) { - return null; - } - INodeNotifier notifier = (INodeNotifier) element.getOwnerDocument(); - if (notifier == null) { - return null; - } - ModelQueryAdapter mqa = (ModelQueryAdapter) notifier - .getAdapterFor(ModelQueryAdapter.class); - if (mqa == null) { - return null; - } - return mqa.getModelQuery().getCMElementDeclaration(element); - } - - /** - * @param element - * @return the TLDElementDeclaration for element or null if not found - */ - public static TLDElementDeclaration getTLDElementDeclaration(Element element) { - CMNode decl = getElementDeclaration(element); - if (decl instanceof CMNodeWrapper) { - decl = ((CMNodeWrapper) decl).getOriginNode(); - } - if (decl instanceof TLDElementDeclaration) { - return (TLDElementDeclaration) decl; - } - return null; - } - - /** - * give an element, get its namespace URI. - * - * @param element - * @return the namespace URI - */ - public static String getElementNamespaceURI(Element element) { - CMElementDeclaration decl = getElementDeclaration(element); - if (decl == null) { - return null; - } - - if (isJSP(decl)) { - return ITLDConstants.URI_JSP; - } else if (isHTML(decl)) { - return ITLDConstants.URI_HTML; - } - - return getTagURI(decl); - } - - /** - * @param element - * @return true if the element can have children - */ - public static boolean canHaveDirectTextChild(Element element) { - CMElementDeclaration decl = getElementDeclaration(element); - if (decl == null) { - return true; - } - int contentType = decl.getContentType(); - return contentType != CMElementDeclaration.ELEMENT - && contentType != CMElementDeclaration.EMPTY; - - } - - private CMUtil() - { - // util class, no external instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/DocumentTagIdentifier.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/DocumentTagIdentifier.java deleted file mode 100644 index 1af913f00..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/DocumentTagIdentifier.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.tld; - -import org.eclipse.jst.jsf.common.dom.TagIdentifier; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.w3c.dom.Element; - -/** - * A tag wrapper for a DOM element. This element may or may not be a JSP tag, - * but must be contained in a DOM tree. - * - * @author cbateman - * - */ -/*package*/ class DocumentTagIdentifier extends TagIdentifier -{ - private final Element _element; - - /** - * @param element - */ - public DocumentTagIdentifier(Element element) - { - _element = element; - } - - public String getTagName() - { - return _element.getLocalName(); - } - - public String getUri() { - String uri = CMUtil.getElementNamespaceURI(_element); - - // give the content model priority - if (uri == null) - { - uri = _element.getNamespaceURI(); - } - - return uri; - } - - public boolean isJSPTag() { - CMElementDeclaration elemDecl = getElementDeclaration(); - - if (elemDecl != null) - { - return CMUtil.isJSP(elemDecl); - } - - return false; - } - - /** - * @return the element declaration for this tag - */ - protected final CMElementDeclaration getElementDeclaration() - { - return CMUtil.getElementDeclaration(_element); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/IJSFConstants.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/IJSFConstants.java deleted file mode 100644 index 7e49a037f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/IJSFConstants.java +++ /dev/null @@ -1,782 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.tld; - -import org.eclipse.jst.jsf.common.dom.TagIdentifier; - -/** - * Constants covering the JSF Core and JSF HTML tag and tag attribute names - */ -public interface IJSFConstants -{ - - /** - * actionListener tagname - */ - final static public String TAG_ACTIONLISTENER = "actionListener"; - - /** - * attribute tagname - */ - final static public String TAG_ATTRIBUTE = "attribute"; - - /** - * convertDateTime tagname - */ - final static public String TAG_CONVERTDATETIME = "convertDateTime"; - - /** - * converter tagname - */ - final static public String TAG_CONVERTER = "converter"; - - /** - * convertNumber tagname - */ - final static public String TAG_CONVERTNUMBER = "convertNumber"; - - /** - * facet tagname - */ - final static public String TAG_FACET = "facet"; - - /** - * loadBundle tagname - */ - final static public String TAG_LOADBUNDLE = "loadBundle"; - - /** - * param tagname - */ - final static public String TAG_PARAM = "param"; - - /** - * selectItem tagname - */ - final static public String TAG_SELECTITEM = "selectItem"; - - /** - * selectItems tagname - */ - final static public String TAG_SELECTITEMS = "selectItems"; - - /** - * subview tagname - */ - final static public String TAG_SUBVIEW = "subview"; - - /** - * validateDoubleRange tagname - */ - final static public String TAG_VALIDATEDOUBLERANGE = "validateDoubleRange"; - - /** - * validateLength tagname - */ - final static public String TAG_VALIDATELENGTH = "validateLength"; - - /** - * validateLongRange tagname - */ - final static public String TAG_VALIDATELONGRANGE = "validateLongRange"; - - /** - * validator tagname - */ - final static public String TAG_VALIDATOR = "validator"; - - /** - * valueChangeListener tagname - */ - final static public String TAG_VALUECHANGELISTENER = "valueChangeListener"; - - /** - * verbatim tagname - */ - final static public String TAG_VERBATIM = "verbatim"; - - /** - * view tagname - */ - final static public String TAG_VIEW = "view"; - - /** - * column tagname - */ - final static public String TAG_COLUMN = "column"; - - /** - * commandButton tagname - */ - final static public String TAG_COMMANDBUTTON = "commandButton"; - - /** - * commandLink tagname - */ - final static public String TAG_COMMANDLINK = "commandLink"; - - /** - * dataTable tagname - */ - final static public String TAG_DATATABLE = "dataTable"; - - /** - * form tagname - */ - final static public String TAG_FORM = "form"; - - /** - * graphicImage tagname - */ - final static public String TAG_GRAPHICIMAGE = "graphicImage"; - - /** - * inputHidden tagname - */ - final static public String TAG_INPUTHIDDEN = "inputHidden"; - - /** - * inputSecret tagname - */ - final static public String TAG_INPUTSECRET = "inputSecret"; - - /** - * inputText tagname - */ - final static public String TAG_INPUTTEXT = "inputText"; - - /** - * inputTextarea tagname - */ - final static public String TAG_INPUTTEXTAREA = "inputTextarea"; - - /** - * message tagname - */ - final static public String TAG_MESSAGE = "message"; - - /** - * messages tagname - */ - final static public String TAG_MESSAGES = "messages"; - - /** - * outputFormat tagname - */ - final static public String TAG_OUTPUTFORMAT = "outputFormat"; - - /** - * outputLabel tagname - */ - final static public String TAG_OUTPUTLABEL = "outputLabel"; - - /** - * outputLink tagname - */ - final static public String TAG_OUTPUTLINK = "outputLink"; - - /** - * outputText tagname - */ - final static public String TAG_OUTPUTTEXT = "outputText"; - - /** - * panelGrid tagname - */ - final static public String TAG_PANELGRID = "panelGrid"; - - /** - * panelGroup tagname - */ - final static public String TAG_PANELGROUP = "panelGroup"; - - /** - * selectBooleanCheckbox tagname - */ - final static public String TAG_SELECTBOOLEANCHECKBOX = "selectBooleanCheckbox"; - - /** - * selectManyCheckbox tagname - */ - final static public String TAG_SELECTMANYCHECKBOX = "selectManyCheckbox"; - - /** - * selectManyListbox tagname - */ - final static public String TAG_SELECTMANYLISTBOX = "selectManyListbox"; - - /** - * selectManyMenu tagname - */ - final static public String TAG_SELECTMANYMENU = "selectManyMenu"; - - /** - * selectOneListbox tagname - */ - final static public String TAG_SELECTONELISTBOX = "selectOneListbox"; - - /** - * selectOneMenu tagname - */ - final static public String TAG_SELECTONEMENU = "selectOneMenu"; - - /** - * selectOneMenu tagname - */ - final static public String TAG_SELECTONERADIO = "selectOneRadio"; - - // tag identifiers - /** - * TagIdentifier for TAG_VIEW - */ - final static TagIdentifier TAG_IDENTIFIER_VIEW = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_CORE, TAG_VIEW); - - /** - * TagIdentifier for TAG_LOADBUNDLE - */ - final static TagIdentifier TAG_IDENTIFIER_LOADBUNDLE = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_CORE, TAG_LOADBUNDLE); - - /** - * TagIdentifier for TAG_FACET - */ - final static TagIdentifier TAG_IDENTIFIER_FACET = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_CORE, TAG_FACET); - - /** - * TagIdentifier for TAG_VERBATIM - */ - final static TagIdentifier TAG_IDENTIFIER_VERBATIM = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_CORE, TAG_VERBATIM); - - /** - * TagIdentifier for TAG_DATATABLE - */ - final static TagIdentifier TAG_IDENTIFIER_DATA_TABLE = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_DATATABLE); - - /** - * TagIdentifier for TAG_PANELGRID - */ - final static TagIdentifier TAG_IDENTIFIER_PANEL_GRID = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_PANELGRID); - - /** - * TagIdentifier for TAG_COLUMN - */ - final static TagIdentifier TAG_IDENTIFIER_COLUMN = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_COLUMN); - - /** - * TagIdentifier for TAG_FORM - */ - final static TagIdentifier TAG_IDENTIFIER_FORM = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_FORM); - - /** - * TagIdentifier for TAG_INPUTTEXT - */ - final static TagIdentifier TAG_IDENTIFIER_INPUTTEXT = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_INPUTTEXT); - - /** - * TagIdentifier for TAG_INPUTSECRET - */ - final static TagIdentifier TAG_IDENTIFIER_INPUTSECRET = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_INPUTSECRET); - - /** - * TagIdentifier for TAG_INPUTTEXTAREA - */ - final static TagIdentifier TAG_IDENTIFIER_INPUTTEXTAREA = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_INPUTTEXTAREA); - - /** - * TagIdentifier for TAG_OUTPUTTEXT - */ - final static TagIdentifier TAG_IDENTIFIER_OUTPUTTEXT = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_OUTPUTTEXT); - - /** - * TagIdentifier for TAG_OUTPUTLABEL - */ - final static TagIdentifier TAG_IDENTIFIER_OUTPUTLABEL = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_OUTPUTLABEL); - - /** - * TagIdentifier for TAG_GRAPHICIMAGE - */ - final static TagIdentifier TAG_IDENTIFIER_GRAPHICIMAGE = - TagIdentifierFactory.createJSPTagWrapper(ITLDConstants.URI_JSF_HTML, TAG_GRAPHICIMAGE); - - // attribute names - /** - * accept tag attribute name - */ - final static public String ATTR_ACCEPT = "accept"; - - /** - * acceptcharset tag attribute name - */ - final static public String ATTR_ACCEPTCHARSET = "acceptcharset"; - - /** - * accesskey tag attribute name - */ - final static public String ATTR_ACCESSKEY = "accesskey"; - - /** - * action tag attribute name - */ - final static public String ATTR_ACTION = "action"; - - /** - * actionListener tag attribute name - */ - final static public String ATTR_ACTIONLISTENER = "actionListener"; - - /** - * alt tag attribute name - */ - final static public String ATTR_ALT = "alt"; - - /** - * basename tag attribute name - */ - final static public String ATTR_BASENAME = "basename"; - - /** - * bgcolor tag attribute name - */ - final static public String ATTR_BGCOLOR = "bgcolor"; - - /** - * binding tag attribute name - */ - final static public String ATTR_BINDING = "binding"; - - /** - * border tag attribute name - */ - final static public String ATTR_BORDER = "border"; - - /** - * cellpadding tag attribute name - */ - final static public String ATTR_CELLPADDING = "cellpadding"; - - /** - * cellspacing tag attribute name - */ - final static public String ATTR_CELLSPACING = "cellspacing"; - - /** - * charset tag attribute name - */ - final static public String ATTR_CHARSET = "charset"; - - /** - * cols tag attribute name - */ - final static public String ATTR_COLS = "cols"; - - /** - * columnClasses tag attribute name - */ - final static public String ATTR_COLUMNCLASSES = "columnClasses"; - - /** - * columns tag attribute name - */ - final static public String ATTR_COLUMNS = "columns"; - - /** - * converterId tag attribute name - */ - final static public String ATTR_CONVERTERID = "converterId"; - - /** - * coords tag attribute name - */ - final static public String ATTR_COORDS = "coords"; - - /** - * currencyCode tag attribute name - */ - final static public String ATTR_CURRENCYCODE = "currencyCode"; - - /** - * currencySymbol tag attribute name - */ - final static public String ATTR_CURRENCYSYMBOL = "currencySymbol"; - - /** - * dateStyle tag attribute name - */ - final static public String ATTR_DATESTYLE = "dateStyle"; - - /** - * dir tag attribute name - */ - final static public String ATTR_DIR = "dir"; - - /** - * disabled tag attribute name - */ - final static public String ATTR_DISABLED = "disabled"; - - /** - * errorClass tag attribute name - */ - final static public String ATTR_ERRORCLASS = "errorClass"; - - /** - * errorStyle tag attribute name - */ - final static public String ATTR_ERRORSTYLE = "errorStyle"; - - /** - * escape tag attribute name - */ - final static public String ATTR_ESCAPE = "escape"; - - /** - * fatalClass tag attribute name - */ - final static public String ATTR_FATALCLASS = "fatalClass"; - - /** - * fatalStyle tag attribute name - */ - final static public String ATTR_FATALSTYLE = "fatalStyle"; - - /** - * first tag attribute name - */ - final static public String ATTR_FIRST = "first"; - - /** - * footerClass tag attribute name - */ - final static public String ATTR_FOOTERCLASS = "footerClass"; - - /** - * for tag attribute name - */ - final static public String ATTR_FOR = "for"; - - /** - * frame tag attribute name - */ - final static public String ATTR_FRAME = "frame"; - - /** - * globalOnly tag attribute name - */ - final static public String ATTR_GLOBEONLY = "globalOnly"; - - /** - * headerClass tag attribute name - */ - final static public String ATTR_HEADERCLASS = "headerClass"; - - /** - * hreflang tag attribute name - */ - final static public String ATTR_HREFLANG = "hreflang"; - - /** - * id tag attribute name - */ - final static public String ATTR_ID = "id"; - - /** - * image tag attribute name - */ - final static public String ATTR_IMAGE = "image"; - - /** - * immediate tag attribute name - */ - final static public String ATTR_IMMEDIATE = "immediate"; - - /** - * infoClass tag attribute name - */ - final static public String ATTR_INFOCLASS = "infoClass"; - - /** - * infoStyle tag attribute name - */ - final static public String ATTR_INFOSTYLE = "infoStyle"; - - /** - * itemDescription tag attribute name - */ - final static public String ATTR_ITEMDESCRIPTION = "itemDescription"; - - /** - * itemDisabled tag attribute name - */ - final static public String ATTR_ITEMDISABLED = "itemDisabled"; - - /** - * itemLabel tag attribute name - */ - final static public String ATTR_ITEMLABEL = "itemLabel"; - - /** - * itemValue tag attribute name - */ - final static public String ATTR_ITEMVALUE = "itemValue"; - - /** - * lang tag attribute name - */ - final static public String ATTR_LANG = "lang"; - - /** - * layout tag attribute name - */ - final static public String ATTR_LAYOUT = "layout"; - - /** - * locale tag attribute name - */ - final static public String ATTR_LOCALE = "locale"; - - /** - * maximum tag attribute name - */ - final static public String ATTR_MAXIMUM = "maximum"; - - /** - * minimum tag attribute name - */ - final static public String ATTR_MINIMUM = "minimum"; - - /** - * name tag attribute name - */ - final static public String ATTR_NAME = "name"; - - /** - * onblur tag attribute name - */ - final static public String ATTR_ONBLUR = "onblur"; - - /** - * onchange tag attribute name - */ - final static public String ATTR_ONCHANGE = "onchange"; - - /** - * onclick tag attribute name - */ - final static public String ATTR_ONCLICK = "onclick"; - - /** - * ondblclick tag attribute name - */ - final static public String ATTR_ONDBLCLICK = "ondblclick"; - - /** - * onfocus tag attribute name - */ - final static public String ATTR_ONFOCUS = "onfocus"; - - /** - * onkeydown tag attribute name - */ - final static public String ATTR_ONKEYDOWN = "onkeydown"; - - /** - * onkeypress tag attribute name - */ - final static public String ATTR_ONKEYPRESS = "onkeypress"; - - /** - * onkeyup tag attribute name - */ - final static public String ATTR_ONKEYUP = "onkeyup"; - - /** - * onmousedown tag attribute name - */ - final static public String ATTR_ONMOUSEDOWN = "onmousedown"; - - /** - * onmousemove tag attribute name - */ - final static public String ATTR_ONMOUSEMOVE = "onmousemove"; - - /** - * onmouseout tag attribute name - */ - final static public String ATTR_ONMOUSEOUT = "onmouseout"; - - /** - * onmouseover tag attribute name - */ - final static public String ATTR_ONMOUSEOVER = "onmouseover"; - - /** - * onmouseup tag attribute name - */ - final static public String ATTR_ONMOUSEUP = "onmouseup"; - - /** - * onselect tag attribute name - */ - final static public String ATTR_ONSELECT = "onselect"; - - /** - * pattern tag attribute name - */ - final static public String ATTR_PATTERN = "pattern"; - - /** - * readonly tag attribute name - */ - final static public String ATTR_READONLY = "readonly"; - - /** - * rel tag attribute name - */ - final static public String ATTR_REL = "rel"; - - /** - * rendered tag attribute name - */ - final static public String ATTR_RENDERED = "rendered"; - - /** - * rev tag attribute name - */ - final static public String ATTR_REV = "rev"; - - /** - * rowClasses tag attribute name - */ - final static public String ATTR_ROWCLASSES = "rowClasses"; - - /** - * rows tag attribute name - */ - final static public String ATTR_ROWS = "rows"; - - /** - * rules tag attribute name - */ - final static public String ATTR_RULES = "rules"; - - /** - * shape tag attribute name - */ - final static public String ATTR_SHAPE = "shape"; - - /** - * showDetail tag attribute name - */ - final static public String ATTR_SHOWDETAIL = "showDetail"; - - /** - * showSummary tag attribute name - */ - final static public String ATTR_SHOWSUMMARY = "showSummary"; - - /** - * size tag attribute name - */ - final static public String ATTR_SIZE = "size"; - - /** - * style tag attribute name - */ - final static public String ATTR_STYLE = "style"; - - /** - * styleClass tag attribute name - */ - final static public String ATTR_STYLECLASS = "styleClass"; - - /** - * summary tag attribute name - */ - final static public String ATTR_SUMMARY = "summary"; - - /** - * tabindex tag attribute name - */ - final static public String ATTR_TABINDEX = "tabindex"; - - /** - * target tag attribute name - */ - final static public String ATTR_TARGET = "target"; - - /** - * timeStyle tag attribute name - */ - final static public String ATTR_TIMESTYLE = "timeStyle"; - - /** - * title tag attribute name - */ - final static public String ATTR_TITLE = "title"; - - /** - * tooltip tag attribute name - */ - final static public String ATTR_TOOLTIP = "tooltip"; - - /** - * type tag attribute name - */ - final static public String ATTR_TYPE = "type"; - - /** - * url tag attribute name - */ - final static public String ATTR_URL = "url"; - - /** - * validatorId tag attribute name - */ - final static public String ATTR_VALIDATORID = "validatorId"; - - /** - * value tag attribute name - */ - final static public String ATTR_VALUE = "value"; - - /** - * var tag attribute name - */ - final static public String ATTR_VAR = "var"; - - /** - * warnClass tag attribute name - */ - final static public String ATTR_WARNCLASS = "warnClass"; - - /** - * warnStyle tag attribute name - */ - final static public String ATTR_WARNSTYLE = "warnStyle"; - - /** - * width tag attribute name - */ - final static public String ATTR_WIDTH = "width"; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/ITLDConstants.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/ITLDConstants.java deleted file mode 100644 index 3ec16f476..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/ITLDConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.tld; - -/** - * Global tag library constants - * - * @author cbateman - * - */ -public interface ITLDConstants { - - /** - * The JSF core (f) component URI - */ - public static final String URI_JSF_CORE = "http://java.sun.com/jsf/core"; //$NON-NLS-1$ - /** - * The JSF html (h) component URI - */ - public static final String URI_JSF_HTML = "http://java.sun.com/jsf/html"; //$NON-NLS-1$ - /** - * The last component of the html uri - */ - public static final String URI_HTML = "html"; //$NON-NLS-1$ - /** - * The last component of the core uri - */ - public static final String URI_JSP = "jsp"; //$NON-NLS-1$ - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/JSPTagIdentifier.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/JSPTagIdentifier.java deleted file mode 100644 index 8546c38f2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/JSPTagIdentifier.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.tld; - -import org.eclipse.jst.jsf.common.dom.TagIdentifier; - -/** - * A tag wrapper for a JSP tag. - * - * @author cbateman - * - */ -/*package*/ class JSPTagIdentifier extends TagIdentifier -{ - private final String _uri; - private final String _tagName; - - /** - * @param uri - * @param tagName - */ - public JSPTagIdentifier(final String uri, final String tagName) - { - _uri = uri; - _tagName = tagName; - } - public String getTagName() { - return _tagName; - } - - public String getUri() { - return _uri; - } - - public boolean isJSPTag() { - return true; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/LoadBundleUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/LoadBundleUtil.java deleted file mode 100644 index daf4e7a82..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/LoadBundleUtil.java +++ /dev/null @@ -1,297 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.tld; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IStorage; -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.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; - -/** - * @author mengbo - */ -public class LoadBundleUtil { - - private LoadBundleUtil() { - // no external instantiation - } - - - /** - * @param project - * @param baseName - * @return an IStorage pointing to the request bundle or null if not found - * @throws CoreException if the search for the file encounters a problem - */ - public static IStorage getLoadBundleResource(final IProject project, - final String baseName) throws CoreException { - if (project == null || baseName == null) { - return null; - } - IStorage loadBundleResource = null; - if (project.hasNature(JavaCore.NATURE_ID)) { - IJavaProject javaProject = JavaCore.create(project); - IFile sourceFile = getSourceFile(javaProject, baseName); - if (sourceFile == null || !sourceFile.exists()) { - loadBundleResource = getJarFile(javaProject, baseName); - } else { - loadBundleResource = sourceFile; - } - } - - return loadBundleResource; - } - - private static IFile getSourceFile(IJavaProject javaProject, String baseName) - throws JavaModelException { - IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); - for (int i = 0; i < classpathEntries.length; i++) { - if (classpathEntries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { - IPath path = classpathEntries[i].getPath().append( - getFilePath(baseName)).removeFirstSegments(1); - path = javaProject.getProject().getFullPath().append(path); - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( - path); - if (file.exists()) { - return file; - } - } - } - return null; - } - - private static IPath getFilePath(String baseName) { - IPath path = new Path(baseName.replace('.', '/'));//$NON-NLS-1$ - path = path.addFileExtension("properties");//$NON-NLS-1$ - return path; - } - - private static IStorage getJarFile(IJavaProject javaProject, String baseName) - throws JavaModelException { - IClasspathEntry[] roots = javaProject.getRawClasspath(); - for (int i = 0; i < roots.length; i++) { - if (roots[i].getEntryKind() != IClasspathEntry.CPE_LIBRARY) { - continue; - } - - IPackageFragmentRoot[] packageFragmentRoots = javaProject - .findPackageFragmentRoots(roots[i]); - for (int j = 0; j < packageFragmentRoots.length; j++) { - String packageName = getPackageName(baseName); - Object[] resources = null; - if (packageName.length() == 0) { - resources = packageFragmentRoots[j].getNonJavaResources(); - } else { - IPackageFragment fragment = packageFragmentRoots[j] - .getPackageFragment(getPackageName(baseName)); - if (fragment != null && fragment.exists()) { - resources = fragment.getNonJavaResources(); - } - } - - if (resources != null && resources.length > 0) { - for (int k = 0; k < resources.length; k++) { - if (resources[k] instanceof IStorage) { - IStorage storage = (IStorage) resources[k]; - if (getFileName(baseName).equalsIgnoreCase( - storage.getName())) { - return storage; - } - } - } - } - } - } - return null; - } - - private static String getPackageName(String baseName) { - int index = baseName.lastIndexOf('.');//$NON-NLS-1$ - if (index == -1) { - return "";//$NON-NLS-1$ - } - return baseName.substring(0, index); - } - - private static String getFileName(String baseName) { - int index = baseName.lastIndexOf('.');//$NON-NLS-1$ - if (index == -1) { - return baseName + ".properties"; - } - return baseName.substring(index + 1).concat(".properties");//$NON-NLS-1$ - } - - /** - * Encapsulates the hiearchy of bundle data sources in the hierarchy - * for a ResourceBundle base name. In practice this is often simply - * a single IFile for a - * @author cbateman - * - */ -// public static class BundleHierarchy -// { -// // list in order from most specific (first queried) to least, -// // front to back -// //private final List _hierarchy; -// -// /** -// * Takes the list *by reference*. Does not take a copy. -// * @param hierarchy -// */ -// public BundleHierarchy(List hierarchy) -// { -// _hierarchy = hierarchy; -// } -// -// public BundleHierarchy() -// { -// _hierarchy = new ArrayList(); -// } -// } - - /** - * Used to describe the design time approximation of the locale lookup precendence - * that will be used by ResourceBundle to find a localized resource bundle. - * - * See the official JavaDoc for java.util.ResourceBundle.getBundle for docs on search - * order. - * - * @author cbateman - * - */ - public static class LocaleDescriptor - { - private Locale _locale; - private List _possibleSuffices; - - /** - * @param language -- must not be null - */ - public LocaleDescriptor(String language) - { - _locale = new Locale(language); - } - - /** - * All arguments must be non-null. To set a language only descriptor, - * see others. - * - * @param language -- must not be null - * @param country -- must not be null - */ - public LocaleDescriptor(String language, - String country) - { - _locale = new Locale(language, country); - } - - /** - * All arguments must be non-null. Null arguments will cause an exception. - * To create descriptor without variant and/or country set, see other constructors - * @param language -- must not be null - * @param country -- must not be null - * @param variant -- must not be null - */ - public LocaleDescriptor(String language, - String country, String variant) - { - _locale = new Locale(language, country, variant); - } - - /** - * @param baseName - * @return an iterator through all possible bundle names starting with the most - * specific and becoming more general for base name based on this locale. - * - * i.e. if baseName is "bundle" and the local is en_US_1 then in order the - * iterator will produce: - * - * bundle_en_US_1 - * bundle_en_US - * bundle_en - * bundle - * - * per the ResourceBundle API - * - */ - public Iterator getBundleNameIterator(final String baseName) - { - - return new Iterator() - { - final Iterator it = getPossibleBaseNameSuffices().iterator(); - - public boolean hasNext() { - return it.hasNext(); - } - - public Object next() { - return baseName+it.next(); - } - - public void remove() { - // delegate; should throw exception - it.remove(); - } - }; - } - - private synchronized List getPossibleBaseNameSuffices() - { - if (_possibleSuffices == null) - { - List possibleSuffices = new ArrayList(3); - - final String language = _locale.getLanguage(); - final String country = _locale.getCountry(); - final String variant = _locale.getVariant(); - - possibleSuffices.add(""); - possibleSuffices.add("_"+language); - if (country != null) - { - possibleSuffices.add(0, "_"+language + "_" + country); - if (variant != null) - { - possibleSuffices.add(0, "_"+language+"_"+country+"_"+variant); - } - } - _possibleSuffices = Collections.unmodifiableList(possibleSuffices); - } - - return _possibleSuffices; - } - - /** - * @return the local information as a standard locale object - */ - public Locale getLocale() - { - return _locale; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/TagIdentifierFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/TagIdentifierFactory.java deleted file mode 100644 index 0c8d702a1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/TagIdentifierFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.tld; - -import org.eclipse.jst.jsf.common.dom.TagIdentifier; -import org.w3c.dom.Element; - -/** - * Factory creating tag identifiers - * - * @author cbateman - * - */ -public final class TagIdentifierFactory -{ - /** - * Create a tag identifier based on a uri and tagName - * - * @param uri - * @param tagName - * @return a new tag identifier for (uri, tagName) - */ - public static TagIdentifier createJSPTagWrapper(final String uri, final String tagName) - { - return new JSPTagIdentifier(uri, tagName); - } - - /** - * @param element - * @return a tag identifier based on a DOM element - */ - public static TagIdentifier createDocumentTagWrapper(final Element element) - { - return new DocumentTagIdentifier(element); - } - - private TagIdentifierFactory() - { - // static class, no external instantiation - } -} - diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/AbstractJSFAppConfigLocater.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/AbstractJSFAppConfigLocater.java deleted file mode 100644 index 943fecb99..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/AbstractJSFAppConfigLocater.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * Abstract implementation of {@link IJSFAppConfigLocater} that provides common - * locater functionality. {@link IJSFAppConfigLocater} implementations should - * extend this class or provide similar functionality. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public abstract class AbstractJSFAppConfigLocater implements IJSFAppConfigLocater { - - /** - * {@link JSFAppConfigManager} instance to which this locater belongs. - */ - protected JSFAppConfigManager manager = null; - - /** - * Set of known {@link IJSFAppConfigProvider} instances. - */ - protected Set configProviders = new LinkedHashSet(); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigLocater#setJSFAppConfigManager(org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager) - */ - public void setJSFAppConfigManager(JSFAppConfigManager manager) { - this.manager = manager; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigLocater#getJSFAppConfigManager() - */ - public JSFAppConfigManager getJSFAppConfigManager() { - return manager; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigLocater#startLocating() - */ - public abstract void startLocating(); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigLocater#stopLocating() - */ - public abstract void stopLocating(); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigLocater#getJSFAppConfigProviders() - */ - public Set getJSFAppConfigProviders() { - return configProviders; - } - - /** - * Adds an {@link IJSFAppConfigProvider} instance to the set of known - * instances and notifies {@link JSFAppConfigManager} instance of the - * addition if successful. - * - * @param configProvider {@link IJSFAppConfigProvider} instance to be - * added. - * @return true if instance was added, else false. - */ - protected boolean addConfigProvider(IJSFAppConfigProvider configProvider) { - boolean added = configProviders.add(configProvider); - if (added && manager != null) { - configProvider.setJSFAppConfigLocater(this); - manager.notifyJSFAppConfigProvidersChangeListeners( - configProvider, - JSFAppConfigProvidersChangeEvent.ADDED); - } - return added; - } - - /** - * Removes an {@link IJSFAppConfigProvider} instance from the set of known - * instances and notifies {@link JSFAppConfigManager} instance of the - * removal if successful. - * - * @param configProvider {@link IJSFAppConfigProvider} instance to be - * removed. - * @return true if instance was removed, else false. - */ - protected boolean removeConfigProvider(IJSFAppConfigProvider configProvider) { - if (configProvider != null) { - configProvider.releaseFacesConfigModel(); - } - boolean removed = configProviders.remove(configProvider); - if (removed && manager != null) { - manager.notifyJSFAppConfigProvidersChangeListeners( - configProvider, - JSFAppConfigProvidersChangeEvent.REMOVED); - } - return removed; - } - - /** - * Updates known set of {@link IJSFAppConfigProvider} instances by removing - * instances that are in the existing set but not in the passed set and - * adding instances that are in the passed set but not in the existing set. - * Instances that are in both the existing set and the passed set are left - * unchanged. The {@link JSFAppConfigManager} is notified of removals and - * additions, and no notification is sent for instances that are left - * unchanged. - * - * @param newConfigProviders New set of {@link IJSFAppConfigProvider} - * instances. - */ - protected void updateConfigProviders(Set newConfigProviders) { - if (newConfigProviders != null) { - LinkedHashSet oldConfigProviders = new LinkedHashSet(); - //iterate over existing set - Iterator itConfigProviders = configProviders.iterator(); - while (itConfigProviders.hasNext()) { - IJSFAppConfigProvider configProvider = (IJSFAppConfigProvider)itConfigProviders.next(); - //remove provider from new set if it is already in existing set - if (!newConfigProviders.remove(configProvider)) { - //stage removal of existing provider that is not in new set - oldConfigProviders.add(configProvider); - } - } - //remove providers that are not in new set from existing set - Iterator itOldConfigProviders = oldConfigProviders.iterator(); - while (itOldConfigProviders.hasNext()) { - IJSFAppConfigProvider configProvider = (IJSFAppConfigProvider)itOldConfigProviders.next(); - //call removeConfigProvider(...) method so manager's listeners are notified - removeConfigProvider(configProvider); - } - //add providers that are still in new set to existing set - Iterator itNewConfigProviders = newConfigProviders.iterator(); - while (itNewConfigProviders.hasNext()) { - IJSFAppConfigProvider configProvider = (IJSFAppConfigProvider)itNewConfigProviders.next(); - //call addConfigProvider(...) method so manager's listeners are notified - addConfigProvider(configProvider); - } - } - } - - /** - * Removes all {@link IJSFAppConfigProvider} instances from the known set, - * sending notification of all removals to the {@link JSFAppConfigManager} - * instance. - */ - protected void removeAllConfigProviders() { - updateConfigProviders(Collections.EMPTY_SET); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#finalize() - */ - protected void finalize() { - removeAllConfigProviders(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/AbstractJSFAppConfigProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/AbstractJSFAppConfigProvider.java deleted file mode 100644 index baaf9e14e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/AbstractJSFAppConfigProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; - -/** - * Abstract implementation of {@link IJSFAppConfigProvider} that provides - * common provider functionality. {@link IJSFAppConfigProvider} instances - * should extend this class or provide similar functionality. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public abstract class AbstractJSFAppConfigProvider implements IJSFAppConfigProvider { - - /** - * {@link IJSFAppConfigLocater} instance that located this instance. - */ - protected IJSFAppConfigLocater jsfAppConfigLocater = null; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#setJSFAppConfigLocater(org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigLocater) - */ - public void setJSFAppConfigLocater(IJSFAppConfigLocater locater) { - this.jsfAppConfigLocater = locater; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#getFacesConfigModel() - */ - public abstract FacesConfigType getFacesConfigModel(); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#releaseFacesConfigModel() - */ - public abstract void releaseFacesConfigModel(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ArtifactEditJSFAppConfigProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ArtifactEditJSFAppConfigProvider.java deleted file mode 100644 index f9f39e9de..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ArtifactEditJSFAppConfigProvider.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit; - -/** - * ArtifactEditJSFAppConfigProvider uses FacesConfigArtifactEdit to provide - * the root element of an application configuration model. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class ArtifactEditJSFAppConfigProvider extends AbstractJSFAppConfigProvider { - - /** - * IFile instance that represents an application configuration resource - * file. - */ - protected IFile appConfigFile = null; - - /** - * FacesConfigArtifactEdit instance used to get the application - * configuration model. - */ - protected FacesConfigArtifactEdit facesConfigArtifactEdit = null; - - /** - * Cached {@link FacesConfigType} instance. - */ - protected FacesConfigType facesConfig = null; - - /** - * Creates an instance, storing the passed IFile instance for subsequent - * processing. - * - * @param appConfigFile IFile instance that represents an application - * configuration resource file - */ - public ArtifactEditJSFAppConfigProvider(IFile appConfigFile) { - this.appConfigFile = appConfigFile; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#getFacesConfigModel() - */ - public FacesConfigType getFacesConfigModel() { - if (facesConfig == null) { - if (appConfigFile != null) { - IProject project = appConfigFile.getProject(); - IPath appConfigFilePath = JSFAppConfigUtils.getWebContentFolderRelativePath(appConfigFile); - if (appConfigFilePath != null) { - facesConfigArtifactEdit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(project, appConfigFilePath.toString()); - if (facesConfigArtifactEdit != null) { - facesConfig = facesConfigArtifactEdit.getFacesConfig(); - if (facesConfig != null) { - jsfAppConfigLocater.getJSFAppConfigManager().addFacesConfigChangeAdapter(facesConfig); - } - } - } - } - } - return facesConfig; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#releaseFacesConfigModel() - */ - public void releaseFacesConfigModel() { - jsfAppConfigLocater.getJSFAppConfigManager().removeFacesConfigChangeAdapter(facesConfig); - if (facesConfigArtifactEdit != null) { - facesConfigArtifactEdit.dispose(); - } - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object otherObject) { - boolean equals = false; - if (otherObject != null && otherObject instanceof ArtifactEditJSFAppConfigProvider) { - IFile otherAppConfigFile = ((ArtifactEditJSFAppConfigProvider)otherObject).appConfigFile; - if (appConfigFile != null) { - equals = appConfigFile.equals(otherAppConfigFile); - } else { - equals = otherAppConfigFile == null; - } - } - return equals; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return appConfigFile != null ? appConfigFile.hashCode() : 0; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer sb = new StringBuffer("ArtifactEditJSFAppConfigProvider["); //$NON-NLS-1$ - if (appConfigFile != null) { - sb.append(appConfigFile.toString()); - } else { - sb.append("null"); //$NON-NLS-1$ - } - sb.append("]"); //$NON-NLS-1$ - return sb.toString(); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#finalize() - */ - protected void finalize() { - releaseFacesConfigModel(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ContextParamSpecifiedJSFAppConfigLocater.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ContextParamSpecifiedJSFAppConfigLocater.java deleted file mode 100644 index 5df2941cb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ContextParamSpecifiedJSFAppConfigLocater.java +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.j2ee.common.ParamValue; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.ContextParam; -import org.eclipse.jst.j2ee.webapplication.WebApp; - -/** - * ContextParamSpecifiedJSFAppConfigLocater attempts to locate application - * configuration files specified by the JSF CONFIG_FILES context parameter. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - * TODO:cleanup once JavaEE API's stabilize - */ -public class ContextParamSpecifiedJSFAppConfigLocater extends WebContentRelativeJSFAppConfigLocater { - - /** - * Cached instance of ContextParamAdapter. - */ - protected ContextParamAdapter contextParamAdapter = null; - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#startLocating() - */ - public void startLocating() { - locateProviders(); - Object webAppObj = getModelObject(); - if (webAppObj != null){ - contextParamAdapter = new ContextParamAdapter(); - if (webAppObj instanceof WebApp) - startLocatingJ2EEConfigs((WebApp)webAppObj); - else if (webAppObj instanceof org.eclipse.jst.javaee.web.WebApp) - startLocatingJEEConfigs((org.eclipse.jst.javaee.web.WebApp)webAppObj); - } else { - //TODO should never get here. Log err? - } - } - - private Object getModelObject() { - IModelProvider provider = ModelProviderManager.getModelProvider(getJSFAppConfigManager().getProject()); - return provider.getModelObject(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#stopLocating() - */ - public void stopLocating() { - if (contextParamAdapter != null) { - Object webAppObj = getModelObject(); - if (webAppObj != null){ - if (webAppObj instanceof WebApp) - stopLocatingJ2EEConfigs((WebApp)webAppObj); - else if (webAppObj instanceof org.eclipse.jst.javaee.web.WebApp) - stopLocatingJEEConfigs((org.eclipse.jst.javaee.web.WebApp)webAppObj); - } else { - //TODO should never get here. Log err? - } - contextParamAdapter = null; - } - } - - private void startLocatingJ2EEConfigs(WebApp webApp){ - webApp.eAdapters().add(contextParamAdapter); - EList contexts = webApp.getContexts(); - if (contexts != null) { - Iterator itContexts = contexts.iterator(); - while (itContexts.hasNext()) { - ContextParam contextParam = (ContextParam)itContexts.next(); - contextParam.eAdapters().add(contextParamAdapter); - } - } - EList contextParams = webApp.getContextParams(); - if (contextParams != null) { - Iterator itContextParams = contextParams.iterator(); - while (itContextParams.hasNext()) { - ParamValue paramValue = (ParamValue)itContextParams.next(); - paramValue.eAdapters().add(contextParamAdapter); - } - } - } - - private void startLocatingJEEConfigs(org.eclipse.jst.javaee.web.WebApp webApp){ - ((EObject)webApp).eAdapters().add(contextParamAdapter); -// System.out.println(((EObject)webApp).eDeliver()); - List params = webApp.getContextParams(); - if (params != null) { - Iterator itContexts = params.iterator(); - while (itContexts.hasNext()) { - EObject contextParam = (EObject)itContexts.next(); - contextParam.eAdapters().add(contextParamAdapter); - } - } - } - - - private void stopLocatingJ2EEConfigs(WebApp webApp) { - webApp.eAdapters().remove(contextParamAdapter); - EList contexts = webApp.getContexts(); - if (contexts != null) { - Iterator itContexts = contexts.iterator(); - while (itContexts.hasNext()) { - ContextParam contextParam = (ContextParam)itContexts.next(); - contextParam.eAdapters().remove(contextParamAdapter); - } - } - EList contextParams = webApp.getContextParams(); - if (contextParams != null) { - Iterator itContextParams = contextParams.iterator(); - while (itContextParams.hasNext()) { - ParamValue paramValue = (ParamValue)itContextParams.next(); - paramValue.eAdapters().remove(contextParamAdapter); - } - } - } - - private void stopLocatingJEEConfigs(org.eclipse.jst.javaee.web.WebApp webApp) { - ((EObject)webApp).eAdapters().remove(contextParamAdapter); - List contextParams = webApp.getContextParams(); - if (contextParams != null) { - Iterator itContextParams = contextParams.iterator(); - while (itContextParams.hasNext()) { - EObject paramValue = (EObject)itContextParams.next(); - paramValue.eAdapters().remove(contextParamAdapter); - } - } - } - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.WebContentRelativeJSFAppConfigLocater#getFilenames() - */ - protected List getFilenames() { - return JSFAppConfigUtils.getConfigFilesFromContextParam(manager.getProject()); - } - - /** - * Adapter implementation used to monitor addition/removal of context-param - * nodes and change in name of existing nodes in order to respond to - * changes to the JSF CONFIG_FILES context-param. - * - * @author Ian Trimble - Oracle - */ - class ContextParamAdapter extends AdapterImpl { - - /* - * (non-Javadoc) - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification notification) { - Object objNotifier = notification.getNotifier(); -// System.out.println(objNotifier.toString()); - if (objNotifier instanceof WebApp || - objNotifier instanceof org.eclipse.jst.javaee.web.WebApp) { - int eventType = notification.getEventType(); - switch (eventType) { - case Notification.ADD: - Object objNewValue = notification.getNewValue(); - if (objNewValue instanceof ContextParam || - objNewValue instanceof org.eclipse.jst.javaee.core.ParamValue) { - contextParamAdded((EObject)objNewValue); - } else if (objNewValue instanceof ParamValue ) { - paramValueAdded((EObject)objNewValue); - } - break; - case Notification.REMOVE: - Object objOldValue = notification.getOldValue(); - if (objOldValue instanceof ContextParam || - objOldValue instanceof org.eclipse.jst.javaee.core.ParamValue) { - contextParamRemoved((EObject)objOldValue); - } else if (objOldValue instanceof ParamValue) { - paramValueRemoved((EObject)objOldValue); - } - break; - } - } else if (objNotifier instanceof ContextParam || - objNotifier instanceof org.eclipse.jst.javaee.core.ParamValue) { - if (notification.getEventType() != Notification.REMOVING_ADAPTER) { - locateProviders(); - } - } else if (objNotifier instanceof ParamValue) { - if (notification.getEventType() != Notification.REMOVING_ADAPTER) { - locateProviders(); - } - } - } - - /** - * Called when a new ContextParam instance is added. - * - * @param contextParam ContextParam instance. - */ - protected void contextParamAdded(EObject contextParam) { - if (isConfigFilesContextParam(contextParam)) { - locateProviders(); - } - contextParam.eAdapters().add(this); - } - - /** - * Called when a new ParamValue instance is added. - * - * @param paramValue ParamValue instance. - */ - protected void paramValueAdded(EObject paramValue) { - if (isConfigFilesParamValue(paramValue)) { - locateProviders(); - } - paramValue.eAdapters().add(this); - } - - /** - * Called when a ContextParam instance is removed. - * - * @param contextParam ContextParam instance. - */ - protected void contextParamRemoved(EObject contextParam) { - if (isConfigFilesContextParam(contextParam)) { - locateProviders(); - } - contextParam.eAdapters().remove(this); - } - - /** - * Called when a ParamValue instance is removed. - * - * @param paramValue ParamValue instance. - */ - protected void paramValueRemoved(EObject paramValue) { - if (isConfigFilesParamValue(paramValue)) { - locateProviders(); - } - paramValue.eAdapters().remove(this); - } - - /** - * Tests if the passed ContextParam instance is the JSF CONFIG_FILES - * context parameter. - * - * @param contextParam ContextParam instance. - * @return true if the passed ContextParam instance is the JSF - * CONFIG_FILES context parameter, else false - */ - protected boolean isConfigFilesContextParam(EObject contextParam) { - boolean isConfigFiles = false; - if (contextParam != null) { - String name = null; - if (contextParam instanceof ContextParam) - name = ((ContextParam)contextParam).getParamName(); - else if (contextParam instanceof org.eclipse.jst.javaee.core.ParamValue) - name = ((org.eclipse.jst.javaee.core.ParamValue)contextParam).getParamName(); - - if (name != null && name.equals(JSFAppConfigUtils.CONFIG_FILES_CONTEXT_PARAM_NAME)) { - isConfigFiles = true; - } - } - return isConfigFiles; - } - - /** - * Tests if the passed ParamValue instance is the JSF CONFIG_FILES - * context parameter. - * - * @param paramVal as EObject ParamValue instance. - * @return true if the passed ParamValue instance is the JSF - * CONFIG_FILES context parameter, else false - */ - protected boolean isConfigFilesParamValue(EObject paramVal) { - boolean isConfigFiles = false; - if (paramVal != null) { - String name = null; - if (paramVal instanceof ParamValue) - name = ((ParamValue)paramVal).getName(); - else if (paramVal instanceof org.eclipse.jst.javaee.core.ParamValue) - name = ((org.eclipse.jst.javaee.core.ParamValue)paramVal).getParamName(); - - if (name != null && name.equals(JSFAppConfigUtils.CONFIG_FILES_CONTEXT_PARAM_NAME)) { - isConfigFiles = true; - } - } - return isConfigFiles; - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/DefaultJSFAppConfigLocater.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/DefaultJSFAppConfigLocater.java deleted file mode 100644 index 4cc953df5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/DefaultJSFAppConfigLocater.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -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.IStatus; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -/** - * DefaultJSFAppConfigLocater attempts to locate the default application - * configuration file, located at "/WEB-INF/faces-config.xml". - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class DefaultJSFAppConfigLocater extends WebContentRelativeJSFAppConfigLocater - implements IResourceChangeListener { - - /** - * Web content folder-relative name of the default application - * configuration resource file. - */ - public static final String DEF_APPCONFIGRESOURCE_FILENAME = "WEB-INF/faces-config.xml"; //$NON-NLS-1$ - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#startLocating() - */ - public void startLocating() { - locateProviders(); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.addResourceChangeListener(this, IResourceChangeEvent.POST_BUILD); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#stopLocating() - */ - public void stopLocating() { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.removeResourceChangeListener(this); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.WebContentRelativeJSFAppConfigLocater#getFilenames() - */ - protected List getFilenames() { - List filenames = new ArrayList(); - filenames.add(DEF_APPCONFIGRESOURCE_FILENAME); - return filenames; - } - - /** - * Responds to resource change events. - * - * @param event IResourceChangeEvent instance. - */ - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - try { - delta.accept(new ResourceDeltaVisitor()); - } catch (CoreException cex) { - JSFCorePlugin.log( - IStatus.WARNING, - cex.getLocalizedMessage(), - cex); - } - } - - /** - * ResourceDeltaVisitor is used to visit an IResourceDelta instance to - * discover if the default application configuration resource file has - * been added or removed. - * - * @author Ian Trimble - Oracle - */ - class ResourceDeltaVisitor implements IResourceDeltaVisitor { - - /** - * Cached IPath instance for default configuration resource file. - */ - protected IPath defConfigPath = null; - - /* - * (non-Javadoc) - * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta) - */ - public boolean visit(IResourceDelta delta) { - boolean visitChildren = false; - initDefConfigPath(); - if (defConfigPath != null) { - IPath deltaPath = delta.getFullPath(); - if (deltaPath != null) { - if (defConfigPath.equals(deltaPath)) { - locateProviders(); - } else if (deltaPath.isPrefixOf(defConfigPath)) { - visitChildren = true; - } - } - } else { - locateProviders(); - } - return visitChildren; - } - - /** - * Determines IPath instance for default configuration resource file - * and caches in class member. - */ - protected void initDefConfigPath() { - if (defConfigPath == null) { - IProject project = manager.getProject(); - if (project != null) { - IVirtualFolder webContentFolder = JSFAppConfigUtils.getWebContentFolder(project); - if (webContentFolder != null) { - IVirtualResource defConfigFile = webContentFolder.findMember(DEF_APPCONFIGRESOURCE_FILENAME); - if (defConfigFile != null) { - defConfigPath = defConfigFile.getWorkspaceRelativePath(); - } - } - } - } - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IFacesConfigChangeListener.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IFacesConfigChangeListener.java deleted file mode 100644 index 7f40db6c7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IFacesConfigChangeListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import org.eclipse.emf.common.notify.Notification; - -/** - * IFacesConfigChangeListener is the interface that must be implemented by - * objects interested in receiving notification of changes to application - * configuration models. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public interface IFacesConfigChangeListener { - - /** - * Called when a change in an application configuration model for which - * this listener has been registered occurs. - * - * @param notification EMF {@link Notification} instance that describes the - * model change. - */ - public void notifyChanged(Notification notification); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigLocater.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigLocater.java deleted file mode 100644 index 6c0a6a2a5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigLocater.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.util.Set; - -/** - * IJSFAppConfigLocater is the interface that Objects capable of locating - * and providing JSF application configuration resources must implement. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public interface IJSFAppConfigLocater { - - /** - * Sets the {@link JSFAppConfigManager} instance to which this locater - * belongs. - * - * @param manager {@link JSFAppConfigManager} instance to be set. - */ - public void setJSFAppConfigManager(JSFAppConfigManager manager); - - /** - * Gets the {@link JSFAppConfigManager} instance to which this locater - * belongs. - * - * @return {@link JSFAppConfigManager} instance to which this locater - * belongs. - */ - public JSFAppConfigManager getJSFAppConfigManager(); - - /** - * Starts locating JSF application configuration resources. - */ - public void startLocating(); - - /** - * Stops locating JSF application configuration resources. - */ - public void stopLocating(); - - /** - * Gets the set of {@link IJSFAppConfigProvider} instances that this - * locater has located. - * - * @return set of {@link IJSFAppConfigProvider} instances. - */ - public Set getJSFAppConfigProviders(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigProvider.java deleted file mode 100644 index a351eaa4d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; - -/** - * IJSFAppConfigProvider is the interface that Objects capable of providing - * JSF application configuration models must implement. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public interface IJSFAppConfigProvider { - - /** - * Sets the {@link IJSFAppConfigLocater} instance that located this - * instance. - * - * @param locater {@link IJSFAppConfigLocater} instance that located this - * instance. - */ - public void setJSFAppConfigLocater(IJSFAppConfigLocater locater); - - /** - * Gets the root element of the application configuration model for read - * access. - * - * @return FacesConfigType instance, which is the root element of an - * application configuration model. - */ - public FacesConfigType getFacesConfigModel(); - - /** - * Releases resources associated with acquiring the application - * configuration model (if any). - */ - public void releaseFacesConfigModel(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigProvidersChangeListener.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigProvidersChangeListener.java deleted file mode 100644 index d8282c90f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/IJSFAppConfigProvidersChangeListener.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -/** - * Interface that an Object wishing to be notified about changes to the Set of - * IJSFAppConfigProvider instances implements. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle. - */ -public interface IJSFAppConfigProvidersChangeListener { - - /** - * Callback method indicating a change in the Set of JSFAppConfigProvider - * instances. - * - * @param event JSFAppConfigProvidersChangeEvent instance. - */ - public void changedJSFAppConfigProviders(JSFAppConfigProvidersChangeEvent event); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigLocater.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigLocater.java deleted file mode 100644 index eddcfeb95..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigLocater.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * ImplicitRuntimeJSFAppConfigLocater creates an {@link IJSFAppConfigProvider} - * instance that provides an application configuration model that contains - * implicit configuration elements that are specified as required to be - * provided by a JSF implementation. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class ImplicitRuntimeJSFAppConfigLocater extends AbstractJSFAppConfigLocater { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#startLocating() - */ - public void startLocating() { - locateProviders(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#stopLocating() - */ - public void stopLocating() { - //nothing to do - } - - /** - * Adds an {@link IJSFAppConfigProvider} instance that provides an - * application configuration model that contains implicit configuration - * objects provided by a JSF implementation at runtime. - */ - public void locateProviders() { - Set newConfigProviders = new LinkedHashSet(); - newConfigProviders.add(new ImplicitRuntimeJSFAppConfigProvider()); - updateConfigProviders(newConfigProviders); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java deleted file mode 100644 index eea8207be..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/ImplicitRuntimeJSFAppConfigProvider.java +++ /dev/null @@ -1,270 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentType; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentTypeType; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterIdType; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorIdType; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorType; - -/** - * ImplicitRuntimeJSFAppConfigProvider provides an application configuration - * model that contains implicit configuration objects provided by a JSF - * implementation at runtime. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class ImplicitRuntimeJSFAppConfigProvider extends AbstractJSFAppConfigProvider { - - /** - * Cached {@link FacesConfigType} instance. - */ - protected FacesConfigType facesConfig = null; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#getFacesConfigModel() - */ - public FacesConfigType getFacesConfigModel() { - if (facesConfig == null) { - createModel(); - if (facesConfig != null) { - jsfAppConfigLocater.getJSFAppConfigManager().addFacesConfigChangeAdapter(facesConfig); - } - } - return facesConfig; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#releaseFacesConfigModel() - */ - public void releaseFacesConfigModel() { - jsfAppConfigLocater.getJSFAppConfigManager().removeFacesConfigChangeAdapter(facesConfig); - facesConfig = null; - } - - /** - * Creates the application configuration model and assigns it to the - * facesConfig property. - */ - protected void createModel() { - facesConfig = FacesConfigFactory.eINSTANCE.createFacesConfigType(); - //create and add converters - EList converters = facesConfig.getConverter(); - converters.add(createConverter("BigDecimal")); //$NON-NLS-1$ - converters.add(createConverter("BigInteger")); //$NON-NLS-1$ - converters.add(createConverter("Boolean")); //$NON-NLS-1$ - converters.add(createConverter("Byte")); //$NON-NLS-1$ - converters.add(createConverter("Character")); //$NON-NLS-1$ - converters.add(createConverter("DateTime")); //$NON-NLS-1$ - converters.add(createConverter("Double")); //$NON-NLS-1$ - converters.add(createConverter("Float")); //$NON-NLS-1$ - converters.add(createConverter("Integer")); //$NON-NLS-1$ - converters.add(createConverter("Long")); //$NON-NLS-1$ - converters.add(createConverter("Number")); //$NON-NLS-1$ - converters.add(createConverter("Short")); //$NON-NLS-1$ - //create and add validators - EList validators = facesConfig.getValidator(); - validators.add(createValidator("DoubleRange")); //$NON-NLS-1$ - validators.add(createValidator("Length")); //$NON-NLS-1$ - validators.add(createValidator("LongRange")); //$NON-NLS-1$ - //create and add UI components - EList components = facesConfig.getComponent(); - components.add(createUIComponent("Column")); //$NON-NLS-1$ - components.add(createUIComponent("Command")); //$NON-NLS-1$ - components.add(createUIComponent("Data")); //$NON-NLS-1$ - components.add(createUIComponent("Form")); //$NON-NLS-1$ - components.add(createUIComponent("Graphic")); //$NON-NLS-1$ - components.add(createUIComponent("Input")); //$NON-NLS-1$ - components.add(createUIComponent("Message")); //$NON-NLS-1$ - components.add(createUIComponent("Messages")); //$NON-NLS-1$ - components.add(createUIComponent("Output")); //$NON-NLS-1$ - components.add(createUIComponent("Panel")); //$NON-NLS-1$ - components.add(createUIComponent("Parameter")); //$NON-NLS-1$ - components.add(createUIComponent("SelectBoolean")); //$NON-NLS-1$ - components.add(createUIComponent("SelectItem")); //$NON-NLS-1$ - components.add(createUIComponent("SelectItems")); //$NON-NLS-1$ - components.add(createUIComponent("SelectMany")); //$NON-NLS-1$ - components.add(createUIComponent("SelectOne")); //$NON-NLS-1$ - components.add(createUIComponent("ViewRoot")); //$NON-NLS-1$ - //create and add HTML components - components.add(createHTMLComponent("HtmlCommandButton")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlCommandLink")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlDataTable")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlForm")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlGraphicImage")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlInputHidden")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlInputSecret")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlInputText")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlInputTextarea")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlMessage")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlMessages")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlOutputFormat")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlOutputLabel")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlOutputLink")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlOutputText")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlPanelGrid")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlPanelGroup")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlSelectBooleanCheckbox")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlSelectManyCheckbox")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlSelectManyListbox")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlSelectManyMenu")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlSelectOneListbox")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlSelectOneMenu")); //$NON-NLS-1$ - components.add(createHTMLComponent("HtmlSelectOneRadio")); //$NON-NLS-1$ - } - - /** - * Creates a {@link ConverterType} instance. - * - * @param name Base name of converter from which converter-id and - * converter-class are formed. - * @return {@link ConverterType} instance. - */ - protected ConverterType createConverter(String name) { - ConverterType converterType = FacesConfigFactory.eINSTANCE.createConverterType(); - //set converter-id - ConverterIdType converterIdType = FacesConfigFactory.eINSTANCE.createConverterIdType(); - StringBuffer sb = new StringBuffer(); - sb.append("javax.faces."); //$NON-NLS-1$ - sb.append(name); - converterIdType.setTextContent(sb.toString()); - converterType.setConverterId(converterIdType); - //set converter-class - ConverterClassType converterClassType = FacesConfigFactory.eINSTANCE.createConverterClassType(); - sb = new StringBuffer(); - sb.append("javax.faces.convert."); //$NON-NLS-1$ - sb.append(name); - sb.append("Converter"); //$NON-NLS-1$ - converterClassType.setTextContent(sb.toString()); - converterType.setConverterClass(converterClassType); - return converterType; - } - - /** - * Creates a {@link ValidatorType} instance. - * - * @param name Base name of validator from which validator-id and - * validator-class are formed. - * @return {@link ValidatorType} instance. - */ - protected ValidatorType createValidator(String name) { - ValidatorType validatorType = FacesConfigFactory.eINSTANCE.createValidatorType(); - //set validator-id - ValidatorIdType validatorIdType = FacesConfigFactory.eINSTANCE.createValidatorIdType(); - StringBuffer sb = new StringBuffer(); - sb.append("javax.faces."); //$NON-NLS-1$ - sb.append(name); - validatorIdType.setTextContent(sb.toString()); - validatorType.setValidatorId(validatorIdType); - //set validator-class - ValidatorClassType validatorClassType = FacesConfigFactory.eINSTANCE.createValidatorClassType(); - sb = new StringBuffer(); - sb.append("javax.faces.validator."); //$NON-NLS-1$ - sb.append(name); - sb.append("Validator"); //$NON-NLS-1$ - validatorClassType.setTextContent(sb.toString()); - validatorType.setValidatorClass(validatorClassType); - return validatorType; - } - - /** - * Creates a {@link ComponentType} instance to represent a standard UI - * component. - * - * @param name Base name of component from which component-type and - * component-class are formed. - * @return {@link ComponentType} instance. - */ - protected ComponentType createUIComponent(String name) { - ComponentType componentType = FacesConfigFactory.eINSTANCE.createComponentType(); - //set component-type - ComponentTypeType componentTypeType = FacesConfigFactory.eINSTANCE.createComponentTypeType(); - StringBuffer sb = new StringBuffer(); - sb.append("javax.faces."); //$NON-NLS-1$ - sb.append(name); - componentTypeType.setTextContent(sb.toString()); - componentType.setComponentType(componentTypeType); - //set component-class - ComponentClassType componentClassType = FacesConfigFactory.eINSTANCE.createComponentClassType(); - sb = new StringBuffer(); - sb.append("javax.faces.component.UI"); //$NON-NLS-1$ - sb.append(name); - componentClassType.setTextContent(sb.toString()); - componentType.setComponentClass(componentClassType); - return componentType; - } - - /** - * Creates a {@link ComponentType} instance to represent a concrete HTML - * component. - * - * @param name Base name of component from which component-type and - * component-class are formed. - * @return {@link ComponentType} instance. - */ - protected ComponentType createHTMLComponent(String name) { - ComponentType componentType = FacesConfigFactory.eINSTANCE.createComponentType(); - //set component-type - ComponentTypeType componentTypeType = FacesConfigFactory.eINSTANCE.createComponentTypeType(); - StringBuffer sb = new StringBuffer(); - sb.append("javax.faces."); //$NON-NLS-1$ - sb.append(name); - componentTypeType.setTextContent(sb.toString()); - componentType.setComponentType(componentTypeType); - //set component-class - ComponentClassType componentClassType = FacesConfigFactory.eINSTANCE.createComponentClassType(); - sb = new StringBuffer(); - sb.append("javax.faces.component.html."); //$NON-NLS-1$ - sb.append(name); - componentClassType.setTextContent(sb.toString()); - componentType.setComponentClass(componentClassType); - return componentType; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object otherObject) { - boolean equals = false; - if (otherObject instanceof ImplicitRuntimeJSFAppConfigProvider) { - equals = true; - } - return equals; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return ImplicitRuntimeJSFAppConfigProvider.class.getName().hashCode(); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - return "ImplicitRuntimeJSFAppConfigProvider[]"; //$NON-NLS-1$ - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JARFileJSFAppConfigProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JARFileJSFAppConfigProvider.java deleted file mode 100644 index 84eca2239..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JARFileJSFAppConfigProvider.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.io.IOException; -import java.util.Collections; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.util.FacesConfigResourceFactory; -import org.eclipse.osgi.util.NLS; - -/** - * JARFileJSFAppConfigProvider provides the root element of an application - * configuration model by loading the model from a /META-INF/faces-config.xml - * entry in a JAR file. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class JARFileJSFAppConfigProvider extends AbstractJSFAppConfigProvider { - - /** - * Prefix required to turn filename into a JAR URI. - */ - public static final String JARFILE_URI_PREFIX = "jar:file:///"; - - /** - * Suffix required to turn filename into a JAR URI. - */ - public static final String FACES_CONFIG_IN_JAR_SUFFIX = "!/META-INF/faces-config.xml"; - - /** - * Name of a JAR file that contains a /META-INF/faces-config.xml entry. - */ - protected String filename = null; - - /** - * Cached {@link FacesConfigType} instance. - */ - protected FacesConfigType facesConfig = null; - - /** - * Flag to track if load error has been logged at least once. - */ - protected boolean loadErrorLogged = false; - - /** - * Creates an instance, storing the passed IProject instance and file name - * String to be used for subsequent processing. - * - * @param filename Name of a JAR file that contains a - * /META-INF/faces-config.xml entry. - */ - public JARFileJSFAppConfigProvider(String filename) { - this.filename = filename; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#getFacesConfigModel() - */ - public FacesConfigType getFacesConfigModel() { - // TODO: should this job be pushed into the model? - if (facesConfig == null) { - if (filename != null) { - StringBuffer sb = new StringBuffer(); - sb.append(JARFILE_URI_PREFIX); - sb.append(filename); - sb.append(FACES_CONFIG_IN_JAR_SUFFIX); - URI jarFileURI = URI.createURI(sb.toString()); - FacesConfigResourceFactory resourceFactory = FacesConfigResourceFactory.createResourceFactoryForJar(); - Resource resource = resourceFactory.createResource(jarFileURI); - try { - resource.load(Collections.EMPTY_MAP); - if (resource != null) { - EList resourceContents = resource.getContents(); - if (resourceContents != null && resourceContents.size() > 0) { - facesConfig = (FacesConfigType)resourceContents.get(0); - if (facesConfig != null) { - jsfAppConfigLocater.getJSFAppConfigManager().addFacesConfigChangeAdapter(facesConfig); - } - } - } - } catch(IllegalStateException ise) { - //log error - logLoadError(ise); - } catch(IOException ioe) { - //log error - logLoadError(ioe); - } - } - } - return facesConfig; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.IJSFAppConfigProvider#releaseFacesConfigModel() - */ - public void releaseFacesConfigModel() { - jsfAppConfigLocater.getJSFAppConfigManager().removeFacesConfigChangeAdapter(facesConfig); - } - - /** - * Called to log a load error; load error will be logged once only per - * instance, per VM session. - * - * @param ex Throwable instance to be logged. - */ - protected void logLoadError(Throwable ex) { - if (!loadErrorLogged) { - JSFCorePlugin.log( - IStatus.ERROR, - NLS.bind(Messages.JARFileJSFAppConfigProvider_ErrorLoadingModel, JARFILE_URI_PREFIX + filename + FACES_CONFIG_IN_JAR_SUFFIX), - ex); - loadErrorLogged = true; - } - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object otherObject) { - boolean equals = false; - if (otherObject instanceof JARFileJSFAppConfigProvider) { - String otherFilename = ((JARFileJSFAppConfigProvider)otherObject).filename; - if (filename != null) { - equals = filename.equals(otherFilename); - } else { - equals = otherFilename == null; - } - } - return equals; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return filename != null ? filename.hashCode() : 0; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer sb = new StringBuffer("JARFileJSFAppConfigProvider["); //$NON-NLS-1$ - if (filename != null) { - sb.append(filename); - } else { - sb.append("null"); //$NON-NLS-1$ - } - sb.append("]"); //$NON-NLS-1$ - return sb.toString(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigManager.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigManager.java deleted file mode 100644 index 381fc67f5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigManager.java +++ /dev/null @@ -1,746 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -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.IStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.FromViewIdType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; - -/** - * JSFAppConfigManager provides an entry point to an entire JSF application - * configuration, which is defined in one or more application configuration - * resource files. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class JSFAppConfigManager implements IResourceChangeListener { - - /** - * Key that is used for the IProject instance's session property that - * holds a JSFAppConfigManager instance. - */ - public static final QualifiedName KEY_SESSIONPROPERTY = - new QualifiedName(JSFCorePlugin.PLUGIN_ID, "JSFAppConfigManager"); //$NON-NLS-1$ - - /** - * IProject instance to which this JSFAppConfigManager instance is keyed. - */ - protected IProject project = null; - - /** - * Collection of {@link IJSFAppConfigLocater} instances. - */ - protected List configLocaters = null; - - /** - * Collection of {@link IJSFAppConfigProvidersChangeListener} instances. - */ - protected List configProvidersChangeListeners = null; - - /** - * Map of application configuration model EMF classes to - * {@link IFacesConfigChangeListener} instances. - */ - protected Map facesConfigChangeListeners = null; - - /** - * Single {@link FacesConfigChangeAdapter} instance. - */ - protected FacesConfigChangeAdapter facesConfigChangeAdapter = null; - - /** - * Gets a JSFAppConfigManager instance that is keyed to the passed IProject - * parameter. May return null if the project is not valid or if a - * CoreException is thrown while attempting to get or set the instance as - * a session property. - * - * @param project IProject instance to which the returned - * JSFAppConfigManager instance is keyed. - * @return JSFAppConfigManager instance, or null. - */ - public static synchronized JSFAppConfigManager getInstance(IProject project) { - JSFAppConfigManager manager = null; - if (JSFAppConfigUtils.isValidJSFProject(project)) { - manager = getFromSessionProperty(project); - if (manager == null) { - manager = new JSFAppConfigManager(project); - } - } - return manager; - } - - /** - * Attempts to get a JSFAppConfigManager instance from a session property - * of the passed IProject instance. Will return null if the session - * property has not yet been set. - * - * @param project IProject instance from which to retrieve the - * JSFAppConfigManager instance. - * @return JSFAppConfigManager instance, or null. - */ - protected static JSFAppConfigManager getFromSessionProperty(IProject project) { - JSFAppConfigManager manager = null; - try { - Object obj = project.getSessionProperty(KEY_SESSIONPROPERTY); - if (obj != null && obj instanceof JSFAppConfigManager) { - manager = (JSFAppConfigManager)obj; - } - } catch(CoreException ce) { - //log error - JSFCorePlugin.log(IStatus.ERROR, ce.getLocalizedMessage(), ce); - } - return manager; - } - - /** - * Sets this JSFAppConfigManager instance as a session property of its - * IProject instance. - */ - protected void setAsSessionProperty() { - if (project != null && project.isAccessible()) { - try { - project.setSessionProperty(KEY_SESSIONPROPERTY, this); - } catch(CoreException ce) { - //log error - JSFCorePlugin.log(IStatus.ERROR, ce.getLocalizedMessage(), ce); - } - } - } - - /** - * Unsets this JSFAppConfigManager instance as a session property of its - * IProject instance. - */ - protected void unsetAsSessionProperty() { - if (project != null && project.isAccessible()) { - try { - project.setSessionProperty(KEY_SESSIONPROPERTY, null); - } catch(CoreException ce) { - //log error - JSFCorePlugin.log(IStatus.ERROR, ce.getLocalizedMessage(), ce); - } - } - } - - /** - * Constructor is private to prevent direct instantiation; call - * getInstance(IProject). - * - * @param project IProject instance to which the new JSFAppConfigManager - * instance is keyed. - */ - private JSFAppConfigManager(IProject project) { - this.project = project; - initialize(); - } - - /** - * Gets this instance's IProject instance. - * - * @return This instance's IProject instance. - */ - public IProject getProject() { - return project; - } - - /** - * Initializes instance by: - * <ul> - * <li>creating facesConfigChangeListeners collection, </li> - * <li>creating configProvidersChangeListeners collection, </li> - * <li>creating and populating configLocaters collection, </li> - * <li>invoking the startLocating() method on all configLocaters, </li> - * <li>setting instance as a session property of the IProject instance, </li> - * <li>adding a resource change listener to the workspace.</li> - * </ul> - */ - protected void initialize() { - //create collections - facesConfigChangeListeners = new HashMap(); - configProvidersChangeListeners = new ArrayList(); - configLocaters = new ArrayList(); - //populate initial set of locaters - populateConfigLocaters(); - //instruct locaters to start locating - startConfigLocaters(); - //set as session property of project - setAsSessionProperty(); - //add resource change listener - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); - } - - /** - * Populates configLocaters Set with "built-in" set of - * {@link IJSFAppConfigLocater} implementations. - */ - protected void populateConfigLocaters() { - //implicit runtime-provided configuration - IJSFAppConfigLocater implicitRuntimeConfigLocater = new ImplicitRuntimeJSFAppConfigLocater(); - implicitRuntimeConfigLocater.setJSFAppConfigManager(this); - configLocaters.add(implicitRuntimeConfigLocater); - //default ("/WEB-INF/faces-config.xml") locater - IJSFAppConfigLocater defaultConfigLocater = new DefaultJSFAppConfigLocater(); - defaultConfigLocater.setJSFAppConfigManager(this); - configLocaters.add(defaultConfigLocater); - //web.xml context-parameter specified locater - IJSFAppConfigLocater contextParamConfigLocater = new ContextParamSpecifiedJSFAppConfigLocater(); - contextParamConfigLocater.setJSFAppConfigManager(this); - configLocaters.add(contextParamConfigLocater); - //runtime classpath locater - IJSFAppConfigLocater classpathConfigLocater = new RuntimeClasspathJSFAppConfigLocater(); - classpathConfigLocater.setJSFAppConfigManager(this); - configLocaters.add(classpathConfigLocater); - } - - /** - * Instructs set of {@link IJSFAppConfigLocater} instances to start - * locating JSF application configuration resources. - */ - protected void startConfigLocaters() { - Iterator itConfigLocaters = configLocaters.iterator(); - while (itConfigLocaters.hasNext()) { - IJSFAppConfigLocater configLocater = (IJSFAppConfigLocater)itConfigLocaters.next(); - configLocater.startLocating(); - } - } - - /** - * Instructs set of {@link IJSFAppConfigLocater} instances to stop - * locating JSF application configuration resources. - */ - protected void stopConfigLocaters() { - Iterator itConfigLocaters = configLocaters.iterator(); - while (itConfigLocaters.hasNext()) { - IJSFAppConfigLocater configLocater = (IJSFAppConfigLocater)itConfigLocaters.next(); - configLocater.stopLocating(); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - if (delta.getKind() == IResourceDelta.CHANGED) { - IResourceDelta[] removedDeltas = delta.getAffectedChildren(IResourceDelta.REMOVED); - if (removedDeltas.length == 1) { - IResourceDelta removedDelta = removedDeltas[0]; - IResource removedResource = removedDelta.getResource(); - if (removedResource != null && removedResource == project) { - IResourceDelta[] addedDeltas = delta.getAffectedChildren(IResourceDelta.ADDED); - if (addedDeltas.length == 1) { - IResourceDelta addedDelta = addedDeltas[0]; - IResource addedResource = addedDelta.getResource(); - if (addedResource != null && addedResource instanceof IProject) { - changeProject((IProject)addedResource); - } - } - } - } - } - } - - /** - * Called to respond to a change in the IProject instance to which this - * instance belongs. Changes the cached IProject instance, stops all config - * locaters, starts all config locaters. - * - * @param newProject New IProject instance to which this manager belongs. - */ - protected void changeProject(IProject newProject) { - this.project = newProject; - stopConfigLocaters(); - startConfigLocaters(); - } - - /** - * Adds an instance of {@link IJSFAppConfigProvidersChangeListener}. - * - * @param listener An instance of {@link IJSFAppConfigProvidersChangeListener}. - * @return true if added, else false. - */ - public boolean addJSFAppConfigProvidersChangeListener(IJSFAppConfigProvidersChangeListener listener) { - return configProvidersChangeListeners.add(listener); - } - - /** - * Removes an instance of {@link IJSFAppConfigProvidersChangeListener}. - * - * @param listener an instance of {@link IJSFAppConfigProvidersChangeListener}. - * @return true if removed, else false. - */ - public boolean removeJSFAppConfigProvidersChangeListener(IJSFAppConfigProvidersChangeListener listener) { - return configProvidersChangeListeners.remove(listener); - } - - /** - * Notifies all {@link IJSFAppConfigProvidersChangeListener} instances of - * a change in the Set of {@link IJSFAppConfigProvider} instances. - * - * @param configProvider {@link IJSFAppConfigProvider} instance that has - * changed. - * @param eventType Event type. - */ - public void notifyJSFAppConfigProvidersChangeListeners(IJSFAppConfigProvider configProvider, int eventType) { - JSFAppConfigProvidersChangeEvent event = new JSFAppConfigProvidersChangeEvent(configProvider, eventType); - Iterator itListeners = configProvidersChangeListeners.iterator(); - while (itListeners.hasNext()) { - IJSFAppConfigProvidersChangeListener listener = - (IJSFAppConfigProvidersChangeListener)itListeners.next(); - listener.changedJSFAppConfigProviders(event); - } - } - - /** - * Adds an instance of {@link IFacesConfigChangeListener}. <br> - * <br> - * <b>NOTE:</b> Calling this method will cause all application - * configuration models to be loaded, to ensure that a - * {@link FacesConfigChangeAdapter} has been added to each model. - * - * @param emfClass EMF class in which the listener is interested. - * @param listener {@link IFacesConfigChangeListener} instance. - * @return Previous {@link IFacesConfigChangeListener}, or null. - */ - public Object addFacesConfigChangeListener(Class emfClass, IFacesConfigChangeListener listener) { - /* - * Get all models, which will ensure that each one has had a - * FacesConfigChangeAdapter added to it. - */ - getFacesConfigModels(); - return facesConfigChangeListeners.put(emfClass, listener); - } - - /** - * Removes an instance of {@link IFacesConfigChangeListener}. - * - * @param emfClass EMF class in which the listener was interested. - * @return Removed {@link IFacesConfigChangeListener}, or null. - */ - public Object removeFacesConfigChangeListener(Class emfClass) { - return facesConfigChangeListeners.remove(emfClass); - } - - /** - * Notifies {@link IFacesConfigChangeListener} instances of model changes - * in which they registered interest. - * - * @param notification EMF {@link Notification} instance that describes the - * model change. - */ - public void notifyFacesConfigChangeListeners(Notification notification) { - Object emfFeature = notification.getFeature(); - if (emfFeature != null && emfFeature instanceof EStructuralFeature) { - Class emfClass = ((EStructuralFeature)emfFeature).getEType().getInstanceClass(); - IFacesConfigChangeListener listener = (IFacesConfigChangeListener)facesConfigChangeListeners.get(emfClass); - if (listener != null) { - listener.notifyChanged(notification); - } - } - } - - /** - * Gets all {@link IJSFAppConfigProvider} instances from all - * {@link IJSFAppConfigLocater} instances. - * - * @return Set of all {@link IJSFAppConfigProvider} instances. - */ - public Set getJSFAppConfigProviders() { - Set allConfigProviders = new LinkedHashSet(); - Iterator itConfigLocaters = configLocaters.iterator(); - while (itConfigLocaters.hasNext()) { - IJSFAppConfigLocater configLocater = (IJSFAppConfigLocater)itConfigLocaters.next(); - allConfigProviders.addAll(configLocater.getJSFAppConfigProviders()); - } - return allConfigProviders; - } - - /** - * Gets all {@link FacesConfigType} instances from all - * {@link IJSFAppConfigProvider} instances. - * - * @return List of all {@link FacesConfigType} instances. - */ - public List getFacesConfigModels() { - List facesConfigModels = new ArrayList(); - Iterator itConfigProviders = getJSFAppConfigProviders().iterator(); - while (itConfigProviders.hasNext()) { - IJSFAppConfigProvider configProvider = (IJSFAppConfigProvider)itConfigProviders.next(); - FacesConfigType facesConfig = configProvider.getFacesConfigModel(); - if (facesConfig != null) { - facesConfigModels.add(facesConfig); - } - } - return facesConfigModels; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#finalize() - */ - protected void finalize() { - //remove resource change listener - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.removeResourceChangeListener(this); - //remove session property from project - unsetAsSessionProperty(); - //instruct locaters to stop locating - stopConfigLocaters(); - //clear collections - configLocaters.clear(); - configProvidersChangeListeners.clear(); - facesConfigChangeListeners.clear(); - } - - /** - * Gets list of all ManagedBeanType instances from all known faces-config - * models; list may be empty. - * - * @return List of all ManagedBeanType instances from all known - * faces-config models (list may be empty). - */ - public List getManagedBeans() { - List allManagedBeans = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList managedBeans = facesConfig.getManagedBean(); - allManagedBeans.addAll(managedBeans); - } - return allManagedBeans; - } - - /** - * Gets list of all ValidatorType instances from all known faces-config - * models; list may be empty. - * - * @return List of all ValidatorType instances from all known faces-config - * models (list may be empty). - */ - public List getValidators() { - List allValidators = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList validators = facesConfig.getValidator(); - allValidators.addAll(validators); - } - return allValidators; - } - - /** - * Gets list of all ConverterType instances from all known faces-config - * models; list may be empty. - * - * @return List of all ConverterType instances from all known faces-config - * models (list may be empty). - */ - public List getConverters() { - List allConverters = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList converters = facesConfig.getConverter(); - allConverters.addAll(converters); - } - return allConverters; - } - - /** - * Gets list of all NavigationRuleType instances from all known - * faces-config models; list may be empty. - * - * @return List of all NavigationRuleType instances from all known - * faces-config models (list may be empty). - */ - public List getNavigationRules() { - List allNavigationRules = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList navigationRules = facesConfig.getNavigationRule(); - allNavigationRules.addAll(navigationRules); - } - return allNavigationRules; - } - - /** - * Gets list of all NavigationRuleType instances from all known - * faces-config models where the navigation-rule's from-view-id value - * matches the web content folder-relative value of the passed IFile - * instance; list may be empty. Matching is performed in the same manner - * as for a JSF implementation's default NavigationHandler. - * - * @param pageFile IFile instance to match against the from-view-id value - * of all NavigationRuleType instances. File is assumed to be relative to - * the web content folder, but may be expressed in a more complete form; - * its path will be calculated relative to the web content folder. - * @return List of all NavigationRuleType instances from all known - * faces-config models where the navigation-rule's from-view-id value - * matches the web content folder-relative value of the passed IFile - * instance (list may be empty). - */ - public List getNavigationRulesForPage(IFile pageFile) { - List navigationRulesForPage = new ArrayList(); - IPath pageFilePath = JSFAppConfigUtils.getWebContentFolderRelativePath(pageFile); - if (pageFilePath != null) { - String pageFileString = pageFilePath.toString(); - if (!pageFileString.startsWith("/")) { - pageFileString = "/" + pageFileString; - } - List navigationRules = getNavigationRules(); - Iterator itNavigationRules = navigationRules.iterator(); - while (itNavigationRules.hasNext()) { - NavigationRuleType navigationRule = (NavigationRuleType)itNavigationRules.next(); - FromViewIdType fromViewIdType = navigationRule.getFromViewId(); - if (fromViewIdType != null) { - String fromViewId = fromViewIdType.getTextContent(); - if (fromViewId != null && fromViewId.length() > 0) { - if (!fromViewId.equals("*")) { //$NON-NLS-1$ - if (fromViewId.equals(pageFileString)) { - //exact match - navigationRulesForPage.add(navigationRule); - } else if (fromViewId.endsWith("*")) { //$NON-NLS-1$ - String prefixFromViewId = fromViewId.substring(0, fromViewId.length() - 1); - if (pageFileString.startsWith(prefixFromViewId)) { - //prefix match - navigationRulesForPage.add(navigationRule); - } - } - } else { - //from-view-id == "*" - matches all pages - navigationRulesForPage.add(navigationRule); - } - } - } else { - //no from-view-id element - matches all pages - navigationRulesForPage.add(navigationRule); - } - } - } - return navigationRulesForPage; - } - - /** - * Gets list of all ApplicationType instances from all known - * faces-config models; list may be empty. - * - * @return List of all ApplicationType instances from all known - * faces-config models (list may be empty). - */ - public List getApplications() { - List allApplications = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList applications = facesConfig.getApplication(); - allApplications.addAll(applications); - } - return allApplications; - } - - /** - * Gets list of all FactoryType instances from all known faces-config - * models; list may be empty. - * - * @return List of all FactoryType instances from all known faces-config - * models (list may be empty). - */ - public List getFactories() { - List allFactories = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList factories = facesConfig.getFactory(); - allFactories.addAll(factories); - } - return allFactories; - } - - /** - * Gets list of all ComponentType instances from all known faces-config - * models; list may be empty. - * - * @return List of all ComponentType instances from all known faces-config - * models (list may be empty). - */ - public List getComponents() { - List allComponents = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList components = facesConfig.getComponent(); - allComponents.addAll(components); - } - return allComponents; - } - - /** - * Gets list of all ReferencedBeanType instances from all known - * faces-config models; list may be empty. - * - * @return List of all ReferencedBeanType instances from all known - * faces-config models (list may be empty). - */ - public List getReferencedBeans() { - List allReferencedBeans = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList referencedBeans = facesConfig.getReferencedBean(); - allReferencedBeans.addAll(referencedBeans); - } - return allReferencedBeans; - } - - /** - * Gets list of all RenderKitType instances from all known faces-config - * models; list may be empty. - * - * @return List of all RenderKitType instances from all known faces-config - * models (list may be empty). - */ - public List getRenderKits() { - List allRenderKits = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList renderKits = facesConfig.getRenderKit(); - allRenderKits.addAll(renderKits); - } - return allRenderKits; - } - - /** - * Gets list of all LifecycleType instances from all known faces-config - * models; list may be empty. - * - * @return List of all LifecycleType instances from all known faces-config - * models (list may be empty). - */ - public List getLifecycles() { - List allLifecycles = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - EList lifecycles = facesConfig.getLifecycle(); - allLifecycles.addAll(lifecycles); - } - return allLifecycles; - } - - /** - * @return the list of all resource bundles declared in all the FacesConfig - * configurations found. - */ - public List getResourceBundles() - { - List allResourceBundles = new ArrayList(); - List facesConfigs = getFacesConfigModels(); - Iterator itFacesConfigs = facesConfigs.iterator(); - while (itFacesConfigs.hasNext()) { - FacesConfigType facesConfig = (FacesConfigType)itFacesConfigs.next(); - for (final Iterator applicationIt = facesConfig.getApplication().iterator(); applicationIt.hasNext();) - { - ApplicationType appType = (ApplicationType) applicationIt.next(); - allResourceBundles.addAll(appType.getResourceBundle()); - } - } - return allResourceBundles; - } - - /** - * Adds this instance's {@link FacesConfigChangeAdapter} instance to the - * passed application configuration model's adapters collection. - * - * @param facesConfig Application configuration model's root object. - */ - public void addFacesConfigChangeAdapter(FacesConfigType facesConfig) { - if (facesConfig != null) { - if (facesConfigChangeAdapter == null) { - facesConfigChangeAdapter = new FacesConfigChangeAdapter(); - } - facesConfig.eAdapters().add(facesConfigChangeAdapter); - } - } - - /** - * Removes this instance's {@link FacesConfigChangeAdapter} instance from - * the passed application configuration model's adapters collection. - * - * @param facesConfig Application configuration model's root object. - */ - public void removeFacesConfigChangeAdapter(FacesConfigType facesConfig) { - if (facesConfig != null && facesConfigChangeAdapter != null) { - facesConfig.eAdapters().remove(facesConfigChangeAdapter); - } - } - - /** - * FacesConfigChangeAdapter is an EMF adapter which provides a mechanism - * for notification of changes to features in any application configuration - * model for which {@link IFacesConfigChangeListener} instances have - * registered an interest. - * - * @author Ian Trimble - Oracle - */ - class FacesConfigChangeAdapter extends EContentAdapter { - /* - * (non-Javadoc) - * @see org.eclipse.emf.ecore.util.EContentAdapter#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification notification) { - super.notifyChanged(notification); - notifyFacesConfigChangeListeners(notification); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigProvidersChangeEvent.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigProvidersChangeEvent.java deleted file mode 100644 index a946e4c02..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigProvidersChangeEvent.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -/** - * JSFAppConfigProvidersChangeEvent provides change information to instances of - * IJSFAppConfigProvidersChangeListener. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class JSFAppConfigProvidersChangeEvent { - - /** - * Event type; instance of IJSFAppConfigProvider was added (value == 1). - */ - public static final int ADDED = 1; - - /** - * Event type; instance of IJSFAppConfigProvider was removed (value == 2). - */ - public static final int REMOVED = 2; - - /** - * Instance of IJSFAppConfigProvider that was added or removed. - */ - protected IJSFAppConfigProvider configProvider = null; - - /** - * Event type. - */ - protected int eventType; - - /** - * Constructs an instance. - * - * @param configProvider Instance of IJSFAppConfigProvider that was added - * or removed - * @param eventType Event type - */ - public JSFAppConfigProvidersChangeEvent(IJSFAppConfigProvider configProvider, int eventType) { - this.configProvider = configProvider; - this.eventType = eventType; - } - - /** - * Gets the instance of IJSFAppConfigProvider that was added or removed. - * - * @return Instance of IJSFAppConfigProvider that was added or removed - */ - public IJSFAppConfigProvider getJSFAppConfigProvider() { - return configProvider; - } - - /** - * Gets the event type. - * - * @return Event type - */ - public int getEventType() { - return eventType; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigUtils.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigUtils.java deleted file mode 100644 index b9593f6e7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/JSFAppConfigUtils.java +++ /dev/null @@ -1,364 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.StringTokenizer; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.j2ee.common.ParamValue; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.webapplication.ContextParam; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * JSFAppConfigUtils provides utility methods useful in processing of a JSF - * application configuration. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class JSFAppConfigUtils { - - /** - * Name of JSF CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES"). - */ - public static final String CONFIG_FILES_CONTEXT_PARAM_NAME = "javax.faces.CONFIG_FILES"; //$NON-NLS-1$ - - /** - * Location in JAR file of application configuration resource file - * ("META-INF/faces-config.xml"). - */ - public static final String FACES_CONFIG_IN_JAR_PATH = "META-INF/faces-config.xml"; //$NON-NLS-1$ - - - /** - * @param project - * @param minVersion - * @return true if project is a JSF facet project and the version of the project - * is at least minVersion. - */ - public static boolean isValidJSFProject(IProject project, String minVersion) - { - boolean isValid = false; - - final IProjectFacetVersion projectFacetVersion = getProjectFacet(project); - - if (projectFacetVersion != null) - { - try - { - final String versionString = - projectFacetVersion.getVersionString(); - final Comparator comparator = - projectFacetVersion.getProjectFacet().getVersionComparator(); - final int compareToMin = - comparator.compare(versionString, minVersion); - - if (compareToMin >=0) - { - return true; - } - } - catch (CoreException ce) - { - JSFCorePlugin.log(ce, "Error checking facet version"); //$NON-NLS-1$ - } - } - return isValid; - } - - /** - * Tests if the passed IProject instance is a valid JSF project in the - * following ways: - * <ul> - * <li>project is not null and is accessible, </li> - * <li>project has the JSF facet set on it.</li> - * </ul> - * - * @param project IProject instance to be tested. - * @return true if the IProject instance is a valid JSF project, else - * false. - */ - public static boolean isValidJSFProject(IProject project) { - boolean isValid = false; - IProjectFacetVersion projectFacet = getProjectFacet(project); - if (projectFacet != null) - { - isValid = true; - } - return isValid; - } - /** - * Get the facet version for the project - * @param project - * @return the project facet version or null if could not be found or if - * project is not accessible - */ - public static IProjectFacetVersion getProjectFacet(IProject project) - { - //check for null or inaccessible project - if (project != null && project.isAccessible()) { - //check for JSF facet on project - try { - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - if (facetedProject != null) { - Set projectFacets = facetedProject.getProjectFacets(); - Iterator itProjectFacets = projectFacets.iterator(); - while (itProjectFacets.hasNext()) { - IProjectFacetVersion projectFacetVersion = (IProjectFacetVersion)itProjectFacets.next(); - if (IJSFCoreConstants.JSF_CORE_FACET_ID.equals(projectFacetVersion.getProjectFacet().getId())) - { - return projectFacetVersion; - } - } - } - } catch(CoreException ce) { - //log error - JSFCorePlugin.log(IStatus.ERROR, ce.getLocalizedMessage(), ce); - } - } - return null; - } - - /** - * Gets an IVirtualFolder instance which represents the root context's - * web content folder. - * - * @param project IProject instance for which to get the folder. - * @return IVirtualFolder instance which represents the root context's - * web content folder. - */ - public static IVirtualFolder getWebContentFolder(IProject project) { - IVirtualFolder folder = null; - IVirtualComponent component = ComponentCore.createComponent(project); - if (component != null) { - folder = component.getRootFolder(); - } - return folder; - } - - /** - * Gets an IPath instance representing the path of the passed IFile - * instance relative to the web content folder. - * - * @param file IFile instance for which a path is required. - * @return IPath instance representing the path relative to the web content - * folder. - */ - public static IPath getWebContentFolderRelativePath(IFile file) { - IPath path = null; - if (file != null) { - IVirtualFolder webContentFolder = getWebContentFolder(file.getProject()); - if (webContentFolder != null) { - IPath webContentPath = webContentFolder.getProjectRelativePath(); - IPath filePath = file.getProjectRelativePath(); - int matchingFirstSegments = webContentPath.matchingFirstSegments(filePath); - path = filePath.removeFirstSegments(matchingFirstSegments); - } - } - return path; - } - - /** - * Gets list of application configuration file names as listed in the JSF - * CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES"). Will return - * an empty list if WebArtifactEdit is null, if WebApp is null, if context - * parameter does not exist, or if trimmed context parameter's value is - * an empty String. - * - * @param project IProject instance for which to get the context - * parameter's value. - * @return List of application configuration file names as listed in the - * JSF CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES"); list - * may be empty. - */ - public static List getConfigFilesFromContextParam(IProject project) { - List filesList = Collections.EMPTY_LIST; - if (isValidJSFProject(project)) { - IModelProvider provider = ModelProviderManager.getModelProvider(project); - Object webAppObj = provider.getModelObject(); - if (webAppObj != null){ - if (webAppObj instanceof WebApp) - filesList = getConfigFilesForJ2EEApp(project); - else if (webAppObj instanceof org.eclipse.jst.javaee.web.WebApp) - filesList = getConfigFilesForJEEApp((org.eclipse.jst.javaee.web.WebApp)webAppObj); - } - - } - return filesList; - } - - private static List getConfigFilesForJEEApp(org.eclipse.jst.javaee.web.WebApp webApp) { - String filesString = null; - List contextParams = webApp.getContextParams(); - Iterator itContextParams = contextParams.iterator(); - while (itContextParams.hasNext()) { - org.eclipse.jst.javaee.core.ParamValue paramValue = (org.eclipse.jst.javaee.core.ParamValue)itContextParams.next(); - if (paramValue.getParamName().equals(CONFIG_FILES_CONTEXT_PARAM_NAME)) { - filesString = paramValue.getParamValue(); - break; - } - } - return parseFilesString(filesString); - } - - private static List getConfigFilesForJ2EEApp(IProject project){ - List filesList = new ArrayList(); - WebArtifactEdit webArtifactEdit = WebArtifactEdit.getWebArtifactEditForRead(project); - if (webArtifactEdit != null) { - try { - WebApp webApp = null; - try { - webApp = webArtifactEdit.getWebApp(); - } catch(ClassCastException cce) { - //occasionally thrown from WTP code in RC3 and possibly later - JSFCorePlugin.log(IStatus.ERROR, cce.getLocalizedMessage(), cce); - return filesList; - } - if (webApp != null) { - String filesString = null; - //need to branch here due to model version differences (BugZilla #119442) - if (webApp.getVersionID() == J2EEVersionConstants.WEB_2_3_ID) { - EList contexts = webApp.getContexts(); - Iterator itContexts = contexts.iterator(); - while (itContexts.hasNext()) { - ContextParam contextParam = (ContextParam)itContexts.next(); - if (contextParam.getParamName().equals(CONFIG_FILES_CONTEXT_PARAM_NAME)) { - filesString = contextParam.getParamValue(); - break; - } - } - } else { - EList contextParams = webApp.getContextParams(); - Iterator itContextParams = contextParams.iterator(); - while (itContextParams.hasNext()) { - ParamValue paramValue = (ParamValue)itContextParams.next(); - if (paramValue.getName().equals(CONFIG_FILES_CONTEXT_PARAM_NAME)) { - filesString = paramValue.getValue(); - break; - } - } - } - filesList = parseFilesString(filesString); - } - } finally { - webArtifactEdit.dispose(); - } - } - - return filesList; - } - - private static List parseFilesString(String filesString) { - List filesList = new ArrayList(); - if (filesString != null && filesString.trim().length() > 0) { - StringTokenizer stFilesString = new StringTokenizer(filesString, ","); //$NON-NLS-1$ - while (stFilesString.hasMoreTokens()) { - String configFile = stFilesString.nextToken().trim(); - filesList.add(configFile); - } - } - return filesList; - } - - /** - * Gets list of JAR file names, where each file name represents a JAR on - * the classpath that contains a /META-INF/faces-config.xml entry. Will - * return an empty list if no such JAR files are located. - * - * @param project IProject instance for which to scan the classpath. - * @return List of JAR file names, where each file name represents a JAR - * on the classpath that contains a ...META-INF/faces-config.xml entry; - * list may be empty. - * @throws CoreException Thrown when underlying calls into JavaCore fail. - * @throws IOException Thrown when attempt to open JAR to determine if it - * contains a /META-INF/faces-config.xml entry fails. - */ - public static List getConfigFileJARsFromClasspath(IProject project) throws CoreException, IOException { - ArrayList JARsList = new ArrayList(); - if (project.isAccessible() - && project.hasNature(JavaCore.NATURE_ID)) { - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null) { - IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true); - if (classpathEntries != null && classpathEntries.length > 0) { - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - for (int i = 0; i < classpathEntries.length; i++) { - IClasspathEntry classpathEntry = classpathEntries[i]; - if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { - IPath libraryPath = classpathEntry.getPath(); - if (libraryPath.getFileExtension() != null && libraryPath.getFileExtension().length() > 0) { - if (libraryPath.getDevice() == null && workspaceRoot.getProject(libraryPath.segment(0)).exists()) { - libraryPath = workspaceRoot.getFile(libraryPath).getLocation(); - } - String libraryPathString = libraryPath.toString(); - JarFile jarFile = null; - try { - jarFile = new JarFile(libraryPathString); - if (jarFile != null) { - JarEntry jarEntry = jarFile.getJarEntry(FACES_CONFIG_IN_JAR_PATH); - if (jarEntry != null) { - JARsList.add(libraryPathString); - } - } - } catch(IOException ioe) { - JSFCorePlugin.log( - IStatus.ERROR, - NLS.bind(Messages.JSFAppConfigUtils_ErrorOpeningJarFile, libraryPathString), - ioe); - } finally { - if (jarFile != null) { - jarFile.close(); - } - } - } - } - } - } - } - } - return JARsList; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/RuntimeClasspathJSFAppConfigLocater.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/RuntimeClasspathJSFAppConfigLocater.java deleted file mode 100644 index 7cb04b06b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/RuntimeClasspathJSFAppConfigLocater.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.io.IOException; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.ElementChangedEvent; -import org.eclipse.jdt.core.IElementChangedListener; -import org.eclipse.jdt.core.IJavaElementDelta; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; - -/** - * RuntimeClasspathJSFAppConfigLocater attempts to locate application - * configuration files in JAR files on the runtime classpath. The runtime - * classpath includes the server runtime classpath and the JAR files that will - * be deployed to the web application's /WEB-INF/lib folder. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public class RuntimeClasspathJSFAppConfigLocater extends AbstractJSFAppConfigLocater - implements IElementChangedListener { - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#startLocating() - */ - public void startLocating() { - locateProviders(); - JavaCore.addElementChangedListener(this); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsfappconfig.AbstractJSFAppConfigLocater#stopLocating() - */ - public void stopLocating() { - JavaCore.removeElementChangedListener(this); - } - - /** - * Locates application configuration resources specified in JAR files on - * the runtime classpath, and updates the set of - * {@link IJSFAppConfigProvider} instances accordingly. - */ - public void locateProviders() { - try { - List JARs = JSFAppConfigUtils.getConfigFileJARsFromClasspath(manager.getProject()); - Iterator itJARs = JARs.iterator(); - Set newConfigProviders = new LinkedHashSet(); - while (itJARs.hasNext()) { - String JARFilename = (String)itJARs.next(); - JARFileJSFAppConfigProvider configProvider = new JARFileJSFAppConfigProvider(JARFilename); - newConfigProviders.add(configProvider); - } - updateConfigProviders(newConfigProviders); - } catch(CoreException ce) { - //log error - JSFCorePlugin.log(IStatus.ERROR, ce.getLocalizedMessage(), ce); - } catch(IOException ioe) { - //log error - JSFCorePlugin.log(IStatus.ERROR, ioe.getLocalizedMessage(), ioe); - } - } - - /** - * Called when a Java element has changed. - * - * @param event ElementChangedEvent instance describing the change. - */ - public void elementChanged(ElementChangedEvent event) { - if (classpathChanged(event.getDelta())) { - locateProviders(); - } - } - - /** - * Recursively tests if the passed IJavaElementDelta instance or any of its - * descendents indicate a classpath change has occurred. - * - * @param delta IJavaElement instance to be tested. - * @return true if a claspath change has occurred, else false. - */ - protected boolean classpathChanged(IJavaElementDelta delta) { - int deltaFlags = delta.getFlags(); - if (((deltaFlags & IJavaElementDelta.F_ADDED_TO_CLASSPATH) == IJavaElementDelta.F_ADDED_TO_CLASSPATH) || - ((deltaFlags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) == IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) || - ((deltaFlags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) == IJavaElementDelta.F_REMOVED_FROM_CLASSPATH)) { - return true; - } - boolean changed = false; - IJavaElementDelta[] childDeltas = delta.getAffectedChildren(); - if (childDeltas != null) { - for (int i = 0; i < childDeltas.length; i++) { - if (classpathChanged(childDeltas[i])) { - changed = true; - break; - } - } - } - return changed; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/WebContentRelativeJSFAppConfigLocater.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/WebContentRelativeJSFAppConfigLocater.java deleted file mode 100644 index 4359d216c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsfappconfig/WebContentRelativeJSFAppConfigLocater.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsfappconfig; - -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -/** - * WebContentRelativeJSFAppConfigLocater is an abstract base class that - * attempts to locate specified application configuration files relative to a - * web content folder. Subclasses must override the getFilenames() method to - * return a list of filenames that the locateProviders() method will attempt to - * locate, and call locateProviders(). - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author Ian Trimble - Oracle - */ -public abstract class WebContentRelativeJSFAppConfigLocater extends AbstractJSFAppConfigLocater { - - /** - * Locates application configuration resources specified by the filenames - * (relative to the web content folder) returned by getFilenames(), and - * updates the set of {@link IJSFAppConfigProvider} instances accordingly. - */ - public void locateProviders() { - IProject project = manager.getProject(); - IVirtualFolder webContentFolder = JSFAppConfigUtils.getWebContentFolder(project); - if (webContentFolder != null) { - List filenames = getFilenames(); - Iterator itFilenames = filenames.iterator(); - Set newConfigProviders = new LinkedHashSet(); - while (itFilenames.hasNext()) { - String filename = (String)itFilenames.next(); - IVirtualResource appConfigResource = webContentFolder.findMember(filename); - if (appConfigResource != null && appConfigResource.getType() == IVirtualResource.FILE) { - IFile file = (IFile)appConfigResource.getUnderlyingResource(); - if (file != null && file.exists()) { - ArtifactEditJSFAppConfigProvider configProvider = new ArtifactEditJSFAppConfigProvider(file); - newConfigProviders.add(configProvider); - } - } - } - updateConfigProviders(newConfigProviders); - } - } - - /** - * Gets a list of Strings representing the filenames (relative to the web - * content folder) that locateProviders() will attempt to locate. - * - * @return A list of Strings representing the filenames (relative to the - * web content folder) that locateProviders() will attempt to locate. - */ - protected abstract List getFilenames(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryConfigurationHelper.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryConfigurationHelper.java deleted file mode 100644 index 0f9818f67..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryConfigurationHelper.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration; - -import java.util.Collection; -import java.util.HashSet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal.JSFLibraryReferenceFacadeFactory; - -/** - * Helper class for adopters needing to deal with JSF Library References - * @since WTP JSF 1.0 - */ -public final class JSFLibraryConfigurationHelper { - /** - * container id for JSF Library Classpath Containers - */ - public static final String JSF_LIBRARY_CP_CONTAINER_ID="org.eclipse.jst.jsf.core.internal.jsflibrarycontainer"; - - /** - * @param project - * @return collection of references - */ - public static Collection<JSFLibraryReference> getJSFLibraryReferences(IProject project) { - Collection<JSFLibraryReference> results = new HashSet<JSFLibraryReference>(); - IJavaProject jproj = JavaCore.create(project); - try { - IClasspathEntry[] entries = jproj.getRawClasspath(); - boolean foundImpl = false; - for (int i=0;i<entries.length;i++){ - JSFLibraryReference ref = JSFLibraryReferenceFacadeFactory.create(entries[i]); - if (ref != null){ - results.add(ref); - if (ref.isJSFImplementation()) - foundImpl = true; - } - } - if (! foundImpl){ - results.add(JSFLibraryReferenceFacadeFactory.createServerSuppliedJSFLibRef()); - } - } catch (JavaModelException e) { - JSFCorePlugin.log(e, "Exception occurred calling getJSFLibraryReferences for "+project.getName()); - } - return results; - } - - /** - * @param cpEntry - * @return boolean indicating that the classpath entry is a JSF Libary Classpath Container - */ - public static boolean isJSFLibraryContainer(IClasspathEntry cpEntry) { - if (cpEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER) - return false; - - IPath path = cpEntry.getPath(); - return path != null && path.segmentCount() == 2 && JSF_LIBRARY_CP_CONTAINER_ID.equals(path.segment(0)); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReference.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReference.java deleted file mode 100644 index ee9ed625f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReference.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration; - -import java.util.Collection; - -import org.eclipse.jdt.core.IClasspathEntry; - -/** - * Represents a reference to a JSF Library on a project - * - */ -public abstract interface JSFLibraryReference { - /** - * @return id for the library - */ - public String getId(); - /** - * @return name - */ - public String getName(); - /** - * @return collection of jars as {@link IClasspathEntry}s - */ - public Collection<IClasspathEntry> getJars(); - /** - * @return {@link JSFVersion} value - */ - public JSFVersion getMaxSupportedVersion(); - /** - * @return label user sees for this library - */ - public String getLabel(); - /** - * @return flag - */ - public boolean isJSFImplementation(); - /** - * @return is deployed (marked as J2EE Module Dependency) - */ - public boolean isDeployed(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferencePluginProvided.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferencePluginProvided.java deleted file mode 100644 index 7884124ea..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferencePluginProvided.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration; - -/** - * A reference to a plugin defined JSF Library - * - */ -public interface JSFLibraryReferencePluginProvided extends JSFLibraryReferenceUserDefined { - /** - * @return plugin id. May return null if plugin id cannot be determined. - */ - public String getPluginId(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferenceServerSupplied.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferenceServerSupplied.java deleted file mode 100644 index 50617b17a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferenceServerSupplied.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration; - -/** - * @author gekessle - * - */ -public interface JSFLibraryReferenceServerSupplied extends - JSFLibraryReference { - - /** - * Constant used for server supplied virtual JSF Library referencew - */ - public static final String ID = "_ServerSupplied_"; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferenceUserDefined.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferenceUserDefined.java deleted file mode 100644 index 67d880853..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFLibraryReferenceUserDefined.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration; - - -/** - * Represents an reference to a user defined JSF Library - */ -public interface JSFLibraryReferenceUserDefined extends JSFLibraryReference { - // -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFVersion.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFVersion.java deleted file mode 100644 index a0f36cf23..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/JSFVersion.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration; - -/** - * @author gekessle - * - */ -public enum JSFVersion { - - /** - * Unknown version support - */ - UNKNOWN, - /** - * Supports JSF Version 1.0 - */ - V1_0, - /** - * Supports JSF Version 1.1 - */ - V1_1, - /** - * Supports JSF Version 1.1 - */ - V1_2; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/AbstractJSFLibraryReferenceImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/AbstractJSFLibraryReferenceImpl.java deleted file mode 100644 index ad6d8fedc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/AbstractJSFLibraryReferenceImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal; - - - - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReference; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFVersion; -/** - * @author gekessle - * - */ -public abstract class AbstractJSFLibraryReferenceImpl implements JSFLibraryReference { - - /** - * The {@link org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference} being wrapped - */ - protected JSFLibraryInternalReference libRef; - private String _id; - private String _label; - private boolean _isImplementation; - private boolean _isDeloyed; - - /** - * Constructor for "virtual" JSF Library References like "ServerSupplied" - * @param id - * @param label - * @param isImplementation - */ - public AbstractJSFLibraryReferenceImpl(String id, String label, boolean isImplementation){ - _id = id; - _label = label; - _isImplementation = isImplementation; - } - - /** - * Constructor non-virtual library references - * @param libRef - * @param isDeployed - */ - public AbstractJSFLibraryReferenceImpl(JSFLibraryInternalReference libRef, boolean isDeployed){ - this.libRef = libRef; - _isDeloyed = isDeployed; - } - - public String getId() { - if (libRef != null) - return libRef.getID(); - - return _id; - } - - public String getLabel() { - if (libRef != null) - return libRef.getLabel(); - - return _label; - } - - public boolean isDeployed() { - return _isDeloyed; - } - - public boolean isJSFImplementation() { - if (libRef != null) - return libRef.isImplementation(); - - return _isImplementation; - } - - /** - * @return the JSFLibrary underpinning the reference. - * May be null if the library is missing or cannot be resolved from the registry. - */ - protected JSFLibrary getLibrary(){ - return libRef.getLibrary(); - } - - public Collection<IClasspathEntry> getJars() { - Set<IClasspathEntry> results = new HashSet<IClasspathEntry>(); - if (getLibrary() != null){ - List jars = getLibrary().getArchiveFiles(); - for (Iterator it= jars.iterator();it.hasNext();){ - ArchiveFile jar = (ArchiveFile)it.next(); - String path = jar.getResolvedSourceLocation(); - results.add(JavaCore.newLibraryEntry(new Path(path), null, null)); - } - } - return results; - } - - public JSFVersion getMaxSupportedVersion() { - if (getLibrary() != null) - return adaptVersion(getLibrary().getJSFVersion()); - return null; - } - - private JSFVersion adaptVersion( - org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion version) { - - switch (version.getValue()){ - case org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion.V1_1: - return JSFVersion.V1_1; - case org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion.V1_2: - return JSFVersion.V1_2; - default: - return JSFVersion.UNKNOWN; - - } - } - - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReference#getName() - */ - public String getName() { - if (getLibrary()!= null) { - return getLibrary().getName(); - } - return getId(); - } - - public String toString(){ - StringBuffer buf = new StringBuffer("id: "); - buf.append(getId()); - buf.append(", label: "); - buf.append(getLabel()); - buf.append(", isDeployed: "); - buf.append(isDeployed()); - buf.append(", isImpl: "); - buf.append(isJSFImplementation()); - buf.append(", version: "); - buf.append(getMaxSupportedVersion().name()); - - return buf.toString(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceFacadeFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceFacadeFactory.java deleted file mode 100644 index 8f371e509..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceFacadeFactory.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal; - -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReference; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReferenceServerSupplied; - -/** - * Factory for producing facade objects for references to the internal EMF JSF Library classes - */ -public class JSFLibraryReferenceFacadeFactory { - /** - * Returns a JSFLibraryReferenceUserDefined or JSFLibraryReferencePluginProvided instance. - * Will not create a JSFLibraryReferenceServerSupplied as there is no cp entry. Use createServerSuppliedJSFLibRef instead. - * @param cpEntry - * @return an instance of JSFLibraryInternalReference. Null will be returned if the cpEntry is not a - */ - public static JSFLibraryReference create(final IClasspathEntry cpEntry) { - if (JSFLibraryConfigurationHelper.isJSFLibraryContainer(cpEntry)){ - return createReference(cpEntry); - } - return null; - } - - /** - * @return instance of {@link JSFLibraryReferenceServerSupplied} - */ - public static JSFLibraryReferenceServerSupplied createServerSuppliedJSFLibRef(){ - return new JSFLibraryReferenceServerSuppliedImpl(); - } - - - /** - * @param cpEntry - * @return {@link JSFLibraryReference} - */ - private static JSFLibraryReference createReference( - final IClasspathEntry cpEntry) { - - String libID = cpEntry.getPath().segment(1).toString(); - org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference libRef = JSFLibraryRegistryUtil.getInstance().getJSFLibraryReferencebyID(libID); - if (libRef!= null){ - boolean isDeployed = getJ2EEModuleDependency(cpEntry); - if (libRef.getLibrary() != null && libRef.getLibrary() instanceof PluginProvidedJSFLibrary) - return new JSFLibraryReferencePluginProvidedImpl(libRef, isDeployed); - - return new JSFLibraryReferenceUserDefinedImpl(libRef, isDeployed); - } - return null; - } - - private static boolean getJ2EEModuleDependency(IClasspathEntry cpEntry) { - IClasspathAttribute[] attrs = cpEntry.getExtraAttributes(); - for (int i=0;i<attrs.length;i++){ - IClasspathAttribute attr = attrs[i]; - if (attr.getName().equals(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY)){ - return true; - } - } - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferencePluginProvidedImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferencePluginProvidedImpl.java deleted file mode 100644 index bb847ae9c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferencePluginProvidedImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal; - -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReferencePluginProvided; - -/** - * - */ -public class JSFLibraryReferencePluginProvidedImpl extends AbstractJSFLibraryReferenceImpl implements JSFLibraryReferencePluginProvided { - - /** - * Constructor - * @param libRef - * @param isDeployed - */ - public JSFLibraryReferencePluginProvidedImpl(JSFLibraryInternalReference libRef, boolean isDeployed) { - super(libRef, isDeployed); - } - - public String getPluginId() { - if (getLibrary() != null) - return ((PluginProvidedJSFLibrary) getLibrary()).getPluginID(); - - return null; - } - - public String toString() { - StringBuffer buf = new StringBuffer("PluginProvided: ("); - buf.append(super.toString()); - - return buf.toString(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceServerSuppliedImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceServerSuppliedImpl.java deleted file mode 100644 index 6ab76eff9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceServerSuppliedImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal; - -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReferenceServerSupplied; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFVersion; - -/** - * @author gekessle - * - */ -public class JSFLibraryReferenceServerSuppliedImpl - extends AbstractJSFLibraryReferenceImpl - implements JSFLibraryReferenceServerSupplied { - - /** - * Constructor - */ - public JSFLibraryReferenceServerSuppliedImpl(){ - //TODO: replace label with constant - super(JSFLibraryReferenceServerSupplied.ID, "Server Supplied", true); - } - - public String toString() { - StringBuffer buf = new StringBuffer("ServerSupplied: ("); - buf.append(super.toString()); - buf.append(")"); - - return buf.toString(); - } - - protected JSFLibrary getLibrary(){ - return null; - } - - public JSFVersion getMaxSupportedVersion() { - return JSFVersion.UNKNOWN; - } -// -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceUserDefinedImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceUserDefinedImpl.java deleted file mode 100644 index 98508e0db..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryconfiguration/internal/JSFLibraryReferenceUserDefinedImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal; - -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference; -import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReferenceUserDefined; - -/** - * Implementation of a reference to a user defined JSF Library - * - */ -public class JSFLibraryReferenceUserDefinedImpl extends AbstractJSFLibraryReferenceImpl implements JSFLibraryReferenceUserDefined{ - /** - * @param libRef of type {@link JSFLibraryInternalReference} - * @param isDeployed - */ - public JSFLibraryReferenceUserDefinedImpl( - JSFLibraryInternalReference libRef, boolean isDeployed) { - - super(libRef, isDeployed); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal.AbstractJSFLibraryReferenceImpl#toString() - */ - public String toString() { - StringBuffer buf = new StringBuffer("UserDefined: ("); - buf.append(super.toString()); - buf.append(")"); - - return buf.toString(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/InvalidArchiveFilesCreationException.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/InvalidArchiveFilesCreationException.java deleted file mode 100644 index d76849ca2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/InvalidArchiveFilesCreationException.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryregistry; - -/** - * Exception class thrown by PluginProvidedJSFLibraryCreationHelper. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @deprecated - */ -public class InvalidArchiveFilesCreationException extends Exception { - private static final long serialVersionUID = 1L; - - /** - * Creates an instance with the specified message. - * @param msg This instance's message - */ - public InvalidArchiveFilesCreationException(String msg) { - super(msg); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/JSFLibraryArchiveFilesDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/JSFLibraryArchiveFilesDelegate.java deleted file mode 100644 index e4422b2e9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/JSFLibraryArchiveFilesDelegate.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryregistry; - -import java.util.Collection; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.osgi.framework.Bundle; - -/** - * Abstract delegate class used by jsfLibraries ext-pt to return collection of - * ArchiveFiles to PluginProvidedJSFLibraryCreationHelper. - * - * Caller must first setConfigurationElement(IConfigurationElement element) - * before a call to getArchiveFiles(). - * - * <p><b>Provisional API - subject to change</b></p> - * - * @deprecated along with the jsflibraries extension-point - */ -public abstract class JSFLibraryArchiveFilesDelegate { - private IConfigurationElement extPtElement; - private String libID = null; - private IPath pluginPath = null; - private String pluginID; - private String relativeDestLocation = "WEB-INF/lib"; //$NON-NLS-1$ - - /** - * Returns a Collection of <code>org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile</code> - * instances. - * - * @return A Collection of <code>org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile</code> - * instances - */ - public abstract Collection getArchiveFiles(); - - /** - * Sets the IConfigurationElement instance to be subsequently used to get - * the plugin ID and the name defined for the JSF Library. - * - * @param extPtElement IConfigurationElement instance - */ - public final void setConfigurationElement(IConfigurationElement extPtElement){ - this.extPtElement = extPtElement; - } - - /** - * Constructs an instance. - */ - public JSFLibraryArchiveFilesDelegate() { - super(); - } - - /** - * Sets the relative destination location subsequently used to set the - * corresponding property on each created ArchiveFile. - * - * @param relPath Relative destination location for ArchiveFile instances - */ - protected void setRelativeDestinationLocation(String relPath){ - relativeDestLocation = relPath; - } - - /** - * Returns ArchiveFile where the location is set relative to the plugin. - * As long as the ArchiveFile is on the local machine somewhere, it should - * be locatable. - * - * @param relativePathFileName Relative location of the ArchiveFile - * @return ArchiveFile instance. - */ - protected ArchiveFile createArchiveFile(String relativePathFileName){ - ArchiveFile file = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile(); - file.setRelativeToWorkspace(false); - file.setSourceLocation(relativePathFileName); - file.setRelativeDestLocation(relativeDestLocation); - return file; - } - -// protected ArchiveFile createArchiveFileWithAbsolutePath(String fullPath){ -// ArchiveFile file = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile(); -// file.setRelativeToWorkspace(false); -// file.setSourceLocation(fullPath); -// file.setRelativeDestLocation(relativeDestLocation); -// return file; -// } - - /** - * Returns the JSFLibrary ID as set on the extension point. - * - * @return JSFLibrary ID - */ - protected String getLibID(){ - if (libID == null){ - StringBuffer buf = new StringBuffer(getPluginID()); - buf.append("/").append(extPtElement.getAttribute(PluginProvidedJSFLibraryCreationHelper.NAME)); //$NON-NLS-1$ - libID = buf.toString(); - } - return libID; - } - - /** - * Returns the plugin's path. - * - * @return The plugin's path. - */ - protected IPath getPluginPath(){ - if (pluginPath == null){ - Bundle bundle = Platform.getBundle(getPluginID()); - pluginPath = new Path(bundle.getLocation()); - } - return pluginPath; - } - - /** - * Returns the plugin's ID. - * - * @return The plugin's ID. - */ - private String getPluginID() { - if (pluginID == null){ - pluginID = extPtElement.getDeclaringExtension().getContributor().getName(); - } - return pluginID; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/PluginProvidedJSFLibraryArchiveFilesDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/PluginProvidedJSFLibraryArchiveFilesDelegate.java deleted file mode 100644 index e260f6979..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/PluginProvidedJSFLibraryArchiveFilesDelegate.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryregistry; - -import org.eclipse.jst.jsf.core.jsflibraryregistry.internal.PluginProvidedJSFLibraryCreationHelper2; - -/** - * Abstract class to be used for supplying the jar file names for a plugin provided jsf library. - * <br>Adopters must implement getArchiveFiles() making use of the addArchiveFile(String pluginRootRelativePath) method. - * <br><em>Note: A plugin providing jsf libraries cannot be jarred at this time. </em> - * <br><br>ex. - * <br> <pre><code>public void getArchiveFiles() { - addArchiveFile("/lib/JAR1.jar"); - addArchiveFile("/lib/JAR2.jar"); - } - </code> - </pre> - * - * <p><b>Provisional API - subject to change</b></p> - * - */ -public abstract class PluginProvidedJSFLibraryArchiveFilesDelegate { - private PluginProvidedJSFLibraryCreationHelper2 helper; - - /** - * Constructs an instance. - */ - public PluginProvidedJSFLibraryArchiveFilesDelegate() { - super(); - } - - /** - * Concrete delegate must implement this method to define jars in the library. - * Use addJarFile(String pluginRootRelativePath) within this method to add jars to the library. - */ - public abstract void getArchiveFiles(); - - /** - * Adds jar file to the library. Verification of file existence does not occur at this point. - * - * Jar must be specified as being relative to the plugin. - * ex. "/lib/MyJar.jar" where the lib directory is a child of the root. - * - * @param pluginRootRelativePath - */ - protected void addArchiveFile(String pluginRootRelativePath) { - helper.addArchiveFile(pluginRootRelativePath);//getArchiveFiles().add(helper.createArchiveFile(pluginRootRelativePath)); - } - - /** - * Not to be implemented by subclasses - * @param helper - */ - public void setCreationHelper( - PluginProvidedJSFLibraryCreationHelper2 helper) { - this.helper = helper; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/PluginProvidedJSFLibraryCreationHelper.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/PluginProvidedJSFLibraryCreationHelper.java deleted file mode 100644 index cda0083cb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/PluginProvidedJSFLibraryCreationHelper.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryregistry; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; -import org.eclipse.osgi.util.NLS; - -/** - * Helper class used to create JSF Libraries from the - * <code>org.eclipse.jst.jsf.core.jsflibraries</code> extension-point. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @deprecated - clients should not use - */ -public final class PluginProvidedJSFLibraryCreationHelper { - private IConfigurationElement config_element; - - /** - * Key of the 'name' attribute of the extension point. - */ - public final static String NAME = "name"; //$NON-NLS-1$ - /** - * Key of the 'isImplementation' attribute of the extension point. - */ - public final static String IS_IMPL = "isImplementation"; //$NON-NLS-1$ - /** - * Key of the 'maxVersionSupported' attribute of the extension point. - */ - public final static String VERSION = "maxVersionSupported"; //$NON-NLS-1$ - /** - * Key of the 'archiveFilesDelegate' attribute of the extension point. - */ - public final static String DELEGATE = "archiveFilesDelegate"; //$NON-NLS-1$ - - /** - * Creates an instance with the specified IConfigurationElement instance. - * - * @param jsfLibrary IConfigurationElement instance - */ - public PluginProvidedJSFLibraryCreationHelper (IConfigurationElement jsfLibrary){ - this.config_element = jsfLibrary; - } - - /** - * Creates a new PluginProvidedJSFLibrary from the JSFLibrary extension point. - * - * @return PluginProvidedJSFLibrary instance. - */ - public JSFLibrary create(){ - PluginProvidedJSFLibrary newLib = JSFLibraryRegistryFactory.eINSTANCE.createPluginProvidedJSFLibrary(); -// newLib.setID(getLibID()); - newLib.setPluginID(getPluginID()); - newLib.setName(config_element.getAttribute(NAME)); - newLib.setImplementation(config_element.getAttribute(IS_IMPL).equals("true") ? true : false); //$NON-NLS-1$ - newLib.setJSFVersion(JSFVersion.getJSFVersion(config_element.getAttribute(VERSION))); - - try { - addArchives(newLib); - return newLib; - } catch (Exception e) { - JSFCorePlugin.log( - e, - NLS.bind( - Messages.PluginProvidedJSFLibraryCreationHelper_ErrorCreating, - newLib.getName())); - } - return null; - } - - /** - * Adds ArchiveFile instances to the specified JSFLibrary instance. - * - * @param newLib JSFLibrary instance - * @throws InvalidArchiveFilesCreationException on attempt to create - * multiple instances at same location. - * @throws CoreException on core failure. - */ - private void addArchives(JSFLibrary newLib) throws InvalidArchiveFilesCreationException, CoreException { - JSFLibraryArchiveFilesDelegate jarCol = null; - ArchiveFile jar = null; - - jarCol = (JSFLibraryArchiveFilesDelegate)config_element.createExecutableExtension(DELEGATE); - if (jarCol != null){ - jarCol.setConfigurationElement(config_element); - Collection jars = jarCol.getArchiveFiles(); - if (jars == null)//TODO: better validation and error handling - return; - Iterator it = jars.iterator(); - while (it.hasNext()){ - Object aJar = it.next(); - if (aJar instanceof ArchiveFile){//for now check to see ArchiveFiles were being returned - jar = (ArchiveFile)aJar; - if (!newLib.containsArchiveFile(jar.getSourceLocation())) - newLib.getArchiveFiles().add(jar); - } - else { - throw new InvalidArchiveFilesCreationException( - NLS.bind( - Messages.PluginProvidedJSFLibraryCreationHelper_ErrorMultipleDefinition, - jar.getSourceLocation(), - config_element.getName())); - } - - } - } - } - - /** - * Returns the plugin's ID. - * - * @return The plugin's ID - */ - private String getPluginID() { - return config_element.getDeclaringExtension().getContributor().getName(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/internal/PluginProvidedJSFLibraryCreationHelper2.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/internal/PluginProvidedJSFLibraryCreationHelper2.java deleted file mode 100644 index 7c280ea22..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/jsflibraryregistry/internal/PluginProvidedJSFLibraryCreationHelper2.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.jsflibraryregistry.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary; -import org.eclipse.jst.jsf.core.jsflibraryregistry.PluginProvidedJSFLibraryArchiveFilesDelegate; -import org.eclipse.osgi.util.NLS; - -/** - * Helper class used to create plugin-rovided JSF Libraries from the - * <code>org.eclipse.jst.jsf.core.pluginProvidedJsfLibraries</code> extension-point. - * <br> - * - * @author Gerry Kessler - Oracle - */ -public final class PluginProvidedJSFLibraryCreationHelper2 { - private PluginProvidedJSFLibrary newLib; - private IConfigurationElement config_element; - private String relativeDestLocation = "WEB-INF/lib"; //$NON-NLS-1$ - - /** - * Key of the 'name' attribute of the extension point. - */ - public final static String NAME = "name"; //$NON-NLS-1$ - /** - * Key of the 'isImplementation' attribute of the extension point. - */ - public final static String IS_IMPL = "isImplementation"; //$NON-NLS-1$ - /** - * Key of the 'maxVersionSupported' attribute of the extension point. - */ - public final static String VERSION = "maxVersionSupported"; //$NON-NLS-1$ - /** - * Key of the 'archiveFilesDelegate' attribute of the extension point. - */ - public final static String DELEGATE = "archiveFilesDelegate"; //$NON-NLS-1$ - /** - * Key of the 'label' attribute of the extension point. - */ - public final static String LABEL = "label"; //$NON-NLS-1$ - - /** - * Creates an instance with the specified IConfigurationElement instance. - * - * @param jsfLibrary IConfigurationElement instance - */ - public PluginProvidedJSFLibraryCreationHelper2 (IConfigurationElement jsfLibrary){ - this.config_element = jsfLibrary; - } - - /** - * Add a jar file to the library - * @param pluginRootRelativePath - */ - public void addArchiveFile(String pluginRootRelativePath) { - ArchiveFile jar = createArchiveFile(pluginRootRelativePath); - if (!newLib.containsArchiveFile(jar.getSourceLocation())) - newLib.getArchiveFiles().add(jar); - } - - /** - * Creates a new PluginProvidedJSFLibrary from the JSFLibrary extension point. - * - * @return PluginProvidedJSFLibrary instance. - */ - public JSFLibrary create(){ - newLib = JSFLibraryRegistryFactory.eINSTANCE.createPluginProvidedJSFLibrary(); - newLib.setPluginID(getPluginID()); - newLib.setName(config_element.getAttribute(NAME)); - String label = config_element.getAttribute(LABEL); - if (label != null && label.length() > 0){ - newLib.setLabel(label); - } - newLib.setImplementation(config_element.getAttribute(IS_IMPL).equals("true") ? true : false); //$NON-NLS-1$ - newLib.setJSFVersion(JSFVersion.getJSFVersion(config_element.getAttribute(VERSION))); - - try { - addArchives(); - return newLib; - } catch (Exception e) { - JSFCorePlugin.log( - e, - NLS.bind( - Messages.PluginProvidedJSFLibraryCreationHelper_ErrorCreating, - newLib.getName())); - } - return null; - } - - /** - * Adds ArchiveFile instances to the specified JSFLibrary instance. - * - * @param newLib JSFLibrary instance - * @throws CoreException on core failure. - */ - private void addArchives() throws CoreException { - PluginProvidedJSFLibraryArchiveFilesDelegate jarCol = null; - - jarCol = (PluginProvidedJSFLibraryArchiveFilesDelegate)config_element.createExecutableExtension(DELEGATE); - if (jarCol != null){ - jarCol.setCreationHelper(this); - jarCol.getArchiveFiles(); - } - } - /** - * Returns ArchiveFile where the location is set relative to the plugin. - * As long as the ArchiveFile is on the local machine somewhere, it should - * be locatable. - * - * @param relativePathFileName Relative location of the ArchiveFile - * @return ArchiveFile instance. - */ - private ArchiveFile createArchiveFile(String pluginRootRelativePath){ - ArchiveFile file = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile(); - file.setRelativeToWorkspace(false); - file.setSourceLocation(pluginRootRelativePath); - file.setRelativeDestLocation(relativeDestLocation); - return file; - } - - /** - * Returns the plugin's ID. - * - * @return The plugin's ID - */ - private String getPluginID() { - return config_element.getDeclaringExtension().getContributor().getName(); - } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/set/constraint/MemberConstraint.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/set/constraint/MemberConstraint.java deleted file mode 100644 index e6e69ca7d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/set/constraint/MemberConstraint.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.set.constraint; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; -import org.eclipse.jst.jsf.common.sets.constraint.AbstractSetConstraint; - -/** - * A set constraint that is satisfied if a test set contains all of the specified - * mustBeMembers. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class MemberConstraint extends AbstractSetConstraint -{ - private final AxiomaticSet _mustBeMembers; - - /** - * @param mustBeMembers -- the set of objects that must occur in the - * input set for the constraint to satisfy. - */ - public MemberConstraint(AxiomaticSet mustBeMembers) - { - _mustBeMembers = mustBeMembers; - } - - /** - * Members of set must be comparable with thos in mustBeMembers using equals() - * @param set - * @return whether or not the constraint is satisfied. If not satisfied, the - * diagnostic's data array will contain the objects that are missing. - */ - public Diagnostic isSatisfied(AxiomaticSet set) - { - // the constraint is satisfied iff _mustBeMembers is a subset - // of set. In other words, if every member of _mustBeMembers - // is also in set. - - // we want to take _mustBeMembers - set. If the result is empty, then - // all of the required elements are members of set. If the set is non-empty, - // this tells us what is missing - final AxiomaticSet complement = _mustBeMembers.subtract(set); - - if (complement.isEmpty()) - { - return Diagnostic.OK_INSTANCE; - } - - return new BasicDiagnostic(Diagnostic.ERROR, this.getClass().getName(), - 0, "Failed membership constraint", complement.toArray()); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/set/mapping/ElementToTagIdentifierMapping.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/set/mapping/ElementToTagIdentifierMapping.java deleted file mode 100644 index 5af60bf39..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/set/mapping/ElementToTagIdentifierMapping.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.set.mapping; - -import org.eclipse.jst.jsf.common.sets.mapping.AbstractObjectInjectiveSetMapping; -import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory; -import org.w3c.dom.Element; - -/** - * Converts a set of DOM element's to a set of (object) injective set - * of TagIdentifiers. If the element is a JSP tag, the tag uri will - * be looked up. - * - * IMPORTANT: the returned TagIdentifiers are wrapper objects, so they only - * maintain immutability and idempotency as long as the input dom elements - * do not change. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class ElementToTagIdentifierMapping extends - AbstractObjectInjectiveSetMapping -{ - public Object map(Object element) { - Element domElement = (Element) element; - return TagIdentifierFactory.createDocumentTagWrapper(domElement); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/EvaluationException.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/EvaluationException.java deleted file mode 100644 index 0774212d4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/EvaluationException.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.tagmatcher; - -/** - * Wraps an exception thrown during algorithm evaluation - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class EvaluationException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = -3250608181004283586L; - - /** - * - */ - public EvaluationException() { - super(); - } - - /** - * @param message - */ - public EvaluationException(String message) { - super(message); - } - - /** - * @param cause - */ - public EvaluationException(Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - */ - public EvaluationException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/InvalidExpressionException.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/InvalidExpressionException.java deleted file mode 100644 index 2651db8bf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/InvalidExpressionException.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.tagmatcher; - -/** - * Indicates an exception trapped while compiling or evaluating an - * expression. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class InvalidExpressionException extends RuntimeException { - /** - * - */ - private static final long serialVersionUID = 1445871263234840885L; - - /** - * @see RuntimeException - */ - public InvalidExpressionException() { - super(); - } - - /** - * @param message - * @param cause - */ - public InvalidExpressionException(String message, Throwable cause) { - super(message, cause); - } - - /** - * @param message - */ - public InvalidExpressionException(String message) { - super(message); - } - - /** - * @param cause - */ - public InvalidExpressionException(Throwable cause) { - super(cause); - } - - - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/TagMatchingAlgorithm.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/TagMatchingAlgorithm.java deleted file mode 100644 index 11bce8649..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/TagMatchingAlgorithm.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.tagmatcher; - -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; -import org.w3c.dom.Node; - -/** - * An algorithm that can be applied at a particular DOM node. The result - * may be expressed as a boolean or a set of matching nodes. The following - * are equivalent: - * - * false and empty set - * true and non-empty set - * - * Concrete implementations must be idempotent on evaluate(): - * - * 1) evaluate(node) must always return the same set if called repeatedly on - * the same node in the same DOM tree. - * 2) evaluate must be able to be called on any number of nodes in order and always - * produce the same result independent of what was called before and in what order. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public abstract class TagMatchingAlgorithm -{ - private boolean _isInvalid; // = false; - - private boolean _isInitialized; - /** - * The expression being passed to the algorithm - */ - protected final String _expression; - - /** - * Constructor. - * - * @param expression - */ - protected TagMatchingAlgorithm(String expression) - { - _expression = expression; - } - - /** - * Called exactly once to initialize any pre-evaluation setup for - * the expression set for the algorithm. This is public to allow - * the client control when this initialization occurs in case it is expensive. - * evaluate() will call this method automatically if it has never been called - * @throws InvalidExpressionException if the underlying algorithm throws an - * exception during init - * @throws IllegalStateException if it has already been determined that the - * expression is invalid. - */ - public final void initialize() - { - if (_isInvalid) - { - throw new IllegalStateException("Expression: "+_expression+" has already been determined to be invalid"); - } - - if (!_isInitialized) - { - try - { - doInitialize(); - } - catch (Exception e) - { - _isInvalid = true; - throw new InvalidExpressionException(e); - } - _isInitialized = true; - } - } - - /** - * @param applyTo - * @return the set matching the configured expression applied to applyTo - * using the algorithm represented by this instance. - * @throws InvalidExpressionException of a problem occurs initializing the expression - * @throws EvaluationException if the internal algorithm throws an exception while - * evaluating. - * @throws IllegalStateException if evaluate is called again once InvalidExpressionException - * has already been thrown. - */ - public final AxiomaticSet evaluate(Node applyTo) - { - initialize(); - return doEvaluate(applyTo); - } - - /** - * Implementers must override to the evaluation of the target,expression pair - * @param target - * @return the algorithm evaluated with - */ - protected abstract AxiomaticSet doEvaluate(Node target); - - /** - * Do any initialization that is required before the algorithm is used - * to evaluate an expression on any node. This will get called exactly once and - * is guaranteed to be called, at latest, immediately before doEvaluate - * - * Method may throw runtime exceptions. These will be repropagated as - * InvalidExpressionException's with the original exception wrapped. - * @throws Exception - */ - protected abstract void doInitialize() throws Exception; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/XPathMatchingAlgorithm.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/XPathMatchingAlgorithm.java deleted file mode 100644 index 9ce74dddb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/tagmatcher/XPathMatchingAlgorithm.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.core.tagmatcher; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; -import org.eclipse.jst.jsf.common.sets.ConcreteAxiomaticSet; -import org.eclipse.jst.jsf.common.sets.NodeSet; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * A algorithm that uses an XPath expression to evaluate a result. The - * algorithm assumes (although cannot verify beforehand) that the expression - * provided can be evaluated with a node set return type (see JAXP). If the - * algorithm's underlying XPath evaluator throws an exception indicating that - * the return type cannot be coerced to a node set, the algorithm will return - * an empty set (no match) unless the strictMatching flag is set to true, in which - * case it will re-throw the exception wrapped as an unchecked EvaluationException. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class XPathMatchingAlgorithm extends TagMatchingAlgorithm -{ - private final boolean _isStrictMatching; - private final XPath _xpath; - private XPathExpression _compiledExpr; - - /** - * @param expression - */ - public XPathMatchingAlgorithm(String expression) - { - this(expression, false); - } - - /** - * @param expression - * @param isStrictMatching - */ - public XPathMatchingAlgorithm(String expression, boolean isStrictMatching) - { - super(expression); - _isStrictMatching = isStrictMatching; - _xpath = XPathFactory.newInstance().newXPath(); - } - - protected AxiomaticSet doEvaluate(Node target) - { - try - { - NodeList nodeList = - (NodeList) _compiledExpr.evaluate(target, XPathConstants.NODESET); - return new NodeSet(nodeList); - } - catch (XPathExpressionException xpam) - { - if (_isStrictMatching) - { - throw new EvaluationException(xpam); - } - // if not strict checking, return empty set - return new ConcreteAxiomaticSet(); - } - } - - protected void doInitialize() throws XPathExpressionException { - // compile the xpath expr - _compiledExpr = _xpath.compile(_expression); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DesignTimeApplicationManager.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DesignTimeApplicationManager.java deleted file mode 100644 index 79abedc2f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/DesignTimeApplicationManager.java +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.designtime.context.AbstractDTExternalContextFactory; -import org.eclipse.jst.jsf.designtime.context.DTFacesContext; -import org.eclipse.jst.jsf.designtime.context.IExternalContextFactoryLocator; -import org.eclipse.jst.jsf.designtime.el.AbstractDTMethodResolver; -import org.eclipse.jst.jsf.designtime.el.AbstractDTPropertyResolver; -import org.eclipse.jst.jsf.designtime.el.AbstractDTVariableResolver; - - -/** - * Per-web-application manager that manages design time information for a corresponding - * project. - * - * @author cbateman - * - */ -public final class DesignTimeApplicationManager -{ - // TODO: load from property file? - private static final String PROPERTY_QUALIFIER = "org.eclipse.jst.jsf.designtime.internal"; //$NON-NLS-1$ - private static final String SESSION_PROPERTY_NAME_PROJECT = "DesignTimeApplicationManager"; //$NON-NLS-1$ - private static final QualifiedName SESSION_PROPERTY_KEY_PROJECT - = new QualifiedName(PROPERTY_QUALIFIER, SESSION_PROPERTY_NAME_PROJECT); - - private static final String SESSION_PROPERTY_NAME_FACES_CONTEXT = "DTFacesContext"; //$NON-NLS-1$ - private static final QualifiedName SESSION_PROPERTY_KEY_FACES_CONTEXT - = new QualifiedName(PROPERTY_QUALIFIER, SESSION_PROPERTY_NAME_FACES_CONTEXT); - - private static final String PERSIST_PROPERTY_NAME_EXTERNAL_CONTEXT_PROVIDER = - "ExternalContextProvider"; //$NON-NLS-1$ - private static final QualifiedName PERSIST_PROPERTY_KEY_EXTERNAL_CONTEXT_PROVIDER = - new QualifiedName(PROPERTY_QUALIFIER, PERSIST_PROPERTY_NAME_EXTERNAL_CONTEXT_PROVIDER); - - private static final String PERSIST_PROPERTY_NAME_VARIABLE_RESOLVER_PROVIDER = - "VariableResolverProvider"; //$NON-NLS-1$ - private static final QualifiedName PERSIST_PROPERTY_KEY_VARIABLE_RESOLVER_PROVIDER - = new QualifiedName(PROPERTY_QUALIFIER, PERSIST_PROPERTY_NAME_VARIABLE_RESOLVER_PROVIDER); - - private static final String PERSIST_PROPERTY_NAME_PROPERTY_RESOLVER_PROVIDER = - "PropertyResolverProvider"; //$NON-NLS-1$ - private static final QualifiedName PERSIST_PROPERTY_KEY_PROPERTY_RESOLVER_PROVIDER = - new QualifiedName(PROPERTY_QUALIFIER, PERSIST_PROPERTY_NAME_PROPERTY_RESOLVER_PROVIDER); - - private static final String PERSIST_PROPERTY_NAME_METHOD_RESOLVER_PROVIDER = - "MethodResolverProvider"; //$NON-NLS-1$ - private static final QualifiedName PERSIST_PROPERTY_KEY_METHOD_RESOLVER_PROVIDER = - new QualifiedName(PROPERTY_QUALIFIER, PERSIST_PROPERTY_NAME_METHOD_RESOLVER_PROVIDER); - - private static final String DEFAULT_EXTERNAL_CONTEXT_ID = - "org.eclipse.jst.jsf.core.externalcontext.default"; //$NON-NLS-1$ - - private static final String DEFAULT_VARIABLE_RESOLVER_ID = - "org.eclipse.jst.jsf.core.variableresolver.default"; //$NON-NLS-1$ - - private static final String DEFAULT_PROPERTY_RESOLVER_ID = - "org.eclipse.jst.jsf.core.propertyresolver.default"; //$NON-NLS-1$ - - private static final String DEFAULT_METHOD_RESOLVER_ID = - "org.eclipse.jst.jsf.core.methodresolver.default"; //$NON-NLS-1$ - - /** - * @param project - * @return the app manager associated with project - */ - public final static DesignTimeApplicationManager getInstance(IProject project) - { - if (project == null) - { - return null; - } - - try - { - synchronized(project) - { - Object manager = - project.getSessionProperty(SESSION_PROPERTY_KEY_PROJECT); - - if (manager == null) - { - manager = new DesignTimeApplicationManager(project); - project.setSessionProperty(SESSION_PROPERTY_KEY_PROJECT, manager); - } - - return (DesignTimeApplicationManager) manager; - } - } - catch (CoreException ce) - { - Platform.getLog(JSFCorePlugin.getDefault().getBundle()).log(new Status(IStatus.ERROR, JSFCorePlugin.getDefault().getBundle().getSymbolicName(), 0, "Problem loading design time appmanager", new Throwable(ce))); //$NON-NLS-1$ - } - - return null; - } - - // instance definition - private final IProject _project; - private final IExternalContextFactoryLocator _locator; - - private DesignTimeApplicationManager(IProject project) - { - _project = project; - _locator = new MyExternalContextFactoryLocator(); - } - - /** - * @param file must not be null - * @return the faces context for the file or null if not found - */ - public DTFacesContext getFacesContext(IFile file) - { - assert file != null; - - try - { - synchronized(file) - { - Object context = file.getSessionProperty(SESSION_PROPERTY_KEY_FACES_CONTEXT); - - if (context == null) - { - context = new DTFacesContext(_locator); - file.setSessionProperty(SESSION_PROPERTY_KEY_PROJECT, context); - } - - return (DTFacesContext) context; - } - } - catch (CoreException ce) - { - Platform.getLog(JSFCorePlugin.getDefault().getBundle()) - .log(new Status(IStatus.ERROR, - JSFCorePlugin.getDefault().getBundle().getSymbolicName(), - 0, "Problem loading design time facescontext", //$NON-NLS-1$ - new Throwable(ce))); - } - - return null; - } - - /** - * @param resolverPluginId - * @throws CoreException - */ - public synchronized void setExternalContextProvider(final String resolverPluginId) - throws CoreException - { - _project.setPersistentProperty - (PERSIST_PROPERTY_KEY_EXTERNAL_CONTEXT_PROVIDER, resolverPluginId); - } - - /** - * @return the id of the active design time external context provider - */ - public synchronized String getExternalContextProvider() - { - return getResolverId(PERSIST_PROPERTY_KEY_EXTERNAL_CONTEXT_PROVIDER, - DEFAULT_EXTERNAL_CONTEXT_ID); - } - - /** - * @return the designtime variable resolver for this application - */ - public synchronized AbstractDTVariableResolver getVariableResolver() - { - return getResolver(PERSIST_PROPERTY_KEY_VARIABLE_RESOLVER_PROVIDER, - JSFCorePlugin.getVariableResolvers(), - DEFAULT_VARIABLE_RESOLVER_ID); - } - - /** - * Sets the plugin used to determine the designtime variable resolver. To - * reset to the default, pass null. - * - * @param resolverPluginId - * @throws CoreException -- if the setting the new value fails - */ - public synchronized void setVariableResolverProvider(final String resolverPluginId) - throws CoreException - { - _project.setPersistentProperty - (PERSIST_PROPERTY_KEY_VARIABLE_RESOLVER_PROVIDER, resolverPluginId); - } - - /** - * @return the id of the active design time variable resolver - */ - public synchronized String getVariableResolverProvider() - { - return getResolverId(PERSIST_PROPERTY_KEY_VARIABLE_RESOLVER_PROVIDER, - DEFAULT_VARIABLE_RESOLVER_ID); - } - - - /** - * @return the designtime property resolver for this application - */ - public synchronized AbstractDTPropertyResolver getPropertyResolver() - { - return getResolver(PERSIST_PROPERTY_KEY_PROPERTY_RESOLVER_PROVIDER, - JSFCorePlugin.getPropertyResolvers(), - DEFAULT_PROPERTY_RESOLVER_ID); - } - - /** - * @param resolverPluginId - * @throws CoreException -- if setting the provider fails - */ - public synchronized void setPropertyResolverProvider(final String resolverPluginId) - throws CoreException - { - _project.setPersistentProperty - (PERSIST_PROPERTY_KEY_PROPERTY_RESOLVER_PROVIDER, resolverPluginId); - } - - /** - * @return the id of the active design time variable resolver - */ - public synchronized String getPropertyResolverProvider() - { - return getResolverId(PERSIST_PROPERTY_KEY_PROPERTY_RESOLVER_PROVIDER, - DEFAULT_PROPERTY_RESOLVER_ID); - } - - /** - * @return the designtime method resolver for this application - */ - public synchronized AbstractDTMethodResolver getMethodResolver() - { - return getResolver(PERSIST_PROPERTY_KEY_METHOD_RESOLVER_PROVIDER, - JSFCorePlugin.getMethodResolvers(), - DEFAULT_METHOD_RESOLVER_ID); - } - - /** - * @param resolverPluginId - * @throws CoreException -- if setting the plugin fails - */ - public synchronized void setMethodResolverProvider(final String resolverPluginId) - throws CoreException - { - _project.setPersistentProperty - (PERSIST_PROPERTY_KEY_METHOD_RESOLVER_PROVIDER, resolverPluginId); - - } - - /** - * @return the id of the active design time variable resolver - */ - public synchronized String getMethodResolverProvider() - { - return getResolverId(PERSIST_PROPERTY_KEY_METHOD_RESOLVER_PROVIDER, - DEFAULT_METHOD_RESOLVER_ID); - } - - - private <ResolverProvider> ResolverProvider getResolver(final QualifiedName pluginKey, - final Map<String, ResolverProvider> registry, - final String defaultId) - { - String pluginId = defaultId; - - try - { - pluginId = - _project.getPersistentProperty(pluginKey); - - // if don't have the plugin in the registry, then - // revert to default - if (pluginId == null) - { - pluginId = defaultId; - } - else if (registry.get(pluginId) == null) - { - JSFCorePlugin.getDefault().getLog().log( - new Status(IStatus.WARNING, JSFCorePlugin.PLUGIN_ID, - 0, "Plugin: "+pluginId+" not found", //$NON-NLS-1$ //$NON-NLS-2$ - new Throwable())); - pluginId = defaultId; - } - } - catch (CoreException ce) - { - JSFCorePlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, - 0, "Error getting plugin property", //$NON-NLS-1$ - ce)); - pluginId = defaultId; - // fall-through and use the default - } - - return registry.get(pluginId); - } - - private String getResolverId(final QualifiedName key, final String defaultValue) - { - String id = defaultValue; - - try - { - final String userId = - _project.getPersistentProperty(key); - - if (userId != null) - { - id = userId; - } - } - catch (CoreException ce) - { - // do nothing; fall through and return default - } - - return id; - } - - private class MyExternalContextFactoryLocator implements IExternalContextFactoryLocator - { - public AbstractDTExternalContextFactory getFactory() { - return getResolver(PERSIST_PROPERTY_KEY_EXTERNAL_CONTEXT_PROVIDER, - JSFCorePlugin.getExternalContextProviders(), - DEFAULT_EXTERNAL_CONTEXT_ID); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContext.java deleted file mode 100644 index 44c2fc642..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContext.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.designtime.context; - -import java.util.Collections; -import java.util.Map; - -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; - -/** - * The parent of all IDTExternalContext implementations - * - * Clients must sub-class to create IDTExternalContext implementations - * - * @author cbateman - * - */ -public abstract class AbstractDTExternalContext implements IDTExternalContext -{ - - /** - * Return a map of available symbols in each of the masked scopes - * indexed by symbol name - * - * Called by {@link #getMapForScope(int)} to satify the interface. - * If null is returned {@link #getMapForScope(int)} will automatically - * return an EMPTY_MAP. - * - * @param scopeMask - * @return the map of symbols - */ - protected abstract Map<String, ISymbol> doGetMapForScope(int scopeMask); - - - public final Map<String, ISymbol> getMapForScope(final int scopeMask) - { - Map<String, ISymbol> mapForScope = doGetMapForScope(scopeMask); - - if (mapForScope == null) - { - mapForScope = Collections.EMPTY_MAP; - } - else - { - mapForScope = Collections.unmodifiableMap(mapForScope); - } - return mapForScope; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getRequestMap() - */ - public final Map<String, ISymbol> getRequestMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_REQUEST); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getSessionMap() - */ - public final Map<String, ISymbol> getSessionMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_SESSION); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getApplicationMap() - */ - public final Map<String, ISymbol> getApplicationMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_APPLICATION); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getNoneMap() - */ - public final Map<String, ISymbol> getNoneMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_NONE); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContextFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContextFactory.java deleted file mode 100644 index b2fbbbf13..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContextFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * Super-class of all external context factories - * - * @author cbateman - * - */ -public abstract class AbstractDTExternalContextFactory -{ - /** - * @param containerContext - * @return a new IDTExternalContext for the containerContext refered - * to by containerContext. - */ - public abstract IDTExternalContext create(IAdaptable containerContext); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractExternalContextFactoryLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractExternalContextFactoryLocator.java deleted file mode 100644 index 77ae0861d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractExternalContextFactoryLocator.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.designtime.context; - -/** - * Parent of all implementers of IExternalContextFactoryLocator - * @author cbateman - * - */ -public abstract class AbstractExternalContextFactoryLocator implements - IExternalContextFactoryLocator -{ - /** - * @return the current external context factory - */ - public abstract AbstractDTExternalContextFactory getFactory(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTFacesContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTFacesContext.java deleted file mode 100644 index d0ae96760..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTFacesContext.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; - -/** - * Represents a design-time version of the JSF FacesContext for a particular - * web application. - * - * Client may not sub-class. - * - * @author cbateman - * - */ -public final class DTFacesContext -{ - private final IExternalContextFactoryLocator _locator; - - /** - * @param locator - */ - public DTFacesContext(final IExternalContextFactoryLocator locator) - { - _locator = locator; - } - - /** - * @param contextObject -- the object corresponding to the external context. - * Usually an IFile point to a file containing the external context. It must - * be adaptable to an IFile. - * - * @return the designtime external context or null if one is not defined - * for this contextObject - */ - public IDTExternalContext getDTExternalContext(final IAdaptable contextObject) - { - - IDTExternalContext externalContext = null; - - // if the context object is an IFile or can be adapted to one, create a - // new externalContext for it - if (contextObject instanceof IFile - || (contextObject != null && contextObject.getAdapter(IFile.class)!=null)) - { - - AbstractDTExternalContextFactory factory = _locator.getFactory(); - externalContext = factory.create(contextObject); - } - - return externalContext; - } - - private String _localeString = ""; //$NON-NLS-1$ - - /** - * @return the current locale string - */ - public String getLocaleString() - { - return _localeString; - } - - /** - * @param newLocaleString - */ - public void setLocaleString(final String newLocaleString) - { - _localeString = newLocaleString; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTJSPExternalContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTJSPExternalContext.java deleted file mode 100644 index 6add410a7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTJSPExternalContext.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import java.io.PrintStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProvider; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProviderFactory; - - -/** - * A designtime proxy for the Faces ExternalContext - * - * Clients may sub-class. - * - * @author cbateman - * - */ -public class DTJSPExternalContext extends AbstractDTExternalContext -{ - /** - * - */ - private final IFile _jspFile; - - /** - * Construct a default external context - * - * @param jspFile - */ - protected DTJSPExternalContext(final IAdaptable jspFile) - { - if (jspFile instanceof IFile) - { - _jspFile = (IFile) jspFile; - } - else if (jspFile != null) - { - IFile file = (IFile) jspFile.getAdapter(IFile.class); - - if (file != null) - { - _jspFile = file; - } - else - { - _jspFile = null; - throw new AssertionError("jspFile must be adapable to an IFile"); //$NON-NLS-1$ - } - } - else - { - _jspFile = null; - throw new AssertionError("jspFile must be adapable to an IFile"); //$NON-NLS-1$ - } - } - - @Override - protected Map doGetMapForScope(final int scopeMask) { - final Map map = new HashMap(); - - for (final Iterator it = JSFCommonPlugin.getSymbolSourceProviders().iterator(); it.hasNext();) - { - final ISymbolSourceProviderFactory factory = (ISymbolSourceProviderFactory) it.next(); - final ISymbolSourceProvider provider = factory.createInstance(_jspFile.getProject()); - - final ISymbol[] symbols = provider.getSymbols(_jspFile, scopeMask); - - for (int i = 0; i < symbols.length; i++) - { - map.put(symbols[i].getName(), symbols[i]); - } - } - - return map; - } - - - /** - * @param stream - */ - public final void trace(PrintStream stream) - { - String[] scopeNames = {ISymbolConstants.SYMBOL_SCOPE_REQUEST_STRING, - ISymbolConstants.SYMBOL_SCOPE_SESSION_STRING, - ISymbolConstants.SYMBOL_SCOPE_APPLICATION_STRING, - ISymbolConstants.SYMBOL_SCOPE_NONE_STRING - }; - Map[] symbolMaps = {getRequestMap(), getSessionMap(), getApplicationMap()}; - - for (int i = 0; i < scopeNames.length; i++) - { - stream.println("--------------"); //$NON-NLS-1$ - stream.println(scopeNames[i]+" Scope:"); //$NON-NLS-1$ - stream.println("--------------"); //$NON-NLS-1$ - - for (final Iterator it = symbolMaps[i].values().iterator(); it.hasNext();) - { - ISymbol symbol = (ISymbol) it.next(); - System.out.println(symbol.getName()); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DefaultDTExternalContextFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DefaultDTExternalContextFactory.java deleted file mode 100644 index 1d2af78b3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DefaultDTExternalContextFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * Creates external contexts for JSPs - * - * Clients may sub-class - * - * @author cbateman - * - */ -public class DefaultDTExternalContextFactory extends - AbstractDTExternalContextFactory -{ - - /** - * @param containerContext -- must be adaptable to an IFile of content type - * JSP - * - * @return a new DT external context - */ - public IDTExternalContext create(final IAdaptable containerContext) - { - return new DTJSPExternalContext(containerContext); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IDTExternalContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IDTExternalContext.java deleted file mode 100644 index 3df048ce1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IDTExternalContext.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import java.util.Map; - -import org.eclipse.jst.jsf.context.symbol.ISymbol; - -/** - * Interface that must be implemented by all design time external contexts - * - * Clients may implement but should not sub-class. If implementing, sub-class - * AbstractDTExternalContext instead. - * - * @author cbateman - * - */ -public interface IDTExternalContext -{ - /** - * @param scopeMask -- the scope for which to return the symbol map - * @return a map of ISymbols representing the currently available - * scope variables. Never null, empty if no symbols - * - * Map is unmodifiable (throws exception on mutation operations) - */ - public abstract Map<String, ISymbol> getMapForScope(int scopeMask); - - /** - * @return a map of ISymbols representing the currently available - * request scope variables. Never null, empty if no symbols - * - * Map is unmodifiable (throws exception on mutation operations) - */ - public abstract Map<String, ISymbol> getRequestMap(); - - /** - * @return a map of ISymbols representing the currently available - * session scope variables. Never null, empty if no symbols - * Map is unmodifiable (throws exception on mutation operations) - */ - public abstract Map<String, ISymbol> getSessionMap(); - - /** - * @return a map of ISymbols representing the currently available - * application scope variables. Never null, empty if no symbols - * Map is unmodifiable (throws exception on mutation operations) - */ - public abstract Map<String, ISymbol> getApplicationMap(); - - /** - * @return a map of ISymbols representing the currently available - * none scope variables. Never null, empty if no symbols - * Map is unmodifiable (throws exception on mutation operations) - */ - public abstract Map<String, ISymbol> getNoneMap(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IExternalContextFactoryLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IExternalContextFactoryLocator.java deleted file mode 100644 index 0842ed8b4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IExternalContextFactoryLocator.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -/** - * This interface is used to decouple the faces context from the - * DesignTimeApplicationManager - * - * Client must NOT implement or subclass. - * Extend AbstractExternalContextFactoryLocator instead - * - * @author cbateman - * - */ -public interface IExternalContextFactoryLocator -{ - /** - * @return the current external context factory - */ - AbstractDTExternalContextFactory getFactory(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTMethodResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTMethodResolver.java deleted file mode 100644 index da115122b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTMethodResolver.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.el; - -import org.eclipse.jst.jsf.context.symbol.IMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; - -/** - * Sub-class of all design time method resolvers - * - * @author cbateman - * - */ -public abstract class AbstractDTMethodResolver -{ - /** - * Returns a symbol encapsulating the method on base with the name - * methodId - * - * @param base - * @param methodId - * @return the symbol for the named methodId or null if not found - */ - public abstract IMethodSymbol getMethod(IObjectSymbol base, Object methodId); - - - /** - * @param base - * @return all method binding symbols for base - */ - public abstract ISymbol[] getMethods(IObjectSymbol base); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTPropertyResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTPropertyResolver.java deleted file mode 100644 index 23e6b5744..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTPropertyResolver.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.el; - -import org.eclipse.jst.jsf.context.symbol.ISymbol; - -/** - * Super-class of all design time property resolvers - * - * @author cbateman - * - */ -public abstract class AbstractDTPropertyResolver -{ - /** - * Returns a symbol encapsulating the property on base with the name - * properyId. Note that getProperty may return *more* property symbols - * for the same 'base' because some ISymbol's have unconstrained type - * descriptors. For example, a bean that implements java.util.Map, - * may have any number of possible properties add at runtime that cannot - * be determined at design time. It is up to implementers of this interface - * to decide how (whether) to return these objects at design time - * - * @param base - * @param propertyId - * @return the symbol for the named propertyId or null if not found - */ - public abstract ISymbol getProperty(ISymbol base, Object propertyId); - - /** - * @param base - * @param offset - * @return the symbol for the property referred to by the offset - * into base when it is treated as either an array or a list. - * The symbol returned is *not* found in the getAllProperties list. - */ - public abstract ISymbol getProperty(ISymbol base, int offset); - - /** - * @param base - * @return all properties of base that can be determined concretely - * at designtime. Note that getProperty(base, x) may return non-null - * for objects not found in the return from this method. @see getProperty - */ - public abstract ISymbol[] getAllProperties(ISymbol base); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTVariableResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTVariableResolver.java deleted file mode 100644 index 532fc5d99..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/AbstractDTVariableResolver.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.el; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.designtime.context.DTFacesContext; - -/** - * Super-class of all design-time variable resolver. A design time variable - * resolver - * - * Clients may sub-class. - * - * @author cbateman - * - */ -public abstract class AbstractDTVariableResolver -{ - /** - * @param context - * @param name - * @param externalContextKey -- an adapter that identifies the external application - * context within which to resolve name. For example, this could be an IFile - * representing a JavaServer Page in which we want to resolve the symbol name - * @return the symbol corresponding to name in the faces context or null - * if not found - */ - public abstract ISymbol resolveVariable(DTFacesContext context, String name, IAdaptable externalContextKey); - - /** - * @param facesContext - * @param externalContextKey - * @return all variables - */ - public abstract ISymbol[] getAllVariables(DTFacesContext facesContext, - IAdaptable externalContextKey); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTMethodResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTMethodResolver.java deleted file mode 100644 index bc6814bd4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTMethodResolver.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.el; - -import java.util.Iterator; - -import org.eclipse.jst.jsf.context.symbol.IMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; - -/** - * This resolver has no direct analogue at runtime. JSF Components implement - * method bindings at runtime in a runtime specific way. But at design time - * we have no direct DTComponent so instead we use this resolver to resolve - * an IInstanceSymbol and method name to an IMethodSymbol (if one exists). - * - * Clients may sub-class - * - * @author cbateman - * - */ -public class DefaultDTMethodResolver extends AbstractDTMethodResolver -{ - /** - * Returns a symbol encapsulating the method on base with the name - * methodId - * - * @param base - * @param methodId - * @return the symbol for the named methodId or null if not found - */ - public IMethodSymbol getMethod(IObjectSymbol base, Object methodId) - { - for (final Iterator it = base.getTypeDescriptor().getMethods().iterator(); it.hasNext();) - { - IMethodSymbol element = (IMethodSymbol) it.next(); - if (element.getName().equals(methodId)) - { - return element; - } - } - - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.el.AbstractDTMethodResolver#getMethods(org.eclipse.jst.jsf.context.symbol.IInstanceSymbol) - */ - public ISymbol[] getMethods(IObjectSymbol base) - { - return (ISymbol[]) - base.getTypeDescriptor().getMethods(). - toArray(new ISymbol[0]); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTPropertyResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTPropertyResolver.java deleted file mode 100644 index d4a5eee1c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTPropertyResolver.java +++ /dev/null @@ -1,280 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.el; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.StringLiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.symbol.IBoundedTypeDescriptor; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.ITypeDescriptor; - -/** - * A design time proxy for the runtime PropertyResolver. This is used to - * resolve all but the first element of a var.prop.prop2 type of sub-expression in - * a JSF EL expression. @see DefaultDTVariableResolver for how to resolve 'var' at - * designtime - * - * Clients may implement - * - * @author cbateman - */ -public class DefaultDTPropertyResolver extends AbstractDTPropertyResolver -{ - /** - * Returns a symbol encapsulating the property on base with the name - * properyId - * - * @param base - * @param propertyId - * @return the symbol for the named propertyId or null if not found - */ - public ISymbol getProperty(ISymbol base, Object propertyId) - { - ITypeDescriptor typeDesc = null; - - Object[] factoredProperties = new Object[] {propertyId}; - - // check for expected interface types per JSP.2.3.4 - if (base instanceof IObjectSymbol) - { - final IObjectSymbol objSymbol = (IObjectSymbol) base; - typeDesc = objSymbol.getTypeDescriptor(); - - // although not stated explicitly stated by the spec, in practice (based on Sun RI), - // a list cannot have non-numeric indexed properties - // note: due to remove(Object) having different return types - // an object can't be both a List and a Map! So we can consider - // a List instanceof out of order - if (objSymbol.supportsCoercion(TypeConstants.TYPE_LIST)) - { - typeDesc = null; - } - // per JSP.2.3.4, if instance of map (unconstrained in our terminology) - else if (objSymbol.supportsCoercion(TypeConstants.TYPE_MAP)) - { - EList<ValueType> args = new BasicEList<ValueType>(); - args.add(new StringLiteralType(propertyId.toString())); - - ISymbol prop = objSymbol.call("get", args, propertyId.toString()); //$NON-NLS-1$ - - if (prop != null) - { - return prop; - } - - typeDesc = objSymbol.coerce(TypeConstants.TYPE_MAP); - - // handle string keys into maps that contain dots. Because type descriptor - // handle dotted property ids (i.e. 'x.y.z') as separate properties with - // intermediate parts, we need to handle this specially. - if (propertyId instanceof String && ((String)propertyId).indexOf('.')>-1) - { - factoredProperties = factorKey(propertyId); - } - } - - // check unconstrained type - if (typeDesc instanceof IBoundedTypeDescriptor) - { - // TODO: propertyId may need to change when supporting - // template types - if (((IBoundedTypeDescriptor)typeDesc).isUnboundedForType(TypeConstants.TYPE_JAVAOBJECT)) - { - // the most we know is that it could be an Object - return ((IBoundedTypeDescriptor)typeDesc).getUnboundedProperty(propertyId, TypeConstants.TYPE_JAVAOBJECT); - } - } - } - - int i = 0; - ISymbol matchedSymbol; - - do - { - matchedSymbol = null; // always reset so if the for completes without setting, the - // while ends - SEARCH_SEGMENT: for (final Iterator it = getIterator(typeDesc); it.hasNext();) - { - final ISymbol element = (ISymbol) it.next(); - - if (element.getName().equals(factoredProperties[i]) - && element instanceof IObjectSymbol) - { - matchedSymbol = element; - typeDesc = ((IObjectSymbol)matchedSymbol).getTypeDescriptor(); - break SEARCH_SEGMENT; - } - } - } while(++i < factoredProperties.length && matchedSymbol != null); - - // may be null if none matched - return matchedSymbol; - } - - /** - * @param base - * @return all properties of base - */ - public ISymbol[] getAllProperties(ISymbol base) - { - // if nothing found, return an empty array - List symbolsList = Collections.EMPTY_LIST; - - if (base instanceof IObjectSymbol) - { - ITypeDescriptor typeDesc = null; - - // per JSP.2.3.4, if instance of map (unconstrained in our terminology) - if (((IObjectSymbol)base).supportsCoercion(TypeConstants.TYPE_MAP)) - { - typeDesc = - ((IObjectSymbol)base).coerce(TypeConstants.TYPE_MAP); - } - // Lists have no properties, even if they are also beans - else if (((IObjectSymbol)base).supportsCoercion(TypeConstants.TYPE_LIST)) - { - typeDesc = null; - } - else - { - typeDesc = ((IObjectSymbol)base).getTypeDescriptor(); - - } - - if (typeDesc != null) - { - symbolsList = typeDesc.getProperties(); - } - } - - return (ISymbol[]) symbolsList.toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.el.AbstractDTPropertyResolver#getProperty(org.eclipse.jst.jsf.context.symbol.ISymbol, int) - */ - public ISymbol getProperty(ISymbol base, int offset) - { - ITypeDescriptor typeDesc = null; - - if (offset < 0) - { - // should never be called with offset < 0 - throw new AssertionError("offsets must be >=0 to be valid"); //$NON-NLS-1$ - } - - // check for expected interface types per JSP.2.3.4 - if (base instanceof IObjectSymbol) - { - - final IObjectSymbol objSymbol = (IObjectSymbol) base; - typeDesc = objSymbol.getTypeDescriptor(); - - // per JSP.2.3.4, if instance of array (unconstrained in our terminology) - if (typeDesc.isArray()) - { - ISymbol arrayElement = typeDesc.getArrayElement(); - // reset the name - arrayElement.setName(base.getName()+"["+offset+"]"); //$NON-NLS-1$ //$NON-NLS-2$ - return arrayElement; - } - - // per JSP.2.3.4, if instance of list (unbounded in our terminology) - if (objSymbol.supportsCoercion(TypeConstants.TYPE_LIST)) - { - //typeDesc = objSymbol.coerce(TypeConstants.TYPE_LIST); - final EList<ValueType> args = new BasicEList<ValueType>(); - args.add(new ValueType(Signature.SIG_INT, ValueType.ASSIGNMENT_TYPE_RHS)); - return objSymbol.call("get", args, base.getName()+"["+offset+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - // check unconstrained type -// if (typeDesc instanceof IBoundedTypeDescriptor) -// { -// // TODO: propertyId may need to change when supporting -// // template types -// if (((IBoundedTypeDescriptor)typeDesc).isUnboundedForType(TypeConstants.TYPE_BOXED_INTEGER)) -// { - // the most we know is that it could be an Object -// return ((IBoundedTypeDescriptor)typeDesc) -// .getUnboundedProperty -// (new Integer(offset), TypeConstants.TYPE_BOXED_INTEGER); -// final EList<Object> args = new BasicEList<Object>(); -// args.add(offset); -// return ((IBoundedTypeDescriptor)typeDesc) -// .call("get", args, base.getName()+"["+offset+"]"); -// } -// } - } - - return null; - } - - /** - * @param typeDesc - * @return the type descriptor's property iterator or empty list - * if null - */ - protected final Iterator getIterator(ITypeDescriptor typeDesc) - { - if (typeDesc != null) - { - return typeDesc.getProperties().iterator(); - } - return Collections.EMPTY_LIST.iterator(); - } - - /** - * Takes a key expression and factors it down to into all property segments it contains. - * Property segments occur mainly when String keys contain '.' characters, indicating that - * more one than property actually must be traversed to evaluate the whole expr. - * @param key - * @return an array containing all property segments of the key. If the key contains only - * one property, then this is returned a single element in the array - */ - protected final Object[] factorKey(Object key) - { - if (key instanceof String) - { - List segments = new ArrayList(); - - String stringKey = (String) key; - int nextPos = -1; - - while ((nextPos = stringKey.indexOf('.')) > -1) - { - segments.add(stringKey.substring(0, nextPos)); - stringKey = stringKey.substring(nextPos+1); - } - - if (stringKey != null && stringKey.length() > 0) - { - segments.add(stringKey); - } - - return segments.toArray(); - } - - return new Object[] {key}; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTVariableResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTVariableResolver.java deleted file mode 100644 index 7b9aee543..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/el/DefaultDTVariableResolver.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.el; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; -import org.eclipse.jst.jsf.designtime.context.DTFacesContext; -import org.eclipse.jst.jsf.designtime.context.IDTExternalContext; -import org.eclipse.jst.jsf.designtime.symbols.DefaultBeanSymbolSourceProvider; -import org.eclipse.jst.jsf.designtime.symbols.DefaultBuiltInSymbolProvider; - -/** - * A design time proxy for the runtime VariableResolver. This is used to - * resolve the first element of a var.prop.prop2 type of sub-expression in - * a JSF EL expression - * - * Clients may sub-class - * - * @author cbateman - * - */ -public class DefaultDTVariableResolver extends AbstractDTVariableResolver -{ - /** - * Tries to mirror the JSF 1.1 runtime VariableResolver - * - * @see org.eclipse.jst.jsf.designtime.el.AbstractDTVariableResolver#resolveVariable(org.eclipse.jst.jsf.designtime.context.DTFacesContext, java.lang.String, org.eclipse.core.runtime.IAdaptable) - */ - public ISymbol resolveVariable(DTFacesContext context, String name, IAdaptable externalContextKey) - { - // check implicits first - final DefaultBuiltInSymbolProvider builtins = - DefaultBuiltInSymbolProvider.getInstance(); - - ISymbol symbol = builtins.getSymbol(name, externalContextKey, ISymbolConstants.SYMBOL_SCOPE_ALL); - - if (symbol != null) - { - return symbol; - } - - // next check the scope maps from request up to application - final IDTExternalContext externalContext = - context.getDTExternalContext(externalContextKey); - - if (externalContext == null) - { - // TODO: try to find bean here? - return null; - } - - symbol = externalContext.getRequestMap().get(name); - - // check request scope - if (symbol == null) - { - symbol = externalContext.getSessionMap().get(name); - - // then check session scope - if (symbol == null) - { - symbol = externalContext.getApplicationMap().get(name); - - // if the symbol is not found at any scope, then look for a - // a bean. - if (symbol == null) - { - final DefaultBeanSymbolSourceProvider beanProvider = - DefaultBeanSymbolSourceProvider.getInstance(); - - symbol = beanProvider.getSymbol(name, externalContextKey, - ISymbolConstants.SYMBOL_SCOPE_ALL); - } - } - } - - return symbol; - } - - /** - * @param facesContext - * @param externalContextKey - * @return all variables - */ - public ISymbol[] getAllVariables(DTFacesContext facesContext, - IAdaptable externalContextKey) - { - final List allSymbols = new ArrayList(); - - addBuiltins(allSymbols, externalContextKey); - - final IDTExternalContext externalContext = - facesContext.getDTExternalContext(externalContextKey); - - if (externalContext != null) - { - addExternalContextSymbols(allSymbols, externalContext); - } - - addBeanSymbols(allSymbols, externalContextKey); - - return (ISymbol[]) allSymbols.toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - - /** - * Adds the built-in symbols to the list. This behaviour is standarized and should - * not be overriden in general. However, you may wish to change the default - * built-in symbol provider with your own. - * - * @param list - * @param externalContextKey - */ - protected void addBuiltins(final List list, final IAdaptable externalContextKey) - { - // check implicits first - final DefaultBuiltInSymbolProvider builtins = - DefaultBuiltInSymbolProvider.getInstance(); - - list.addAll(Arrays.asList(builtins.getSymbols(externalContextKey, - ISymbolConstants.SYMBOL_SCOPE_ALL))); - } - - /** - * Simulate resolution of symbols from the request, session, application and none - * scope maps. Use a symbol provider instead if you simply want to add - * new symbols for a tag variable or other symbol source. - * - * @param list - * @param externalContext - */ - protected void addExternalContextSymbols(final List list, - final IDTExternalContext externalContext) - { - if (externalContext != null) - { - final ISymbol[] externalContextSymbols = - externalContext.getMapForScope - (ISymbolConstants.SYMBOL_SCOPE_ALL).values(). - toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - list.addAll(Arrays.asList(externalContextSymbols)); - } - } - - /** - * Gets all the bean symbols. If you wish to override it would be advisable - * to look at and/or sub-class the default bean symbol source provider - * - * @param list - * @param externalContextKey - */ - protected void addBeanSymbols(final List list, final IAdaptable externalContextKey) - { - final DefaultBeanSymbolSourceProvider beanProvider = - DefaultBeanSymbolSourceProvider.getInstance(); - - final ISymbol[] beanSymbols = - beanProvider.getSymbols(externalContextKey, - ISymbolConstants.SYMBOL_SCOPE_ALL); - - list.addAll(Arrays.asList(beanSymbols)); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/DataModelVariableFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/DataModelVariableFactory.java deleted file mode 100644 index 95cde302c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/DataModelVariableFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.designtime.internal.jsp; - -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants; -import org.eclipse.jst.jsf.designtime.symbols.AbstractDataModelVariableFactory; -import org.eclipse.jst.jsf.designtime.symbols.DefaultDataTableSymbolFactory; -import org.w3c.dom.Element; - -/** - * Constructs an EL IObjectSymbol for a particular data table row access variable - * based on the type of the bound data (the value attribute) - * - * - * @author cbateman - * - */ -class DataModelVariableFactory extends DefaultDataTableSymbolFactory -{ - private static DataModelVariableFactory INSTANCE; - - /** - * @return an instance of the factory - */ - public synchronized static DataModelVariableFactory getInstance() - { - if (INSTANCE == null) - { - INSTANCE = new DataModelVariableFactory(); - } - - return INSTANCE; - } - - @Override - public ISymbol createSymbolForDataTableValue(String symbolName, - Element dataTableElement, IStructuredDocumentContext context) - { - if (!IJSFConstants.TAG_DATATABLE.equals(dataTableElement.getLocalName())) - { - throw new AssertionError("dataTableElement must be a dataTable"); //$NON-NLS-1$ - } - - return super.createSymbolForDataTableValue(symbolName, dataTableElement, context); - } - - //private String getELText(IStructuredDocumentConte) - private DataModelVariableFactory() - { - // no external instantiation - super(new MyDataModelVariableFactory()); - } - - private static class MyDataModelVariableFactory extends AbstractDataModelVariableFactory - { - @Override - protected String getVariableSourceName() { - return "dataTable"; //$NON-NLS-1$ - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/JSPDefaultSymbolFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/JSPDefaultSymbolFactory.java deleted file mode 100644 index 5edf7a927..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/JSPDefaultSymbolFactory.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.internal.jsp; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextResolver; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.symbol.IComponentSymbol; -import org.eclipse.jst.jsf.context.symbol.IMapTypeDescriptor; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.SymbolFactory; -import org.eclipse.jst.jsf.context.symbol.source.AbstractContextSymbolFactory; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants; -import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants; -import org.eclipse.jst.jsf.designtime.internal.symbols.ResourceBundleMapSourceFactory; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -/** - * @author cbateman - * - */ -public class JSPDefaultSymbolFactory extends AbstractContextSymbolFactory -{ - protected ISymbol internalCreate(String symbolName,int scope,IAdaptable context,List problems) - { - final IStructuredDocumentContext sContext = - (IStructuredDocumentContext) - context.getAdapter(IStructuredDocumentContext.class); - - final IDOMContextResolver domResolver = - IStructuredDocumentContextResolverFactory.INSTANCE.getDOMContextResolver(sContext); - - if (domResolver != null) - { - final Node curNode = domResolver.getNode(); - - if (curNode instanceof Attr) - { - final Attr attr = (Attr) curNode; - final Node owningElement = attr.getOwnerElement(); - - if (owningElement != null) - { - return handleSymbolCreation(symbolName, sContext, attr, owningElement, problems); - } - } - } - - return null; - } - - - private ISymbol handleSymbolCreation(final String symbolName, - final IStructuredDocumentContext context, - final Attr attr, - final Node owningElement, - final List problems) - { - final ITaglibContextResolver resolver = - IStructuredDocumentContextResolverFactory.INSTANCE.getTaglibContextResolver(context); - - - if (resolver == null - || !resolver.canResolveContext(context)) - { - return null; - } - - final String uri = resolver.getTagURIForNodeName(owningElement); - - // process core taglib - if (ITLDConstants.URI_JSF_CORE.equals(uri)) - { - return handleCoreTags(symbolName, owningElement, attr, context, problems); - } - else if (ITLDConstants.URI_JSF_HTML.equals(uri)) - { - return handleHtmlTags(symbolName, owningElement, attr, context, problems); - } - - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.context.symbol.source.AbstractContextSymbolFactory#supports(org.eclipse.core.runtime.IAdaptable) - */ - public boolean supports(IAdaptable context) - { - return context.getAdapter(IStructuredDocumentContext.class) != null; - } - - private ISymbol handleHtmlTags(String symbolName, Node owningElement, Attr attr, IStructuredDocumentContext context, List problems) - { - final String elementName = owningElement.getLocalName(); - final String attrName = attr.getName(); - - if (IJSFConstants.TAG_DATATABLE.equals(elementName)) - { - if (IJSFConstants.ATTR_VAR.equals(attrName)) - { - return DataModelVariableFactory.getInstance() - .createSymbolForDataTableValue(symbolName, (Element) owningElement, context); - } - } - - return null; - } - - private ISymbol handleCoreTags(String symbolName, Node owningElement, Attr attr, IStructuredDocumentContext context, List problems) - { - final String elementName = owningElement.getLocalName(); - - if (IJSFConstants.TAG_LOADBUNDLE.equals(elementName)) - { -// long startTime = System.currentTimeMillis(); - ISymbol symbol = handleLoadBundleTag(symbolName, owningElement, attr, context, problems); - -// long endTime = System.currentTimeMillis(); -// long totalTime = endTime-startTime; - //System.out.println("Loadbundle resolution for symbol "+symbolName+" took: "+totalTime+"ms"); - return symbol; - } - return null; - } - - private ISymbol handleLoadBundleTag(String symbolName, Node owningElement, Attr attr, IStructuredDocumentContext context, List problems) - { - final String attrName = attr.getName(); - if (IJSFConstants.ATTR_VAR.equals(attrName)) - { - final NamedNodeMap attrMap = owningElement.getAttributes(); - final Node baseNameNode = attrMap.getNamedItem(IJSFConstants.ATTR_BASENAME); - - - if (baseNameNode != null) - { - try - { - final IWorkspaceContextResolver wkspaceResolver = - IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context); - IProject project = wkspaceResolver.getProject(); - - if (project == null) - { - throw new RuntimeException("Error acquiring project"); //$NON-NLS-1$ - } - - final Map source = - ResourceBundleMapSourceFactory - .getResourceBundleMapSource(project, baseNameNode.getNodeValue()); - final IMapTypeDescriptor typeDesc = - SymbolFactory.eINSTANCE.createIMapTypeDescriptor(); - typeDesc.setMapSource(source); - final IComponentSymbol symbol = - SymbolFactory.eINSTANCE.createIComponentSymbol(); - symbol.setName(symbolName); - symbol.setTypeDescriptor(typeDesc); - symbol.setDetailedDescription(Messages.getString("JSPDefaultSymbolFactory.Resource.bundle.map.detailedDescription")+baseNameNode.getNodeValue()+"</i>"); //$NON-NLS-1$ //$NON-NLS-2$ - - return symbol; - } - catch (IOException ioe) - { - problems.add(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0,Messages.getString("JSPDefaultSymbolFactory.Problem.ErrorCreatingVariable"), ioe)); //$NON-NLS-1$ - } - catch (JavaModelException jme) - { - problems.add(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0,Messages.getString("JSPDefaultSymbolFactory.Problem.ErrorCreatingVariable"), jme)); //$NON-NLS-1$ - } - catch (CoreException ce) - { - problems.add(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0,Messages.getString("JSPDefaultSymbolFactory.Problem.ErrorCreatingVariable"), ce)); //$NON-NLS-1$ - } - } - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/JSPModelProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/JSPModelProcessor.java deleted file mode 100644 index 18436fc9c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/JSPModelProcessor.java +++ /dev/null @@ -1,623 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.internal.jsp; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.TraitValueHelper; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory; -import org.eclipse.jst.jsf.context.symbol.IComponentSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.SymbolFactory; -import org.eclipse.jst.jsf.context.symbol.source.AbstractContextSymbolFactory; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.designtime.DesignTimeApplicationManager; -import org.eclipse.jst.jsf.designtime.context.DTFacesContext; -import org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent; -import org.eclipse.wst.sse.core.internal.provisional.IModelLifecycleListener; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -/** - * Processes a JSP model to determine information of interest about it such - * as what tags are currently in use. Listens to the model and updates it's - * information when the model changes. - * - * @author cbateman - * - */ -public class JSPModelProcessor -{ - private final static String SESSION_PROPERTY_QUALIFIER = "net.eclipse.jst.jsf.jsp"; //$NON-NLS-1$ - private final static String SESSION_PROPERTY_NAME_JSPMODELPROCESSOR = "JSPModelProcessor"; //$NON-NLS-1$ - private final static QualifiedName SESSION_PROPERTY_JSPMODELPROCESSOR_KEY = - new QualifiedName(SESSION_PROPERTY_QUALIFIER,SESSION_PROPERTY_NAME_JSPMODELPROCESSOR); - /** - * @param file The file to get the model processor for - * @return the processor for a particular model, creating it if it does not - * already exist - * @throws CoreException if an attempt to get the model associated with file - * fails due to reasons other than I/O problems - * @throws IOException if an attempt to get the model associated with file - * fails due to I/O problems - */ - public static JSPModelProcessor get(IFile file) throws CoreException, IOException - { - synchronized(file) - { - JSPModelProcessor processor = - (JSPModelProcessor) file.getSessionProperty(SESSION_PROPERTY_JSPMODELPROCESSOR_KEY); - - if (processor == null) - { - processor = new JSPModelProcessor(file); - file.setSessionProperty(SESSION_PROPERTY_JSPMODELPROCESSOR_KEY, processor); - } - return processor; - } - } - - /** - * Disposes of the JSPModelProcessor associated with model - * @param file the file associated with the model processor to be disposed - */ - public static void dispose(IFile file) - { - try - { - synchronized(file) - { - // TODO: do we need worry about the processor not being - // disposed if the underlying file has been deleted? - // TODO: need isLocal check? - if (file.isAccessible()) - { - JSPModelProcessor processor = - get(file); - - if (processor != null - && !processor.isDisposed) - { - file.setSessionProperty(SESSION_PROPERTY_JSPMODELPROCESSOR_KEY, null); - processor.dispose(); - } - } - } - } - catch (CoreException ce) - { - Platform.getLog(JSFCorePlugin.getDefault().getBundle()).log( - new Status(IStatus.ERROR, JSFCorePlugin.getDefault().getBundle().getSymbolicName(), 0, "Problem disposing JSPModelProcessor", new Throwable(ce))); //$NON-NLS-1$ - } - catch (IOException ioe) - { - Platform.getLog(JSFCorePlugin.getDefault().getBundle()).log( - new Status(IStatus.ERROR, JSFCorePlugin.getDefault().getBundle().getSymbolicName(), 0, "Problem disposing JSPModelProcessor", new Throwable(ioe))); //$NON-NLS-1$ - } - } - - private final IFile _file; - private final DOMModelForJSP _model; - private final ModelListener _modelListener; - private boolean isDisposed; - private Map<Object, ISymbol> _requestMap; - private Map<Object, ISymbol> _sessionMap; - private Map<Object, ISymbol> _applicationMap; - private Map<Object, ISymbol> _noneMap; - private long _lastModificationStamp; - - // used to avoid infinite recursion in refresh. Must never be null - private final CountingMutex _lastModificationStampMonitor = new CountingMutex(); - - /** - * Construct a new JSPModelProcessor for model - * - * @param model - */ - private JSPModelProcessor(IFile file) throws CoreException, IOException - { - _model = getModelForFile(file); - _modelListener = new ModelListener(); - _model.addModelLifecycleListener(_modelListener); - _file = file; - // a negative value guarantees that refresh(false) will - // force a refresh on the first run - _lastModificationStamp = -1; - } - - - private DOMModelForJSP getModelForFile(IFile file) - throws CoreException, IOException - { - final IModelManager modelManager = - StructuredModelManager.getModelManager(); - - IStructuredModel model = modelManager.getModelForRead(file); - - if (model instanceof DOMModelForJSP) - { - return (DOMModelForJSP) model; - } - - model.releaseFromRead(); - - throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.blah", 0, //$NON-NLS-1$ - "model not of expected type", new Throwable())); //$NON-NLS-1$ - } - - private void dispose() - { - if (!isDisposed) - { - _model.releaseFromRead(); - _model.removeModelLifecycleListener(_modelListener); - - if (_requestMap != null) - { - _requestMap.clear(); - _requestMap = null; - } - - if (_sessionMap != null) - { - _sessionMap.clear(); - _sessionMap = null; - } - - if (_applicationMap != null) - { - _applicationMap.clear(); - _applicationMap = null; - } - - if (_noneMap != null) - { - _noneMap.clear(); - _noneMap = null; - } - - // mark as disposed - isDisposed = true; - } - } - - /** - * @return true if this model processor has been disposed. Disposed - * processors should not be used. - */ - boolean isDisposed() - { - return isDisposed; - } - - /** - * Updates the internal model - * @param forceRefresh -- if true, always refreshes, if false, - * then it only refreshes if the file's modification has changed - * since the last refresh - */ - public void refresh(final boolean forceRefresh) - { - synchronized(_lastModificationStampMonitor) - { - if (_lastModificationStampMonitor.isSignalled()) - { - // if this calls succeeds, then this thread has obtained the - // lock already and has called through here before. - // return immediately to ensure that we don't recurse infinitely - return; - } - - try - { - _lastModificationStampMonitor.setSignalled(true); - - long currentModificationStamp; - - currentModificationStamp = _file.getModificationStamp(); - - // only refresh if forced or if the underlying file has changed - // since the last run - if (forceRefresh - || _lastModificationStamp != currentModificationStamp) - { - refreshInternal(); - _lastModificationStamp = _file.getModificationStamp(); - } - } - // make sure that we unsignal the monitor before releasing the - // mutex - finally - { - _lastModificationStampMonitor.setSignalled(false); - } - } - } - - private void refreshInternal() - { - final IStructuredDocumentContext context = - IStructuredDocumentContextFactory.INSTANCE.getContext(_model.getStructuredDocument(), -1); - final ITaglibContextResolver taglibResolver = - IStructuredDocumentContextResolverFactory.INSTANCE.getTaglibContextResolver(context); - IDOMDocument document = _model.getDocument(); - getApplicationMap().clear(); - getRequestMap().clear(); - getSessionMap().clear(); - //long curTime = System.currentTimeMillis(); - recurseChildNodes(document.getChildNodes(), taglibResolver); - //long netTime = System.currentTimeMillis() - curTime; - //System.out.println("Net time to recurse document: "+netTime); - } - - private void recurseChildNodes(final NodeList nodes, - final ITaglibContextResolver taglibResolver) - { - for (int i = 0; i < nodes.getLength(); i++) - { - final Node child = nodes.item(i); - - // process attributes at this node before recursing - processAttributes(child, taglibResolver); - recurseChildNodes(child.getChildNodes(), taglibResolver); - } - } - - private void processAttributes(final Node node, - final ITaglibContextResolver taglibResolver) - { - if (taglibResolver.hasTag(node)) - { - final String uri = - taglibResolver.getTagURIForNodeName(node); - final String elementName = node.getLocalName(); - - for (int i = 0; i < node.getAttributes().getLength(); i++) - { - final Node attribute = node.getAttributes().item(i); - - processSymbolContrib(uri, elementName, attribute); - processSetsLocale(uri, elementName, attribute); - } - } - } - - private void processSymbolContrib(final String uri, final String elementName, Node attribute) - { - final SymbolContribAggregator aggregator = - SymbolContribAggregator. - create(_file.getProject(), uri, elementName, attribute.getLocalName()); - - if (aggregator != null) - { - final AbstractContextSymbolFactory factory = aggregator.getFactory(); - final String symbolName = attribute.getNodeValue(); - - if (factory != null) - { -// long curTime = System.currentTimeMillis(); - - final List problems = new ArrayList(); - ISymbol symbol = - factory.create(symbolName, - ISymbolConstants.SYMBOL_SCOPE_REQUEST, //TODO: - IStructuredDocumentContextFactory.INSTANCE. - getContext(_model.getStructuredDocument(), - attribute), - problems); - -// long netTime = System.currentTimeMillis() - curTime; -// System.out.println("Time to process loadBundle: "+netTime); - - if (symbol != null) - { - updateMap(symbol, aggregator.getScope()); - } - } - else - { - IComponentSymbol componentSymbol = - SymbolFactory.eINSTANCE.createIComponentSymbol(); - componentSymbol.setName(symbolName); - - updateMap(componentSymbol, aggregator.getScope()); - } - } - } - - private void processSetsLocale(final String uri, final String elementName, Node attribute) - { - LocaleSetAggregator aggregator = LocaleSetAggregator.create(_file.getProject(), uri, elementName, attribute.getLocalName()); - - if (aggregator != null) - { - DesignTimeApplicationManager dtAppMgr = - DesignTimeApplicationManager.getInstance(_file.getProject()); - - DTFacesContext facesContext = dtAppMgr.getFacesContext(_file); - - if (facesContext != null) - { - facesContext.setLocaleString(attribute.getNodeValue()); - } - } - } - - /** - * @param scopeName - one of "request", "session" or "application" - * @return an unmodifable map containing all known symbols for - * that scope. If scopeName is not found, returns the empty map. - */ - public Map<Object, ISymbol> getMapForScope(String scopeName) - { - final Map<Object, ISymbol> map = getMapForScopeInternal(scopeName); - - if (map != null) - { - return Collections.unmodifiableMap(map); - } - - return Collections.EMPTY_MAP; - } - - private void updateMap(ISymbol symbol, String scopeName) - { - final Map<Object, ISymbol> map = getMapForScopeInternal(scopeName); - - if (map != null) - { - map.put(symbol.getName(), symbol); - } - else - { - Platform.getLog(JSFCorePlugin.getDefault().getBundle()).log(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0, "Scope not found: "+scopeName, new Throwable())); //$NON-NLS-1$ - } - } - - private Map<Object, ISymbol> getMapForScopeInternal(String scopeName) - { - if (ISymbolConstants.SYMBOL_SCOPE_REQUEST_STRING.equals(scopeName)) - { - return getRequestMap(); - } - else if (ISymbolConstants.SYMBOL_SCOPE_SESSION_STRING.equals(scopeName)) - { - return getSessionMap(); - } - else if (ISymbolConstants.SYMBOL_SCOPE_APPLICATION_STRING.equals(scopeName)) - { - return getApplicationMap(); - } - else if (ISymbolConstants.SYMBOL_SCOPE_NONE_STRING.equals(scopeName)) - { - return getNoneMap(); - } - - Platform.getLog(JSFCorePlugin.getDefault().getBundle()).log(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0, "Scope not found: "+scopeName, new Throwable())); //$NON-NLS-1$ - return null; - - } - - private Map getRequestMap() - { - if (_requestMap == null) - { - _requestMap = new HashMap<Object, ISymbol>(); - } - - return _requestMap; - } - - private Map<Object, ISymbol> getSessionMap() - { - if (_sessionMap == null) - { - _sessionMap = new HashMap<Object, ISymbol>(); - } - - return _sessionMap; - } - - private Map<Object, ISymbol> getApplicationMap() - { - if (_applicationMap == null) - { - _applicationMap = new HashMap<Object, ISymbol>(); - } - - return _applicationMap; - } - - private Map<Object, ISymbol> getNoneMap() - { - if (_noneMap == null) - { - _noneMap = new HashMap<Object, ISymbol>(); - } - - return _noneMap; - } - - /** - * Listens to the JSP model and reacts to changes - * @author cbateman - * - */ - private class ModelListener implements IModelLifecycleListener - { - public void processPostModelEvent(ModelLifecycleEvent event) - { - // TODO: figure this event structure out seems like it is possibly - // broken... - if (((event.getType() & ModelLifecycleEvent.MODEL_DIRTY_STATE) != 0 - && !_model.isDirty()) // if the dirty state changed as now not dirty, then we have a save - )//|| (event.getType() & ModelLifecycleEvent.MODEL_REINITIALIZED) != 0) - { - // refresh if modified on disk - refresh(false); - } - } - - public void processPreModelEvent(ModelLifecycleEvent arg0) { - // do nothing - } - } - - - /** - * Aggregates the sets-locale meta-data - * - * @author cbateman - */ - private static class LocaleSetAggregator - { - private final static String SETS_LOCALE = "sets-locale"; //$NON-NLS-1$ - - static LocaleSetAggregator create(IProject project, - final String uri, - final String elementName, final String attributeName) - { - final ITaglibDomainMetaDataModelContext mdContext = TaglibDomainMetaDataQueryHelper.createMetaDataModelContext(project, uri); - Trait trait = TaglibDomainMetaDataQueryHelper.getTrait(mdContext, elementName+"/"+attributeName, SETS_LOCALE); //$NON-NLS-1$ - - if (TraitValueHelper.getValueAsBoolean(trait)) - { - return new LocaleSetAggregator(); - } - - return null; - } - } - - /** - * Aggregates all the symbol contributor meta-data into a single object - * - * @author cbateman - * - */ - private static class SymbolContribAggregator - { - private final static String CONTRIBUTES_VALUE_BINDING = - "contributes-value-binding"; //$NON-NLS-1$ - private final static String VALUE_BINDING_SCOPE = "value-binding-scope"; //$NON-NLS-1$ - private final static String VALUE_BINDING_SYMBOL_FACTORY = - "value-binding-symbol-factory"; //$NON-NLS-1$ - - /** - * @param attributeName - * @return a new instance only if attributeName is a symbol contributor - */ - static SymbolContribAggregator create(final IProject project, - final String uri, - final String elementName, - final String attributeName) - { - final String entityKey = elementName+"/"+attributeName; //$NON-NLS-1$ - final ITaglibDomainMetaDataModelContext mdContext = TaglibDomainMetaDataQueryHelper.createMetaDataModelContext(project, uri); - Trait trait = TaglibDomainMetaDataQueryHelper.getTrait(mdContext, entityKey, CONTRIBUTES_VALUE_BINDING); - - boolean contribsValueBindings = TraitValueHelper.getValueAsBoolean(trait); - - if (contribsValueBindings) - { - String scope = null; - String symbolFactory = null; - - trait = TaglibDomainMetaDataQueryHelper.getTrait(mdContext, entityKey, VALUE_BINDING_SCOPE); - scope = TraitValueHelper.getValueAsString(trait); - - if (scope != null & !scope.equals("")) //$NON-NLS-1$ - { - trait = TaglibDomainMetaDataQueryHelper.getTrait(mdContext, entityKey, VALUE_BINDING_SYMBOL_FACTORY); - symbolFactory = TraitValueHelper.getValueAsString(trait); - } - - return new SymbolContribAggregator(scope, symbolFactory); - } - - return null; - } - - private final Map _metadata = new HashMap(4); - - SymbolContribAggregator(final String scope, final String factory) - { - _metadata.put("scope", scope); //$NON-NLS-1$ - _metadata.put("factory", factory); //$NON-NLS-1$ - } - - /** - * @return the scope - */ - public String getScope() - { - return (String) _metadata.get("scope"); //$NON-NLS-1$ - } - - /** - * @return the factory - */ - public AbstractContextSymbolFactory getFactory() - { - return (AbstractContextSymbolFactory) - JSFCommonPlugin.getSymbolFactories().get(_metadata.get("factory")); //$NON-NLS-1$ - } - } - - private static class CountingMutex extends Object - { - private boolean _signalled = false; - - /** - * @return true if the state of mutex is signalled - */ - public synchronized boolean isSignalled() { - return _signalled; - } - - /** - * @param signalled - */ - public synchronized void setSignalled(boolean signalled) { - this._signalled = signalled; - } - - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/Messages.java deleted file mode 100644 index de41104a9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/Messages.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.internal.jsp; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Message resource class - * - * @author cbateman - * - */ -/*package*/ final class Messages { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.designtime.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - // no external instatiation - } - - /** - * @param key - * @return the message string for key or !key! if not found - */ - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/StartupHandler.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/StartupHandler.java deleted file mode 100644 index 954390ec2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/jsp/StartupHandler.java +++ /dev/null @@ -1,223 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.internal.jsp; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.jsf.common.internal.JSPUtil; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IPartListener2; -import org.eclipse.ui.IStartup; -import org.eclipse.ui.IWindowListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPartReference; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -/** - * On workbench startup, registers a part listener that triggers when - * a JSP editor opens. - * - * @author cbateman - * - */ -public class StartupHandler implements IStartup -{ - private final JSPEditorListener _partListener = new JSPEditorListener(); - - public void earlyStartup() - { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() - { - public void run() - { - IWorkbenchWindow windows[] = - PlatformUI.getWorkbench().getWorkbenchWindows(); - - for (int i = 0; i < windows.length; i++) - { - IWorkbenchPage pages[] = windows[i].getPages(); - for (int j = 0; j < pages.length; j++) - { - IEditorReference[] editorReferences = - pages[j].getEditorReferences(); - - for (int k = 0; k < editorReferences.length; k++) - { - if (_partListener.isValidJSPEditor(editorReferences[k])) - { - _partListener.setJSPModelListener(editorReferences[k]); - } - } - } - windows[i].getPartService().addPartListener(_partListener); - } - - // TODO: register with all windows? - PlatformUI.getWorkbench().addWindowListener(new IWindowListener() - { - - public void windowActivated(IWorkbenchWindow window) { - // do nothing - } - - public void windowDeactivated(IWorkbenchWindow window) { - // do nothing - } - - public void windowClosed(IWorkbenchWindow window) { - window.getPartService().removePartListener(_partListener); - } - - public void windowOpened(IWorkbenchWindow window) { - window.getPartService().addPartListener(_partListener); - } - }); - } - }); - } - - private static class JSPEditorListener implements IPartListener2 - { - public void partActivated(IWorkbenchPartReference partRef) { - // do nothing - - } - - public void partBroughtToTop(IWorkbenchPartReference partRef) { - // do nothing - } - - public void partClosed(IWorkbenchPartReference partRef) { - if (isValidJSPEditor(partRef)) - { - releaseJSPModelListener((IEditorReference) partRef); - } - } - - public void partDeactivated(IWorkbenchPartReference partRef) { - // do nothing - } - - public void partOpened(IWorkbenchPartReference partRef) { - if (isValidJSPEditor(partRef)) - { - setJSPModelListener((IEditorReference)partRef); - } - } - - public void partHidden(IWorkbenchPartReference partRef) { - // do nothing - } - - public void partVisible(IWorkbenchPartReference partRef) { - // do nothing - } - - public void partInputChanged(IWorkbenchPartReference partRef) { - // do nothing - - } - - private boolean isJSPEditor(IEditorReference editorRef) - { - IFile file = getIFile(editorRef); - - if (file != null) - { - return JSPUtil.isJSPContentType(file); - } - - return false; - } - - /** - * @param editorRef - * @return true if the editor is editing the JSP content type and - * the owning project is a JSF project - */ - boolean isValidJSPEditor(IEditorReference editorRef) - { - final IFile file = getIFile(editorRef); - - return file != null && - JSFAppConfigUtils.isValidJSFProject(file.getProject()) && - isJSPEditor(editorRef); - } - - - boolean isValidJSPEditor(IWorkbenchPartReference partRef) - { - if (partRef instanceof IEditorReference) - { - return isValidJSPEditor((IEditorReference)partRef); - } - - return false; - } - - void setJSPModelListener(IEditorReference editorRef) - { - IFile file = getIFile(editorRef); - - if (file != null) - { - try - { - // implicitly creates if not present - JSPModelProcessor processor = JSPModelProcessor.get(file); - processor.refresh(false); - } - catch (Exception e) - { - JSFCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0, "Error acquiring model processor",e)); //$NON-NLS-1$ - } - } - } - - void releaseJSPModelListener(IEditorReference editorRef) - { - IFile file = getIFile(editorRef); - - if (file != null) - { - JSPModelProcessor.dispose(file); - } - } - - IFile getIFile(IEditorReference editorRef) - { - try - { - IEditorInput editorInput = editorRef.getEditorInput(); - Object adapt = editorInput.getAdapter(IFile.class); - - if (adapt instanceof IFile) - { - return (IFile) adapt; - } - } - catch (PartInitException excp) - { - JSFCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0, "Error acquiring editor input",excp)); //$NON-NLS-1$ - } - - return null; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/DataModelVariableTestFacade.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/DataModelVariableTestFacade.java deleted file mode 100644 index 493dae5c6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/DataModelVariableTestFacade.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.designtime.internal.symbols; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.designtime.symbols.AbstractDataModelVariableFactory; - -/** - * Used to expose protected final members of AbstractDataModelVariableFactory - * for testing purposes. May change without notice, should *never* be used in - * production code. - * - * @author cbateman - * - */ -public final class DataModelVariableTestFacade extends AbstractDataModelVariableFactory -{ - /** - * Test facade for createArraySymbol - * - * @param symbolName - * @param signature - * @param javaProject - * @return super.createArraySymbol() - */ - public final ISymbol testCreateArraySymbol(final String symbolName, final String signature, final IJavaProject javaProject) - { - return createArraySymbol(symbolName, signature, javaProject); - } - - /** - * Test facade for createFromList - * - * @param symbolName - * @param valueType - * @param javaProject - * @return super.createFromList() - */ - public final ISymbol testCreateFromList(String symbolName, ValueType valueType, IJavaProject javaProject) - { - return createFromList(symbolName, valueType, javaProject); - } - - /** - * @param symbolName - * @param signature - * @param javaProject - * @return a symbol assuming a scalar type wrapping - */ - public ISymbol testCreateScalarSymbol(String symbolName, String signature, IJavaProject javaProject) - { - return createScalarSymbol(symbolName, signature, javaProject); - } - - - /** - * @param symbolName - * @param valueType - * @param javaProject - * @return a symbol from a proxied call to super.createFromType - */ - public ISymbol testCreateFromType(String symbolName, ValueType valueType, - IJavaProject javaProject) { - return super.createFromType(symbolName, valueType, javaProject); - } - - @Override - protected final String getVariableSourceName() - { - return "testFacade -- SHOULD NOT BE USED IN PRODUCTION CODE"; //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/JSPTagVariableSymbolSourceProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/JSPTagVariableSymbolSourceProvider.java deleted file mode 100644 index bc477ddfe..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/JSPTagVariableSymbolSourceProvider.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.internal.symbols; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.source.AbstractSymbolSourceProviderFactory; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProvider; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.designtime.internal.jsp.JSPModelProcessor; -import org.eclipse.jst.jsf.designtime.symbols.FileContextUtil; -import org.eclipse.jst.jsf.designtime.symbols.SymbolUtil; - - -/** - * Self-factory for a symbol provider that derives symbol information from - * meta-data annotations on tag attributes that declare runtime EL variables - * - * @author cbateman - * - */ -public class JSPTagVariableSymbolSourceProvider extends - AbstractSymbolSourceProviderFactory implements ISymbolSourceProvider -{ - protected ISymbolSourceProvider create(IProject project) - { - return this; - } - - public ISymbol[] getSymbols(IAdaptable context, int symbolScopeMask) - { - final IFile fileContext = FileContextUtil.deriveIFileFromContext(context); - - if (isProvider(fileContext)) - { - try - { - final JSPModelProcessor modelProcessor = - JSPModelProcessor.get(fileContext); - - // ensure internal model is sync'ed with document - // but don't force refresh - modelProcessor.refresh(false); - final List<ISymbol> symbols = new ArrayList(); - - if ((symbolScopeMask & ISymbolConstants.SYMBOL_SCOPE_REQUEST) != 0) - { - symbols.addAll(modelProcessor.getMapForScope(ISymbolConstants.SYMBOL_SCOPE_REQUEST_STRING).values()); - } - if ((symbolScopeMask & ISymbolConstants.SYMBOL_SCOPE_SESSION) != 0) - { - symbols.addAll(modelProcessor.getMapForScope(ISymbolConstants.SYMBOL_SCOPE_SESSION_STRING).values()); - } - if ((symbolScopeMask & ISymbolConstants.SYMBOL_SCOPE_APPLICATION) != 0) - { - symbols.addAll(modelProcessor.getMapForScope(ISymbolConstants.SYMBOL_SCOPE_APPLICATION_STRING).values()); - } - if ((symbolScopeMask & ISymbolConstants.SYMBOL_SCOPE_NONE) != 0) - { - symbols.addAll(modelProcessor.getMapForScope(ISymbolConstants.SYMBOL_SCOPE_NONE_STRING).values()); - } - - return symbols.toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - catch (Exception e) - { - JSFCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, 0, "Error acquiring model processor",e)); //$NON-NLS-1$ - // fall-through to empty symbol array - } - } - - return ISymbol.EMPTY_SYMBOL_ARRAY; - } - - public ISymbol[] getSymbols(String prefix, IAdaptable context, - int symbolScopeMask) { - return SymbolUtil. - filterSymbolsByPrefix(getSymbols(context, symbolScopeMask), prefix); - } - - public boolean isProvider(IAdaptable context) - { - IFile file = FileContextUtil.deriveIFileFromContext(context); - - return (file != null - && file.getProject() == this.getProject()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/Messages.java deleted file mode 100644 index f55547720..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/Messages.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.internal.symbols; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Message resource class - * - * @author cbateman - * - */ -/*package*/ final class Messages { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.designtime.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - // no external instatiation - } - - /** - * @param key - * @return the message string for key or !key! if not found - */ - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleMapSource.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleMapSource.java deleted file mode 100644 index 145c62da3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleMapSource.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.designtime.internal.symbols; - -import java.io.IOException; -import java.io.InputStream; -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.tld.LoadBundleUtil; - -class ResourceBundleMapSource extends AbstractMap -{ - private static final String PROPERTY_QUALIFIER = "org.eclipse.jst.jsf.designtime.internal.jsp"; //$NON-NLS-1$ - private static final String SESSION_PROPERTY_NAME_PROJECT = "ResourceBundleMapSource"; //$NON-NLS-1$ - private static final QualifiedName SESSION_PROPERTY_KEY_PROJECT - = new QualifiedName(PROPERTY_QUALIFIER, SESSION_PROPERTY_NAME_PROJECT); - - private static IFile getCachedBundleFile(final IProject project, final String baseName) - { - if (project != null) - { - return (IFile) getBundleFileCache(project).get(baseName); - } - - return null; - } - - private static Map getBundleFileCache(IProject project) - { - synchronized(project) - { - Map bundleFileCache = null; - - try - { - bundleFileCache = - (Map) project.getSessionProperty(SESSION_PROPERTY_KEY_PROJECT); - - if (bundleFileCache == null) - { - bundleFileCache = new HashMap(); - project.setSessionProperty(SESSION_PROPERTY_KEY_PROJECT, bundleFileCache); - } - } - catch (CoreException ce) - { - JSFCorePlugin.log("Error creating bundle file cache", ce); //$NON-NLS-1$ - } - - return bundleFileCache; - } - } - - private static IFile createCachedBundleFile(final IProject project, - final String resourcePathStr) - throws IOException, JavaModelException, CoreException - { - IStorage storage = LoadBundleUtil.getLoadBundleResource(project, resourcePathStr); - - IFile bundleRes = null; - - if (storage != null - && storage.getAdapter(IFile.class) != null) - { - bundleRes = (IFile) storage.getAdapter(IFile.class); - getBundleFileCache(project).put(resourcePathStr, bundleRes); - return bundleRes; - } - - throw new IOException("Bundle "+resourcePathStr+" not found in classpath for project: "+project.getName()); //$NON-NLS-1$ //$NON-NLS-2$ - } - - private Properties _resourceBundle; // = null; set on first access or changes - private final IFile _bundleFile; // the resource - // as returned by IResource.getModificationStamp() - // the last time _resourceBundle was loaded - private long _lastModificationStamp; - - ResourceBundleMapSource(final IProject context, - final String resourcePathStr) - throws IOException, JavaModelException, CoreException - { - IFile cachedBundleFile = getCachedBundleFile(context, resourcePathStr); - - if (cachedBundleFile == null) - { - cachedBundleFile = createCachedBundleFile(context, resourcePathStr); - } - - _bundleFile = cachedBundleFile; - } - - private void checkAndRefreshBundle() - { - if (_resourceBundle == null - || _bundleFile.getModificationStamp() != _lastModificationStamp) - { - InputStream bundleStream = null; - try - { - bundleStream = _bundleFile.getContents(); - _resourceBundle = new Properties(); - _resourceBundle.load(bundleStream); - _lastModificationStamp = _bundleFile.getModificationStamp(); - } - catch (CoreException ce) - { - JSFCorePlugin.log("Error refreshing bundle", ce); //$NON-NLS-1$ - } - catch (IOException ioe) - { - JSFCorePlugin.log("Error refreshing bundle", ioe); //$NON-NLS-1$ - } - finally - { - if (bundleStream != null) - { - try - { - bundleStream.close(); - } - catch (IOException ioe) - { - JSFCorePlugin.log("Error closing bundle", ioe); //$NON-NLS-1$ - } - } - } - } - } - - public Set entrySet() - { - checkAndRefreshBundle(); - return _resourceBundle.entrySet(); - } - - /** - * @see java.util.AbstractMap#get(java.lang.Object) - * @overrride to optimize for the fact that we are doing a hash get - */ - // - public Object get(Object key) - { - checkAndRefreshBundle(); - return _resourceBundle.get(key); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleMapSourceFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleMapSourceFactory.java deleted file mode 100644 index dc2209c6d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleMapSourceFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.internal.symbols; - -import java.io.IOException; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.JavaModelException; - -/** - * Factory class for acquiring a ResourceBundleMapSourceFactory outside the local - * package. This is intended only for internal testing and related use and - * should not be used for normal feature development - * - * @author cbateman - * - */ -public class ResourceBundleMapSourceFactory -{ - /** - * @param project - * @param resourcePathStr - * @return a ResourceBundleMapSource - * @throws CoreException - * @throws IOException - * @throws JavaModelException - */ - public static Map getResourceBundleMapSource(final IProject project, - final String resourcePathStr) - throws JavaModelException, IOException, CoreException - { - return new ResourceBundleMapSource(project, resourcePathStr); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleSymbolSourceProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleSymbolSourceProvider.java deleted file mode 100644 index b96b8a89a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/symbols/ResourceBundleSymbolSourceProvider.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.designtime.internal.symbols; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.context.symbol.IComponentSymbol; -import org.eclipse.jst.jsf.context.symbol.IMapTypeDescriptor; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.SymbolFactory; -import org.eclipse.jst.jsf.context.symbol.source.AbstractSymbolSourceProviderFactory; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProvider; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils; -import org.eclipse.jst.jsf.designtime.symbols.FileContextUtil; -import org.eclipse.jst.jsf.designtime.symbols.SymbolUtil; -import org.eclipse.jst.jsf.facesconfig.emf.BaseNameType; -import org.eclipse.jst.jsf.facesconfig.emf.ResourceBundleType; -import org.eclipse.jst.jsf.facesconfig.emf.VarType; - -/** - * WARNING: this is an interim solution to supporting Faces 1.2 resource - * bundle variables. This class will become obsolete by design once - * the dt framework for Unified EL symbol resolution is added - * - * DO NOT USE THIS CLASS EXTERNALLY, IT WILL BE REMOVED WITHOUT WARNING IN THE FUTURE - * WITH NO MIGRATION PATH - * - * Self-factory for symbol source providers that contribute symbols for - * the resource bundle variables declared in Faces 1.2 and greater - * app configuration files. - * - * @author cbateman - * - */ -public final class ResourceBundleSymbolSourceProvider extends - AbstractSymbolSourceProviderFactory implements ISymbolSourceProvider { - - protected final ISymbolSourceProvider create(IProject project) { - return this; - } - - public final ISymbol[] getSymbols(IAdaptable context, int symbolScopeMask) - { - if (isProvider(context)) - { - final List symbols = new ArrayList(); - final IFile fileContext = FileContextUtil.deriveIFileFromContext(context); - final IProject project = fileContext.getProject(); - - final JSFAppConfigManager appconfigMgr = JSFAppConfigManager.getInstance(project); - final List resourceBundles = appconfigMgr.getResourceBundles(); - - for (final Iterator it = resourceBundles.iterator(); it.hasNext();) - { - ResourceBundleType resBundle = (ResourceBundleType) it.next(); - final String basename = getBaseName(resBundle); - final String name = getVarName(resBundle); - - if (basename != null && name != null) - { - try - { - symbols.add(createSymbolForResourceBundle(project, name, basename)); - } catch (JavaModelException e) { - JSFCorePlugin.log(e, "Error creating base name for: "+basename); //$NON-NLS-1$ - } catch (IOException e) { - JSFCorePlugin.log(e, "Error creating base name for: "+basename); //$NON-NLS-1$ - } catch (CoreException e) { - JSFCorePlugin.log(e, "Error creating base name for: "+basename); //$NON-NLS-1$ - } - } - } - return (ISymbol[]) symbols.toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - return ISymbol.EMPTY_SYMBOL_ARRAY; - } - - private ISymbol createSymbolForResourceBundle(IProject project, - final String name, - final String basename) throws JavaModelException, IOException, CoreException - { - // TODO: push down into ResourceBundleMapSourceFactory and share - // with loadBundle - final Map mapSource = ResourceBundleMapSourceFactory - .getResourceBundleMapSource(project, basename); - final IMapTypeDescriptor typeDesc = - SymbolFactory.eINSTANCE.createIMapTypeDescriptor(); - typeDesc.setMapSource(mapSource); - final IComponentSymbol symbol = - SymbolFactory.eINSTANCE.createIComponentSymbol(); - symbol.setName(name); - symbol.setTypeDescriptor(typeDesc); - symbol.setDetailedDescription(Messages.getString("ResourceBundleSymbolSourceProvider.DetailedDescription")+basename+"</i>"); //$NON-NLS-1$//$NON-NLS-2$ - return symbol; - } - - private String getBaseName(ResourceBundleType resBundle) - { - final BaseNameType baseNameType = resBundle.getBaseName(); - if (baseNameType != null) - { - return baseNameType.getTextContent(); - } - return null; - } - - private String getVarName(ResourceBundleType resBundle) - { - final VarType varName = resBundle.getVar(); - if (varName != null) - { - return varName.getTextContent(); - } - return null; - } - - public final ISymbol[] getSymbols(String prefix, IAdaptable context, - int symbolScopeMask) { - return SymbolUtil. - filterSymbolsByPrefix(getSymbols(context, symbolScopeMask), prefix); - } - - public final boolean isProvider(IAdaptable context) { - IFile file = FileContextUtil.deriveIFileFromContext(context); - - if (file != null) - { - final IProject project = file.getProject(); - - if (project != null && project.isAccessible()) - { - // to be valid, the jsf project must be at least version 1.2 - return JSFAppConfigUtils.isValidJSFProject(project, IJSFCoreConstants.FACET_VERSION_1_2); - } - } - - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/messages.properties deleted file mode 100644 index adccd455f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/messages.properties +++ /dev/null @@ -1,18 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle 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: -# Oracle Corporation - initial API and implementation -############################################################################### -AbstractDataModelVariableFactory.DataModel.Symbol.RowVariable.DetailedDescription=Row variable for dataTable -JSPDefaultSymbolFactory.Resource.bundle.map.detailedDescription=Resource bundle map for bundle <i> -JSPDefaultSymbolFactory.Problem.ErrorCreatingVariable=Error creating loadBundle variable -ResourceBundleSymbolSourceProvider.DetailedDescription=Resource bundle map for bundle <i> -DefaultBeanSymbolSourceProvider.AdditionalInformation.Name=Name: -DefaultBeanSymbolSourceProvider.AdditionalInformation.Type=Type: -DefaultBeanSymbolSourceProvider.AdditionalInformation.Scope=Scope: -DefaultBeanSymbolSourceProvider.AdditionalInformation.Description=Description: diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/AbstractSymbolContextResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/AbstractSymbolContextResolver.java deleted file mode 100644 index 26577326e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/AbstractSymbolContextResolver.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.designtime.resolver; - -import org.eclipse.jst.jsf.context.IModelContext; -import org.eclipse.jst.jsf.context.symbol.IMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; - - -/** - * An abstract that should sub-classed by clients wishing to implement - * the ISymbolContextResolver interface - * - * @author cbateman - * - */ -public abstract class AbstractSymbolContextResolver implements ISymbolContextResolver -{ - public abstract ISymbol[] getAllVariables(); - - public abstract IMethodSymbol getMethod(IObjectSymbol base, Object methodName); - - public abstract ISymbol[] getMethods(IObjectSymbol base); - - public abstract ISymbol[] getProperties(ISymbol symbol); - - public abstract ISymbol getProperty(ISymbol symbol, Object propertyName); - - public abstract ISymbol getVariable(String name); - - public abstract boolean canResolveContext(IModelContext modelContext); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/ISymbolContextResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/ISymbolContextResolver.java deleted file mode 100644 index e6f876e05..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/ISymbolContextResolver.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.resolver; - -import org.eclipse.jst.jsf.context.resolver.IDocumentContextResolver; -import org.eclipse.jst.jsf.context.symbol.IMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; - -/** - * Resolves symbols and possible symbols in a given context - * - * May NOT be sub-classed or implemented by clients. - * Sub-class SymbolContextResolver. - * - * @author cbateman - * - */ -public interface ISymbolContextResolver extends IDocumentContextResolver -{ - /** - * Gets the most appropriate symbol in the current context - * based on name. Most "appropriate" may take into account - * scoping and other rules. - * - * @param name - * @return a symbol - */ - ISymbol getVariable(String name); - - /** - * @return all valid symbols in the current context - */ - ISymbol[] getAllVariables(); - - /** - * @param symbol - * @param propertyName - * @return the property symbol called propertyName or null if not found - */ - ISymbol getProperty(ISymbol symbol, Object propertyName); - - /** - * @param symbol - * @return all properties of symbol - */ - ISymbol[] getProperties(ISymbol symbol); - - /** - * @param base - * @param methodName - * @return the method of base matching methodName or null if not found - */ - IMethodSymbol getMethod(IObjectSymbol base, Object methodName); - - /** - * @param base - * @return all methods belonging to base - */ - ISymbol[] getMethods(IObjectSymbol base); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/StructuredDocumentSymbolResolverFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/StructuredDocumentSymbolResolverFactory.java deleted file mode 100644 index c0fd95f0b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/StructuredDocumentSymbolResolverFactory.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.resolver; - -import org.eclipse.jst.jsf.context.AbstractDelegatingFactory; -import org.eclipse.jst.jsf.context.IModelContext; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -/** - * Factory create resolver capable of resolving symbols in a structured document - * - * Clients may not sub-class. - * - * @author cbateman - * - */ -public final class StructuredDocumentSymbolResolverFactory extends - AbstractDelegatingFactory -{ - private static StructuredDocumentSymbolResolverFactory INSTANCE; - - /** - * @return the singleton factory instance - */ - public final static synchronized StructuredDocumentSymbolResolverFactory getInstance() - { - if (INSTANCE == null) - { - // no delegates supported - INSTANCE = new StructuredDocumentSymbolResolverFactory(new Class[0]); - } - - return INSTANCE; - } - - private StructuredDocumentSymbolResolverFactory(Class[] supportedDelegateTypes) - { - super(supportedDelegateTypes); - } - - /** - * @param context - * @return a new instance of symbol resolver for context - */ - public ISymbolContextResolver getSymbolContextResolver(IModelContext context) { - ISymbolContextResolver resolver = internalGetSymbolContextResolver(context); - - if (resolver == null) - { - resolver = delegateGetSymbolContextResolver(context); - } - - return resolver; - } - - private ISymbolContextResolver internalGetSymbolContextResolver(IModelContext context) - { - if (context instanceof IStructuredDocumentContext && - ((IStructuredDocumentContext)context).getStructuredDocument() instanceof IStructuredDocument) - { - return new SymbolContextResolver((IStructuredDocumentContext) context); - } - - return null; - } - - private ISymbolContextResolver delegateGetSymbolContextResolver(IModelContext context) - { - // no delegates currently supported - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/SymbolContextResolver.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/SymbolContextResolver.java deleted file mode 100644 index 981fd8307..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/SymbolContextResolver.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.resolver; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jst.jsf.context.IModelContext; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.symbol.IMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.designtime.DesignTimeApplicationManager; -import org.eclipse.jst.jsf.designtime.context.DTFacesContext; - -/** - * A symbol context resolver - * Clients may NOT sub-class. - * - * @author cbateman - * - */ -/*package*/ final class SymbolContextResolver extends AbstractSymbolContextResolver -{ - private final IStructuredDocumentContext _context; - private IWorkspaceContextResolver _wkspResolver; // = null; lazy created through getWorkspaceResolver - - /** - * @param context - */ - /*package*/ SymbolContextResolver(IStructuredDocumentContext context) - { - _context = context; - } - - public ISymbol getVariable(String name) - { - final IFile file = getFile(); - - if (file != null) - { - final DesignTimeApplicationManager manager = - DesignTimeApplicationManager.getInstance(file.getProject()); - - final DTFacesContext facesContext = manager.getFacesContext(file); - - return manager.getVariableResolver(). - resolveVariable(facesContext, name, file); - } - - return null; - } - - public ISymbol[] getAllVariables() - { - final IFile file = getFile(); - - if (file != null) - { - final DesignTimeApplicationManager manager = - DesignTimeApplicationManager.getInstance(file.getProject()); - - final DTFacesContext facesContext = manager.getFacesContext(file); - - if (facesContext != null) - { - return manager.getVariableResolver(). - getAllVariables(facesContext, file); - } - } - - return ISymbol.EMPTY_SYMBOL_ARRAY; - } - - public ISymbol getProperty(ISymbol symbol, Object propertyName) - { - final IFile file = getFile(); - - if (file != null) - { - final DesignTimeApplicationManager manager = - DesignTimeApplicationManager.getInstance(file.getProject()); - return manager.getPropertyResolver().getProperty(symbol, propertyName); - } - - return null; - } - - public ISymbol[] getProperties(ISymbol symbol) - { - final IFile file = getFile(); - - if (file != null) - { - final DesignTimeApplicationManager manager = - DesignTimeApplicationManager.getInstance(file.getProject()); - return manager.getPropertyResolver().getAllProperties(symbol); - } - return ISymbol.EMPTY_SYMBOL_ARRAY; - } - - public IMethodSymbol getMethod(IObjectSymbol base, Object methodName) - { - final IFile file = getFile(); - - if (file != null) - { - final DesignTimeApplicationManager manager = - DesignTimeApplicationManager.getInstance(file.getProject()); - return manager.getMethodResolver().getMethod(base, methodName); - } - - return null; - } - - public ISymbol[] getMethods(IObjectSymbol base) - { - final IFile file = getFile(); - - if (file != null) - { - final DesignTimeApplicationManager manager = - DesignTimeApplicationManager.getInstance(file.getProject()); - return manager.getMethodResolver().getMethods(base); - } - - return new IMethodSymbol[0]; - } - - - public boolean canResolveContext(IModelContext modelContext) - { - return modelContext.getAdapter(IStructuredDocumentContext.class) != null; - } - - /** - * @return a lazily loaded workspace resolver for this resolver's context - */ - protected final IWorkspaceContextResolver getWorkspaceResolver() - { - if (_wkspResolver == null) - { - _wkspResolver = IStructuredDocumentContextResolverFactory. - INSTANCE.getWorkspaceContextResolver(_context); - } - - return _wkspResolver; - } - - /** - * @return the underlying IFile for my context or null if can't be determined - */ - protected final IFile getFile() - { - final IWorkspaceContextResolver resolver = getWorkspaceResolver(); - - if (resolver != null) - { - IResource curRes = resolver.getResource(); - - if (curRes instanceof IFile) - { - return (IFile) curRes; - } - } - - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/AbstractDataModelVariableFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/AbstractDataModelVariableFactory.java deleted file mode 100644 index a4dfba412..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/AbstractDataModelVariableFactory.java +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.designtime.symbols; - -import java.util.Arrays; -import java.util.HashMap; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.common.util.TypeUtil; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.symbol.ERuntimeSource; -import org.eclipse.jst.jsf.context.symbol.IComponentSymbol; -import org.eclipse.jst.jsf.context.symbol.IJavaTypeDescriptor2; -import org.eclipse.jst.jsf.context.symbol.IMapTypeDescriptor; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.SymbolFactory; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants; -import org.eclipse.jst.jsf.validation.internal.ValidationPreferences; -import org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidationUtil; -import org.eclipse.jst.jsf.validation.internal.el.ELExpressionValidator; -import org.eclipse.jst.jsf.validation.internal.el.IExpressionSemanticValidator; -import org.w3c.dom.Element; - -/** - * A framework provided variable factory for EL model objects that are - * constructed based on DataModel's dervied from an EL expression. - * - * @author cbateman - * - */ -public abstract class AbstractDataModelVariableFactory -{ - /** - * @param elText The EL expression text. Must not be null - * @param elContext The document context pointing to elText in the source document. Must not be null - * @param file The workspace resource that contains elText. Must not be null. - * @return the value expression resolved from elText or null if it cannot - * be resolved or elText doesn't resolve to value expression (i.e. is a method expression) - */ - public final ValueType createValueExpression(final String elText, final IStructuredDocumentContext elContext, final IFile file) - { - assert elText != null; - assert elContext != null; - assert file != null; - - final ValidationPreferences prefs = - new ValidationPreferences(JSFCorePlugin.getDefault().getPreferenceStore()); - prefs.load(); - - final ELExpressionValidator validator = - new ELExpressionValidator(elContext, elText, file, prefs.getElPrefs()); - validator.validateXMLNode(); - final IExpressionSemanticValidator semValidator = - validator.getSemanticValidator(); - if (semValidator != null - && semValidator.getExpressionType() instanceof ValueType) - { - return (ValueType) semValidator.getExpressionType(); - } - return null; - } - - /** - * @param symbolName The name of the symbol to be created. Must not be null - * @param signature The type signature of the array type. Must not be null - * @param javaProject must not be null - * @return a symbol based approximating an implicit DataModel wrapper for an array - */ - protected final ISymbol createArraySymbol(final String symbolName, final String signature, final IJavaProject javaProject) - { - assert symbolName != null; - assert signature != null; - assert javaProject != null; - - final String arrayElementType = Signature.getElementType(signature); - final int arrayCount = Signature.getArrayCount(signature); - String adjustedSignature = null; - - // if it is a single array nesting, then it will just be the element type, - // but if it is a multi-dim array, then the scalar element will be an array - // with one less nesting level. It's a strange corner case to have an implicit - // array of something as a row type, but it is a valid case. I suppose - // it may be happen if you want to have tables of tables in which the nested tables - // in turn use nested variables as their type... - if (arrayCount > 0) - { - adjustedSignature = Signature.createArraySignature(arrayElementType, arrayCount-1); - } - else - { - adjustedSignature = arrayElementType; - } - - return createScalarSymbol(symbolName, adjustedSignature, javaProject); - } - - /** - * Implements default rules for taking an non-array value expression - * and resolving it to a ISymbol modelling a JSF DataModel - * - * @param symbolName - * @param valueType - * @param javaProject - * @return a symbol where valueType is considered to be the base type upon - * which a data model would be created. This combines the possibility that the - * value expression is either an explicit DataModel implementation or a - * non-DataModel type for which JSF be default provides an implicit wrapper model. - * - * List is treated as a special case here, since their are two subcases: - * 1) the list is a raw type, in which case it must be treated as implicit and opaque (as to the type of the variable created) - * 2) the list has Java 5 type argument information that can be used to infer the type of the row variable - */ - public ISymbol createFromType(String symbolName, ValueType valueType, - IJavaProject javaProject) - { - return internalCreateFromBaseType(symbolName, valueType, javaProject); - } - - private ISymbol internalCreateFromBaseType(String symbolName, ValueType valueType, - IJavaProject javaProject) - { - // based on JSF 1.1 spec section 4.2.1.4 the data model - // value binding can be one of a number of object that will - // get an implicit DataModel wrapper at runtime - - // could be an array - if (Signature.getArrayCount(valueType.getSignature())>0) - { - return createArraySymbol(symbolName, valueType.getSignature(), javaProject); - } - - // if is a list, then we have extra work to do if it - // is generic and has info about its contents - if (valueType.isInstanceOf(TypeConstants.TYPE_LIST)) - { - return createFromList(symbolName, valueType, javaProject); - } - // if is JSTL ResultSet, java ResultSet or DataModel - // return the default symbol -- in the absence of definite - // template info, these row containers are opaque to us - else if (valueType.isInstanceOf(TypeConstants.TYPE_JAVAX_SERVLET_JSP_JSTL_SQL_RESULT) - || valueType.isInstanceOf(TypeConstants.TYPE_RESULT_SET) - || valueType.isInstanceOf(TypeConstants.TYPE_DATA_MODEL)) - { - return createDefaultSymbol(symbolName); - } - - // in other cases, we assume that the value is an explicit single row - // scalar object - return createScalarSymbol(symbolName, valueType.getSignature(), javaProject); - } - - /** - * @param symbolName The name of the symbol to create. Must not be null. - * @param valueType The value expression representing the implicit list. The signature - * on the valueType must be a list. Must not be null. - * @param javaProject The JavaProject whose classpath will be used to resolve types. Must not be null. - * - * @return a symbol that approximates as best as possible an implicit DataModel for java.util.List value expressions. If the List has - * resolvable Java 5 type arguments, then a scalar symbol will be created - * using this type information. If it is a raw type, then - * createDefaultSymbol() is called - */ - protected final ISymbol createFromList(String symbolName, ValueType valueType, IJavaProject javaProject) - { - assert symbolName != null; - assert valueType != null; - assert javaProject != null; - assert TypeConstants.TYPE_LIST.equals(valueType.getSignature()); - - final String[] typeArguments = valueType.getTypeArguments(); - - if (typeArguments != null && typeArguments.length > 0) - { - // a list has a single type argument - final String typeArg = typeArguments[0]; - - if (Signature.getTypeSignatureKind(typeArg) == Signature.CLASS_TYPE_SIGNATURE) - { - return createScalarSymbol(symbolName, typeArg, javaProject); - } - } - - // if no resolvable type signatures, do the default thing - return createDefaultSymbol(symbolName); - } - - - /** - * @param symbolName The name of the symbol to create. Must not be null. - * @param signature The fully resolved type signature of the scalar. Must not be null. - * @param javaProject The JavaProject whose classpath is to be used to resolve type information for signture. Must not be null. - * @return a symbol approximating a scalar object DataModel wrapper. The row variable for the - * data model becomes of type signature - */ - protected final ISymbol createScalarSymbol(final String symbolName, final String signature, final IJavaProject javaProject) - { - assert symbolName != null; - assert signature != null; - assert javaProject != null; - - final String elementType = Signature.getElementType(signature); - - IJavaTypeDescriptor2 desc = - SymbolFactory.eINSTANCE.createIJavaTypeDescriptor2(); - final int arrayCount = Signature.getArrayCount(signature); - if (arrayCount > 0) - { - desc.setArrayCount(arrayCount); - } - - IType type = TypeUtil.resolveType(javaProject, elementType); - if (type != null) - { - desc.setType(type); - } - else - { - desc.setTypeSignatureDelegate(Signature.getTypeErasure(signature)); - } - desc.getTypeParameterSignatures().addAll(Arrays.asList(Signature.getTypeArguments(signature))); - - IComponentSymbol symbol = SymbolFactory.eINSTANCE.createIComponentSymbol(); - symbol.setName(symbolName); - symbol.setTypeDescriptor(desc); - symbol.setRuntimeSource(ERuntimeSource.TAG_INSTANTIATED_SYMBOL_LITERAL); - return symbol; - } - - /** - * @param symbolName The name of the symbol to create. Must not be null - * @return a default symbol that eliminates bogus warnings for this dataTable's - * row variable in cases where something better is resolvable. Note that this is - * not ideal, since will result in any property being accepted on the variable with - * this name. - */ - public final ISymbol createDefaultSymbol(final String symbolName) - { - assert symbolName != null; - - final IMapTypeDescriptor typeDesc = - SymbolFactory.eINSTANCE.createIBoundedMapTypeDescriptor(); - // empty map source - typeDesc.setMapSource(new HashMap()); - final IComponentSymbol symbol = - SymbolFactory.eINSTANCE.createIComponentSymbol(); - symbol.setName(symbolName); - symbol.setTypeDescriptor(typeDesc); - symbol.setDetailedDescription(Messages.getString("AbstractDataModelVariableFactory.DataModel.Symbol.RowVariable.DetailedDescription")); //$NON-NLS-1$ - symbol.setRuntimeSource(ERuntimeSource.TAG_INSTANTIATED_SYMBOL_LITERAL); - return symbol; - } - - /** - * @param dataTableElement the DOM element that has a "value" attribute. - * Must not be null. - * @return the el text from the 'value attribute of a dataTable element - * or null if not found - */ - protected static String getELText(final Element dataTableElement) - { - assert dataTableElement != null; - String attrVal = dataTableElement.getAttribute(IJSFConstants.ATTR_VALUE); - - if (attrVal != null) - { - return AppConfigValidationUtil.extractELExpression(attrVal).getElText(); - } - return null; - } - - /** - * @return the variable source name. Protects against null in the abstract method - */ - protected final String internalGetVariableSourceName() - { - String variableSourceName = getVariableSourceName(); - - if (variableSourceName == null) - { - JSFCorePlugin.log("Missing variableSourceName", new Throwable()); //$NON-NLS-1$ - return "**missing variable source name**"; //$NON-NLS-1$ - } - - return variableSourceName; - } - - /** - * @return a user displayable name for the source of variables created by this factory - * Must not return null. - */ - protected abstract String getVariableSourceName(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultBeanSymbolSourceProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultBeanSymbolSourceProvider.java deleted file mode 100644 index 29614fd34..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultBeanSymbolSourceProvider.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.symbols; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.jsf.context.symbol.ERuntimeSource; -import org.eclipse.jst.jsf.context.symbol.IBeanInstanceSymbol; -import org.eclipse.jst.jsf.context.symbol.IJavaTypeDescriptor2; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.SymbolFactory; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; - -/** - * Self-factory provider of bean symbol information for a particular project. - * - * Context is determined by querying all known managed beans declared in a - * web project. - * - * Client may sub-class - * - * @author cbateman - * - */ -public class DefaultBeanSymbolSourceProvider -{ - private static DefaultBeanSymbolSourceProvider INSTANCE; - - /** - * @return the singleton instance of the provider - */ - public static DefaultBeanSymbolSourceProvider getInstance() - { - if (INSTANCE == null) - { - INSTANCE = new DefaultBeanSymbolSourceProvider(); - } - - return INSTANCE; - } - - /** - * No external instantiation - * - * Left protected to allow sub-classing - */ - protected DefaultBeanSymbolSourceProvider() {/* empty */} - - /** - * @param context - * @param symbolScopeMask - * @return all bean symbols for the context at scopes matching symbolScopeMask - */ - public ISymbol[] getSymbols(IAdaptable context, int symbolScopeMask) - { - final IFile file = FileContextUtil.deriveIFileFromContext(context); - if (file != null) - { - final IProject myProject = file.getProject(); - List managedBeans = getManagedBeanSymbols(myProject, symbolScopeMask); - return (ISymbol[]) managedBeans.toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - - return ISymbol.EMPTY_SYMBOL_ARRAY; - } - - /** - * @param name - * @param context - * @param symbolScopeMask - * @return the symbol called name, in context/symbolScope - */ - public ISymbol getSymbol(final String name, final IAdaptable context, - final int symbolScopeMask) - { - return SymbolUtil. - findSymbolByName(getSymbols(context, symbolScopeMask), name); - } - - /** - * @param prefix - * @param context - * @param symbolScopeMask - * @return all symbols for context and symbolScopeMask that start with - * prefix - */ - public ISymbol[] getSymbols(String prefix, IAdaptable context, - int symbolScopeMask) { - return SymbolUtil. - filterSymbolsByPrefix(getSymbols(context, symbolScopeMask), prefix); - } - - private List getManagedBeanSymbols(IProject iProject, int symbolScopeMask) - { - List symbols = new ArrayList(); - - final JSFAppConfigManager configManager = JSFAppConfigManager.getInstance(iProject); - - - if (configManager != null) - { - for (final Iterator aIt = configManager.getManagedBeans().iterator(); aIt.hasNext();) - { - ManagedBeanType bean = (ManagedBeanType) aIt.next(); - - // only bother with all this if we care about the scope of this bean - if (isBeanScopeInMask(bean.getManagedBeanScope(), symbolScopeMask)) - { - final String name = bean.getManagedBeanName().getTextContent(); - final String detailedDescription = createAdditionalProposalInfo(bean); - IBeanInstanceSymbol symbol = SymbolFactory.eINSTANCE.createIBeanInstanceSymbol(); - symbol.setName(name); - symbol.setDetailedDescription(detailedDescription); - symbol.setRuntimeSource(ERuntimeSource.MANAGED_BEAN_SYMBOL_LITERAL); - try - { - IJavaProject javaProject = JavaCore.create(iProject); - IType type = javaProject.findType(bean.getManagedBeanClass().getTextContent()); - - // don't bother setting a type descriptor if we - // can't find a type - if (type != null) - { - IJavaTypeDescriptor2 javaTypeDescriptor = SymbolFactory.eINSTANCE.createIJavaTypeDescriptor2(); - javaTypeDescriptor.setType(type); - symbol.setJavaTypeDescriptor(javaTypeDescriptor); - } - } - catch (Exception t) - { - // do nothing; skip type info for this bean - } - symbols.add(symbol); - } - } - } - - return symbols; - } - - private String createAdditionalProposalInfo(ManagedBeanType beanType) - { - StringBuffer additionalInfo = new StringBuffer("<p><b>"); //$NON-NLS-1$ - additionalInfo.append(Messages.getString("DefaultBeanSymbolSourceProvider.AdditionalInformation.Name")); //$NON-NLS-1$ - additionalInfo.append("</b>"); //$NON-NLS-1$ - additionalInfo.append(beanType.getManagedBeanName().getTextContent()); - additionalInfo.append("</p><p><b>"); //$NON-NLS-1$ - additionalInfo.append(Messages.getString("DefaultBeanSymbolSourceProvider.AdditionalInformation.Type")); //$NON-NLS-1$ - additionalInfo.append(" </b>"); //$NON-NLS-1$ - additionalInfo.append(beanType.getManagedBeanClass().getTextContent()); - additionalInfo.append("</p><p><b>"); //$NON-NLS-1$ - additionalInfo.append(Messages.getString("DefaultBeanSymbolSourceProvider.AdditionalInformation.Scope")); //$NON-NLS-1$ - additionalInfo.append("</b>"); //$NON-NLS-1$ - additionalInfo.append(beanType.getManagedBeanScope().getTextContent()); - additionalInfo.append("</p>"); //$NON-NLS-1$ - - StringBuffer descBuffer = new StringBuffer(); - - for (final Iterator it = beanType.getDescription().iterator(); it.hasNext();) - { - final DescriptionType descType = (DescriptionType) it.next(); - final String appendString = descType.getTextContent(); - if (appendString != null) - { - descBuffer.append(appendString); - } - } - - if (descBuffer.length() > 0) - { - additionalInfo.append("<p><b>"); //$NON-NLS-1$ - additionalInfo.append(Messages.getString("DefaultBeanSymbolSourceProvider.AdditionalInformation.Description")); //$NON-NLS-1$ - additionalInfo.append("</b>"); //$NON-NLS-1$ - additionalInfo.append(descBuffer); - additionalInfo.append("</p>"); //$NON-NLS-1$ - } - - return additionalInfo.toString(); - } - - - private boolean isBeanScopeInMask(final ManagedBeanScopeType scope, final int scopeMask) - { - final int testScope = ISymbolConstants.getMaskForString(scope.getTextContent()); - - if (testScope != -1) - { - return (scopeMask & testScope) != 0; - } - - // no other cases supported - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultBuiltInSymbolProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultBuiltInSymbolProvider.java deleted file mode 100644 index 5d109447d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultBuiltInSymbolProvider.java +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.symbols; - -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.context.symbol.ERuntimeSource; -import org.eclipse.jst.jsf.context.symbol.IBeanInstanceSymbol; -import org.eclipse.jst.jsf.context.symbol.IInstanceSymbol; -import org.eclipse.jst.jsf.context.symbol.IJavaTypeDescriptor2; -import org.eclipse.jst.jsf.context.symbol.IMapTypeDescriptor; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.SymbolFactory; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; -import org.eclipse.jst.jsf.designtime.DesignTimeApplicationManager; -import org.eclipse.jst.jsf.designtime.context.IDTExternalContext; - -/** - * Provides the default built-in JSF symbols - * - * Clients may sub-class - * - * @author cbateman - * - */ -public class DefaultBuiltInSymbolProvider -{ - private static DefaultBuiltInSymbolProvider INSTANCE; - - /** - * @return the singleton instance - */ - public synchronized static DefaultBuiltInSymbolProvider getInstance() - { - if (INSTANCE == null) - { - INSTANCE = new DefaultBuiltInSymbolProvider(); - } - - return INSTANCE; - } - - - private static final String APPLICATION_SCOPE = "applicationScope"; //$NON-NLS-1$ - private static final String SESSION_SCOPE = "sessionScope"; //$NON-NLS-1$ - private static final String REQUEST_SCOPE = "requestScope"; //$NON-NLS-1$ - private static final String COOKIE_IMPLICIT_OBJ = "cookie"; //$NON-NLS-1$ - private static final String FACES_CONTEXT_IMPLICIT_OBJ = "facesContext"; //$NON-NLS-1$ - private static final String HEADER_IMPLICIT_OBJ = "header"; //$NON-NLS-1$ - private static final String HEADER_VALUES_IMPLICIT_OBJ = "headerValues"; //$NON-NLS-1$ - private static final String INIT_PARAM_IMPLICIT_OBJ = "initParam"; //$NON-NLS-1$ - private static final String PARAM_IMPLICIT_OBJ = "param"; //$NON-NLS-1$ - private static final String PARAM_VALUES_IMPLICIT_OBJ = "paramValues"; //$NON-NLS-1$ - private static final String VIEW_IMPLICIT_OBJ = "view"; //$NON-NLS-1$ - - private static final String FACES_CONTEXT_FULLY_QUALIFIED_CLASS = - "javax.faces.context.FacesContext"; //$NON-NLS-1$ - private static final String VIEW_FULLY_QUALIFIED_CLASS = - "javax.faces.component.UIViewRoot"; //$NON-NLS-1$ - - /** - * Now direct instantiation -- use getInstance - * - * Made protected to allow sub-classing - */ - protected DefaultBuiltInSymbolProvider() {/* empty; do nothing */} - - /** - * @param context - * @param symbolScopeMask - * @return all symbols for context in scopes matching symbolScopeMask - */ - public ISymbol[] getSymbols(IAdaptable context, int symbolScopeMask) - { - final IFile fileContext = FileContextUtil.deriveIFileFromContext(context); - return (ISymbol[]) getSymbolsForScope(fileContext, symbolScopeMask).toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - - /** - * @param name - * @param context - * @param symbolScopeMask - * @return the symbol in context matching name or null if not found - */ - public ISymbol getSymbol(String name, IAdaptable context, int symbolScopeMask) - { - return SymbolUtil. - findSymbolByName(getSymbols(context, symbolScopeMask), name); - } - - /** - * @param prefix - * @param context - * @param symbolScopeMask - * @return all implicit symbols for context starting with prefix in - * scopes matching symbolScopeMask - */ - public ISymbol[] getSymbols(String prefix, IAdaptable context, int symbolScopeMask) - { - return SymbolUtil. - filterSymbolsByPrefix(getSymbols(context, symbolScopeMask), prefix); - } - - private List getSymbolsForScope(final IFile file, final int symbolScopeMask) - { - List symbols = new ArrayList(); - if ((symbolScopeMask & ISymbolConstants.SYMBOL_SCOPE_REQUEST) != 0) - { - symbols.addAll(getRequestScopeSymbols(file)); - } - if ((symbolScopeMask & ISymbolConstants.SYMBOL_SCOPE_SESSION) != 0) - { - symbols.addAll(getSessionScopeSymbols(file)); - } - if ((symbolScopeMask & ISymbolConstants.SYMBOL_SCOPE_APPLICATION) != 0) - { - symbols.addAll(getApplicationScopeSymbols(file)); - } - - return symbols; - } - - private List getRequestScopeSymbols(final IFile file) - { - List symbols = new ArrayList(); - - symbols.add(createScopeSymbol(file, ISymbolConstants.SYMBOL_SCOPE_REQUEST, REQUEST_SCOPE)); - symbols.add(createUnresolvedMapSymbol(COOKIE_IMPLICIT_OBJ)); - symbols.add(createUnresolvedMapSymbol(HEADER_IMPLICIT_OBJ)); - symbols.add(createUnresolvedMapSymbol(HEADER_VALUES_IMPLICIT_OBJ)); - symbols.add(createUnresolvedMapSymbol(PARAM_IMPLICIT_OBJ)); - symbols.add(createUnresolvedMapSymbol(PARAM_VALUES_IMPLICIT_OBJ)); - // TODO: these aren't maps; need to find way to handle - symbols.add(createJavaInstanceSymbol(file.getProject(), FACES_CONTEXT_FULLY_QUALIFIED_CLASS, FACES_CONTEXT_IMPLICIT_OBJ)); - symbols.add(createJavaInstanceSymbol(file.getProject(), VIEW_FULLY_QUALIFIED_CLASS, VIEW_IMPLICIT_OBJ)); - - return symbols; - } - - private List getSessionScopeSymbols(final IFile file) - { - return Collections. - singletonList - (createScopeSymbol - (file, ISymbolConstants.SYMBOL_SCOPE_SESSION, SESSION_SCOPE)); - } - - private List getApplicationScopeSymbols(final IFile file) - { - List symbols = new ArrayList(); - - // TODO: may be able to resolve this one based on web.xml - symbols.add(createUnresolvedMapSymbol(INIT_PARAM_IMPLICIT_OBJ)); - symbols.add(createScopeSymbol - (file, ISymbolConstants.SYMBOL_SCOPE_APPLICATION, APPLICATION_SCOPE)); - - return symbols; - } - - private ISymbol createScopeSymbol(final IFile file, final int scopeMask, final String name) - { - final Map mapSource = new ScopeMap(file, - scopeMask); - final IMapTypeDescriptor typeDesc = - SymbolFactory.eINSTANCE.createIMapTypeDescriptor(); - typeDesc.setMapSource(mapSource); - typeDesc.setImmutable(false); // scope maps are mutable - final IInstanceSymbol symbol = - SymbolFactory.eINSTANCE.createIInstanceSymbol(); - symbol.setName(name); - symbol.setRuntimeSource(ERuntimeSource.BUILT_IN_SYMBOL_LITERAL); - symbol.setTypeDescriptor(typeDesc); - // TODO:symbol.setDetailedDescription("A Map of the application scope attribute values, keyed by attribute name"); - - return symbol; - } - - // TODO: this one may be able to be factored up to the symbols plugin - private ISymbol createUnresolvedMapSymbol(final String name) - { - final IMapTypeDescriptor typeDesc = - SymbolFactory.eINSTANCE.createIMapTypeDescriptor(); - typeDesc.setMapSource(Collections.EMPTY_MAP); - final IInstanceSymbol symbol = - SymbolFactory.eINSTANCE.createIInstanceSymbol(); - symbol.setName(name); - symbol.setRuntimeSource(ERuntimeSource.BUILT_IN_SYMBOL_LITERAL); - symbol.setTypeDescriptor(typeDesc); - - return symbol; - } - - private ISymbol createJavaInstanceSymbol(IProject project, - String fullyQualifiedClass, - String symbolName) - { - final IJavaProject javaProject = JavaCore.create(project); - try - { - final IType type = - javaProject.findType(fullyQualifiedClass); - - // TODO: this is a high-bred since it consists of a java instance - // but also has properties we can populate at designtime such as - // the maps. Need to add the second part - if (type != null) - { - final IJavaTypeDescriptor2 typeDesc = - SymbolFactory.eINSTANCE.createIJavaTypeDescriptor2(); - typeDesc.setType(type); - IBeanInstanceSymbol facesContextVar = - SymbolFactory.eINSTANCE.createIBeanInstanceSymbol(); - facesContextVar.setTypeDescriptor(typeDesc); - facesContextVar.setName(symbolName); - return facesContextVar; - } - } - catch(JavaModelException jme) - { - // fall-through and fail with unresolved map - } - - ISymbol symbol = createUnresolvedMapSymbol(symbolName); - ((IInstanceSymbol)symbol).getTypeDescriptor(). - setTypeSignatureDelegate(Signature.createTypeSignature(fullyQualifiedClass, true)); - - return symbol; - } - - private static class ScopeMap extends AbstractMap - { - private final IFile _externalContextKey; - private final int _scopeMask; - - ScopeMap( IFile externalContextKey, - int scopeMask) - { - _externalContextKey = externalContextKey; - _scopeMask = scopeMask; - } - - public Set entrySet() - { - final Map scopeMap = new HashMap(); - final DesignTimeApplicationManager manager = - DesignTimeApplicationManager. - getInstance(_externalContextKey.getProject()); - - // do beans first so in case of name collision, beans are hidden - final DefaultBeanSymbolSourceProvider beanProvider = - DefaultBeanSymbolSourceProvider.getInstance(); - - final ISymbol beanSymbols[] = - beanProvider.getSymbols(_externalContextKey, _scopeMask); - - for (int i = 0; i < beanSymbols.length; i++) - { - scopeMap.put(beanSymbols[i].getName(), beanSymbols[i]); - } - - final IDTExternalContext externalContext = - manager.getFacesContext(_externalContextKey). - getDTExternalContext(_externalContextKey); - - scopeMap.putAll(externalContext.getMapForScope(_scopeMask)); - - return scopeMap.entrySet(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultDataTableSymbolFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultDataTableSymbolFactory.java deleted file mode 100644 index 94f2ce27e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/DefaultDataTableSymbolFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.designtime.symbols; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.w3c.dom.Element; - -/** - * The default factory for creating DataModel symbols based on an value expression - * in a dataTable. - * - * Clients may sub-class. - * - * @author cbateman - * - */ -public class DefaultDataTableSymbolFactory -{ - private final AbstractDataModelVariableFactory _dataModelSymbolFactory; - - /** - * @param dataModelSymbolFactory - */ - public DefaultDataTableSymbolFactory(AbstractDataModelVariableFactory dataModelSymbolFactory) - { - assert dataModelSymbolFactory != null; - _dataModelSymbolFactory = dataModelSymbolFactory; - } - - /** - * @param symbolName the name of the symbol to be created. Must not be null. - * @param dataTableElement the DOM element representing the dataTable tag. - * @param context the document context pointing to dataTableElement - * @return a symbol named symbolName based on the variable declared - * by dataTableElement - */ - public ISymbol createSymbolForDataTableValue(final String symbolName, - final Element dataTableElement, - final IStructuredDocumentContext context) - { - final String elText = AbstractDataModelVariableFactory.getELText(dataTableElement); - final IFile file = FileContextUtil.deriveIFileFromContext(context); - - if (elText != null && file != null) - { - final IStructuredDocumentContext elContext = - IStructuredDocumentContextFactory.INSTANCE.getContext(context.getStructuredDocument(), dataTableElement.getAttributeNode("value")); //$NON-NLS-1$ - - final IJavaProject javaProject = JavaCore.create(file.getProject()); - - final ValueType valueExpr = _dataModelSymbolFactory.createValueExpression(elText, elContext, file); - - if (valueExpr != null) - { - // otherwise, we have to try to resolve the base type and see - // if it's an instanceof any of the supported implicit or explict types - return _dataModelSymbolFactory.createFromType(symbolName, valueExpr, javaProject); - } - } - - // by default create a default - return _dataModelSymbolFactory.createDefaultSymbol(symbolName); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/FileContextUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/FileContextUtil.java deleted file mode 100644 index 0e5c8cbc5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/FileContextUtil.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.symbols; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; - -/** - * Utility for deriving an IFile from an IAdaptable - * - * @author cbateman - * - */ -public final class FileContextUtil -{ - /** - * @param context - * @return an IFile derived from context or null if not derivable - */ - public static IFile deriveIFileFromContext(IAdaptable context) - { - // - if (context instanceof IFile) - { - return (IFile) context; - } - else if (context.getAdapter(IFile.class) != null) - { - return (IFile) context.getAdapter(IFile.class); - } - else if (context instanceof IStructuredDocumentContext) - { - return deriveIFileFromContext((IStructuredDocumentContext)context); - } - else - { - IStructuredDocumentContext sdContext = - (IStructuredDocumentContext) context.getAdapter(IStructuredDocumentContext.class); - - if (sdContext != null) - { - return deriveIFileFromContext(sdContext); - } - } - - return null; - } - - private static IFile deriveIFileFromContext(IStructuredDocumentContext context) - { - IWorkspaceContextResolver resolver = - IStructuredDocumentContextResolverFactory. - INSTANCE. - getWorkspaceContextResolver(context); - - if (resolver != null) - { - IResource res = resolver.getResource(); - - if (res instanceof IFile) - { - return (IFile) res; - } - } - - return null; - } - - private FileContextUtil() - { - // no instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/Messages.java deleted file mode 100644 index e68910e60..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/Messages.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.designtime.symbols; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/*package*/ class Messages { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.designtime.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - // no external instantiation - } - - /** - * @param key - * @return the resource or !key! if not found. - */ - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/SymbolUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/SymbolUtil.java deleted file mode 100644 index 101310c84..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/symbols/SymbolUtil.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.symbols; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jst.jsf.context.symbol.ISymbol; - -/** - * Utilities for symbol handling - * - * @author cbateman - * - */ -public final class SymbolUtil -{ - /** - * @param symbols - * @param name - * @return the symbol in symbols matching name or null if not there - */ - public static ISymbol findSymbolByName(final ISymbol[] symbols, final String name) - { - for (int i = 0; i < symbols.length; i++) - { - if (name.equals(symbols[i].getName())) - { - return symbols[i]; - } - } - - // if not found, return null - return null; - } - - /** - * @param allSymbols - * @param prefix - * @return an array of symbols filtered based on name.startsWith(prefix) - */ - public static ISymbol[] filterSymbolsByPrefix(final ISymbol[] allSymbols, final String prefix) - { - List filteredSymbols = new ArrayList(allSymbols.length); - for (int i = 0; i < allSymbols.length; i++) - { - if (allSymbols[i].getName().startsWith(prefix)) - { - filteredSymbols.add(allSymbols[i]); - } - } - - return (ISymbol[]) - filteredSymbols.toArray(ISymbol.EMPTY_SYMBOL_ARRAY); - } - - private SymbolUtil() - { - // no external instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java deleted file mode 100644 index e6f65abff..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IImageDescriptorProvider; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.TraitValueHelper; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues; - -/** - * Simple abstract class that implementers of {@link IMetaDataEnabledFeature} can subclass in the <b>TagLibDomain</b> of metadata - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - * - */ -public abstract class AbstractMetaDataEnabledFeature implements IMetaDataEnabledFeature{ - - private MetaDataContext mdContext; - private IStructuredDocumentContext sdContext; - - private static final List EMPTY_LIST = new ArrayList(0); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature#setMetaDataContext(org.eclipse.jst.jsf.metadataprocessors.MetaDataContext) - */ - public void setMetaDataContext(final MetaDataContext context) { - this.mdContext = context; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature#getMetaDataContext() - */ - public MetaDataContext getMetaDataContext() { - return mdContext; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature#setStructuredDocumentContext(org.eclipse.wtp.jsf.context.structureddocument.IStructuredDocumentContext) - */ - public void setStructuredDocumentContext(final IStructuredDocumentContext context) { - this.sdContext = context; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature#getStructuredDocumentContext() - */ - public IStructuredDocumentContext getStructuredDocumentContext() { - return sdContext; - } - -// private IProject getProject(){ -// if (_project == null){ -// _project = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(sdContext).getProject(); -// } -// return _project; -// } - - - //common metadata accessors - /** - * Return the single expected String value for a given property. - * - * Since the MetaDataContext, where the type-id was found, - * may have come from a wild card, or the property being looked up now is, - * we should first look for the named property on the specific element and - * only if not found, look for it on the * element. - * - * @param traitName property name - * @return String value - */ - protected String getTraitValueAsString(final String traitName){ - Trait t = getTraitForEntityUsingContext(traitName); - if (t != null){ - return TraitValueHelper.getValueAsString(t); - } - - return null; - - } - - /** - * Return the List of values for a given property. - * - * Since the MetaDataContext, where the type-id was found, - * may have come from a wild card, or the property being looked up now is, - * we should first look for the named property on the specific element and - * only if not found, look for it on the * element. - * - * @param traitName trait name - * @return List of String values - */ - protected List getTraitValueAsListOfStrings(final String traitName){ - Trait t = getTraitForEntityUsingContext(traitName); - if (t != null){ - return TraitValueHelper.getValueAsListOfStrings(t); - } - - return EMPTY_LIST; - } - - private Trait getTraitForEntityUsingContext(final String traitName) { - //look for trait on given entity - final Entity entity = ((TaglibMetadataContext)getMetaDataContext()).getEntity(); - return TaglibDomainMetaDataQueryHelper.getTrait(entity, traitName); - } - - /** - * @return small-icon name - */ - protected String getSmallIcon() { - return getTraitValueAsString(IPossibleValues.POSSIBLE_VALUES_SMALL_ICON_PROP_NAME); - } - - /** - * @return ImageDescriptor from the small-icon property for annotation from the same - * source model provider as the trait - */ - protected ImageDescriptor getImage() { - final String smallIcon = getSmallIcon(); - if (smallIcon == null) - return null; - - try { - Trait t = getMetaDataContext().getTrait(); - IMetaDataSourceModelProvider provider = t.getSourceModelProvider(); - IImageDescriptorProvider ip = (IImageDescriptorProvider)provider.getAdapter(IImageDescriptorProvider.class); - if (ip != null){ - return ip.getImageDescriptor(smallIcon); - } - } catch (RuntimeException e) { - //TODO: log error? - - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractRootTypeDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractRootTypeDescriptor.java deleted file mode 100644 index 4a22c20d8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractRootTypeDescriptor.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jst.jsf.metadataprocessors.internal.IMetaDataEnabledFeatureExtension; -import org.eclipse.jst.jsf.metadataprocessors.internal.MetaDataEnabledFeatureAdapterFactory; -import org.eclipse.jst.jsf.metadataprocessors.internal.MetaDataEnabledFeatureRegistry; - - -/** - * Default implementation that a metadata type should strongly consider for using as it's root. - * This implementation allows for a class implementing {@link ITypeDescriptor} to also contain features so - * that it is not necessary to declare the features using the MetaDataEnabledFeatures ext-pt - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class AbstractRootTypeDescriptor extends AbstractMetaDataEnabledFeature - implements ITypeDescriptor { - - private IType type; - - /** - * Default implementation that will return <code>this</code> if it supports the processing feature, - * and all {@link IMetaDataEnabledFeature}s that also support this feature on this type. The caller can determine - * which one or more of the returned processors to use. - * - * @param processingFeature class - * @return List of <code>IMetaDataEnabledFeature</code>s that support the - * specified featureType interface. - * - * @see org.eclipse.jst.jsf.metadataprocessors.ITypeDescriptor#getFeatureAdapters(java.lang.Class) - */ - public List getFeatureAdapters(Class processingFeature) { - Assert.isTrue(processingFeature.isInterface()); - List ret = new ArrayList(3); - if (processingFeature.isInstance(this)) { -// ((IMetaDataEnabledFeature)this).setBundleID(type.getBundleID()); - ret.add(this); - } - - //add extensions here - ret.addAll(findMetaDataEnabledFeaturesForThisType(processingFeature)); - return ret; - - } - - /** - * This implementation relies on the the feature implementor using a subclass of AbstractRootTypeDescriptor - * which implements {@link IMetaDataEnabledFeature}. - * - * @param processingFeature - * @return list of <code>IMetaDataEnabledFeature</code>s - */ - protected final List findMetaDataEnabledFeaturesForThisType(Class processingFeature) { - List ret = new ArrayList(3); - List extensions = MetaDataEnabledFeatureRegistry.getInstance() - .getFeatures(getTypeExtension().getTypeID()); - - if (!extensions.isEmpty()){ - for (int i=0;i<extensions.size();i++){ - IMetaDataEnabledFeatureExtension aFeature = (IMetaDataEnabledFeatureExtension)extensions.get(i); - IMetaDataEnabledFeature feature = MetaDataEnabledFeatureAdapterFactory.getInstance().getFeatureAdapter(aFeature, processingFeature); - if (feature != null && processingFeature.isInstance(feature)){ - ret.add(feature); - } - } - } - return ret; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.ITypeDescriptor#getRuntimeType() - */ - public IType getTypeExtension() { - return type; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.ITypeDescriptor#setRuntimeType(org.eclipse.jst.jsf.metadataprocessors.internal.AbstractMetaDataEnabledType) - */ - public void setTypeExtension(IType type) { - this.type = type; - } - - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/DefaultTypeDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/DefaultTypeDescriptor.java deleted file mode 100644 index 49b5ad916..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/DefaultTypeDescriptor.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - - -/** - * Type descriptor that is created if no class if provided for the implementation - * in the AttributeValueRuntimeTypes extension point. - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - */ -public class DefaultTypeDescriptor extends AbstractRootTypeDescriptor { - // abstract super contains no abstract methods, so do nothing: automatic default -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/IMetaDataEnabledFeature.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/IMetaDataEnabledFeature.java deleted file mode 100644 index f25054ddf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/IMetaDataEnabledFeature.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; - -/** - * Required interface used by the MetaData feature processing framework. - * All features must extend this interface. - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - */ -public abstract interface IMetaDataEnabledFeature { - - /** - * Sets structured document context that this feature will operating on - * @param context - */ - public void setStructuredDocumentContext(IStructuredDocumentContext context); - - /** - * Gets structured document context that this feature will operating on - * @return IStructuredDocumentContext - */ - public IStructuredDocumentContext getStructuredDocumentContext(); - - /** - * Sets metadata model context that this feature will operating on - * @param context - */ - public void setMetaDataContext(MetaDataContext context); - - /** - * Gets metadata model context that this feature will be operating on. - * @return MetaDataContext - */ - public MetaDataContext getMetaDataContext(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/IType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/IType.java deleted file mode 100644 index 7466b576c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/IType.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - - -/** - * Interface representing the information contained by the type registries. - * Encapsulates the IConfigurationElement information. - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - */ -public interface IType { - /** - * @return type id - */ - public String getTypeID(); - /** - * @return bundle id where it is defined - */ - public String getBundleID(); - /** - * @return classname for the type that must be located within the bundle - */ - public String getClassName(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/ITypeDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/ITypeDescriptor.java deleted file mode 100644 index bbf8aa961..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/ITypeDescriptor.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - -import java.util.List; - -/** - * Interface describing the runtime type of a metadata enabled annotation. - * The type descriptor will load the feature adapters for a certain kind of - * feature that it supports. The type descriptor is registered by an extension point. - * <p><b>Provisional API - subject to change</b></p> - * @see IMetaDataEnabledFeature - * @see AbstractRootTypeDescriptor - * @see org.eclipse.jst.jsf.metadataprocessors.internal.AbstractMetaDataEnabledTypeFactory - * @see IType - * - * @author Gerry Kessler - Oracle - * - */ -public interface ITypeDescriptor { - /** - * @param type - * The IType must be set after the ITypeDescriptor is constructed - */ - public void setTypeExtension(IType type); - /** - * @return IType - * Must not be null - */ - public IType getTypeExtension(); - - /** - * @param processingFeature interface class - * @return List of <code>IMetaDataEnabledFeature</code>s that support the - * specified processingFeature interface. - */ - public List getFeatureAdapters(Class processingFeature); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataContext.java deleted file mode 100644 index 237745ab8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataContext.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Trait; - - -/** - * The current metadata model context being used for processing. - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - */ -public class MetaDataContext { - private Trait trait; - private Entity entity; - - /** - * Constructor - * @param entity - * @param trait - */ - public MetaDataContext(Entity entity, Trait trait) { - this.entity = entity; - this.trait = trait; - } - - /** - * @return Entiry - */ - public Entity getEntity(){ - return entity; - } - /** - * @return Trait - */ - public Trait getTrait(){ - return trait; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java deleted file mode 100644 index fca310583..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.TraitValueHelper; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.metadataprocessors.internal.AttributeValueRuntimeTypeFactory; - - -/** - * Singleton class that will produce <code>IMetaDataEnabledFeature</code>s that the - * caller can use for processing. - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - */ -public final class MetaDataEnabledProcessingFactory { - private static MetaDataEnabledProcessingFactory INSTANCE; - - /** - * Name of property in annotation file to use when applying a runtime type to an attribute value - */ - public static final String ATTRIBUTE_VALUE_RUNTIME_TYPE_PROP_NAME = "attribute-value-runtime-type"; - - /** - * @return singleton instance - */ - public static MetaDataEnabledProcessingFactory getInstance(){ - if (INSTANCE == null){ - INSTANCE = new MetaDataEnabledProcessingFactory(); - } - return INSTANCE; - } - - private MetaDataEnabledProcessingFactory(){ - super(); - } - - /** - * Returns list of <code>IMetaDataEnabledFeature</code> adapters for the given Taglibrary attribute. - * - * Adapters will be scanned for first by uri, element, attribute and if not found, - * uri, "*", attribute and if still not found by "*", "*", attribute. - * @param featureType feature type. eg. <code>IPossibleValues</code>, <code>IValidValues</code>, etc. Must be subclass of IMetaDataEnabledFeature. - * @param sdContext - * @param uri annotation file uri - * @param elementName - * @param attributeName - * @return returns null - if the metadata was not found - * <br>returns empty list - if not a <code>IMetaDataEnabledFeature</code> proccessor or is not valid or does not support the specified feature - * - * @see MetaDataEnabledProcessingFactory#ATTRIBUTE_VALUE_RUNTIME_TYPE_PROP_NAME - */ - public List getAttributeValueRuntimeTypeFeatureProcessors(Class featureType, IStructuredDocumentContext sdContext, String uri, String elementName, String attributeName){ - List retList = new ArrayList(2); - //look up the attribute's runtime type from MD - IProject _project = null; - if (sdContext !=null){ - IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(sdContext); - _project = resolver != null ? resolver.getProject() : null; - } - String _elem = elementName + "/" + attributeName; - String _uri = uri; - ITaglibDomainMetaDataModelContext modelContext = TaglibDomainMetaDataQueryHelper.createMetaDataModelContext(_project, _uri); - Entity entity = TaglibDomainMetaDataQueryHelper.getEntity(modelContext, _elem); - Trait trait = null; - if (entity != null){ - trait = TaglibDomainMetaDataQueryHelper.getTrait(entity, ATTRIBUTE_VALUE_RUNTIME_TYPE_PROP_NAME); - } - - if (trait==null){ - return retList; - } - - String typeId = TraitValueHelper.getValueAsString(trait); - - //get the implementing class for the type - ITypeDescriptor type = AttributeValueRuntimeTypeFactory.getInstance().getType(typeId); - if (type != null){ - TaglibMetadataContext context = new TaglibMetadataContext(uri, elementName, attributeName, entity, trait); - //get all the feature adapters (IMetaDataEnabledFeature) for this type - List aList = type.getFeatureAdapters(featureType); - for (int j=0;j<aList.size();j++){ - //set the context in the feature - ((IMetaDataEnabledFeature)aList.get(j)).setMetaDataContext(context); - ((IMetaDataEnabledFeature)aList.get(j)).setStructuredDocumentContext(sdContext); - retList.add(aList.get(j)); - } - - } - //return list of IMetaDataEnabledFeatures for this type - return retList; - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/TaglibMetadataContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/TaglibMetadataContext.java deleted file mode 100644 index 89978e6eb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/TaglibMetadataContext.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.metadataprocessors; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Trait; - -/** - * Binds tag library context to the metadata context - * <p><b>Provisional API - subject to change</b></p> - */ -public class TaglibMetadataContext extends MetaDataContext { - - private String uri; - private String tagName; - private String attributeName; - - /** - * Constructor - * - * @param uri - must not be null - * @param tagName - must not be null - * @param attributeName - may be null - * @param entity - the metadata entity represented by the tag or attribute - * @param trait - the metadata trait of interest - */ - public TaglibMetadataContext(String uri, String tagName, String attributeName, Entity entity, Trait trait){ - super(entity, trait); - this.uri = uri; - this.tagName = tagName; - this.attributeName = attributeName; - } - - /** - * @return URI - */ - public String getUri() { - return uri; - } - - /** - * @return Tag name - should not be null - */ - public String getTagName() { - return tagName; - } - - /** - * @return Attribute name - may be null - */ - public String getAttributeName() { - return attributeName; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ELIsNotValidException.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ELIsNotValidException.java deleted file mode 100644 index f1b5b1698..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ELIsNotValidException.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -/** - * Exception - * - * <p><b>Provisional API - subject to change</b></p> - */ -public class ELIsNotValidException extends Exception { - private static final long serialVersionUID = 1L; - - /** - * Constructor - * @param msg - */ - public ELIsNotValidException(String msg){ - super(msg); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ICreateValues.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ICreateValues.java deleted file mode 100644 index 6c25a65d8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ICreateValues.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature; - -/** - * @author Gerry Kessler - Oracle - * - * Experimental - not currently used - * <p><b>Provisional API - subject to change</b></p> - * - */ -public interface ICreateValues extends IMetaDataEnabledFeature{ - /** - * @return object created - */ - public Object createValue(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IDefaultValue.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IDefaultValue.java deleted file mode 100644 index 93d93b812..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IDefaultValue.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature; - -/** - * Interface providing a default value. - * - * @author Gerry Kessler - Oracle - * - * <p><b>Provisional API - subject to change</b></p> - * - */ -public interface IDefaultValue extends IMetaDataEnabledFeature { - /** - * Default name of property in annotation file to use when supplying default values from meta-data - */ - String DEFAULT_VALUE_PROP_NAME = "default-value"; - - /** - * @return default value or null if one not defined - */ - public String getDefaultValue(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IPossibleValue.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IPossibleValue.java deleted file mode 100644 index d4cdbf955..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IPossibleValue.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Interface for providing lists of possible values - * Values can be different than displayed values. - * - * <p><b>Provisional API - subject to change</b></p> - * - */ -public interface IPossibleValue { - /** - * @return value to set. should not return null. - */ - public String getValue(); - /** - * @return value to display in a proposal which can be different than what is set. Must not return null. - */ - public String getDisplayValue(); - /** - * @return ImageDescriptor for image to be displayed in a proposal. May be null. - */ - public ImageDescriptor getIcon(); - /** - * @return true if is known to be the default value. - */ - public boolean isDefaultValue(); - - /** - * @return additional information that could be used for descriptive help - * May be null - */ - public String getAdditionalInformation(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IPossibleValues.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IPossibleValues.java deleted file mode 100644 index 4d43d8706..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IPossibleValues.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import java.util.List; - -import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature; - -/** - * Interface for providing possible values. - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - */ -public interface IPossibleValues extends IMetaDataEnabledFeature{ - - /** - * Default name of property in annotation file to use when supplying possible values from meta-data - */ - public static final String POSSIBLE_VALUES_PROP_NAME = "valid-values"; - /** - * Default name of property in annotation file to use when supplying possible displayed values from meta-data - */ - public static final String POSSIBLE_VALUES_FOR_DISPLAY_PROP_NAME = "displayed-values"; - /** - * Default name of property in annotation file to use when supplying icon displayed values from meta-data - */ - public static final String POSSIBLE_VALUES_SMALL_ICON_PROP_NAME = "small-icon"; - /** - * @return List of IPossibleValue instances representing possible values - * Implementer must ensure that an empty rather than null list is returned if no values are posssible. - */ - public List getPossibleValues(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidELValues.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidELValues.java deleted file mode 100644 index ca0b8f697..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidELValues.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature; - -/** - * An {@link IMetaDataEnabledFeature} for semantic validation of EL Values - * - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IValidELValues extends IMetaDataEnabledFeature { - /** - * Expected runtime type for EL value - * @return CompositeType - * @throws ELIsNotValidException - */ - public CompositeType getExpectedRuntimeType() throws ELIsNotValidException; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidValues.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidValues.java deleted file mode 100644 index 25baa406a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidValues.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import java.util.List; - -import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature; - -/** - * An {@link IMetaDataEnabledFeature} for validating values using metadata - * - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IValidValues extends IMetaDataEnabledFeature{ - /** - * Trait name for valid-values - */ - public static final String VALID_VALUES_PROP_NAME = "valid-values"; - - /** - * Trait name for valid-values-code - */ - public static final String VALID_VALUES_CODE_PROP_NAME = VALID_VALUES_PROP_NAME + "-code"; - /** - * Trait name for valid-values-severity - */ - public static final String VALID_VALUES_SEVERITY_PROP_NAME = VALID_VALUES_PROP_NAME + "-severity"; - /** - * Trait name for valid-values-message - */ - public static final String VALID_VALUES_MESSAGE_PROP_NAME = VALID_VALUES_PROP_NAME + "-message"; - /** - * Trait name for valid-maximum - */ - public static final String VALID_VALUES_MAX_PROP_NAME = "valid-maximum"; - /** - * Trait name for valid-minimum - */ - public static final String VALID_VALUES_MIN_PROP_NAME = "valid-minimum"; - /** - * @param value fully resolved value as String - * @return true if is valid - */ - public boolean isValidValue(String value); - /** - * @return List of IValidationMessage objects if invalid - * Must return empty list rather than null - * Call to isValidValue(String value) required before this should be called. - */ - public List getValidationMessages(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidationMessage.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidationMessage.java deleted file mode 100644 index 4f29c782d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/IValidationMessage.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -/** - * Interface for validation messages for metadata features - * - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IValidationMessage { - /** - * @return localized string desribing validation issue - * Should not be null; - */ - public String getMessage(); - - /** - * @return String representing a validation code associated with validation issue - * Can return null - */ - public String getCode(); - - /** - * @return integer value representing severity. - * Valid values are 0 (IStatus.INFO), 1 (IStatus.WARNING) and 4 (IStatus.ERROR) - */ - public int getSeverity(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/PossibleValue.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/PossibleValue.java deleted file mode 100644 index dbbde0636..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/PossibleValue.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import org.eclipse.jface.resource.ImageDescriptor; - - -/** - * Implements {@link IPossibleValues} - * - * <p><b>Provisional API - subject to change</b></p> - * - */ -public class PossibleValue implements IPossibleValue { - private String value; - private String displayValue; - private ImageDescriptor smallIcon; - private boolean isDefault = false; - private String additionalInfo; - - /** - * Constructor when display value is same as stored value - * @param value - */ - public PossibleValue(String value){ - this.value = value; - } - - /** - * Constructor when display-value may be different than stored value - * @param value - * @param displayValue - */ - public PossibleValue(String value, String displayValue){ - this.value = value; - this.displayValue = displayValue; - } - - /** - * Constructor when display-value may be different than stored value - * and a default value is known - * @param value - * @param displayValue - * @param isDefaultValue - */ - public PossibleValue(String value, String displayValue, boolean isDefaultValue) { - this.value = value; - this.displayValue = displayValue; - this.isDefault = isDefaultValue; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValue#getValue() - */ - public String getValue() { - return value; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValue#getDisplayValue() - */ - public String getDisplayValue() { - if (displayValue == null) - return value; - return displayValue; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValue#getIcon() - */ - public ImageDescriptor getIcon() { - return smallIcon; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValue#isDefaultValue() - */ - public boolean isDefaultValue() { - return isDefault; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValue#getAdditionalInformation() - */ - public String getAdditionalInformation() { - return additionalInfo; - } - - /** - * @param value - */ - public void setValue(String value) { - this.value = value; - } - - /** - * @param displayValue - */ - public void setDisplayValue(String displayValue) { - this.displayValue = displayValue; - } - - /** - * @param smallIcon - */ - public void setIcon(ImageDescriptor smallIcon) { - this.smallIcon = smallIcon; - } - - /** - * @param isDefault - */ - public void setIsDefault(boolean isDefault) { - this.isDefault = isDefault; - } - - /** - * @param additionalInfo - */ - public void setAdditionalInformation(String additionalInfo){ - this.additionalInfo = additionalInfo; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ValidationMessage.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ValidationMessage.java deleted file mode 100644 index 5aaf29e1a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/ValidationMessage.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.features; - -import org.eclipse.core.runtime.IStatus; - -/** - * Metadata Validation Message implementation - * - * <p><b>Provisional API - subject to change</b></p> - */ -public class ValidationMessage implements IValidationMessage { - - private String code; - private String msg; - private int severity = IStatus.WARNING; - - /** - * Constructor - * @param msg - */ - public ValidationMessage(String msg){ - this.msg = msg; - } - - /** - * Constructor - * @param msg - * @param code - * @param severity - */ - public ValidationMessage(String msg, String code, int severity){ - this.msg = msg; - this.code = code; - this.severity = severity; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage#getMessage() - */ - public String getMessage() { - return msg; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage#getCode() - */ - public String getCode() { - return code; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage#getSeverity() - */ - public int getSeverity() { - return severity; - } - - /** - * @param msg - */ - public void setMessage(String msg) { - this.msg = msg; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/package-info.java deleted file mode 100644 index 5922fbffc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/features/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -/** - * This package is used to provide tooling services for tag attribute values - * based on the org.eclipse.jst.jsf.core.AttributeValueRuntimeTypes. - * - * New features can added to the system using the org.eclipse.jst.jsf.core.MetaDataEnabledFeatures - * extension-point. This extension point provides the binding of a AttributeValueRuntimeTypes to a feature - * so that new behaviors can be added to existing types. - * - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.metadataprocessors.features; diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledType.java deleted file mode 100644 index 0ae2de2d7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledType.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -import org.eclipse.jst.jsf.metadataprocessors.IType; - - -/** - * Class that encapuslates the information from the - * <code>AttributeValueRuntimeTypes</code> and - * <code>MetaDataEnabledFeatures</code> - * extension points. - * - * @author Gerry Kessler - Oracle - * - */ -public class AbstractMetaDataEnabledType implements IType{ - String typeId; - String bundleId; - String klass; - - AbstractMetaDataEnabledType(String bundleID, String id, String klass){ - this.bundleId = bundleID; - this.typeId = bundleId + "." + id; - this.klass = klass; - } - - public String getTypeID(){ - return typeId; - } - - public String getBundleID(){ - return bundleId; - } - - public String getClassName(){ - return klass; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledTypeFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledTypeFactory.java deleted file mode 100644 index b03b52204..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledTypeFactory.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.metadataprocessors.IType; -import org.eclipse.jst.jsf.metadataprocessors.ITypeDescriptor; -import org.osgi.framework.Bundle; - -/** - * Abstract factory producing <code>ITypeDescriptor</code>s - * from instances of <code>AbstractMetaDataEnabledType</code>s - * - * @author Gerry Kessler - Oracle - * - */ -public abstract class AbstractMetaDataEnabledTypeFactory { - /** - * The factory instance - * TODO: why is this defined here it is only used in sub-classes?? - */ - protected static AbstractMetaDataEnabledTypeFactory INSTANCE; - - /** - * No arg constructor - */ - protected AbstractMetaDataEnabledTypeFactory(){ - super(); - } - - /** - * Concrete factory must pass instances of the it's types. - * - * @param typeId - * @return list of instances identified by the type id - */ - public abstract ITypeDescriptor getType(String typeId); - - /** - * @param type - * @return list of instances identified by the type id - */ - public ITypeDescriptor getType(AbstractMetaDataEnabledType type){ - - return createType(type); - - } - - /** - * Creates instances of <code>ITypeDescriptor</code>s from - * <code>AbstractMetaDataEnabledType</code>s - * - * @param atype - * @return the meta-data type descriptor - */ - protected ITypeDescriptor createType(IType atype){ - if (atype != null){ - ITypeDescriptor desc = createDescriptor(atype); - if (desc != null){ - desc.setTypeExtension(atype); - return desc; - } - } - return null; - } - - - private ITypeDescriptor createDescriptor(IType type){ - String className = type.getClassName(); - try { - Bundle bundle =Platform.getBundle(type.getBundleID()); - if (bundle == null){ - JSFCorePlugin.log(IStatus.ERROR, type.getBundleID() + " could not be created to load " + className); - return null; - } - Class klass = bundle.loadClass(className); - if (klass != null){ - //make sure the class can support the feature/extended interface - if (ITypeDescriptor.class.isAssignableFrom(klass)) - { - return (ITypeDescriptor)klass.newInstance(); - } - JSFCorePlugin.log(IStatus.INFO, className + " was not found in " + type.getBundleID() +" for " + type.getTypeID()); - } - } catch (ClassNotFoundException e) { - JSFCorePlugin.log(IStatus.ERROR, className + " was not found in " + type.getBundleID() +" for " + type.getTypeID()); - } catch (InstantiationException e) { - JSFCorePlugin.log(IStatus.ERROR, "InstantiationException: " + className + " in " + type.getBundleID() +" for " + type.getTypeID()); - } catch (IllegalAccessException e) { - JSFCorePlugin.log(IStatus.ERROR, "IllegalAccessException: " + className + " in " + type.getBundleID() +" for " + type.getTypeID()); - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledTypeRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledTypeRegistry.java deleted file mode 100644 index 5c4b0b2c0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AbstractMetaDataEnabledTypeRegistry.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -import java.util.HashMap; - -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.InvalidRegistryObjectException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; - -/** - * Abstract registry of <code>AbstractMetaDataEnabledType<code> - * mapped by type id. - * - * @author Gerry Kessler - Oracle - * - */ -public abstract class AbstractMetaDataEnabledTypeRegistry { - private final HashMap typeMap; //map of types keyed by id - private final String ext_pt_id; //type ext-pt id - - /** - * @param extPtId - */ - public AbstractMetaDataEnabledTypeRegistry(String extPtId){ - typeMap = new HashMap(); - ext_pt_id = extPtId; - - readRegistry(); - } - - /** - * @param bundleID - * @param id - * @param klass - * @param runtimeType - */ - protected void registerType(String bundleID, String id, String klass, String runtimeType){ - AbstractMetaDataEnabledType atype = new AbstractMetaDataEnabledType(bundleID, id, klass); - if (!typeMap.containsKey(atype.getTypeID())){ - typeMap.put(atype.getTypeID(), atype); - } - else { - //is there any point in putting this more in the user's face? this is really an internal error. - JSFCorePlugin.log(IStatus.ERROR, "Duplicate RuntimeTypeId being registered from " + ext_pt_id + ": " + atype.getTypeID()); - } - } - - /** - * Return the metadata enabled type for the given id - * @param id - * @return type - */ - public AbstractMetaDataEnabledType getType(String id){ - if (typeMap.containsKey(id)) - { - return (AbstractMetaDataEnabledType)typeMap.get(id); - } - return null; - } - - /** - * Reads the extensions for a particular type id - */ - protected void readRegistry() { - try { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(JSFCorePlugin.PLUGIN_ID, ext_pt_id); - IExtension[] extensions = point.getExtensions(); - for (int i=0;i < extensions.length;i++){ - IExtension ext = extensions[i]; - for (int j=0;j < ext.getConfigurationElements().length;j++){ - final String bundleId = ext.getConfigurationElements()[j].getContributor().getName(); - final String id = ext.getConfigurationElements()[j].getAttribute("id"); - String klass = ext.getConfigurationElements()[j].getAttribute("class"); - final String runtimeType = ext.getConfigurationElements()[j].getAttribute("runtime-type"); - if (klass == null || klass.trim().equals("")){ - klass = getDefaultClassName(); - } - registerType(bundleId, id, klass, runtimeType); - } - } - } catch (InvalidRegistryObjectException e) { - JSFCorePlugin.log(e, "Unable to read " + JSFCorePlugin.PLUGIN_ID + ext_pt_id + " registry"); - } - } - - /** - * @return default classname to use for the type - */ - protected abstract String getDefaultClassName(); - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AttributeValueRuntimeTypeFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AttributeValueRuntimeTypeFactory.java deleted file mode 100644 index 78638e287..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AttributeValueRuntimeTypeFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -import org.eclipse.jst.jsf.metadataprocessors.ITypeDescriptor; - - -/** - * Factory producing <code>IMetaDataEnabledFeature</code>s from - * <code>AttributeValueRuntimeType</code> objects - * - * @author Gerry Kessler - Oracle - * - */ -public class AttributeValueRuntimeTypeFactory extends AbstractMetaDataEnabledTypeFactory{ - - /** - * @return the single instance... TODO: why is this allocated here if it is - * declared in super? - */ - public static AttributeValueRuntimeTypeFactory getInstance(){ - if (INSTANCE == null){ - INSTANCE = new AttributeValueRuntimeTypeFactory(); - } - return (AttributeValueRuntimeTypeFactory)INSTANCE; - } - - private AttributeValueRuntimeTypeFactory(){ - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.internal.AbstractMetaDataEnabledTypeFactory#getType(java.lang.String) - */ - public ITypeDescriptor getType(String typeId){ - - return createType(AttributeValueRuntimeTypeRegistry.getInstance().getType(typeId)); - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AttributeValueRuntimeTypeRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AttributeValueRuntimeTypeRegistry.java deleted file mode 100644 index 9deab17ae..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/AttributeValueRuntimeTypeRegistry.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -/** - * Registry of <code>AbstractMetaDataEnabledType</code>s that are loaded from - * the <code>AttributeValueRuntimeValueType</code> extension point - * - * @author Gerry Kessler - Oracle - * - */ -public class AttributeValueRuntimeTypeRegistry extends AbstractMetaDataEnabledTypeRegistry { - - private static final String EXTPTID = "AttributeValueRuntimeTypes"; - private static final String DEFAULT_CLASS = "org.eclipse.jst.jsf.metadataprocessors.DefaultTypeDescriptor"; - private static AttributeValueRuntimeTypeRegistry INSTANCE; - - /** - * @return singleton instance - */ - public static AttributeValueRuntimeTypeRegistry getInstance(){ - if (INSTANCE == null){ - INSTANCE = new AttributeValueRuntimeTypeRegistry(); - } - return INSTANCE; - } - - private AttributeValueRuntimeTypeRegistry(){ - super(EXTPTID); - } - - protected String getDefaultClassName() { - return DEFAULT_CLASS; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/IMetaDataEnabledFeatureExtension.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/IMetaDataEnabledFeatureExtension.java deleted file mode 100644 index bde9ca613..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/IMetaDataEnabledFeatureExtension.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -/** - * Interface used to bind feature extensions to metadata enabled types - * - */ -public interface IMetaDataEnabledFeatureExtension { - /** - * @return bundle id - */ - public String getBundleID(); - /** - * @return type id - */ - public String getTypeID(); - /** - * @return class name to use for type. Must be located within the bundle. - */ - public String getClassName(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureAdapterFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureAdapterFactory.java deleted file mode 100644 index e821ec1e4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureAdapterFactory.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature; -import org.osgi.framework.Bundle; - -/** - * Factory producing <code>IMetaDataEnabledFeature</code>s from - * <code>IType</code> objects that implement a specified feature - * - * @author Gerry Kessler - Oracle - * - */ -public final class MetaDataEnabledFeatureAdapterFactory { - private static MetaDataEnabledFeatureAdapterFactory INSTANCE; - - /** - * @return singleton instance - */ - public static MetaDataEnabledFeatureAdapterFactory getInstance(){ - if (INSTANCE == null){ - INSTANCE = new MetaDataEnabledFeatureAdapterFactory(); - } - return INSTANCE; - } - - private MetaDataEnabledFeatureAdapterFactory(){ - super(); - } - - /** - * Given the feature extension, create and return the {@link IMetaDataEnabledFeature} for a given processing feature - * @param feature - * @param processingFeature class - * @return IMetaDataEnabledFeature - */ - public IMetaDataEnabledFeature getFeatureAdapter(IMetaDataEnabledFeatureExtension feature, Class processingFeature){ - if (feature != null){ - return createFeature(feature, processingFeature); - } - return null; - } - - private IMetaDataEnabledFeature createFeature(IMetaDataEnabledFeatureExtension featureExt, Class processingFeature){ - String className = featureExt.getClassName(); - try { - Bundle bundle =Platform.getBundle(featureExt.getBundleID()); - if (bundle == null){ - JSFCorePlugin.log(IStatus.ERROR, featureExt.getBundleID() + " could not be created to load " + className); - return null; - } - Class klass = bundle.loadClass(className); - if (klass != null){ - if (!IMetaDataEnabledFeature.class.isAssignableFrom(klass)){ - JSFCorePlugin.log(IStatus.INFO, className + " is not a IMetaDataEnabledFeature. " + featureExt.getBundleID() +" : " + featureExt.getTypeID()); - } - else if (processingFeature.isAssignableFrom(klass)){ - IMetaDataEnabledFeature obj = (IMetaDataEnabledFeature)klass.newInstance(); -// obj.setBundleID(featureExt.getBundleID()); - return obj; - } - } - } catch (ClassNotFoundException e) { - JSFCorePlugin.log(IStatus.ERROR, className + " was not found in " + featureExt.getBundleID() +" for " + featureExt.getTypeID()); - } catch (InstantiationException e) { - JSFCorePlugin.log(IStatus.ERROR, "InstantiationException: " + className + " in " + featureExt.getBundleID() +" for " + featureExt.getTypeID()); - } catch (IllegalAccessException e) { - JSFCorePlugin.log(IStatus.ERROR, "IllegalAccessException: " + className + " in " + featureExt.getBundleID() +" for " + featureExt.getTypeID()); - } - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureExtension.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureExtension.java deleted file mode 100644 index ae90a9a5e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureExtension.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - - -/** - * - * @author Gerry Kessler - Oracle - * - */ -public class MetaDataEnabledFeatureExtension implements IMetaDataEnabledFeatureExtension{ - - private String klass; - private String typeId; - private String bundleId; - - MetaDataEnabledFeatureExtension(String bundleID, String typeId, String klass) { - this.bundleId = bundleID; - this.typeId = typeId; - this.klass = klass; - } - - public String getBundleID() { - return bundleId; - } - - public String getClassName() { - return klass; - } - - public String getTypeID() { - return typeId; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureRegistry.java deleted file mode 100644 index 47bb44b56..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/MetaDataEnabledFeatureRegistry.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.metadataprocessors.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.InvalidRegistryObjectException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; - -/** - * Registry of <code>AbstractMetaDataEnabledType</code>s loaded from - * the <code>MetaDataEnabledFeatures</code> extension point - * - * A map of features keyed by type id - * - * @author Gerry Kessler - Oracle - * - */ -public class MetaDataEnabledFeatureRegistry{ - private static final String EXTPTID = "MetaDataEnabledFeatures"; - private Map featuresMap; - private List EMPTY_LIST = new ArrayList(0); - - private static MetaDataEnabledFeatureRegistry INSTANCE; - - /** - * @return the singleton instance of the MetaDataEnabledFeatureRegistry - */ - public static synchronized MetaDataEnabledFeatureRegistry getInstance(){ - if (INSTANCE == null){ - INSTANCE = new MetaDataEnabledFeatureRegistry(); - } - return INSTANCE; - } - - private MetaDataEnabledFeatureRegistry(){ - featuresMap = new HashMap(); - readRegistry(); - } - - /** - * Reads the MetaDataEnabledFeatures extensions into a registry - */ - protected void readRegistry() { - try { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(JSFCorePlugin.PLUGIN_ID, EXTPTID); - IExtension[] extensions = point.getExtensions(); - for (int i=0;i < extensions.length;i++){ - IExtension ext = extensions[i]; - for (int j=0;j < ext.getConfigurationElements().length;j++){ - final String bundleId = ext.getConfigurationElements()[j].getContributor().getName(); - final String id = ext.getConfigurationElements()[j].getAttribute("typeid"); - final String klass = ext.getConfigurationElements()[j].getAttribute("class"); - registerFeature(bundleId, id, klass); - } - } - } catch (InvalidRegistryObjectException e) { - JSFCorePlugin.log(e, "Unable to read " + JSFCorePlugin.PLUGIN_ID + EXTPTID + " registry"); - } - } - - /** - * Create {@link IMetaDataEnabledFeatureExtension}s and add to registry - * @param bundleID - * @param typeId - * @param klass - */ - protected void registerFeature(String bundleID, String typeId, String klass){ - IMetaDataEnabledFeatureExtension aFeature = new MetaDataEnabledFeatureExtension(bundleID, typeId, klass); - if (!featuresMap.containsKey(typeId)){ - List list = new ArrayList(); - list.add(aFeature); - featuresMap.put(typeId, list); - } - else { - List list = (List)featuresMap.get(typeId); - list.add(aFeature); - } - } - - /** - * @param typeId - * @return List of <code>AbstractMetaDataEnabledRuntimeTypeExtensions</code> - * for a given by type id - */ - public List getFeatures(String typeId) { - if (featuresMap.containsKey(typeId)) - { - return (List)featuresMap.get(typeId); - } - return EMPTY_LIST; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/package-info.java deleted file mode 100644 index f791e43bd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -/** - * This package is used to provide tooling support for taglibraries using the Design-time Metadata - * feature (org.eclipse.jst.jsf.common.metadata).<p> - * The MetaDataEnabledProcessingFactory singleton instance is the entry point. The tool requests - * the IMetaDataEnabled feature for a particular tag attribute, and through metadata, will locate the - * "metadata processing" feature using the attribute value runtime type system. - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.metadataprocessors; diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java deleted file mode 100644 index 8690ddeba..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager; -import org.eclipse.jst.jsf.facesconfig.FacesConfigPlugin; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; -import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage; -import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue; -import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage; -import org.eclipse.osgi.util.NLS; -import org.osgi.framework.Bundle; - -/** - * Meta-data processing type representing an "action" attribute - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class ActionType extends MethodBindingType implements IPossibleValues{ - /** - * Image to use if metadata defined image cannot be created - */ - protected static final ImageDescriptor MISSING_IMAGE = ImageDescriptor.getMissingImageDescriptor(); - - private static final String IMAGE_NAME = "/icons/full/obj16/NavigationCaseType.gif"; //$NON-NLS-1$ - private ImageDescriptor imageDescriptor; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.MethodBindingType#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value){ - if (value != null && value.length() > 0) - return true; - // what other coercion rules apply??? - - IValidationMessage msg = new ValidationMessage(Messages.ActionType_invalid_value); - getValidationMessages().add(msg); - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues#getPossibleValues() - */ - public List getPossibleValues() { - // TODO getNavigationRules for this page from JSFAppMgr - List ret = new ArrayList(); - IWorkspaceContextResolver wr = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext()); - if (wr != null){ - IFile jsp = (IFile)wr.getResource(); - List rules = JSFAppConfigManager.getInstance(wr.getProject()).getNavigationRulesForPage(jsp); - for(Iterator it=rules.iterator();it.hasNext();){ - NavigationRuleType rule = (NavigationRuleType)it.next(); - if (rule != null) - ret.addAll(createProposals(rule)); - } - } - return ret; - } - - private List createProposals(NavigationRuleType rule) { - List ret = new ArrayList(); - List cases = rule.getNavigationCase(); - for(Iterator it=cases.iterator();it.hasNext();){ - NavigationCaseType navCase = (NavigationCaseType)it.next(); - PossibleValue pv = createProposal(rule, navCase); - if (pv != null) - ret.add(pv); - } - return ret; - } - - private PossibleValue createProposal(NavigationRuleType rule, NavigationCaseType navCase) { - PossibleValue pv = null; - String value = null; - String ruleDisp = null; - String navDisplay = null; - String navAction = null; - String toViewId = null; - - if (navCase.getFromOutcome() != null) - value = navCase.getFromOutcome().getTextContent(); - if (navCase.getToViewId()!= null) - toViewId = navCase.getToViewId().getTextContent(); - if (rule.getFromViewId() != null) - ruleDisp = rule.getFromViewId().getTextContent(); - if (navCase.getDisplayName() != null - && navCase.getDisplayName().size() > 0) { - navDisplay = ((DisplayNameType) navCase - .getDisplayName().get(0)).getTextContent(); - } - if (navCase.getFromAction() != null) { - navAction= navCase.getFromAction().getTextContent(); - } - if (navDisplay == null || navDisplay.trim().equals("")) //$NON-NLS-1$ - navDisplay = NLS.bind(Messages.ActionType_navcase_display, new String[]{value, toViewId}); - - if (value != null){ - pv = new PossibleValue(value, navDisplay); - pv.setIcon(getNavCaseImageDescriptor()); - pv.setAdditionalInformation("from-outcome: "+value //$NON-NLS-1$ - + "<br>to-view-id: " + toViewId //$NON-NLS-1$ - + "<br>from-view-id: " + ruleDisp //$NON-NLS-1$ - + "<br>from-action: " + (navAction == null ? "null" : navAction)); //$NON-NLS-1$ //$NON-NLS-2$ - } - - return pv; - } - - - private ImageDescriptor getNavCaseImageDescriptor() { - ImageDescriptor ret = super.getImage(); - if (ret != null && ret != MISSING_IMAGE) - return ret; - - if (imageDescriptor == null){ - imageDescriptor = getImageDesc(IMAGE_NAME); - } - return imageDescriptor; - - } - - private ImageDescriptor getImageDesc(String img) - { - Bundle bundle = FacesConfigPlugin.getPlugin().getBundle(); - URL url = FileLocator.find(bundle, new Path(img), null); - ImageDescriptor desc = ImageDescriptor.createFromURL(url); - if (desc == MISSING_IMAGE){ - return null; - } - return desc; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/BindingType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/BindingType.java deleted file mode 100644 index 6932796c6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/BindingType.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import org.eclipse.jst.jsf.metadataprocessors.AbstractRootTypeDescriptor; - -/** - * Abstract meta-data processing type representing a binding - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class BindingType extends AbstractRootTypeDescriptor{ - // TODO: what's the point of this? -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/BooleanType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/BooleanType.java deleted file mode 100644 index cd90e74be..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/BooleanType.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue; -import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue; - -/** - * Meta-data processing type representing a boolean attribute value runtime type - * that implements IPossibleValues, IValidValues, IDefaultValue, IValidELValues - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class BooleanType extends EnumerationType implements IValidValues, IPossibleValues, IDefaultValue{ - private static final String TRUE_VAL = "true"; //$NON-NLS-1$ - private static final String FALSE_VAL = "false"; //$NON-NLS-1$ - - private static final String BOOLTYPE_VALIDATION_MSG = Messages.BooleanType_invalid_values; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.EnumerationType#getReturnType() - */ - protected String getReturnType(){ return "boolean";} //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues#getPossibleValues() - */ - public List getPossibleValues() { - String def = getDefaultValue(); - List vals = new ArrayList(); - vals.add(new PossibleValue(TRUE_VAL, TRUE_VAL, def != null && def.equals(TRUE_VAL) )); - vals.add(new PossibleValue(FALSE_VAL, FALSE_VAL, def != null && def.equals(FALSE_VAL) )); - return vals; - } - - /** - * Type coercion according to JSP 2.0 spec: JSP.1.14.2.1 Conversions from String values - * Although not completely faithful to spec, we will validate values as either 'true' or 'false' - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - **/ - public boolean isValidValue(String value) { - if(TRUE_VAL.equalsIgnoreCase(value) || FALSE_VAL.equalsIgnoreCase(value)) { - return true; - } - addNewValidationMessage(BOOLTYPE_VALIDATION_MSG); - return false; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ComponentBindingType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ComponentBindingType.java deleted file mode 100644 index 4e394ede7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ComponentBindingType.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - - -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage; -import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage; - -/** - * Meta-data processing type representing a "binding" attribute - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class ComponentBindingType extends ValueBindingType implements - IValidValues, IValidELValues { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value) { - //Strings are invalid. Requires a EL value binding. - IValidationMessage msg = new ValidationMessage(Messages.ComponentBindingType_invalid_value); - getValidationMessages().add(msg); - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ComponentIDType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ComponentIDType.java deleted file mode 100644 index 016d21b25..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ComponentIDType.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - - -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage; -import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage; - -/** - * Meta-data processing type representing an "id" attribute - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class ComponentIDType extends ValueBindingType implements - IValidValues, IValidELValues { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.ValueBindingType#getExpectedRuntimeType() - */ - public CompositeType getExpectedRuntimeType() throws ELIsNotValidException { - throw new ELIsNotValidException(Messages.ComponentIDType_invalid_as_el); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value) { - IValidationMessage msg = null; - if (value != null && value.trim().length() == 0) - msg = new ValidationMessage(Messages.ComponentIDType_invalid_value); - else { - //we could validate uniqueness, but will not for the time being. This would require a DT FacesContext. - //any other coercion rules apply here? - return true; - } - getValidationMessages().add(msg); - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/DirectBindingType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/DirectBindingType.java deleted file mode 100644 index 2c5f7c0b1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/DirectBindingType.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; -/** - * Abstract meta-data processing type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class DirectBindingType extends BindingType { - // TODO: what is the point of this? -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/DoubleType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/DoubleType.java deleted file mode 100644 index 0e73d4a9a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/DoubleType.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.List; - -import org.eclipse.osgi.util.NLS; - -/** - * Meta-data processing type representing a "double" attribute value runtime type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class DoubleType extends NumberType { - private static final String INVALID_DOUBLE = Messages.DoubleType_invalid_double; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.EnumerationType#getReturnType() - */ - protected String getReturnType(){ return "double";} //$NON-NLS-1$ - - /** - * Type coercion according to JSP 2.0 spec: JSP.1.14.2.1 Conversions from String values - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - **/ - public boolean isValidValue(String value) { - try { - Double dbl = Double.valueOf(value); - exceedsMaxValue(dbl.doubleValue()); - lessThanMinValue(dbl.doubleValue()); - if (!(minFound || maxFound)){ - List validVals = getMDValidValues(); - if (!validVals.isEmpty()){ - if (!validVals.contains(value)){ - addNewValidationMessage(Messages.DoubleType_invalid_member);//fix me - } - } - } - return getValidationMessages().isEmpty(); - } catch (NumberFormatException e) { - addNewValidationMessage(INVALID_DOUBLE); - return false; - } - - } - - private void exceedsMaxValue(double dbl) { - String strMax = getValidMaximumValue(); - if (strMax != null){ - try { - double max = Double.valueOf(strMax).doubleValue(); - maxFound = true; - if (dbl > max){ - addNewValidationMessage(NLS.bind(EXCEEDS_MAX, strMax)); - } - } catch (NumberFormatException e) { - //TODO: ignore error???? or log it???? - } - } - - } - - private void lessThanMinValue(double dbl) { - String strMin = getValidMinimumValue(); - if (strMin != null){ - try { - double max = Double.valueOf(strMin).doubleValue(); - minFound = true; - if (dbl < max){ - addNewValidationMessage(NLS.bind(LESS_THAN_MIN, strMin)); - } - } catch (NumberFormatException e) { - //TODO: ignore error???? or log it???? - } - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java deleted file mode 100644 index e1bb995d3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.metadataprocessors.AbstractRootTypeDescriptor; -import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException; -import org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue; -import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage; - -/** - * Abstract meta-data processing type representing an enumeration attribute value runtime type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class EnumerationType extends AbstractRootTypeDescriptor implements IValidValues, IDefaultValue, IValidELValues{ - private List validationMessages; - - /** - * An empty list - */ - protected static List EMPTY_LIST = new ArrayList(0); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#getValidationMessages() - */ - public List getValidationMessages() { - if (validationMessages == null){ - validationMessages = new ArrayList(); - } - return validationMessages; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue#getDefaultValue() - */ - public String getDefaultValue() { - return getTraitValueAsString(IDefaultValue.DEFAULT_VALUE_PROP_NAME); - } - - /** - * @return possible values of type as list of Strings using - * {@link IPossibleValues}.POSSIBLE_VALUES_PROP_NAME trait name - */ - protected List getMDPossibleValues() { - return getTraitValueAsListOfStrings(IPossibleValues.POSSIBLE_VALUES_PROP_NAME); - } - - /** - * @return possible values of type to dislay as list of Strings using - * {@link IPossibleValues}.POSSIBLE_VALUES_FOR_DISPLAY_PROP_NAME trait name - */ - protected List getMDPossibleValuesForDisplay() { - return getTraitValueAsListOfStrings(IPossibleValues.POSSIBLE_VALUES_FOR_DISPLAY_PROP_NAME); - } - - /** - * @return list of valid values as list of Strings using - * {@link IValidValues}.VALID_VALUES_PROP_NAME trait name - */ - protected List getMDValidValues() { - return getTraitValueAsListOfStrings(IValidValues.VALID_VALUES_PROP_NAME); - } - - /** - * @return Validation message for type using - * {@link IValidValues}.VALID_VALUES_MESSAGE_PROP_NAME trait name - */ - protected String getMDValidationMessage() { - return getTraitValueAsString(IValidValues.VALID_VALUES_MESSAGE_PROP_NAME); - } - - /** - * @return Validation severity int value for type using - * {@link IValidValues}.VALID_VALUES_SEVERITY_PROP_NAME trait name - */ - protected int getMDValidationSeverity() { - String val = getTraitValueAsString(IValidValues.VALID_VALUES_SEVERITY_PROP_NAME); - if (val == null) - return IStatus.WARNING; - - int severity = Integer.valueOf(val).intValue(); - return severity; - } - - /** - * @return Validation code as String value for type using - * {@link IValidValues}.VALID_VALUES_CODE_PROP_NAME trait name - */ - protected String getMDValidationCode() { - return getTraitValueAsString(IValidValues.VALID_VALUES_CODE_PROP_NAME); - } - - /** - * Create a {@link ValidationMessage} from metadata or use default message - * and add it to the collection of validation messages - * @param defaultMsg - */ - protected void addNewValidationMessage(String defaultMsg) { - String msg = getMDValidationMessage(); - if (msg == null || msg.equals("")) //$NON-NLS-1$ - msg = defaultMsg; - - String code = getMDValidationCode(); - int severity = getMDValidationSeverity(); - ValidationMessage val = new ValidationMessage(msg, code, severity); - getValidationMessages().add(val); - } - - /** - * @return return Java type as string (i.e. boolean, java.lang.String, etc.) - * Must not be null. - */ - protected abstract String getReturnType(); - - /** - * @return the value of {@link org.eclipse.jst.jsf.common.internal.types.IAssignable}.ASSIGNMENT_TYPE_NONE. Subclasses to override. - */ - protected int getAssignmentType(){ - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues#getExpectedRuntimeType() - */ - public CompositeType getExpectedRuntimeType() throws ELIsNotValidException { - String type = Signature.createTypeSignature(getReturnType(), true); - return new CompositeType(type, getAssignmentType()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ExpressionBindingType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ExpressionBindingType.java deleted file mode 100644 index 1ae1d98de..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ExpressionBindingType.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.ArrayList; -import java.util.List; - -/** - * Abstract meta-data processing type representing an expression binding attribute value runtime type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class ExpressionBindingType extends BindingType { - /** - * Valid values is any fully qualified Java type or primitive. - * Assign a value for each parameter in order - */ - public static final String RUNTIME_PARAMS_TYPES = "runtime-param-types"; //$NON-NLS-1$ - /** - * Valid values is any fully qualified Java type or primitive. - */ - public static final String RUNTIME_RETURN_TYPE = "runtime-return-type"; //$NON-NLS-1$ - /** - * Value should be set true or false. If not specified, the default inmplementation assumes false. - */ - public static final String RUNTIME_SETTER_REQUIRED = "runtime-type-setter-required"; //$NON-NLS-1$ - private List validationMessages; - - - /** - * @return String value of the "runtime-return-type" trait - */ - protected String getReturnType() { - return getTraitValueAsString(RUNTIME_RETURN_TYPE); - } - - /** - * @return String[] value of the "runtime-param-types" trait - */ - protected String[] getParams() { - List params = getTraitValueAsListOfStrings(RUNTIME_PARAMS_TYPES); - - return (String[])params.toArray(new String[0]); - } - - /** - * @return lits of validation messages - */ - public List getValidationMessages() { - if (validationMessages == null){ - validationMessages = new ArrayList(); - } - return validationMessages; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java deleted file mode 100644 index bcad2195b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterType; -import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue; -import org.eclipse.osgi.util.NLS; - -/** - * Meta-data processing feature representing an attribute value requiring a "converterid" - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class FacesConfigConverterIDFeatures extends FacesConfigIdentifierFeatures { - - /** - * Faces converter classname - */ - protected static final String CONVERTER = "javax.faces.convert.Converter"; //$NON-NLS-1$ - /** - * Imagename to use when displaying converter - */ - protected static final String IMAGE_NAME = "/icons/full/obj16/FacesConfig_Converter.gif"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getElements(org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager) - */ - protected List getElements(JSFAppConfigManager mgr) { - if (mgr != null) - return mgr.getConverters(); - return new ArrayList(0); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getReturnType() - */ - protected String getReturnType(){ return CONVERTER;} - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getPossibleValueProposals(java.util.List) - */ - protected List getPossibleValueProposals(List elements) { - List ret = new ArrayList(); - Collections.sort(elements, new ConverterSorter()); - for (Iterator it = elements.iterator();it.hasNext();){ - ConverterType obj = (ConverterType)it.next(); - if (obj.getConverterId() != null && obj.getConverterId().getTextContent() != null){ - PossibleValue pv = createProposal(obj.getConverterId().getTextContent(), obj.getDisplayName(), obj.getDescription()); - if (pv != null){ - pv.setIcon(getImage()); - ret.add(pv); - } - } - } - return ret; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getImageName() - */ - protected String getImageName() { - return IMAGE_NAME; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getMyValidationMessage(java.lang.String) - */ - protected String getMyValidationMessage(String value) { - if (value == null || value.trim().equals("")) //$NON-NLS-1$ - return Messages.FacesConfigConverterIDFeatures_converterid_empty; - - return NLS.bind(Messages.FacesConfigIdentifierType_invalid_converter_id, new String[]{singleQuote(value)}); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getElementIDs(org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager) - */ - protected List getElementIDs(JSFAppConfigManager mgr) { - List elements = getElements(mgr); - List ret = new ArrayList(elements.size()); - for (Iterator it = elements.iterator();it.hasNext();){ - ConverterType aType = (ConverterType)it.next(); - if (aType.getConverterId() != null && aType.getConverterId().getTextContent() != null){ - String id = aType.getConverterId().getTextContent(); - if (id != null) - ret.add(id.trim()); - } - } - return ret; - } - - /** - * - * Converter ID Sorter - incomplete - */ - class ConverterSorter implements Comparator { - - public int compare(Object o1, Object o2) { - //TODO - return 0; - - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDType.java deleted file mode 100644 index 3e81d0484..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDType.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -/** - * Type representing a FacesConfig Converter attribute - * - * <p><b>Provisional API - subject to change</b></p> - */ -public class FacesConfigConverterIDType extends FacesConfigIdentifierType { - // FIXME: why do we have an empty class? -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java deleted file mode 100644 index b22f4d1ec..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager; -import org.eclipse.jst.jsf.facesconfig.FacesConfigPlugin; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.metadataprocessors.AbstractMetaDataEnabledFeature; -import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException; -import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage; -import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue; -import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage; -import org.osgi.framework.Bundle; - -/** - * Abstract meta-data processing feature representing a faces-config type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class FacesConfigIdentifierFeatures extends AbstractMetaDataEnabledFeature - implements IPossibleValues, IValidValues, IValidELValues{ - - /** - * Meta-data property name to use for identifying the faces-config type - * - * see jsf_core.xml converterID and validatorID attributes - */ - public static final String ID_TYPE_PROP_NAME = "config-type"; //$NON-NLS-1$ - - /** - * Missing image descriptor - */ - protected static final ImageDescriptor MISSING_IMAGE = ImageDescriptor.getMissingImageDescriptor(); - - /** - * Name of image file to use with content assist proposals - */ - protected String imageName; - private ImageDescriptor imageDescriptor; - /** - * Validation messages to return - */ - protected List validationMessages; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues#getPossibleValues() - */ - public List getPossibleValues() { - List ret = new ArrayList(); - List idTypes = getConfigTypes(); - - if (idTypes != null){ - for (int i=0;i<idTypes.size();i++){ - //verify this feature can deal with this type - if (getReturnType().equals(idTypes.get(i))){ - ret.addAll(createPossibleValues()); - } - } - } - - return ret; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value) { - List idTypes = getConfigTypes(); - if (idTypes != null){ - for (int i=0;i<idTypes.size();i++){ - if (getReturnType().equals(idTypes.get(i))){ - if (hasValue(getElementIDs(getJSFAppConfigMgr()), value)){ - getValidationMessages().clear(); - return true; - } - getValidationMessages().add(getValidationMessage(value)); - } - } - } - return false; - } - - private boolean hasValue(List elements, String value) { - for (Iterator it=elements.iterator();it.hasNext();){ - if (value.equals(it.next())) - return true; - } - return false; - } - - /** - * @param value of the attribute - * @return the validation message String - */ - protected abstract String getMyValidationMessage(String value); - - /** - * Creates an IValidationMessage - * @param value - * @return IValidationMessage - */ - protected IValidationMessage getValidationMessage(String value) { - String msg; - msg = getCMValidationMessage(); - if (msg == null){ - msg = getMyValidationMessage(value); - } - String code = getCMValidationCode(); - int severity = getCMValidationSeverity(); - - IValidationMessage valMsg = new ValidationMessage(msg, code, severity); - return valMsg; - } - - /** - * - * @param value - * @return single-quoted value - */ - protected String singleQuote(String value){ - return "'" + value+"'"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#getValidationMessages() - */ - public List getValidationMessages(){ - if (validationMessages == null){ - validationMessages = new ArrayList(); - } - return validationMessages; - } - - /** - * @param jsfAppConfigManager - * @return list of faces-config element for the specified config-type - */ - protected abstract List getElements(JSFAppConfigManager jsfAppConfigManager); - /** - * @param elements - * @return list of IPossibleValue objects for the specified list of config elements - */ - protected abstract List getPossibleValueProposals(List elements); - /** - * @return image name relative to the FacesConfigEditPlugin where the images are stored - */ - protected abstract String getImageName(); - - private List createPossibleValues() { - return getPossibleValueProposals(getElements(getJSFAppConfigMgr())); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.AbstractMetaDataEnabledFeature#getImage() - */ - protected ImageDescriptor getImage() { - ImageDescriptor ret = super.getImage(); - if (ret != null && ret != MISSING_IMAGE) - return ret; - - if (imageDescriptor == null){ - imageDescriptor = getImageDesc(getImageName()); - } - return imageDescriptor; - - } - - //return FacesConfigPlugin relative image descriptor - private ImageDescriptor getImageDesc(String img) { - Bundle bundle = FacesConfigPlugin.getPlugin().getBundle(); - URL url = FileLocator.find(bundle, new Path(img), null); - ImageDescriptor desc = ImageDescriptor.createFromURL(url); - if (desc == MISSING_IMAGE){ - return null; - } - return desc; - } - - /** - * @param value - * @param displayName - * @param description - * @return PossibleValue object - */ - protected PossibleValue createProposal(String value, EList displayName, EList description) { - String display = value; - if (displayName.size() > 0) { - DisplayNameType displayNameType= (DisplayNameType) displayName.get(0); - display = displayNameType.getTextContent(); - } - String desc = null; - if (description.size() > 0) { - DescriptionType descType= (DescriptionType) description.get(0); - desc = descType.getTextContent(); - } - PossibleValue pv = new PossibleValue(value, display); - if (desc != null) - pv.setAdditionalInformation(desc); - - return pv; - - } - - private List getConfigTypes() { - return getTraitValueAsListOfStrings(ID_TYPE_PROP_NAME); - -// return CMAnnotationHelper.getCMAttributePropertyValues(getMetaDataContext().getBundleId(), -// getMetaDataContext().getUri(), getMetaDataContext().getElementName(), -// getMetaDataContext().getAttributeName(), ID_TYPE_PROP_NAME); - } - - private JSFAppConfigManager getJSFAppConfigMgr(){ - return JSFAppConfigManager.getInstance(getProject()); - } - - private IProject getProject() { - IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext()); - if (resolver != null) - return resolver.getProject(); - - return null; - } - - /** - * @param jsfAppConfigManager - * @return list of identifier Strings for config-type - */ - protected abstract List getElementIDs(JSFAppConfigManager jsfAppConfigManager); - - /** - * @return the config-type - */ - protected abstract String getReturnType(); - /** - * @return int value of {@link IAssignable}.ASSIGNMENT_TYPE_RHS & {@link IAssignable}.ASSIGNMENT_TYPE_LHS - */ - protected int getAssignmentType(){ - //TODO: fix me to get from meta-data(?) - return IAssignable.ASSIGNMENT_TYPE_RHS & IAssignable.ASSIGNMENT_TYPE_LHS; - } - public CompositeType getExpectedRuntimeType() throws ELIsNotValidException { - String type = Signature.createTypeSignature(getReturnType(), true); - return new CompositeType(type, getAssignmentType()); - } - - /** - * @return String value of {@link IValidValues}.VALID_VALUES_MESSAGE_PROP_NAME trait - */ - protected String getCMValidationMessage() { - //TODO: Standard Validation stuff - should be moved somewhere else - return getTraitValueAsString(IValidValues.VALID_VALUES_MESSAGE_PROP_NAME); - } - - /** - * @return int value of {@link IValidValues}.VALID_VALUES_SEVERITY_PROP_NAME trait - */ - protected int getCMValidationSeverity() { - String val = getTraitValueAsString(IValidValues.VALID_VALUES_SEVERITY_PROP_NAME); - if (val == null) - return IStatus.WARNING; - - int severity = Integer.valueOf(val).intValue(); - return severity; - } - - /** - * @return String value of {@link IValidValues}.VALID_VALUES_CODE_PROP_NAME trait - */ - protected String getCMValidationCode() { - return getTraitValueAsString(IValidValues.VALID_VALUES_CODE_PROP_NAME); - } - -} - - diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierType.java deleted file mode 100644 index 5ac934d7c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierType.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -/** - * Meta-data processing type representing a faces-config type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class FacesConfigIdentifierType extends IdentifierType { - // FIXME: why do we have an empty class? -} - - - - diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigValidatorIDFeatures.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigValidatorIDFeatures.java deleted file mode 100644 index b4028175c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigValidatorIDFeatures.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorType; -import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue; -import org.eclipse.osgi.util.NLS; - -/** - * ValidatorID attribute feature - * - * <p><b>Provisional API - subject to change</b></p> - * - */ -public class FacesConfigValidatorIDFeatures extends FacesConfigIdentifierFeatures { - - /** - * Faces validator classname - */ - protected static final String VALIDATOR = "javax.faces.validator.Validator"; //$NON-NLS-1$ - /** - * Imagename to use when displaying validator - */ - protected static final String IMAGE_NAME = "/icons/full/obj16/FacesConfig_Validator.gif"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getReturnType() - */ - protected String getReturnType(){ return VALIDATOR;} - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getElements(org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager) - */ - protected List getElements(JSFAppConfigManager mgr) { - if (mgr != null) - return mgr.getValidators(); - return new ArrayList(0); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getPossibleValueProposals(java.util.List) - */ - protected List getPossibleValueProposals(List elements) { - List ret = new ArrayList(); - Collections.sort(elements, new ValidatorSorter()); - for (Iterator it = elements.iterator();it.hasNext();){ - ValidatorType obj = (ValidatorType)it.next(); - if (obj.getValidatorId() != null && obj.getValidatorId().getTextContent() != null){ - PossibleValue pv = createProposal(obj.getValidatorId().getTextContent(), obj.getDisplayName(), obj.getDescription()); - if (pv != null){ - pv.setIcon(getImage()); - ret.add(pv); - } - } - } - return ret; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getImageName() - */ - protected String getImageName() { - return IMAGE_NAME; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getMyValidationMessage(java.lang.String) - */ - protected String getMyValidationMessage(String value) { - if (value == null || value.trim().equals("")) //$NON-NLS-1$ - return Messages.FacesConfigValidatorIDFeatures_validatorid_empty; - - return NLS.bind(Messages.FacesConfigIdentifierType_invalid_validator_id, new String[]{singleQuote(value)}); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.FacesConfigIdentifierFeatures#getElementIDs(org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager) - */ - protected List getElementIDs(JSFAppConfigManager mgr) { - List elements = getElements(mgr); - List ret = new ArrayList(elements.size()); - for (Iterator it = elements.iterator();it.hasNext();){ - ValidatorType aType = (ValidatorType)it.next(); - if (aType.getValidatorId() != null && aType.getValidatorId().getTextContent() != null){ - String id = aType.getValidatorId().getTextContent(); - if (id != null) - ret.add(id.trim()); - } - } - return ret; - } - - /** - * Validator id sorter - incomplete - */ - class ValidatorSorter implements Comparator { - - public int compare(Object o1, Object o2) { - //TODO - return 0; - - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigValidatorIDType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigValidatorIDType.java deleted file mode 100644 index 65f0504e8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigValidatorIDType.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -/** - * Type representing a FacesConfig Validator attribute - * - * <p><b>Provisional API - subject to change</b></p> - */ -public class FacesConfigValidatorIDType extends FacesConfigIdentifierType { - // FIXME: why do we have an empty class? -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/IdentifierType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/IdentifierType.java deleted file mode 100644 index 134e23d9a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/IdentifierType.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -/** - * Abstract meta-data processing type representing an identifier binding type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class IdentifierType extends DirectBindingType { - // TODO: parent is already abstract; what's the point? -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/IntegerType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/IntegerType.java deleted file mode 100644 index 6fcbdb747..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/IntegerType.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.List; - -import org.eclipse.osgi.util.NLS; - -/** - * Meta-data processing type representing an integer attribute value runtime type - * that implements IValidValues, IDefaultValue, IValidELValues - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class IntegerType extends NumberType { - private static final String INVALID_INTEGER = Messages.IntegerType_invalid_integer; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.EnumerationType#getReturnType() - */ - protected String getReturnType(){ return "int";} //$NON-NLS-1$ - - /** - * Type coercion according to JSP 2.0 spec: JSP.1.14.2.1 Conversions from String values - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - **/ - public boolean isValidValue(String value) { - try { - Integer anInt = Integer.valueOf(value); - exceedsMaxValue(anInt.intValue()); - lessThanMinValue(anInt.intValue()); - if (!(minFound || maxFound)){ - List validVals = getMDValidValues(); - if (!validVals.isEmpty()){ - if (!validVals.contains(value)){ - addNewValidationMessage(Messages.IntegerType_invalid_member);//fix me - } - } - } - return getValidationMessages().isEmpty(); - } catch (NumberFormatException e) { - addNewValidationMessage(INVALID_INTEGER); - return false; - } - - } - - private void exceedsMaxValue(int anInt) { - String strMax = getValidMaximumValue(); - if (strMax != null){ - try { - int max = Integer.valueOf(strMax).intValue(); - maxFound = true; - if (anInt > max){ - addNewValidationMessage(NLS.bind(EXCEEDS_MAX, strMax)); - } - } catch (NumberFormatException e) { - //TODO: ignore error???? or log it???? - } - } - - } - - private void lessThanMinValue(int anInt) { - String strMin = getValidMinimumValue(); - if (strMin != null){ - try { - int max = Integer.valueOf(strMin).intValue(); - minFound = true; - if (anInt < max){ - addNewValidationMessage(NLS.bind(LESS_THAN_MIN, strMin)); - } - } catch (NumberFormatException e) { - //TODO: ignore error???? or log it???? - } - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java deleted file mode 100644 index 816c11cf4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java +++ /dev/null @@ -1,458 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchConstants; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jdt.core.search.SearchParticipant; -import org.eclipse.jdt.core.search.SearchPattern; -import org.eclipse.jdt.core.search.SearchRequestor; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue; -import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage; - -/** - * Provides possible values and validates attribute values that should be fully qualified Java types. - * A type can be verified against muliple "valid-interfaces" and/or a "valid-superclass" from meta-data. - * Code checks to ensure the class can be instantiated (i.e. not abstract, anonymous or inner class) - * Search is scoped to within the current project only. - * - * (Until https://bugs.eclipse.org/bugs/show_bug.cgi?id=142044 is fixed, only the first found will be used) - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - * - */ -public class JavaClassType extends ObjectType implements IPossibleValues, IValidValues{ - /** - * Trait name for valid interfaces - */ - public static final String POSSIBLE_VALUES_INTERFACES_PROP_NAME = "valid-interfaces"; //$NON-NLS-1$ - /** - * Trait name for valid superclass - */ - public static final String POSSIBLE_VALUES_SUPERCLASS_PROP_NAME = "valid-superclass"; //$NON-NLS-1$ - - private List validationMsgs; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues#getPossibleValues() - */ - public List getPossibleValues() { - List results = getTypes(); - if (results != null && !results.isEmpty()){ - - Set vals = new HashSet(results.size()); - Set checkedTypes = new HashSet(); - for (Iterator it = results.iterator();it.hasNext();){ - SearchMatch match = (SearchMatch)it.next(); - IType res = (IType)match.getElement(); - addValidSubClasses(res, vals, checkedTypes); - } - return createPossibleValues(vals); - } - return new ArrayList(0); - } - - private List createPossibleValues(Set vals) { - List list = new ArrayList(vals.size()); - Iterator it = vals.iterator(); - while(it.hasNext()){ - IJavaElement elem = (IJavaElement)it.next(); - list.add(createPossibleValue(elem)); - } - return list; - } - - private void addValidSubClasses(IType res, Set vals, Set checkedTypes) { - - try { - //check to see if we have already checked the hiearchy - if (checkedTypes.contains(res)) - return; - - //should we add itself? - if (isInnerOrAnonymousClass(res)) - return; - if (!isAbstractClass(res)) - vals.add(res); //since it is a set, dupes will not be added - - - ITypeHierarchy hierarchy = res.newTypeHierarchy(getJavaProject(), null); - IType[] subclasses = hierarchy.getSubclasses(res); - checkedTypes.add(res); - for (int i=0;i<subclasses.length;i++){ - addValidSubClasses(subclasses[i], vals, checkedTypes); - } - } catch (JavaModelException e) { - //ignore - } - } - - private IWorkspaceContextResolver getWorkspaceContextResolver(){ - if (getStructuredDocumentContext() == null) - return null; - - return IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext()); - } - - private List getTypes(){ - IJavaProject jp = getJavaProject(); - if (jp == null) - return null; - - List elems = new ArrayList(); - elems.addAll(getInterfaces(jp)); - IType sc = getSuperClass(jp); - if (sc != null) - elems.add(sc); - - if (elems.size() > 0){ - SearchRequestor requestor = new Searcher(); - SearchEngine engine = new SearchEngine(); - - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{jp}, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES); - SearchPattern combined = SearchPattern.createPattern((IJavaElement)elems.get(0), IJavaSearchConstants.IMPLEMENTORS, 0); - -// Until this bug is fixed, stub it out... only the first interface/superclass will be used. -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=142044 -// for(int i=1;i<elems.size();i++){ -// final SearchPattern other = SearchPattern.createPattern((IJavaElement)elems.get(i), IJavaSearchConstants.IMPLEMENTORS, 0); -// combined = SearchPattern.createAndPattern(combined, other); -// } - - try { - engine.search(combined, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, scope, requestor, null); - - } catch (CoreException e) { - //ignore - } - - return ((Searcher)requestor).getResults(); - } - - return new ArrayList(0); - } - - private IJavaProject getJavaProject() { - IWorkspaceContextResolver resolver = getWorkspaceContextResolver(); - if (resolver != null){ - IProject proj = resolver.getProject(); - if (proj != null) - return JavaCore.create(proj); - } - return null; - } - - private List getInterfaces(IJavaProject jp) { - List ret = new ArrayList(); - List propVals = getInterfaceNames(); - - for (Iterator it = propVals.iterator();it.hasNext();){ - String propVal = (String)it.next(); - IType interfase = null; - try { - interfase = findType(jp, propVal); - if (interfase != null){ - ret.add(interfase); - } - } catch (JavaModelException e) { - // suppress and fall-through to return empty list - } - - } - return ret; - } - - private IType getSuperClass(IJavaProject jp){ - IType superclass = null; - try { - String sc = getSuperClassName(); - if (sc != null && !sc.trim().equals("")){ //$NON-NLS-1$ - superclass = findType(jp, sc ); - if (superclass != null){ - return superclass; - } - } - } catch (JavaModelException e) { - //ignore - } - return null; - } - - private PossibleValue createPossibleValue(IJavaElement val) { - return new PossibleValue(((IType)val).getFullyQualifiedName()); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#getValidationMessages() - */ - public List getValidationMessages() { - if (validationMsgs == null){ - validationMsgs = new ArrayList(); - } - return validationMsgs; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value) { - if (value == null || value.trim().equals("")){ //$NON-NLS-1$ - getValidationMessages().add(new ValidationMessage(Messages.JavaClassType_invalid_type)); - return false; - } - IJavaProject jp = getJavaProject(); - if (jp == null) - return false; - - //first verify that the value specified is a resolvable type - IType type = getTypeForValue(jp, value); - if (type != null){ - //ensure that it is not abstract or anonymous - if (!isInnerOrAnonymousClass(type) && !isAbstractClass(type)){ - //now verify that it meets the criteria - List results = getTypes(); - if (!results.isEmpty()){ - for (Iterator it = results.iterator();it.hasNext();){ - SearchMatch match = (SearchMatch)it.next(); - IType res = (IType)match.getElement(); - if (!isInnerOrAnonymousClass(res) ){ - //if this is the class, then optimize to reduce expense of creating hierarchy - if (!isAbstractClass(type) && (res.getFullyQualifiedName().equals(value)) ) - return true; - //check to see if value is in hierarchy - try { - ITypeHierarchy hierarchy = res.newTypeHierarchy(jp, null); - if (hierarchy.contains(type)) - return true; - } catch (JavaModelException e) { - //ignore - } - } - } - } - } - } - addNewValidationMessage(Messages.JavaClassType_not_found); - return false; - } - - private IType getTypeForValue(IJavaProject jp, String value) { - try { - return findType(jp, value); - } catch (JavaModelException e) { - // suppress and fall through to return null - } - return null; - } - - /** - * @return String value of {@link #POSSIBLE_VALUES_SUPERCLASS_PROP_NAME} - */ - protected String getSuperClassName(){ - return getTraitValueAsString(POSSIBLE_VALUES_SUPERCLASS_PROP_NAME); -// return CMAnnotationHelper.getCMAttributePropertyValue(getMetaDataContext().getBundleId(), getMetaDataContext().getUri(), -// getMetaDataContext().getElementName(), getMetaDataContext().getAttributeName(), -// POSSIBLE_VALUES_SUPERCLASS_PROP_NAME); - - } - - /** - * @return List of values from {@link #POSSIBLE_VALUES_INTERFACES_PROP_NAME} - */ - protected List getInterfaceNames(){ - return getTraitValueAsListOfStrings(POSSIBLE_VALUES_INTERFACES_PROP_NAME); - -// return CMAnnotationHelper.getCMAttributePropertyValues(getMetaDataContext().getBundleId(), getMetaDataContext().getUri(), -// getMetaDataContext().getElementName(), getMetaDataContext().getAttributeName(), -// POSSIBLE_VALUES_INTERFACES_PROP_NAME); - - } - - /** - * Create a {@link ValidationMessage} from metadata or use default message - * and add it to the collection of validation messages - * @param defaultMsg - */ - protected void addNewValidationMessage(String defaultMsg) { - //TODO: need to refactor below as this as also in Enumeration - String msg = getCMValidationMessage(); - if (msg == null || msg.equals("")) //$NON-NLS-1$ - msg = defaultMsg; - - String code = getValidationCode(); - int severity = getValidationSeverity(); - ValidationMessage val = new ValidationMessage(msg, code, severity); - getValidationMessages().add(val); - } - - - /** - * @return validation message from meta-data using {@link IValidValues}.VALID_VALUES_MESSAGE_PROP_NAME trait. Can be null. - */ - protected String getCMValidationMessage() { - return getTraitValueAsString(IValidValues.VALID_VALUES_MESSAGE_PROP_NAME); - } - - /** - * @return validation severity as int from meta-data using {@link IValidValues}.VALID_VALUES_SEVERITY_PROP_NAME trait. IStatus.WARNING is default. - */ - protected int getValidationSeverity() { - String val = getTraitValueAsString(IValidValues.VALID_VALUES_SEVERITY_PROP_NAME); - if (val == null) - return IStatus.WARNING; - - int severity = Integer.valueOf(val).intValue(); - return severity; - } - - /** - * @return validation code as String from meta-data. Can be null. - */ - protected String getValidationCode() { - return getTraitValueAsString(IValidValues.VALID_VALUES_CODE_PROP_NAME); - } - - private boolean isInnerOrAnonymousClass(IType res) { - try { - if (res.isClass() && (res.isAnonymous() || - (Flags.isPrivate(res.getFlags())) || - res.getFullyQualifiedName().indexOf("$") > 0)) //must be better way to discover if it is an inner class //$NON-NLS-1$ - return true; - } catch (JavaModelException e) { - //ignore - } - return false; - } - - - private boolean isAbstractClass(IType res) { - try { - if (res.isClass() && Flags.isAbstract(res.getFlags())) - return true; - } catch (JavaModelException e) { - //ignore - } - return false; - } - - private class Searcher extends SearchRequestor{ - private List results = new ArrayList(); - public void acceptSearchMatch(SearchMatch match) throws CoreException { - results.add(match); - } - - /** - * @return list of serach results - */ - public List getResults(){ - return results; - } - } - -///////////////// /////////////////////////////////////////////////////////////////////// -//remainder of this class copied from org.eclipse.jdt.internal.corext.util.JavaCoreUtil // -//TODO: find public version of this functionality // -////////////////////////////////////////////////////////////////////////////////////////// - private IType findType(IJavaProject jproject, String fullyQualifiedName) throws JavaModelException { - //workaround for bug 22883 - IType type= jproject.findType(fullyQualifiedName); - if (type != null) - return type; - - IPackageFragmentRoot[] roots= jproject.getPackageFragmentRoots(); - for (int i= 0; i < roots.length; i++) { - IPackageFragmentRoot root= roots[i]; - type= findType(root, fullyQualifiedName); - if (type != null && type.exists()) - return type; - } - return null; - } - - private IType findType(IPackageFragmentRoot root, String fullyQualifiedName) throws JavaModelException{ - IJavaElement[] children= root.getChildren(); - for (int i= 0; i < children.length; i++) { - IJavaElement element= children[i]; - if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT){ - IPackageFragment pack= (IPackageFragment)element; - if (! fullyQualifiedName.startsWith(pack.getElementName())) - continue; - IType type= findType(pack, fullyQualifiedName); - if (type != null && type.exists()) - return type; - } - } - return null; - } - - private IType findType(IPackageFragment pack, String fullyQualifiedName) throws JavaModelException{ - ICompilationUnit[] cus= pack.getCompilationUnits(); - for (int i= 0; i < cus.length; i++) { - ICompilationUnit unit= cus[i]; - IType type= findType(unit, fullyQualifiedName); - if (type != null && type.exists()) - return type; - } - return null; - } - - private IType findType(ICompilationUnit cu, String fullyQualifiedName) throws JavaModelException{ - IType[] types= cu.getAllTypes(); - for (int i= 0; i < types.length; i++) { - IType type= types[i]; - if (getFullyQualifiedName(type).equals(fullyQualifiedName)) - return type; - } - return null; - } - - private String getFullyQualifiedName(IType type) { - try { - if (type.isBinary() && !type.isAnonymous()) { - IType declaringType= type.getDeclaringType(); - if (declaringType != null) { - return getFullyQualifiedName(declaringType) + '.' + type.getElementName(); - } - } - } catch (JavaModelException e) { - // ignore - } - return type.getFullyQualifiedName('.'); - } -//////////////////////////////////////////////////////////////////////// -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LongType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LongType.java deleted file mode 100644 index a7791e974..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LongType.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.List; - -import org.eclipse.osgi.util.NLS; - -/** - * Meta-data processing type representing a long attribute value runtime type - * that implements IValidValues, IDefaultValue, IValidELValues - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class LongType extends NumberType { - private static final String INVALID_LONG = Messages.LongType_invalid_long; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.EnumerationType#getReturnType() - */ - protected String getReturnType(){ return "long";} //$NON-NLS-1$ - - /** - * Type coercion according to JSP 2.0 spec: JSP.1.14.2.1 Conversions from String values - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - **/ - public boolean isValidValue(String value) { - try { - Long aLong = Long.valueOf(value); - exceedsMaxValue(aLong.longValue()); - lessThanMinValue(aLong.longValue()); - if (!(minFound || maxFound)){ - List validVals = getMDValidValues(); - if (!validVals.isEmpty()){ - if (!validVals.contains(value)){ - addNewValidationMessage(Messages.LongType_invalid_member); - } - } - } - return getValidationMessages().isEmpty(); - } catch (NumberFormatException e) { - addNewValidationMessage(INVALID_LONG); - return false; - } - - } - - private void exceedsMaxValue(long aLong) { - String strMax = getValidMaximumValue(); - if (strMax != null){ - try { - long max = Long.valueOf(strMax).longValue(); - maxFound = true; - if (aLong > max){ - addNewValidationMessage(NLS.bind(EXCEEDS_MAX, strMax)); - } - } catch (NumberFormatException e) { - //TODO: ignore error???? or log it???? - } - } - - } - - private void lessThanMinValue(long aLong) { - String strMin = getValidMinimumValue(); - if (strMin != null){ - try { - long min = Long.valueOf(strMin).longValue(); - minFound = true; - if (aLong < min){ - addNewValidationMessage(NLS.bind(LESS_THAN_MIN, strMin)); - } - } catch (NumberFormatException e) { - //TODO: ignore error???? or log it???? - } - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/Messages.java deleted file mode 100644 index fe92153df..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/Messages.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import org.eclipse.osgi.util.NLS; - -/** - * Message bundle for attributevalue types/features - * - * <p><b>Provisional API - subject to change</b></p> - */ -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.taglibprocessing.attributevalues.messages"; //$NON-NLS-1$ - static { - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - /** - * see messages.properties - */ - public static String ActionType_navcase_display; - /** - * see messages.properties - */ - public static String ActionType_invalid_value; - /** - * see messages.properties - */ - public static String BooleanType_invalid_values; - /** - * see messages.properties - */ - public static String ComponentBindingType_invalid_value; - /** - * see messages.properties - */ - public static String ComponentIDType_invalid_as_el; - /** - * see messages.properties - */ - public static String ComponentIDType_invalid_value; - /** - * see messages.properties - */ - public static String DoubleType_invalid_double; - /** - * see messages.properties - */ - public static String DoubleType_invalid_member; - /** - * see messages.properties - */ - public static String FacesConfigConverterIDFeatures_converterid_empty; - /** - * see messages.properties - */ - public static String FacesConfigIdentifierType_invalid_converter_id; - /** - * see messages.properties - */ - public static String FacesConfigIdentifierType_invalid_validator_id; - /** - * see messages.properties - */ - public static String FacesConfigValidatorIDFeatures_validatorid_empty; - /** - * see messages.properties - */ - public static String IntegerType_invalid_integer; - /** - * see messages.properties - */ - public static String IntegerType_invalid_member; - /** - * see messages.properties - */ - public static String JavaClassType_invalid_type; - /** - * see messages.properties - */ - public static String JavaClassType_not_found; - /** - * see messages.properties - */ - public static String LongType_invalid_long; - /** - * see messages.properties - */ - public static String LongType_invalid_member; - /** - * see messages.properties - */ - public static String MethodBindingType_invalid_value; - /** - * see messages.properties - */ - public static String NumberType_max_val; - /** - * see messages.properties - */ - public static String NumberType_min_val; - /** - * see messages.properties - */ - public static String StringType_invalid_value; - /** - * see messages.properties - */ - public static String ValueType_invalid_value; - /** - * see messages.properties - */ - public static String ValueType_invalid_value_without_setter; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/MethodBindingType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/MethodBindingType.java deleted file mode 100644 index fbc20fabb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/MethodBindingType.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - - -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage; -import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage; - -/** - * Meta-data processing type representing an method-binding attribute value runtime type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class MethodBindingType extends ExpressionBindingType implements IValidELValues, IValidValues{ - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues#getExpectedRuntimeType() - */ - public CompositeType getExpectedRuntimeType() throws ELIsNotValidException { - String[] params = getParams(); - - // need to "signaturize" each parameter - for (int param = 0; param < params.length; param++) - { - params[param] = Signature.createTypeSignature(params[param],true); - } - - String returnType = Signature.createTypeSignature(getReturnType(), true); - if (returnType == null) - { - return null; - } - - String methodSig = Signature.createMethodSignature(params, returnType); - return new CompositeType(methodSig, IAssignable.ASSIGNMENT_TYPE_NONE); - } - - /** - * Non-EL values are invalid for method bound attribute values - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value) { - //if this is being called, we are being called in an non-EL context which is invalid. - IValidationMessage msg = new ValidationMessage(Messages.MethodBindingType_invalid_value); - getValidationMessages().add(msg); - return false; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/NumberType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/NumberType.java deleted file mode 100644 index 4ee78b9c8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/NumberType.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; - -/** - * Abstract meta-data processing type representing a numeric attribute value runtime type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class NumberType extends EnumerationType{ - /** - * flag indicating max value metadata was found - */ - protected boolean maxFound = false; - /** - * flag indicating min value metadata was found - */ - protected boolean minFound = false; - - /** - * Validation message when value has exceeded maximum - */ - protected String EXCEEDS_MAX = Messages.NumberType_max_val; - /** - * Validation message when value is less than minimum - */ - protected String LESS_THAN_MIN = Messages.NumberType_min_val; - - /** - * @return maximum value from property named IValidValues.VALID_VALUES_MAX_PROP_NAME - */ - protected String getValidMaximumValue(){ - return getTraitValueAsString(IValidValues.VALID_VALUES_MAX_PROP_NAME); - } - - /** - * @return minimum value from property named IValidValues.VALID_VALUES_MIN_PROP_NAME - */ - protected String getValidMinimumValue(){ - return getTraitValueAsString(IValidValues.VALID_VALUES_MIN_PROP_NAME); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ObjectType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ObjectType.java deleted file mode 100644 index 07120d4a6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ObjectType.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -/** - * Abstract meta-data processing type representing an Object attribute value runtime type - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public abstract class ObjectType extends DirectBindingType { - // TODO: ???? -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/StringType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/StringType.java deleted file mode 100644 index 709497de5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/StringType.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue; -import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue; - -/** - * Meta-data processing type representing a String attribute value runtime type - * that implements IPossibleValues, IValidValues and IDefaultValues - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class StringType extends EnumerationType implements IValidValues, - IPossibleValues, IDefaultValue { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.EnumerationType#getReturnType() - */ - protected String getReturnType(){ return "java.lang.String";} //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value) { - List vals = getMDValidValues(); - if (vals.isEmpty()) - return true; - - //if the value is empty but there is a default value, consider it valid - if (getDefaultValue() != null && (value == null || value.trim().equals(""))) - return true; - - if(! vals.contains(value)){ - addNewValidationMessage(Messages.StringType_invalid_value); - } - return getValidationMessages().isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues#getPossibleValues() - */ - public List getPossibleValues() { - List pvs = getMDPossibleValues(); - if (pvs.isEmpty()) - return EMPTY_LIST; - - List pdvs = getMDPossibleValuesForDisplay(); - - //if there are no display vals or the meta-data list sizes are different, use the values list for display also - if (pdvs.isEmpty() || pvs.size() != pdvs.size()) - pdvs = pvs; - - ImageDescriptor icon = getImage(); - - String defaultValue = getDefaultValue(); - List ret = new ArrayList(pvs.size()); - for(int i=0;i<pvs.size();i++){ - PossibleValue pv = new PossibleValue((String)pvs.get(i), (String)pdvs.get(i)); - pv.setIcon(icon); - pv.setIsDefault(((String)pvs.get(i)).equals(defaultValue)); - ret.add(pv); - } - return ret; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ValueBindingType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ValueBindingType.java deleted file mode 100644 index ef9c45535..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ValueBindingType.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; - -/** - * Meta-data processing type representing a Value Bound attribute value runtime type - * that implements IValidValues - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class ValueBindingType extends ExpressionBindingType implements IValidELValues{ - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues#getExpectedRuntimeType() - */ - public CompositeType getExpectedRuntimeType() throws ELIsNotValidException { - String returnType = getReturnType(); - if (returnType == null) - return null; - - String methodSig = Signature.createTypeSignature(returnType, true); - return new CompositeType(methodSig, getAssignmentValue()); - } - - /** - * @return {@link IAssignable}.LHS or {@link IAssignable}.RHS - */ - protected int getAssignmentValue(){ - return (getIsSetValueRequired() ? IAssignable.ASSIGNMENT_TYPE_LHS : 0) | IAssignable.ASSIGNMENT_TYPE_RHS; - - } - - /** - * @return is runtime setter required? - */ - protected boolean getIsSetValueRequired(){ - String value = getTraitValueAsString(RUNTIME_SETTER_REQUIRED); - if (value == null || value.trim().length() == 0) - return false; - else if (value.trim().equals("true")) //$NON-NLS-1$ - return true; - else - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ValueType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ValueType.java deleted file mode 100644 index 7c03faef2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ValueType.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; - - -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; - -/** - * Meta-data processing type representing a "value" attribute - * that implements IValidValues and IValidELValues - * - * <p><b>Provisional API - subject to change</b></p> - * @author Gerry Kessler - Oracle - */ -public class ValueType extends ValueBindingType implements IValidValues, IValidELValues { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#isValidValue(java.lang.String) - */ - public boolean isValidValue(String value){ - //value can be a string or a value binding expression - return true; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/messages.properties deleted file mode 100644 index 3265a7b12..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/messages.properties +++ /dev/null @@ -1,34 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle 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: -# Oracle Corporation - initial API and implementation -############################################################################### -IntegerType_invalid_integer=Value is not a valid integer. -IntegerType_invalid_member=Value is not a member of the provided valid values -LongType_invalid_long=Value is not a valid Long. -LongType_invalid_member=Value is not a member of the provided valid values -BooleanType_invalid_values=Valid values are "true" or "false" -NumberType_max_val=Value exceeds maximum of {0} -NumberType_min_val=Value is less than minimum of {0} -DoubleType_invalid_double=Value is not a valid double. -DoubleType_invalid_member=Value is not a member of the provided valid values -StringType_invalid_value=Value is not valid. -FacesConfigIdentifierType_invalid_validator_id= {0} validator id is is not registered. -FacesConfigIdentifierType_invalid_converter_id= {0} converter id is not registered. -FacesConfigConverterIDFeatures_converterid_empty=Converter ids must not be null or empty. -FacesConfigValidatorIDFeatures_validatorid_empty=Validator ids must not be null or empty. -ValueType_invalid_value_without_setter=This 'value' attribute value must be a value binding expression that can take a value assignment. -ValueType_invalid_value=The 'value' attribute must be a non-zero length String or be a value binding expression. -ComponentBindingType_invalid_value=The 'binding' attribute requires an EL value binding reference to a UIComponent. -ComponentIDType_invalid_as_el='id' attributes must be Strings. Consider using 'binding' attribute instead. -ComponentIDType_invalid_value=The 'id' attribute must be a non-zero length String and be uniquely defined on the page. -ActionType_invalid_value=The action attribute must be a non-zero length String. -ActionType_navcase_display={0}: goto {1} -MethodBindingType_invalid_value=MethodBinding attribute values must be EL expressions. -JavaClassType_invalid_type=Value for type attribute must be valid Java class and not empty. -JavaClassType_not_found=Java type not found, not instantiable, or does implement correct interfaces or extend correct superclass. diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/package-info.java deleted file mode 100644 index 8cd990724..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -/** - * This package is used to provide types for tag attribute values so that the - * org.eclipse.jst.jsf.core.metadataprocessors.features can be applied. - * - * A type is added using the org.eclipse.jst.jsf.core.AttributeValueRuntimeTypes extension point. - * These types are referenced using the design-time metadata framework in org.eclipse.jst.jsf.common - * The org.eclipse.jst.jsf.metadataprocessors.features provides the interesting tooling services based upon the type. - * - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.taglibprocessing.attributevalues; diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/ELValidationPreferences.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/ELValidationPreferences.java deleted file mode 100644 index aa02a63ee..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/ELValidationPreferences.java +++ /dev/null @@ -1,812 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal; - -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jst.jsf.core.internal.IJSFPreferenceModel; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Model object for EL validation preferences - * - * @author cbateman - */ -public class ELValidationPreferences implements IJSFPreferenceModel -{ - private final static String KEY_ENABLE_BUILD_VALIDATION = - "org.eclipse.jst.jsf.ui.ValidateJSFELBuild"; - private final static boolean DEFAULT_ENABLE_BUILD_VALIDATION = true; - - private final static String KEY_ENABLE_INCREMENTAL_VALIDATION = - "org.eclipse.jst.jsf.ui.ValidateJSFELIncremental"; - private final static boolean DEFAULT_ENABLE_INCREMENTAL_VALIDATION = false; - - - private boolean _enableBuildValidation; - private boolean _enableIncrementalValidation; - private int[] _severities; - - /** - * Loads the object from the preference store provided - * - * @param prefStore - */ - public void load(IPreferenceStore prefStore) - { - if (!prefStore.contains(KEY_ENABLE_BUILD_VALIDATION)) - { - prefStore.setDefault(KEY_ENABLE_BUILD_VALIDATION, DEFAULT_ENABLE_BUILD_VALIDATION); - } - _enableBuildValidation = - prefStore.getBoolean(KEY_ENABLE_BUILD_VALIDATION); - - if (!prefStore.contains(KEY_ENABLE_INCREMENTAL_VALIDATION)) - { - prefStore.setDefault(KEY_ENABLE_INCREMENTAL_VALIDATION, DEFAULT_ENABLE_INCREMENTAL_VALIDATION); - } - _enableIncrementalValidation = - prefStore.getBoolean(KEY_ENABLE_INCREMENTAL_VALIDATION); - - loadSeverities(prefStore); - } - - private void loadSeverities(final IPreferenceStore prefStore) - { - final int severities[] = getSeverities(); - - for (int i = 0; i < DiagnosticFactory.NUM_IDS; i++) - { - final String key = getKeyById(i); - - if (!prefStore.contains(key)) - { - final int diagSeverity = getDefaultSeverity(i); - final Severity severity = mapDiagToSeverity(diagSeverity); - - prefStore.setDefault(key, severity.toString()); - } - final String storedSeverity = prefStore.getString(key); - severities[i] = mapSeverityToDiag(storedSeverity); - } - } - /** - * Copies the object into the preference store but DOES NOT SAVE IT - * - * @param prefStore - */ - public void commit(IPreferenceStore prefStore) - { - prefStore.setValue(KEY_ENABLE_BUILD_VALIDATION, _enableBuildValidation); - prefStore.setValue(KEY_ENABLE_INCREMENTAL_VALIDATION, - _enableIncrementalValidation); - commitSeverities(prefStore); - } - - private void commitSeverities(final IPreferenceStore prefStore) - { - final int severities[] = getSeverities(); - - for (int i = 0; i < severities.length; i++) - { - final String key = getKeyById(i); - prefStore.setValue(key - , mapDiagToSeverity(severities[i]).toString()); - } - } - - /** - * Reverts the model to it's defaults. Does not commit to pref store. - */ - public void setDefaults() - { - setEnableBuildValidation(DEFAULT_ENABLE_BUILD_VALIDATION); - setEnableIncrementalValidation(DEFAULT_ENABLE_INCREMENTAL_VALIDATION); - setProblemSeverityDefaults(); - } - - private void setProblemSeverityDefaults() - { - final int[] severities = getSeverities(); - - for (int i = 0; i < DiagnosticFactory.NUM_IDS; i++) - { - severities[i] = getDefaultSeverity(i); - } - } - - public Object getValueByKey(IScopeContext context, String key) { - // ignore context for now; will be used when we have project overrides - if (KEY_ENABLE_BUILD_VALIDATION.equals(key)) - { - return Boolean.valueOf(isEnableBuildValidation()); - } - else if (KEY_ENABLE_INCREMENTAL_VALIDATION.equals(key)) - { - return Boolean.valueOf(isEnableIncrementalValidation()); - } - else - { - try - { - final Severity severity = getSeverity(key); - return severity.toString(); - } - catch (IllegalArgumentException e) - { - // getIdByKey will throw this exception if key is not a valid - // severity key. Ignore the exception here and fall-through - } - } - - return null; // not found - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.IJSFPreferenceModel#getStoredValueByKey(org.eclipse.core.runtime.preferences.IScopeContext, java.lang.String) - */ - public Object getStoredValueByKey(IScopeContext context, String key) { - // ignore context for now; will be used when we have project overrides - if (KEY_ENABLE_BUILD_VALIDATION.equals(key)) - { - return Boolean.valueOf(context.getNode("org.eclipse.jst.jsf.ui").getBoolean(key, true)); - } - else if (KEY_ENABLE_INCREMENTAL_VALIDATION.equals(key)) - { - return Boolean.valueOf(context.getNode("org.eclipse.jst.jsf.ui").getBoolean(key, false)); - } - else - { - try - { - return context.getNode("org.eclipse.jst.jsf.core").get(key, mapDiagToSeverity(getDefaultSeverity(getIdByKey(key))).toString()); - } - catch (IllegalArgumentException e) - { - // getIdByKey will throw this exception if key is not a valid - // severity key. Ignore the exception here and fall-through - } - } - - return null; // not found - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.IJSFPreferenceModel#setValueByKey(org.eclipse.core.runtime.preferences.IScopeContext, java.lang.String, java.lang.Object) - */ - public Object setValueByKey(IScopeContext context, String key, Object value) - { - // ignore context for now; will be used when we have project overrides - if (KEY_ENABLE_BUILD_VALIDATION.equals(key)) - { - boolean oldValue = isEnableBuildValidation(); - boolean newValue = ((Boolean)value).booleanValue(); - setEnableBuildValidation(newValue); - return Boolean.valueOf(oldValue); - } - else if (KEY_ENABLE_INCREMENTAL_VALIDATION.equals(key)) - { - boolean oldValue = isEnableIncrementalValidation(); - boolean newValue = ((Boolean)value).booleanValue(); - setEnableIncrementalValidation(newValue); - return Boolean.valueOf(oldValue); - } - else - { - final Severity oldValue = getSeverity(key); - setSeverity(key, (Severity)value); - return oldValue; - } - } - - /** - * @return the build validation enablement - */ - public boolean isEnableBuildValidation() - { - return _enableBuildValidation; - } - - /** - * @return the incremental validation enablement - */ - public boolean isEnableIncrementalValidation() - { - return _enableIncrementalValidation; - } - - /** - * @param enableBuildValidation - */ - public void setEnableBuildValidation(boolean enableBuildValidation) { - _enableBuildValidation = enableBuildValidation; - } - - /** - * @param enableIncrementalValidation - */ - public void setEnableIncrementalValidation(boolean enableIncrementalValidation) { - _enableIncrementalValidation = enableIncrementalValidation; - } - - /** - * @param key - * @return the severity - */ - public Severity getSeverity(final String key) - { - final int severityDiag = _severities[getIdByKey(key)]; - final Severity severity = mapDiagToSeverity(severityDiag); - return severity; - } - - /** - * @param key - * @param severity - */ - public void setSeverity(final String key, final Severity severity) - { - final int newSeverityDiag = mapSeverityToDiag(severity.toString()); - final int diagId = getIdByKey(key); - _severities[diagId] = newSeverityDiag; - } - - /** - * @param diagnosticId - * @return the severity as configured for diagnosticId. The value - * is relative to the Diagnostic class severity scheme - */ - public final int getDiagnosticSeverity(final int diagnosticId) - { - return getSeverities()[diagnosticId]; - } - - private int[] getSeverities() - { - if (_severities == null) - { - _severities = new int[DiagnosticFactory.NUM_IDS]; - } - - return _severities; - } - - /** - * @param diagSeverity - * @return a Severity preference value for a diagnostic severity - */ - public static Severity mapDiagToSeverity(int diagSeverity) - { - switch(diagSeverity) - { - case Diagnostic.ERROR: - return Severity.ERROR; - case Diagnostic.WARNING: - return Severity.WARNING; - default: - return Severity.IGNORE; - } - } - - /** - * @param severity - * @return a Diagnostic severity level for a severity pref string - */ - public static int mapSeverityToDiag(String severity) - { - if ("error".equals(severity)) - { - return Diagnostic.ERROR; - } - else if ("warning".equals(severity)) - { - return Diagnostic.WARNING; - } - else if ("ignore".equals(severity)) - { - return Diagnostic.OK; - } - else - { - throw new IllegalArgumentException("Invalid enum name: "+severity); - } - } - - /** - * @param diagnosticId - * @return the default severity of a diagnostic - */ - public static int getDefaultSeverity(final int diagnosticId) - { - switch(diagnosticId) - { - case DiagnosticFactory.BINARY_OP_BOTH_OPERANDS_NULL_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_POSSIBLE_DIVISION_BY_ZERO_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_NO_AVAILABLE_TYPE_COERCION_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.TERNARY_OP_CHOICE_IS_ALWAYS_SAME_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.MEMBER_NOT_FOUND_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.VARIABLE_NOT_FOUND_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.MISSING_CLOSING_EXPR_BRACKET_ID: - return Diagnostic.ERROR; - case DiagnosticFactory.GENERAL_SYNTAX_ERROR_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.EMPTY_EL_EXPRESSION_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_DOT_WITH_VALUEB_NULL_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME_ID: - return Diagnostic.WARNING; - case DiagnosticFactory.BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE_ID: - return Diagnostic.ERROR; - - default: - throw new IllegalArgumentException("Diagnostic Id: "+ diagnosticId +" is out of range"); - } - } - - /** - * @param diagnosticId - * @return the preference key for the corresponding diagnosticId in the el DiagnosticFactory - */ - public static String getKeyById(final int diagnosticId) - { - switch(diagnosticId) - { - case DiagnosticFactory.BINARY_OP_BOTH_OPERANDS_NULL_ID: - return BINARY_OP_BOTH_OPERANDS_NULL; - case DiagnosticFactory.BINARY_OP_POSSIBLE_DIVISION_BY_ZERO_ID: - return BINARY_OP_POSSIBLE_DIVISION_BY_ZERO; - case DiagnosticFactory.BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID: - return BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION; - case DiagnosticFactory.BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME_ID: - return BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME; - case DiagnosticFactory.BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME_ID: - return BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME; - case DiagnosticFactory.BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID: - return BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN; - case DiagnosticFactory.BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS_ID: - return BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS; - case DiagnosticFactory.BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME_ID: - return BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME; - case DiagnosticFactory.BINARY_OP_NO_AVAILABLE_TYPE_COERCION_ID: - return BINARY_OP_NO_AVAILABLE_TYPE_COERCION; - case DiagnosticFactory.BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS_ID: - return BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS; - case DiagnosticFactory.UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID: - return UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME; - case DiagnosticFactory.UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE_ID: - return UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE; - case DiagnosticFactory.UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO_ID: - return UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO; - case DiagnosticFactory.UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID: - return UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION; - case DiagnosticFactory.UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID: - return UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN; - case DiagnosticFactory.TERNARY_OP_CHOICE_IS_ALWAYS_SAME_ID: - return TERNARY_OP_CHOICE_IS_ALWAYS_SAME; - case DiagnosticFactory.TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID: - return TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN; - case DiagnosticFactory.UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED_ID: - return UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED; - case DiagnosticFactory.CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING_ID: - return CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING; - case DiagnosticFactory.MEMBER_NOT_FOUND_ID: - return MEMBER_NOT_FOUND; - case DiagnosticFactory.VARIABLE_NOT_FOUND_ID: - return VARIABLE_NOT_FOUND; - case DiagnosticFactory.MISSING_CLOSING_EXPR_BRACKET_ID: - return MISSING_CLOSING_EXPR_BRACKET; - case DiagnosticFactory.GENERAL_SYNTAX_ERROR_ID: - return GENERAL_SYNTAX_ERROR; - case DiagnosticFactory.EMPTY_EL_EXPRESSION_ID: - return EMPTY_EL_EXPRESSION; - case DiagnosticFactory.BINARY_OP_DOT_WITH_VALUEB_NULL_ID: - return BINARY_OP_DOT_WITH_VALUEB_NULL; - case DiagnosticFactory.BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY_ID: - return BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY; - case DiagnosticFactory.POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS_ID: - return POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS; - case DiagnosticFactory.BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME_ID: - return BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME; - case DiagnosticFactory.BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE_ID: - return BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE; - - default: - throw new IllegalArgumentException("Diagnostic Id: "+ diagnosticId +" is out of range"); - } - } - - /** - * @param key - * @return the preference key for the corresponding diagnosticId in the el DiagnosticFactory - */ - public static int getIdByKey(final String key) - { - if (BINARY_OP_BOTH_OPERANDS_NULL.equals(key)) - { - return DiagnosticFactory.BINARY_OP_BOTH_OPERANDS_NULL_ID; - } - else if (BINARY_OP_POSSIBLE_DIVISION_BY_ZERO.equals(key)) - { - return DiagnosticFactory.BINARY_OP_POSSIBLE_DIVISION_BY_ZERO_ID; - } - else if (BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION.equals(key)) - { - return DiagnosticFactory.BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID; - } - else if (BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME.equals(key)) - { - return DiagnosticFactory.BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME_ID; - } - else if (BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME.equals(key)) - { - return DiagnosticFactory.BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME_ID; - } - else if (BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN.equals(key)) - { - return DiagnosticFactory.BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID; - } - else if (BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS.equals(key)) - { - return DiagnosticFactory.BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS_ID; - } - else if (BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME.equals(key)) - { - return DiagnosticFactory.BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME_ID; - } - else if (BINARY_OP_NO_AVAILABLE_TYPE_COERCION.equals(key)) - { - return DiagnosticFactory.BINARY_OP_NO_AVAILABLE_TYPE_COERCION_ID; - } - else if (BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS.equals(key)) - { - return DiagnosticFactory.BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS_ID; - } - else if (UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME.equals(key)) - { - return DiagnosticFactory.UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID; - } - else if (UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE.equals(key)) - { - return DiagnosticFactory.UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE_ID; - } - else if (UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO.equals(key)) - { - return DiagnosticFactory.UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO_ID; - } - else if (UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION.equals(key)) - { - return DiagnosticFactory.UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID; - } - else if (UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN.equals(key)) - { - return DiagnosticFactory.UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID; - } - else if (TERNARY_OP_CHOICE_IS_ALWAYS_SAME.equals(key)) - { - return DiagnosticFactory.TERNARY_OP_CHOICE_IS_ALWAYS_SAME_ID; - } - else if (TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN.equals(key)) - { - return DiagnosticFactory.TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID; - } - else if (UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED.equals(key)) - { - return DiagnosticFactory.UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED_ID; - } - else if (CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING.equals(key)) - { - return DiagnosticFactory.CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING_ID; - } - else if (MEMBER_NOT_FOUND.equals(key)) - { - return DiagnosticFactory.MEMBER_NOT_FOUND_ID; - } - else if (VARIABLE_NOT_FOUND.equals(key)) - { - return DiagnosticFactory.VARIABLE_NOT_FOUND_ID; - } - else if (MISSING_CLOSING_EXPR_BRACKET.equals(key)) - { - return DiagnosticFactory.MISSING_CLOSING_EXPR_BRACKET_ID; - } - else if (GENERAL_SYNTAX_ERROR.equals(key)) - { - return DiagnosticFactory.GENERAL_SYNTAX_ERROR_ID; - } - else if (EMPTY_EL_EXPRESSION.equals(key)) - { - return DiagnosticFactory.EMPTY_EL_EXPRESSION_ID; - } - else if (BINARY_OP_DOT_WITH_VALUEB_NULL.equals(key)) - { - return DiagnosticFactory.BINARY_OP_DOT_WITH_VALUEB_NULL_ID; - } - else if (BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY.equals(key)) - { - return DiagnosticFactory.BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY_ID; - } - else if (POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS.equals(key)) - { - return DiagnosticFactory.POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS_ID; - } - else if (BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME.equals(key)) - { - return DiagnosticFactory.BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME_ID; - } - else if (BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE.equals(key)) - { - return DiagnosticFactory.BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE_ID; - } - else - { - throw new IllegalArgumentException("Severity Key: "+ key); - } - } - - /** - * e.g. createQualifiedKeyName("foo") -> org.eclipse.jst.jsf.core.foo - * @param baseName - * @return a plugin qualified key given the baseName - * - */ - private static String createQualifiedKeyName(final String baseName) - { - return JSFCorePlugin.PLUGIN_ID + "." + baseName; - } - - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_BOTH_OPERANDS_NULL = - createQualifiedKeyName("BINARY_OP_BOTH_OPERANDS_NULL"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_POSSIBLE_DIVISION_BY_ZERO = - createQualifiedKeyName("BINARY_OP_POSSIBLE_DIVISION_BY_ZERO"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION = - createQualifiedKeyName("BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME = - createQualifiedKeyName("BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME = - createQualifiedKeyName("BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN = - createQualifiedKeyName("BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS = - createQualifiedKeyName("BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME = - createQualifiedKeyName("BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_NO_AVAILABLE_TYPE_COERCION = - createQualifiedKeyName("BINARY_OP_NO_AVAILABLE_TYPE_COERCION"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS = - createQualifiedKeyName("BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME = - createQualifiedKeyName("UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE = - createQualifiedKeyName("UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO = - createQualifiedKeyName("UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION = - createQualifiedKeyName("UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN = - createQualifiedKeyName("UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String TERNARY_OP_CHOICE_IS_ALWAYS_SAME = - createQualifiedKeyName("TERNARY_OP_CHOICE_IS_ALWAYS_SAME"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN = - createQualifiedKeyName("TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED = - createQualifiedKeyName("UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING = - createQualifiedKeyName("CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String MEMBER_NOT_FOUND = - createQualifiedKeyName("MEMBER_NOT_FOUND"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String VARIABLE_NOT_FOUND = - createQualifiedKeyName("VARIABLE_NOT_FOUND"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String MISSING_CLOSING_EXPR_BRACKET = - createQualifiedKeyName("MISSING_CLOSING_EXPR_BRACKET"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String GENERAL_SYNTAX_ERROR = - createQualifiedKeyName("GENERAL_SYNTAX_ERROR"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String EMPTY_EL_EXPRESSION = - createQualifiedKeyName("EMPTY_EL_EXPRESSION"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_DOT_WITH_VALUEB_NULL = - createQualifiedKeyName("BINARY_OP_DOT_WITH_VALUEB_NULL"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY = - createQualifiedKeyName("BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS = - createQualifiedKeyName("POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME = - createQualifiedKeyName("BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME"); - /** - * preference key. Match to DiagnosticFactory constants - */ - public final static String BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE = - createQualifiedKeyName("BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE"); - - // values - /** - * Severity levels of problems - */ - public enum Severity - { - /** - * Indicates a problem severity of Error - */ - ERROR - { - public java.lang.String toString() { - return "error"; - } - } - , - /** - * Indicates a problem severity of Warning - */ - WARNING - { - public java.lang.String toString() { - return "warning"; - } - } - , - /** - * Indicates no problem should be shown - */ - IGNORE - { - public java.lang.String toString() { - return "ignore"; - } - }; - - /** - * @param value - * @return the enum based on the toString mappings - */ - public static Severity valueOfString(String value) - { - if ("error".equals(value)) - { - return ERROR; - } - else if ("warning".equals(value)) - { - return WARNING; - } - else - { - return IGNORE; - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/IJSPSemanticValidatorTest.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/IJSPSemanticValidatorTest.java deleted file mode 100644 index f6d00afab..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/IJSPSemanticValidatorTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.eclipse.jst.jsf.validation.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.w3c.dom.Element; - -/** - * Exposes certain private members for use by testing. - * - * NOT intended for use by production code. - * - * @author cbateman - * - */ -public interface IJSPSemanticValidatorTest -{ - /** - * Proxies the internal call to validate the containment of a particular - * tag. - * - * @param node - * @param uri - * @param tagName - * @param reporter - * @param file - * @param context - */ - void validateContainment(Element node, String uri, String tagName, IReporter reporter, IFile file, IStructuredDocumentContext context); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/JSPSemanticsValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/JSPSemanticsValidator.java deleted file mode 100644 index 147c35f64..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/JSPSemanticsValidator.java +++ /dev/null @@ -1,678 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.validation.internal; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jst.jsf.common.dom.TagIdentifier; -import org.eclipse.jst.jsf.common.internal.JSPUtil; -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.common.internal.types.TypeComparator; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; -import org.eclipse.jst.jsf.common.sets.ConcreteAxiomaticSet; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory; -import org.eclipse.jst.jsf.core.set.constraint.MemberConstraint; -import org.eclipse.jst.jsf.core.set.mapping.ElementToTagIdentifierMapping; -import org.eclipse.jst.jsf.core.tagmatcher.EvaluationException; -import org.eclipse.jst.jsf.core.tagmatcher.InvalidExpressionException; -import org.eclipse.jst.jsf.core.tagmatcher.XPathMatchingAlgorithm; -import org.eclipse.jst.jsf.metadataprocessors.MetaDataEnabledProcessingFactory; -import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues; -import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage; -import org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint; -import org.eclipse.jst.jsf.validation.internal.constraints.TagId; -import org.eclipse.jst.jsf.validation.internal.constraints.TagSet; -import org.eclipse.jst.jsf.validation.internal.el.ELExpressionValidator; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.ValidationMessageFactory; -import org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP; -import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts; -import org.eclipse.jst.jsp.core.internal.validation.JSPValidator; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * A JSP page validator that makes use of the JSF metadata processing framework so that JSP page - * semantics can be validated. - * - * This implementation currently only validates attribute values. - * @author Gerry Kessler - Oracle - */ -public class JSPSemanticsValidator extends JSPValidator implements ISourceValidator -{ - // TODO: should the source validator be a separate class in jsp.ui? - // problem with simple split off is that preference must also be split off - static final boolean DEBUG; - static { - String value = Platform.getDebugOption("org.eclipse.jst.jsf.validation.internal.el/debug/jspsemanticsvalidator"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - private final static ElementToTagIdentifierMapping elem2TagIdMapper = new ElementToTagIdentifierMapping(); - private IDocument fDocument; - private int containmentValidationCount; // = 0; - - /* (non-Javadoc) - * @see org.eclipse.jst.jsp.core.internal.validation.JSPValidator#validateFile(org.eclipse.core.resources.IFile, org.eclipse.wst.validation.internal.provisional.core.IReporter) - */ - protected void validateFile(IFile file, IReporter reporter) { - IStructuredModel model = null; - if (DEBUG) - System.out.println("executing JSPSemanticsValidator.validateFile"); - try { - model = StructuredModelManager.getModelManager().getModelForRead(file); - - if (model instanceof DOMModelForJSP) - { - ValidationPreferences prefs= new ValidationPreferences(JSFCorePlugin.getDefault().getPreferenceStore()); - prefs.load(); - DiagnosticFactory diagnosticFactory = new DiagnosticFactory(); - - // zero the containment validation count for each mondel - containmentValidationCount = 0; - DOMModelForJSP jspModel = (DOMModelForJSP) model; - IStructuredDocument structuredDoc = jspModel.getStructuredDocument(); - IStructuredDocumentRegion curNode = structuredDoc.getFirstStructuredDocumentRegion(); - while (null != curNode && !reporter.isCancelled()) { - if (curNode.getFirstRegion().getType() == DOMRegionContext.XML_TAG_OPEN ) - { - validateTag(curNode, reporter, file, false, prefs, diagnosticFactory); - } - curNode = curNode.getNext(); - } - } - } - catch (CoreException e) - { - JSFCorePlugin.log("Error validating JSF", e); - } - catch (IOException e) - { - JSFCorePlugin.log("Error validating JSF", e); - } - finally - { - if (null != model) - model.releaseFromRead(); - - // zero the containment count before exit - containmentValidationCount = 0; - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator#validate(org.eclipse.jface.text.IRegion, org.eclipse.wst.validation.internal.provisional.core.IValidationContext, org.eclipse.wst.validation.internal.provisional.core.IReporter) - */ - public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) { - if (DEBUG) - System.out.println("exec JSPSemanticsValidator.validateRegion"); - - ValidationPreferences prefs = new ValidationPreferences(JSFCorePlugin.getDefault().getPreferenceStore()); - prefs.load(); - DiagnosticFactory diagnosticFactory = new DiagnosticFactory(); - if (fDocument instanceof IStructuredDocument) { - IStructuredDocument sDoc = (IStructuredDocument) fDocument; - IStructuredDocumentRegion[] regions = sDoc.getStructuredDocumentRegions(dirtyRegion.getOffset(), dirtyRegion.getLength()); - if (regions != null){ - validateTag(regions[0], reporter, getFile(helper), true, prefs, diagnosticFactory); - } - } - } - - private IFile getFile(IValidationContext helper) { - String[] uris = helper.getURIs(); - IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); - if (uris.length > 0) - return wsRoot.getFile(new Path(uris[0])); - - return null; - } - - - /** - * Validates a JSP tag. - * - * Currently only attribute values with supplied annotation meta-data is being validated. - * Also, only JSF EL is being validated and not JSP EL. - * - * This method may be extended in the future to validate tag semantics an other cross attribute - * validations. - * - * @param container - * @param reporter - * @param file - * @param isIncremental -- true if this validation is "as you type" - * - */ - private void validateTag(ITextRegionCollection container, IReporter reporter, IFile file, boolean isIncremental, ValidationPreferences prefs, DiagnosticFactory diagnosticFactory) - { - ITextRegionCollection containerRegion = container; - Iterator regions = containerRegion.getRegions().iterator(); - ITextRegion region = null; - String uri = null; - String tagName = null; - String attrName = null; - while (regions.hasNext() && !reporter.isCancelled()) - { - region = (ITextRegion) regions.next(); - String type = region.getType(); - IDOMContextResolver resolver = null; - ITaglibContextResolver tagLibResolver = null; - if (type != null && (type == DOMRegionContext.XML_TAG_NAME || type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME || type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) - { - IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE.getContext(((IStructuredDocumentRegion)containerRegion).getParentDocument(), containerRegion.getStartOffset() + region.getStart()); - resolver = IStructuredDocumentContextResolverFactory.INSTANCE.getDOMContextResolver(context); - if (type == DOMRegionContext.XML_TAG_NAME) - { - tagLibResolver = IStructuredDocumentContextResolverFactory.INSTANCE.getTaglibContextResolver(context); - Node node = resolver.getNode(); - tagName = resolver.getNode().getLocalName(); - uri = tagLibResolver.getTagURIForNodeName(resolver.getNode()); - - if (node instanceof Element && uri != null) - { - validateContainment((Element)node, uri, tagName, reporter, file, context); - } - - if (DEBUG) - System.out.println(addDebugSpacer(1)+"tagName= "+ (tagName!= null ? tagName : "null") +": uri= "+(uri != null ? uri : "null") ); - } - else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) - { - attrName = resolver.getNode().getNodeName(); - if (DEBUG) - System.out.println(addDebugSpacer(2)+"attrName= "+(attrName != null ? attrName : "null" )); - if (uri != null && tagName != null) - { - // TODO: validateAttribute(context, region, uri, resolver.getNode(), file); - } - } - else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) - { - final String attributeVal = - resolver.getNode().getNodeValue(); - - // if there's elText then validate it - // TODO: this approach will fail with mixed expressions - if (!checkIfELAndValidate(region, - context, - uri, - tagName, - attrName, - attributeVal, - isIncremental, - reporter, - file, - prefs, - diagnosticFactory) - ) - { - // else validate as static attribute value - if (DEBUG) - System.out.println(addDebugSpacer(3)+"attrVal= "+(attributeVal != null ? attributeVal : "null") ); - - if (uri != null && tagName != null && attrName != null) - validateAttributeValue(context, uri, tagName, attrName, attributeVal, reporter, file); - } - } - } - } - } - - /** - * Checks the region to see if it contains an EL attribute value. If it - * does, validates it - * @return true if validated EL, false otherwise - */ - private boolean checkIfELAndValidate(ITextRegion region, - IStructuredDocumentContext context, - String uri, - String tagName, - String attrName, - String attrValue, - boolean isIncremental, - IReporter reporter, - IFile file, - ValidationPreferences validationPrefs, - DiagnosticFactory diagnosticFactory) - { - if (region instanceof ITextRegionCollection) { - ITextRegionCollection parentRegion = ((ITextRegionCollection) region); - if (parentRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) - { - // look for attribute pattern "#{}" - // TODO: need to generalize this for RValue concatenation - final ITextRegionList regionList = parentRegion.getRegions(); - if (regionList.size() >= 4) - { - ITextRegion openQuote = regionList.get(0); - ITextRegion openVBLQuote = regionList.get(1); - - if ( (openQuote.getType() == DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE - || openQuote.getType() == DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE) - && (openVBLQuote.getType() == DOMJSPRegionContexts.JSP_VBL_OPEN)) - { - // we appear to be inside "#{", so next should be a VBL_CONTENT if there's anything - // here to validate - final ITextRegion content = regionList.get(2); - if (content.getType() == DOMJSPRegionContexts.JSP_VBL_CONTENT) - { - final int contentStart = - parentRegion.getStartOffset(content); - final IStructuredDocumentContext elContext = - IStructuredDocumentContextFactory.INSTANCE. - getContext(context.getStructuredDocument(), - contentStart); - - final String elText = parentRegion.getText(content); - - if (DEBUG) - System.out.println(addDebugSpacer(3)+"EL attrVal= "+elText); - - // EL validation is user configurable because - // it can be computationally costly. - if (checkShouldValidateEL(validationPrefs, isIncremental)) - { - List elVals = MetaDataEnabledProcessingFactory.getInstance().getAttributeValueRuntimeTypeFeatureProcessors(IValidELValues.class, elContext, uri, tagName, attrName); - validateELExpression(context, - elContext, - elVals, - attrValue, - elText, - reporter, - file, - validationPrefs.getElPrefs()); - } - } - else if (content.getType() == DOMJSPRegionContexts.JSP_VBL_CLOSE) - { - final int offset = parentRegion.getStartOffset(openVBLQuote)+1; - final int length = 2; - - // detected empty EL expression - IMessage message = ValidationMessageFactory.createFromDiagnostic( - diagnosticFactory.create_EMPTY_EL_EXPRESSION(), - offset, length, file, validationPrefs.getElPrefs()); - - reportFinding(reporter, message); - } - - boolean foundClosingQuote = false; - for (int i = 2; !foundClosingQuote && i < regionList.size(); i++) - { - ITextRegion searchRegion = regionList.get(i); - if (searchRegion.getType() == DOMJSPRegionContexts.JSP_VBL_CLOSE) - { - foundClosingQuote = true; - } - } - - if (!foundClosingQuote) - { - int offset = context.getDocumentPosition()+1; - int length = parentRegion.getText().length(); - - reportFinding(reporter, - ValidationMessageFactory. - createFromDiagnostic( - diagnosticFactory.create_MISSING_CLOSING_EXPR_BRACKET(), - offset, length, file, validationPrefs.getElPrefs())); - } - - return true; - } - } - } - } - return false; - } - - private void validateELExpression(IStructuredDocumentContext context, - IStructuredDocumentContext elContext, - List elVals, - String attributeVal, - String elText, - IReporter reporter, - IFile file, - ELValidationPreferences prefs) - { - //Call EL validator which will perform at least the syntactical validation - final ELExpressionValidator elValidator = - new ELExpressionValidator(elContext, elText,file,prefs); - elValidator.validateXMLNode(); - elValidator.reportFindings(this, reporter); - - CompositeType exprType = elValidator.getExpressionType(); - if (exprType != null) - { - for (Iterator it=elVals.iterator();it.hasNext();){ - IValidELValues elval = (IValidELValues)it.next(); - CompositeType expectedType; - IMessage message = null; - try { - expectedType = elval.getExpectedRuntimeType(); - - if (expectedType != null) - { - Diagnostic status = TypeComparator.calculateTypeCompatibility - (expectedType, exprType); - if (status.getSeverity() != Diagnostic.OK){ - message = createValidationMessage(context, attributeVal, getSeverity(status.getSeverity()), status.getMessage(), file); - } - } - } catch (ELIsNotValidException e) { - message = createValidationMessage(context, attributeVal, IMessage.NORMAL_SEVERITY, e.getMessage(), file); - } - if (message != null) { - reportFinding(reporter, message); - } - } - } - } - -// private void validateAttribute(IStructuredDocumentContext context, ITextRegion region, String uri, Node attr, IFile file) { - //Not doing anything until the resolver can help me - - //validate that attribute can be part of the tag -// ITaglibContextResolver tagLibResolver = IStructuredDocumentContextResolverFactory.INSTANCE.getTaglibContextResolver(context); -// if (tagLibResolver.getTagURIForNodeName(attr) == null){ -// System.out.println("not ok: "+attr.getNodeName()); -// } -// else -// System.out.println("ok"); - -// } - - /** - * Validates an attribute value in context using the JSF metadata processing framework - * - * @param context - * @param region - * @param uri - * @param tagName - * @param attrName - * @param attributeVal - * @param reporter - * @param file - */ - private void validateAttributeValue(IStructuredDocumentContext context, String uri, String tagName, String attrName, String attributeVal, IReporter reporter, IFile file) { - List vv = MetaDataEnabledProcessingFactory.getInstance().getAttributeValueRuntimeTypeFeatureProcessors(IValidValues.class, context, uri, tagName, attrName); - if (!vv.isEmpty()){ - for (Iterator it = vv.iterator();it.hasNext();){ - IValidValues v = (IValidValues)it.next(); - if (attributeVal == null) attributeVal = "";//ensure to be non-null - if (!v.isValidValue(attributeVal.trim())){ - if (DEBUG) - System.out.println(addDebugSpacer(4)+"NOT VALID "); - - for (Iterator msgs = v.getValidationMessages().iterator();msgs.hasNext();){ - IValidationMessage msg = (IValidationMessage)msgs.next(); - IMessage message = createValidationMessage(context, attributeVal, getSeverity(msg.getSeverity()), msg.getMessage(), file); - if (message != null) { - reportFinding(reporter, message); - } - } - } - else - if (DEBUG) - System.out.println(addDebugSpacer(5) + "VALID "); - } - } - else if (DEBUG) - System.out.println(addDebugSpacer(4)+"NO META DATA "); - } - - private IMessage createValidationMessage(IStructuredDocumentContext context, String attributeValue, int severity, String msg, IFile file){ - IMessage message = new LocalizedMessage(severity, msg, file); - if (message != null) { - final int start = context.getDocumentPosition() + 1; - final int length = attributeValue.length(); - - int lineNo = 0; - try { - lineNo = context.getStructuredDocument().getLineOfOffset(start); - } catch (BadLocationException e) { - // TODO: C.B why need line number? Length and offset should be - // sufficient - } - - message.setLineNo(lineNo); - message.setOffset(start); - message.setLength(length); - } - return message; - } - /** - * Maps IStatus codes to IMessage severity - * @param IStatus codesseverity - * @return IMessage severity - */ - private int getSeverity(int severity) { - - switch (severity){ - case IStatus.ERROR: - return IMessage.HIGH_SEVERITY; - case IStatus.WARNING: - return IMessage.NORMAL_SEVERITY; - case IStatus.INFO: - return IMessage.LOW_SEVERITY; - } - return IMessage.NORMAL_SEVERITY; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator#connect(org.eclipse.jface.text.IDocument) - */ - public void connect(IDocument document) { - fDocument = document; - containmentValidationCount = 0; // ensure is zeroed before we start - } - - /* (non-Javadoc) - * @see org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator#disconnect(org.eclipse.jface.text.IDocument) - */ - public void disconnect(IDocument document) { - containmentValidationCount = 0; // ensure is zeroed when we are finished - } - - private String addDebugSpacer(int count){ - String TAB = "\t"; - StringBuffer ret = new StringBuffer(""); - for(int i=0;i<=count;i++){ - ret.append(TAB); - } - return ret.toString(); - } - - /** - * @param isIncremental -- true if this is "as-you-type" validation, false - * if this is "Build" or "Run Validation" validation - * @return true if user preferences say we should do EL validation, - * false otherwise - */ - private boolean checkShouldValidateEL(ValidationPreferences prefs, boolean isIncremental) - { - prefs.load(); - if (isIncremental) - { - return prefs.getElPrefs().isEnableIncrementalValidation(); - } - - return prefs.getElPrefs().isEnableBuildValidation(); - } - - private void validateContainment(Element node, String uri, String tagName, IReporter reporter, IFile file, IStructuredDocumentContext context) - { - // don't validate JSP fragments since the necessary containment may existing - // in the JSP files that include them - // also only validate the first instance of containment violation in a file - if (JSPUtil.isJSPFragment(file) || containmentValidationCount > 0) - { - return; - } - - final ITaglibDomainMetaDataModelContext modelContext = - TaglibDomainMetaDataQueryHelper.createMetaDataModelContext(file.getProject(), uri); - final Entity entity = - TaglibDomainMetaDataQueryHelper.getEntity(modelContext, tagName); - if (entity != null) - { - final Trait trait = - TaglibDomainMetaDataQueryHelper.getTrait - (entity, "containment-constraint"); - - if (trait != null) - { - final ContainsTagConstraint tagConstraint = - (ContainsTagConstraint) trait.getValue(); - - final String algorithm = tagConstraint.getSetGenerator().getAlgorithm(); - - // TODO: need generalized factory mechanism for registering and constructing - // algorithms. - if (!"xpath".equals(algorithm)) - { - return; - } - - final String expr = tagConstraint.getSetGenerator().getExpression(); - - // TODO: optimize on the expression and cache for reuse - final XPathMatchingAlgorithm xpathAlg = - new XPathMatchingAlgorithm(expr); - - AxiomaticSet set = null; - - try - { - set = xpathAlg.evaluate(node); - // map dom nodes to tag identifiers - set = elem2TagIdMapper.map(set); - } - catch(InvalidExpressionException e) - { - JSFCorePlugin.log(e, "Problem with expression: "+expr+" on node "+node); - return; - } - catch (EvaluationException e) - { - JSFCorePlugin.log(e, "Problem evaluating expression: "+expr+" on node "+node); - return; - } - - final TagSet constraintData = tagConstraint.getSatisfiesSet(); - final AxiomaticSet constraintSet = new ConcreteAxiomaticSet(); - for (final Iterator it = constraintData.getTags().iterator(); it.hasNext();) - { - final TagId tagId = (TagId) it.next(); - constraintSet.add(TagIdentifierFactory.createJSPTagWrapper(tagId.getUri(), tagId.getName())); - } - final MemberConstraint memberConstraint = new MemberConstraint(constraintSet); - final Diagnostic diag = memberConstraint.isSatisfied(set); - - if (diag.getSeverity() != Diagnostic.OK) - { - containmentValidationCount++; // found a violation - - final String messagePattern = "Tag {0} is missing required parent tag \"{1}\" ({2})"; - - List data = diag.getData(); - - for (Iterator it = data.iterator(); it.hasNext();) - { - TagIdentifier missingParent = (TagIdentifier) it.next(); - - IMessage message = - createTagValidationMessage(context, node.getNodeName(), - IMessage.NORMAL_SEVERITY, - MessageFormat.format(messagePattern, new Object[]{node.getNodeName(), missingParent.getTagName(), missingParent.getUri()}) - , file); - reportFinding(reporter, message); - } - } - } - } - } - - /** - * @return the test interface - */ - public IJSPSemanticValidatorTest getTestInterface() - { - return new IJSPSemanticValidatorTest() - { - public void validateContainment(Element node, String uri, - String tagName, IReporter reporter, IFile file, - IStructuredDocumentContext context) { - - JSPSemanticsValidator.this.validateContainment(node, uri, tagName, reporter, file, context); - } - }; - } - - // TODO: need a diagnostic factory - private IMessage createTagValidationMessage(IStructuredDocumentContext context, String attributeValue, int severity, String msg, IFile file) - { - IMessage message = new LocalizedMessage(severity, msg, file); - final int start = context.getDocumentPosition(); - final int length = attributeValue.length(); - - message.setOffset(start); - message.setLength(length); - return message; - } - - private void reportFinding(IReporter reporter, IMessage message) - { - if ((message.getSeverity() & IMessage.ALL_MESSAGES) != 0) - { - reporter.addMessage(this, message); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/ValidationPreferences.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/ValidationPreferences.java deleted file mode 100644 index 9b00a3a8a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/ValidationPreferences.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.validation.internal; - -import org.eclipse.jface.preference.IPreferenceStore; - -/** - * @author cbateman - * - */ -public class ValidationPreferences -{ - private final IPreferenceStore _prefStore; - private final ELValidationPreferences _elPrefs; - - /** - * Constructor - * @param prefStore - */ - public ValidationPreferences(IPreferenceStore prefStore) - { - _prefStore = prefStore; - _elPrefs = new ELValidationPreferences(); - } - - /** - * @return the el preferences - */ - public ELValidationPreferences getElPrefs() - { - return _elPrefs; - } - - /**IPreferenceStore - * The default preference loader - */ - public void load() - { - load(_prefStore); - } - - /** - * Loads preferences from prefStore - * - * @param prefStore - */ - private void load(IPreferenceStore prefStore) - { - _elPrefs.load(prefStore); - } - - /** - * Commits but does not store the preferences - * - * @param prefStore - */ - public void commit(IPreferenceStore prefStore) - { - _elPrefs.commit(prefStore); - } - - /** - * Reverts the model to it's defaults. Does not commit to pref store. - */ - public void setDefaults() - { - _elPrefs.setDefaults(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java deleted file mode 100644 index 6746274f9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidationUtil.java +++ /dev/null @@ -1,441 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.io.StringReader; -import java.util.Iterator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntriesType; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser; -import org.eclipse.jst.jsp.core.internal.java.jspel.ParseException; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSEAdapter; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Node; - -/** - * Common functions for app config validation - * - * @author cbateman - * - */ -public final class AppConfigValidationUtil -{ - /** - * Per the fully-qualified-classType in the Faces 1.2 schema and - * the ClassName entity in the 1.1 DTD - * - * @param fullyQualifiedName - * @param instanceOf - * @param project - * @return null if no problems or a Message if problem found - */ - public static IMessage validateClassName(final String fullyQualifiedName, - final String instanceOf, - final IProject project) - { - try - { - IType type = getType(project, fullyQualifiedName); - if (type == null) - { - return DiagnosticFactory - .create_CANNOT_FIND_CLASS_NAME(fullyQualifiedName); - } - - // must be a class, not an interface or enum - if (!type.isClass()) - { - return DiagnosticFactory - .create_FULLY_QUALIFIED_NAME_MUST_BE_A_CLASS - (fullyQualifiedName); - } - - // must not be abstract since it must instantiable - if (Flags.isAbstract(type.getFlags())) - { - return DiagnosticFactory - .create_CLASS_MUST_BE_CONCRETE(fullyQualifiedName); - } - - if (instanceOf != null) - { - if (!isInstanceOf(type, instanceOf)) - { - // if we get to here, we haven't found the expected - // the super type so error - return DiagnosticFactory.create_CLASS_MUST_BE_INSTANCE_OF - (fullyQualifiedName, Messages.AppConfigValidationUtil_0, instanceOf); - } - } - } - catch(JavaModelException jme) - { - // fall-through, not found - JSFCorePlugin.log(jme, - "Error resolving fully qualified class name: "+fullyQualifiedName); //$NON-NLS-1$ - } - - // either found the class or had an exception so don't report error - return null; - } - - private static IType getType(final IProject project, - final String fullyQualifiedName) throws JavaModelException - { - final IJavaProject javaProject = JavaCore.create(project); - return javaProject.findType(fullyQualifiedName); - } - - /** - * Per the faces-config-el-expressionType in the Faces 1.2 schema and - * the Action entity in the 1.1 DTD - * - * @param textContent - * @return an validation diagnostic or null if the textContent - * represent an expected EL expression - */ - public static IMessage validateELExpression(final String textContent) - { - final ELResultWrapper result = extractELExpression(textContent); - - if (result.elText != null) - { - JSPELParser parser = new JSPELParser(new StringReader(result.elText)); - - try { - parser.Expression(); - } catch (ParseException e) { - // syntax error - return DiagnosticFactory.create_SYNTAX_ERROR_IN_EL(); - } - - return null; - } - - return result.message; - } - - /** - * @param textContent - * @return the result of trying to extract an EL expression from the - * textContent string. The content is expected to be of the form - * #{elText}. elText in the return value will be set to this value - * from within the braces. If a syntax error occurs in this extraction - * message property of the result object will contain a validation message - * and elText will be set to null. - */ - public static ELResultWrapper extractELExpression(final String textContent) - { - final String elRegex = "#\\{(.*)\\}"; //$NON-NLS-1$ - Pattern pattern = Pattern.compile(elRegex); - Matcher matcher = pattern.matcher(textContent.trim()); - if (matcher.matches()) - { - final String elText = matcher.group(1).trim(); - - if ("".equals(elText) || elText == null) //$NON-NLS-1$ - { - return new ELResultWrapper(DiagnosticFactory.create_SYNTAX_ERROR_IN_EL(), null); - } - return new ELResultWrapper(null, elText); - } - return new ELResultWrapper(DiagnosticFactory.create_EL_EXPR_MUST_BE_IN_HASH_BRACES(), null); - } - - /** - * Value object that wraps the result of trying - * to extract an EL expression from an arbitrary String - */ - public static class ELResultWrapper - { - private final IMessage message; - private final String elText; - - ELResultWrapper(IMessage message, String elText) { - super(); - this.message = message; - this.elText = elText; - } - - /** - * @return a message indicating a problem encountered - * trying to extract, or null if no problem was encountered - */ - public IMessage getMessage() { - return message; - } - - /** - * @return the el expression string raw, stripped of any - * sorrounding #{} syntax or null if could not be extracted - */ - public String getElText() { - return elText; - } - } - - /** - * @param eObj - * @return the offset character offset in to the XML document of the - * XML node that eObj was constructed from or -1 if not - * computable - */ - public static int getStartOffset(EObject eObj) - { - IDOMNode node = getDomNode(eObj); - - if (node != null) - { - return node.getStartStructuredDocumentRegion().getStartOffset(); - } - - return -1; - } - - /** - * @param eObj - * @return the length in characters of the XML node that - * eObj was constructed from or -1 if no computable - */ - public static int getLength(EObject eObj) - { - IDOMNode node = getDomNode(eObj); - - if (node != null) - { - return node.getEndStructuredDocumentRegion().getEndOffset() - - node.getStartStructuredDocumentRegion().getStartOffset(); - } - - return -1; - } - - /** - * @param eObj - * @return the DOM node that eObj was constructed from or - * null if not computable - */ - public static IDOMNode getDomNode(EObject eObj) - { - for (Iterator it = eObj.eAdapters().iterator(); it.hasNext();) - { - Adapter adapter = (Adapter) it.next(); - - if (adapter instanceof EMF2DOMSSEAdapter) - { - final EMF2DOMSSEAdapter sseAdapter = (EMF2DOMSSEAdapter) adapter; - final Node node = sseAdapter.getNode(); - if (node instanceof IDOMNode) - { - return (IDOMNode) node; - } - } - } - - return null; - } - - /** - * @param scope - * @return an error message if scope does not match a valid - * scope enum. - */ - public static IMessage validateManagedBeanScope(ManagedBeanScopeType scope) - { - // scope must be one of a few enums - if (!"request".equals(scope.getTextContent()) //$NON-NLS-1$ - && !"session".equals(scope.getTextContent()) //$NON-NLS-1$ - && !"application".equals(scope.getTextContent()) //$NON-NLS-1$ - && !"none".equals(scope.getTextContent())) //$NON-NLS-1$ - { - return DiagnosticFactory.create_BEAN_SCOPE_NOT_VALID(); - } - - return null; - } - - /** - * @param targetName - * @param targetType the type of the object that mapEntries will be assigned to - * @param mapEntries - * @param project - * @return null if okay or an error message if the mapEntries type is - * invalid in some way - * Note: when Java 1.5 support is added we can validate against the template types - */ - public static IMessage validateMapEntries(String targetName, String targetType, MapEntriesType mapEntries, IProject project) - { - if (mapEntries == null || targetType == null || project == null) - { - throw new AssertionError("Arguments to validateMapEntries can't be null"); //$NON-NLS-1$ - } - - try - { - // TODO: do a bean look-up for targetName to verify that it a) matches the type - // and b) exists on the bean - IType type = getType(project, targetType); - - if (type != null && - !(isInstanceOf(type, Signature.toString(TypeConstants.TYPE_MAP)))) - { - return DiagnosticFactory - .create_MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE(targetName); - } - // TODO: validate the the map entries - // TODO: validate the types of the map entries against the values present - // TODO: validate the map key and value types against the template - } - catch (JavaModelException jme) - { - JSFCorePlugin.log(new Exception(jme), "Exception while validating mapEntries"); //$NON-NLS-1$ - } - // if we get to here, we have not found anything meaningful to report - return null; - } - - /** - * @param targetName - * @param targetType the type of the object that mapEntries will be assigned to - * @param listEntries - * @param project - * @return null if okay or an error message if the listEntries type is - * invalid in some way - * Note: when Java 1.5 support is added we can validate against the template types - */ - public static IMessage validateListEntries(String targetName, String targetType, ListEntriesType listEntries, IProject project) - { - if (listEntries == null || targetType == null || project == null) - { - throw new AssertionError("Arguments to validateMapEntries can't be null"); //$NON-NLS-1$ - } - - try - { - IType type = getType(project, targetType); - // TODO: do a bean look-up for targetName to verify that it a) matches the type - // and b) exists on the bean - if (type != null && - !(isInstanceOf(type, Signature.toString(TypeConstants.TYPE_LIST)))) - { - return DiagnosticFactory - .create_LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE(targetName); - } - // TODO: validate the the list entries - // TODO: validate the types of the list entries against the values present - // TODO: validate the value types against the template - } - catch (JavaModelException jme) - { - JSFCorePlugin.log(new Exception(jme), "Exception while validating mapEntries"); //$NON-NLS-1$ - } - // if we get to here, we have not found anything meaningful to report - return null; - } - - /** - * @param localeType - * @return a diagnostic if 'localeType' does not match the - * expected format or null if all is clear - */ - public static IMessage validateLocaleType(final String localeType) - { - // based on the localeType in the Faces 1.2 schema. This is safe - // to apply to 1.1 since it expects the same pattern even though - // the DTD cannot validate it - final String localeTypePattern = "[a-z]{2}(_|-)?([\\p{L}\\-\\p{Nd}]{2})?"; //$NON-NLS-1$ - final Matcher matcher = Pattern.compile(localeTypePattern).matcher(localeType); - - if (!matcher.matches()) - { - return DiagnosticFactory.create_LOCALE_FORMAT_NOT_VALID(); - } - - return null; - } - - /** - * @param type - * @param instanceOf - * @return true if type instanceof instanceOf is true - * - * @throws JavaModelException - */ - public static boolean isInstanceOf(final IType type, final String instanceOf) throws JavaModelException - { - if (instanceOf != null) - { - // must have either a no-arg constructor or an adapter constructor - // that is of the type of instanceOf -// IType constructorParam = getType(project, instanceOf); -// if (constructorParam != null) -// { -// final String constructorMethodName = -// type.getElementName(); -// final IMethod defaultConstructor = -// type.getMethod(constructorMethodName, new String[0]); -// final IMethod adapterConstructor = -// type.getMethod(constructorMethodName, new String[]{instanceOf}); -// final boolean isDefaultConstructor = -// defaultConstructor != null && defaultConstructor.isConstructor(); -// final boolean isAdapterConstructor = -// adapterConstructor != null && adapterConstructor.isConstructor(); -// if (!isDefaultConstructor && !isAdapterConstructor) -// { - // TODO: no constructor == default constructor... -// } -// } - - // if the type is an exact match - if (instanceOf.equals(type.getFullyQualifiedName())) - { - return true; - } - - final ITypeHierarchy typeHierarchy = - type.newSupertypeHierarchy(new NullProgressMonitor()); - - final IType[] supers = typeHierarchy.getAllSupertypes(type); - for (int i = 0; i < supers.length; i++) - { - if (instanceOf.equals(supers[i].getFullyQualifiedName())) - { - return true; - } - } - } - return false; - } - - private AppConfigValidationUtil() - { - // no external construction - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidator.java deleted file mode 100644 index 0ae9104b2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AppConfigValidator.java +++ /dev/null @@ -1,363 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit; -import org.eclipse.jst.jsp.core.internal.Logger; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.w3c.dom.DocumentType; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * General build-time validator for the JSF application configuration file (faces-config.xml)b - * - * @author cbateman - * - */ -public class AppConfigValidator implements IValidatorJob { - - public ISchedulingRule getSchedulingRule(IValidationContext helper) { - // no scheduling rule - return null; - } - - public IStatus validateInJob(IValidationContext helper, IReporter reporter) - throws ValidationException { - IStatus status = Status.OK_STATUS; - try { - validate(helper, reporter); - } - catch (ValidationException e) { - Logger.logException(e); - status = new Status(IStatus.ERROR, JSFCorePlugin.getDefault().getPluginID(), IStatus.ERROR, e.getLocalizedMessage(), e); - } - return status; - } - - public void cleanup(IReporter reporter) { - // no cleanup - - } - - public void validate(IValidationContext helper, IReporter reporter) - throws ValidationException - { - String[] uris = helper.getURIs(); - IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); - if (uris.length > 0) { - IFile currentFile = null; - - for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) { - currentFile = wsRoot.getFile(new Path(uris[i])); - if (currentFile != null && currentFile.exists()) { -// if (shouldValidate(currentFile) && fragmentCheck(currentFile)) { - -// int percent = (i * 100) / uris.length + 1; -//Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + uris[i]); - // reporter.displaySubtask(this, message); - - validateFile(currentFile, reporter); - } - } - } - - // copied from JSPValidator TODO: perhaps just use app config locator? -// else { -// -// // if uris[] length 0 -> validate() gets called for each project -// if (helper instanceof IWorkbenchContext) { -// -// IProject project = ((IWorkbenchContext) helper).getProject(); -// JSPFileVisitor visitor = new JSPFileVisitor(reporter); -// try { -// // collect all jsp files for the project -// project.accept(visitor, IResource.DEPTH_INFINITE); -// } -// catch (CoreException e) { -// if (DEBUG) -// e.printStackTrace(); -// } -// IFile[] files = visitor.getFiles(); -// for (int i = 0; i < files.length && !reporter.isCancelled(); i++) { -// if (shouldValidate(files[i]) && fragmentCheck(files[i])) { -// int percent = (i * 100) / files.length + 1; -// Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + files[i].getFullPath().toString()); -// reporter.displaySubtask(this, message); -// -// validateFile(files[i], reporter); -// } -// if (DEBUG) -// System.out.println("validating: [" + files[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ -// } -// } -// } - } - - private void validateFile(IFile file, IReporter reporter) - { - FacesConfigArtifactEdit facesConfigEdit = null; - - try - { - IPath path = JSFAppConfigUtils.getWebContentFolderRelativePath(file); - facesConfigEdit = FacesConfigArtifactEdit. - getFacesConfigArtifactEditForRead(file.getProject(), path.toString()); - - if (facesConfigEdit != null - && facesConfigEdit.getFacesConfig()!=null) - { - String version = validateVersioning(file, facesConfigEdit, reporter); - validateModel(file, facesConfigEdit,reporter, version); - } - } - finally - { - if (facesConfigEdit != null) - { - facesConfigEdit.dispose(); - } - } - } - - /** - * Ensure that the expected project version (facet) jives with what is in - * the faces-config. Generally this means: - * - * if (version == 1.1) then no 1.2 artifacts (error) - * if (version == 1.2) then warn if using old artifacts (warning) - */ - private String validateVersioning(IFile file, FacesConfigArtifactEdit facesConfigEdit, IReporter reporter) - { - final String appConfigFileVersion = getAppConfigFileVersion(facesConfigEdit); - - if (appConfigFileVersion != null) - { - final String projectVersion = getJSFVersion(file.getProject()); - - if (IJSFCoreConstants.FACET_VERSION_1_1.equals(projectVersion) - || IJSFCoreConstants.FACET_VERSION_1_0.equals(projectVersion)) - { - if (IJSFCoreConstants.FACET_VERSION_1_2.equals(appConfigFileVersion)) - { - reporter.addMessage(this, - DiagnosticFactory - .create_APP_CONFIG_IS_NEWER_THAN_JSF_VERSION(file)); - } - } - else if (IJSFCoreConstants.FACET_VERSION_1_2.equals(projectVersion)) - { - if (IJSFCoreConstants.FACET_VERSION_1_1.equals(appConfigFileVersion) - || IJSFCoreConstants.FACET_VERSION_1_0.equals(appConfigFileVersion)) - { - reporter.addMessage(this, - DiagnosticFactory - .create_APP_CONFIG_IS_OLDER_THAN_JSF_VERSION(file - , appConfigFileVersion, projectVersion)); - } - } - // if no exact match, don't make any assumptions - } - return appConfigFileVersion; - } - - /** - * @param facesConfigEdit - * @return the version of the app config file or null if not determinant - */ - private String getAppConfigFileVersion(FacesConfigArtifactEdit facesConfigEdit) - { - String appConfigVersion = null; - - final IDOMModel domModel = facesConfigEdit.getIDOMModel(); - final IDOMDocument document = domModel.getDocument(); - if (document == null) {return null;} - - final DocumentType docType = domModel.getDocument().getDoctype(); - - // if we have DTD doctype then we're looking at 1.1 or before - if (docType != null) - { - appConfigVersion = extractVersionFromPublicId(docType); - // if not found in the public id, try the system id - if (appConfigVersion == null) - { - appConfigVersion = extractVersionFromSystemId(docType); - } - } - else - { - NodeList rootNodes = domModel.getDocument().getChildNodes(); - - for (int i = 0; i < rootNodes.getLength(); i++) - { - Node node = rootNodes.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE - && "faces-config".equals(node.getLocalName())) - { - NamedNodeMap map = node.getAttributes(); - // the most accurate thing is the version - Node versionAttrib = map.getNamedItem("version"); - - if (versionAttrib != null) - { - appConfigVersion = versionAttrib.getNodeValue(); - break; - } - - // TODO: add additional heuristic to parse out - // the schema - } - } - } - - return appConfigVersion; - } - - - - private void validateModel(final IFile file, - final FacesConfigArtifactEdit facesConfigEdit, - final IReporter reporter, - final String version) - { - final FacesConfigType facesConfigType = facesConfigEdit.getFacesConfig(); - FacesConfigValidator validator = new FacesConfigValidator(version); - List messages = new ArrayList(); - validator.validate(facesConfigType, messages, file); - - for (final Iterator it = messages.iterator(); it.hasNext();) - { - IMessage message = (IMessage) it.next(); - reporter.addMessage(this, message); - } - } - - /** - * @param project - * @return the version string for the JSF facet on project - * or null if not found - */ - private String getJSFVersion(final IProject project) - { - try - { - final IFacetedProject facetedProject = ProjectFacetsManager.create(project); - Set facets = facetedProject.getProjectFacets(); - - for (final Iterator it = facets.iterator(); it.hasNext();) - { - IProjectFacetVersion facetVersion = - (IProjectFacetVersion) it.next(); - - if (IJSFCoreConstants.JSF_CORE_FACET_ID.equals(facetVersion.getProjectFacet().getId())) - { - return facetVersion.getVersionString(); - } - } - } - catch (CoreException ce) - { - JSFCorePlugin.log(ce, "Problem loading faceted project"); - // fall-through and return null - } - return null; - } - - private String extractVersionFromPublicId(DocumentType docType) - { - final String publicId = docType.getPublicId(); - final String publicIdRegex = "-\\/\\/(.*)\\/\\/(.*)\\/\\/.*"; - - if (publicId != null) - { - final Pattern pattern = Pattern.compile(publicIdRegex); - Matcher matcher = pattern.matcher(publicId); - - if (matcher.matches()) - { - final String classTypeString = matcher.group(2); - final String[] classTypes = classTypeString.split("\\s+"); - - // verify that the class type is a DTD - if (classTypes.length > 0 - && "DTD".equals(classTypes[0])) - { - // either 1.0 or 1.1; be most conservative - String appConfigVersion = IJSFCoreConstants.JSF_VERSION_1_0; - - // see if the version is in the public id - if (IJSFCoreConstants.JSF_VERSION_1_1.equals(classTypes[classTypes.length-1])) - { - appConfigVersion = IJSFCoreConstants.FACET_VERSION_1_1; - } - - return appConfigVersion; - } - } - } - - return null; - } - - private String extractVersionFromSystemId(DocumentType docType) - { - final String systemId = docType.getSystemId(); - final String systemIdRegEx = "http:\\/\\/java.sun.com\\/dtd\\/web-facesconfig_(.*)\\.dtd"; - if (systemId != null) - { - final Pattern pattern = Pattern.compile(systemIdRegEx); - Matcher matcher = pattern.matcher(systemId); - - if (matcher.matches()) - { - final String version = matcher.group(1); - if ("1_1".equals(version)||"1_0".equals(version)) - { - return version.replaceAll("_", "."); - } - } - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ApplicationValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ApplicationValidationVisitor.java deleted file mode 100644 index 2c2bd31b4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ApplicationValidationVisitor.java +++ /dev/null @@ -1,286 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.facesconfig.emf.DefaultLocaleType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.LocaleConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.SupportedLocaleType; - -/** - * Validator the <application> node of the app config model - * @author cbateman - * - */ -public class ApplicationValidationVisitor extends EObjectValidationVisitor -{ - - /** - * Default constructure - * @param version - */ - public ApplicationValidationVisitor(String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_Application(), version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing to validate - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - // TODO: validate message and resource bundles - // TODO: validate default render kit id - new ActionListenerValidationVisitor(getVersion()), - new NavigationHandlerValidationVisitor(getVersion()), - new ViewHandlerValidationVisitor(getVersion()), - new StateManagerValidationVisitior(getVersion()), - new PropertyResolverValidationVisitor(getVersion()), - new VariableResolverValidationVisitor(getVersion()), - new ELResolverValidationVisitor(getVersion()), - new LocaleConfigValidationVisitor(getVersion()) - }; - } - - /** - * @param facesConfig - * @param messages - * @param file - */ - protected void validateManagedBeanNames(FacesConfigType facesConfig, List messages, IFile file) - { -// final Map foundBeans = new HashMap(); -// final List firstCollisionInstance = new ArrayList(); -// -// for (final Iterator it = facesConfig.getManagedBean().iterator(); it.hasNext();) -// { -// final ManagedBeanType managedBean = (ManagedBeanType) it.next(); -// -// if (managedBean.getManagedBeanName() == null -// || managedBean.getManagedBeanName().getTextContent() == null -// || "".equals(managedBean.getManagedBeanName().getTextContent())) -// { -// -// } - -// if (!foundBeans.containsKey(managedBean.getManagedBeanName())) -// } - } - - private static class LocaleConfigValidationVisitor extends EObjectValidationVisitor - { - /** - * @param version - */ - public LocaleConfigValidationVisitor(String version) - { - super(FacesConfigPackage.eINSTANCE.getApplicationType_LocaleConfig() - , version); - } - - protected void doValidate(EObject object, List messages, IFile file) - { - final LocaleConfigType localeConfig = (LocaleConfigType) object; - - DefaultLocaleType defaultLocale = localeConfig.getDefaultLocale(); - - if (defaultLocale != null) - { - addMessageInfo( - messages, - AppConfigValidationUtil - .validateLocaleType(defaultLocale.getTextContent()) - , defaultLocale, file); - } - - for (final Iterator it = localeConfig.getSupportedLocale().iterator(); it.hasNext();) - { - final SupportedLocaleType supportedLocale = - (SupportedLocaleType) it.next(); - addMessageInfo( - messages, - AppConfigValidationUtil - .validateLocaleType(supportedLocale.getTextContent()) - , supportedLocale, file); - } - - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - // there are children, but we're going to validate in doValidate - return NO_CHILDREN; - } - - } - - private static class ActionListenerValidationVisitor extends ApplicationClassNameBasedValidationVisitor - { - /** - * @param version - */ - public ActionListenerValidationVisitor(final String version) { - super(FacesConfigPackage.eINSTANCE.getApplicationType_ActionListener(), - version,"javax.faces.event.ActionListener"); - } - } - - private static class NavigationHandlerValidationVisitor extends ApplicationClassNameBasedValidationVisitor - { - /** - * @param version - */ - public NavigationHandlerValidationVisitor(final String version) { - super(FacesConfigPackage.eINSTANCE.getApplicationType_NavigationHandler(), - version,"javax.faces.application.NavigationHandler"); - } - } - - private static class ViewHandlerValidationVisitor extends ApplicationClassNameBasedValidationVisitor - { - ViewHandlerValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getApplicationType_ViewHandler(), - version,"javax.faces.application.ViewHandler"); - } - } - - private static class StateManagerValidationVisitior extends ApplicationClassNameBasedValidationVisitor - { - StateManagerValidationVisitior(final String version) - { - super(FacesConfigPackage.eINSTANCE.getApplicationType_StateManager(), - version,"javax.faces.application.StateManager"); - } - } - - private static class PropertyResolverValidationVisitor extends ApplicationClassNameBasedValidationVisitor - { - PropertyResolverValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getApplicationType_PropertyResolver(), - version,"javax.faces.el.PropertyResolver"); - } - - protected void doValidate(EObject object, List messages, IFile file) { - super.doValidate(object, messages, file); - - // if this version greater than 1.1 then property resolvers are - // deprecated in favour of el-resolvers - final String version = getVersion(); - if (!IJSFCoreConstants.FACET_VERSION_1_0.equals(version) && !IJSFCoreConstants.FACET_VERSION_1_1.equals(version)) - { - addMessageInfo(messages, - DiagnosticFactory.create_API_DEPRECATED_AFTER_VERSION_ID - ("property-resolver", IJSFCoreConstants.FACET_VERSION_1_1, "el-resolver") - , object, file); - } - } - } - - private static class VariableResolverValidationVisitor extends ApplicationClassNameBasedValidationVisitor - { - VariableResolverValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getApplicationType_VariableResolver(), - version, "javax.faces.el.VariableResolver"); - } - - protected void doValidate(EObject object, List messages, IFile file) { - super.doValidate(object, messages, file); - // if this version greater than 1.1 then property resolvers are - // deprecated in favour of el-resolvers - final String version = getVersion(); - if (!IJSFCoreConstants.JSF_VERSION_1_0.equals(version) && !IJSFCoreConstants.JSF_VERSION_1_1.equals(version)) - { - addMessageInfo(messages, - DiagnosticFactory.create_API_DEPRECATED_AFTER_VERSION_ID - ("variable-resolver", IJSFCoreConstants.JSF_VERSION_1_1, "el-resolver") - , object, file); - } - - } - } - - private static class ELResolverValidationVisitor extends ApplicationClassNameBasedValidationVisitor - { - ELResolverValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getApplicationType_ELResolver(), - version, "javax.el.ELResolver"); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // if this version less than 1.2 then property resolvers are - // deprecated in favour of el-resolvers - final String version = getVersion(); - if (IJSFCoreConstants.JSF_VERSION_1_0.equals(version) || IJSFCoreConstants.JSF_VERSION_1_1.equals(version)) - { - addMessageInfo(messages, - DiagnosticFactory.create_API_NOT_AVAILABLE_BEFORE_VERSION - ("el-resolver", IJSFCoreConstants.JSF_VERSION_1_2, "variable-resolver or property-resolver") - , object, file); - } - else - { - super.doValidate(object, messages, file); - } - } - } - - private abstract static class ApplicationClassNameBasedValidationVisitor extends ClassNameEObjectValidationVisitor - { - private final String _instanceOf; - - /** - * @param feature - * @param version - * @param instanceOf - */ - protected ApplicationClassNameBasedValidationVisitor(EStructuralFeature feature, - final String version, final String instanceOf) { - super(feature, version); - _instanceOf = instanceOf; - } - - protected String getFullyQualifiedName(EObject eobj) - { - EStructuralFeature feature = eobj.eClass().getEStructuralFeature("textContent"); - - if (feature != null) - { - return (String)eobj.eGet(feature); - } - - return null; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - // no children - return NO_CHILDREN; - } - - protected String getInstanceOf() { - return _instanceOf; - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AttributeValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AttributeValidationVisitor.java deleted file mode 100644 index 291c8023f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/AttributeValidationVisitor.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.jsf.facesconfig.emf.AttributeClassType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; - -/** - * Validates the <attribute> element of components, converters etc. - * - * @author cbateman - * - */ -public class AttributeValidationVisitor extends EObjectValidationVisitor { - - /** - * @param feature - * @param version - */ - public AttributeValidationVisitor(EStructuralFeature feature, String version) { - // this validator can be attached to numerous parents so it - // cannot hard-code its feature - super(feature,version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing to do - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new AttributeClassValidationVisitor(getVersion()) - }; - } - - private static class AttributeClassValidationVisitor extends ClassNameEObjectValidationVisitor - { - /** - * @param version - */ - public AttributeClassValidationVisitor( - String version) { - super(FacesConfigPackage.eINSTANCE.getAttributeType_AttributeClass() - , version); - } - - protected String getFullyQualifiedName(EObject eobj) { - return ((AttributeClassType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - // null since there is no instance of enforcement here - return null; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ClassNameEObjectValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ClassNameEObjectValidationVisitor.java deleted file mode 100644 index 3757298ed..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ClassNameEObjectValidationVisitor.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * Abstract validation visitor for classname based eobjects - * - * @author cbateman - * - */ -public abstract class ClassNameEObjectValidationVisitor extends - EObjectValidationVisitor -{ - /** - * @param structuralFeature - * @param version - */ - public ClassNameEObjectValidationVisitor( - EStructuralFeature structuralFeature, String version) { - super(structuralFeature, version); - } - - protected void doValidate(EObject object, List messages, IFile file) - { - String fullyQualifiedName = getFullyQualifiedName(object); - // protect against null - fullyQualifiedName = fullyQualifiedName == null ? "" : fullyQualifiedName; - addMessageInfo(messages, - AppConfigValidationUtil - .validateClassName(fullyQualifiedName, getInstanceOf(), - file.getProject()) - ,object, file); - } - - /** - * @param eobj - * @return the fully qualified name from the eobject - */ - protected abstract String getFullyQualifiedName(EObject eobj); - - /** - * @return a fully-qualified - */ - protected abstract String getInstanceOf(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ComponentValidatorVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ComponentValidatorVisitor.java deleted file mode 100644 index 074367053..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ComponentValidatorVisitor.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentClassType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacetNameType; - -/** - * Validator for a <component> - * - * @author cbateman - * - */ -public class ComponentValidatorVisitor extends EObjectValidationVisitor -{ - /** - * @param version - */ - public ComponentValidatorVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_Component(), - version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing in the tag to validate - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new ComponentClassValidationVisitor(getVersion()), - new AttributeValidationVisitor(FacesConfigPackage.eINSTANCE.getComponentType_Attribute(), getVersion()), - new PropertyValidationVisitor - (FacesConfigPackage.eINSTANCE.getComponentType_Property() - ,FacesConfigPackage.eINSTANCE.getComponentType_ComponentClass() - ,getVersion()), - new ComponentFacetValidationVisitor(getVersion()) - }; - } - - private static class ComponentClassValidationVisitor extends ClassNameEObjectValidationVisitor - { - ComponentClassValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getComponentType_ComponentClass(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((ComponentClassType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.component.UIComponent"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - } - - private static class ComponentFacetValidationVisitor extends EObjectValidationVisitor - { - /** - * @param version - */ - public ComponentFacetValidationVisitor(String version) - { - super(FacesConfigPackage.eINSTANCE.getComponentType_Facet(), version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // do nothing - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new FacetNameValidationVisitor(getVersion()) - }; - } - - private static class FacetNameValidationVisitor extends EObjectValidationVisitor - { - /** - * @param version - */ - public FacetNameValidationVisitor(String version) { - super(FacesConfigPackage.eINSTANCE.getFacetType_FacetName(), - version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - FacetNameType name = (FacetNameType) object; - boolean isValid = false; - - if (name.getTextContent() != null - || "".equals(name.getTextContent().trim())) - { - String nameValue = name.getTextContent().trim(); - - // TODO: isJavaIdentifierStart seems broken... - if (Character.isJavaIdentifierStart(nameValue.charAt(0))); - { - isValid = true; - for (int i = 1; i < nameValue.length(); i++) - { - if (!Character.isJavaIdentifierPart(nameValue.charAt(i))) - { - isValid = false; - } - } - } - } - - if (!isValid) - { - addMessageInfo(messages, - DiagnosticFactory.create_MUST_BE_A_VALID_JAVA_IDENT("Facet name") - , object, file); - } - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ConverterValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ConverterValidationVisitor.java deleted file mode 100644 index d46999c5e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ConverterValidationVisitor.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterForClassType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; - -/** - * Validates the converter - */ -public class ConverterValidationVisitor extends EObjectValidationVisitor -{ - - /** - * @param version - */ - public ConverterValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_Converter(), - version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing in the tag to validate - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new ConverterClassValidationVisitor(getVersion()) - , new AttributeValidationVisitor(FacesConfigPackage.eINSTANCE.getConverterType_Attribute(), getVersion()) - , new PropertyValidationVisitor - (FacesConfigPackage.eINSTANCE.getConverterType_Property() - ,FacesConfigPackage.eINSTANCE.getConverterType_ConverterClass() - ,getVersion()) - , new ConverterForClassValidationVisitor(getVersion()) - }; - } - - private static class ConverterClassValidationVisitor extends ClassNameEObjectValidationVisitor - { - ConverterClassValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getConverterType_ConverterClass(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((ConverterClassType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.convert.Converter"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - } - - private static class ConverterForClassValidationVisitor extends ClassNameEObjectValidationVisitor - { - ConverterForClassValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getConverterType_ConverterForClass(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((ConverterForClassType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - // no instanceof enforcement - return null; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java deleted file mode 100644 index b614f9a0f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/DiagnosticFactory.java +++ /dev/null @@ -1,412 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.text.MessageFormat; -import java.util.Locale; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.wst.validation.internal.core.Message; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -/** - * Factory for constructing diagnostic objects for AppConfig file validation - * - * @author cbateman - * - */ -public final class DiagnosticFactory -{ - /** - * Problem id - */ - public final static int EL_EXPR_MUST_BE_IN_HASH_BRACES_ID = 0; - - /** - * Problem id - */ - public final static int SYNTAX_ERROR_IN_EL_ID = 1; - - /** - * Problem id - */ - public final static int CANNOT_FIND_CLASS_NAME_ID = 2; - - /** - * Problem id - */ - public final static int FULLY_QUALIFIED_NAME_MUST_BE_A_CLASS_ID = 3; - - /** - * Problem id - */ - public final static int CLASS_MUST_BE_INSTANCE_OF_ID = 4; - - /** - * Problem id - */ - public final static int CLASS_MUST_BE_CONCRETE_ID = 5; - - /** - * TODO: - */ - public final static int CLASS_MUST_HAVE_DEFAULT_OR_ADAPTER_CONSTRUCTOR_ID = 6; - - /** - * Problem id - */ - public final static int API_DEPRECATED_AFTER_VERSION_ID = 7; - - /** - * Problem id - */ - public final static int BEAN_PROPERTY_NOT_FOUND_ID = 8; - - /** - * Problem id - */ - public final static int MUST_BE_A_VALID_JAVA_IDENT_ID = 9; - - /** - * Problem id - */ - public final static int BEAN_SCOPE_NOT_VALID_ID = 10; - - /** - * Problem id - */ - public final static int MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE_ID = 11; - - /** - * Problem id - */ - public final static int LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE_ID = 12; - - /** - * Problem id - */ - public final static int API_NOT_AVAILABLE_BEFORE_VERSION_ID = 13; - - /** - * Problem id - */ - public final static int APP_CONFIG_IS_NEWER_THAN_JSF_VERSION_ID = 14; - /** - * Problem id - */ - public final static int APP_CONFIG_IS_OLDER_THAN_JSF_VERSION_ID = 15; - - /** - * Problem id - */ - public final static int LOCALE_FORMAT_NOT_VALID_ID = 16; - - /** - * @return message indicating text that should be EL was - * not found sorrounded in #{} values - */ - public static IMessage create_EL_EXPR_MUST_BE_IN_HASH_BRACES() - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - Messages.EL_EXPR_MUST_BE_IN_HASH_BRACES_ID, - null, EL_EXPR_MUST_BE_IN_HASH_BRACES_ID); - } - - /** - * @return message indicating that EL was found that - * was empty or did not parse - */ - public static IMessage create_SYNTAX_ERROR_IN_EL() - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - Messages.SYNTAX_ERROR_IN_EL_ID, - null, SYNTAX_ERROR_IN_EL_ID); - } - - /** - * @param className - * @return message indicating that className can't be found as - * a valid fully qualified class name - */ - public static IMessage create_CANNOT_FIND_CLASS_NAME(final String className) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.CANNOT_FIND_CLASS_NAME_ID,new Object[]{className}), - null, SYNTAX_ERROR_IN_EL_ID); - } - - /** - * @param fullyQualifiedName - * @return the error message for a fullyQualifiedName that resolves to a type - * that is not a class (i.e. an interface or enum) but is expected to be - */ - public static IMessage create_FULLY_QUALIFIED_NAME_MUST_BE_A_CLASS(final String fullyQualifiedName) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.FULLY_QUALIFIED_NAME_MUST_BE_A_CLASS_ID - ,new Object[]{fullyQualifiedName}) - ,null, FULLY_QUALIFIED_NAME_MUST_BE_A_CLASS_ID); - } - - /** - * @param className - * @param extensionType - * @param expectedSuper - * @return an error when a class name must be of type expectedSuper - */ - public static IMessage create_CLASS_MUST_BE_INSTANCE_OF(final String className, - final String extensionType, - final String expectedSuper) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.CLASS_MUST_BE_INSTANCE_OF_ID - ,new Object[]{className, extensionType, expectedSuper}) - ,null, CLASS_MUST_BE_INSTANCE_OF_ID); - } - - - /** - * @param className - * @return error indicating that className must specify a class - * that is concrete - */ - public static IMessage create_CLASS_MUST_BE_CONCRETE(final String className) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.CLASS_MUST_BE_CONCRETE_ID - ,new Object[]{className}) - ,null, CLASS_MUST_BE_CONCRETE_ID); - } - - /** - * @param apiName -- name of deprecated API - * @param afterVersion -- version after which deprecation is effective - * @param useInstead -- name of API to use instead - * @return an error indicating the use of a deprecated API - */ - public static IMessage create_API_DEPRECATED_AFTER_VERSION_ID(final String apiName, final String afterVersion, final String useInstead) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.API_DEPRECATED_AFTER_VERSION_ID - ,new Object[]{apiName, afterVersion, useInstead}) - ,null, API_DEPRECATED_AFTER_VERSION_ID); - } - - /** - * @param propertyName - * @param beanClassName - * @return an error indicating that the propertyName was not - * found on beanClassName - */ - public static IMessage create_BEAN_PROPERTY_NOT_FOUND(final String propertyName, final String beanClassName) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.BEAN_PROPERTY_NOT_FOUND_ID - ,new Object[]{propertyName, beanClassName}) - ,null, BEAN_PROPERTY_NOT_FOUND_ID); - - } - - - /** - * @param nameOfId - * @return an error indicating that some id must be a valid - * Java identifier - */ - public static IMessage create_MUST_BE_A_VALID_JAVA_IDENT(final String nameOfId) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.MUST_BE_A_VALID_JAVA_IDENT_ID - ,new Object[]{nameOfId}) - ,null, MUST_BE_A_VALID_JAVA_IDENT_ID); - } - - /** - * @return an error indicating an invalid bean scope enum value - */ - public static IMessage create_BEAN_SCOPE_NOT_VALID() - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - Messages.BEAN_SCOPE_NOT_VALID_ID - , null, BEAN_SCOPE_NOT_VALID_ID); - } - - /** - * @param targetName - * @return an error indicating that a map entry is being set on a target - * object that is not a java.util.Map - */ - public static IMessage create_MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE(String targetName) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE_ID, - new Object[]{targetName}), - null, MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE_ID); - } - - /** - * @param targetName - * @return an error indicating that a list entry is being set on a target - * object that is not a java.util.List - */ - public static IMessage create_LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE(String targetName) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE_ID, - new Object[]{targetName}), - null, LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE_ID); - } - - /** - * @param apiName - * @param beforeVersion - * @param useInstead - * @return a diagnostic indicating that an API is being used that is not yet - * available in the current JSF version. - */ - public static IMessage create_API_NOT_AVAILABLE_BEFORE_VERSION(final String apiName, final String beforeVersion, final String useInstead) - { - return new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format(Messages.API_NOT_AVAILABLE_BEFORE_VERSION_ID - ,new Object[]{apiName, beforeVersion, useInstead}) - ,null, API_NOT_AVAILABLE_BEFORE_VERSION_ID); - } - - /** - * @param file - * @return a diagnostic indicating that the app config model in use is too - * new for the selected JSF runtime version. - */ - public static IMessage create_APP_CONFIG_IS_NEWER_THAN_JSF_VERSION(IFile file) - { - final IMessage message = new MyLocalizedMessage(IMessage.HIGH_SEVERITY, - Messages.APP_CONFIG_IS_NEWER_THAN_JSF_VERSION_ID - ,null, APP_CONFIG_IS_NEWER_THAN_JSF_VERSION_ID); - message.setTargetObject(file); - return message; - } - - /** - * @param file - * @param appConfigVersion - * @param projectVersion - * @return a diagnostic indicating that the app config model in use is older - * than the selected JSF runtime version. - */ - public static IMessage create_APP_CONFIG_IS_OLDER_THAN_JSF_VERSION(IFile file, String appConfigVersion, String projectVersion) - { - final IMessage message = new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - MessageFormat.format( - Messages.APP_CONFIG_IS_OLDER_THAN_JSF_VERSION_ID, - new Object[] {appConfigVersion, projectVersion}) - ,null, APP_CONFIG_IS_OLDER_THAN_JSF_VERSION_ID); - message.setTargetObject(file); - return message; - } - - /** - * @return a diagnostic indicating that the locale format does - * not match what is expected - */ - public static IMessage create_LOCALE_FORMAT_NOT_VALID() - { - IMessage message = new MyLocalizedMessage(IMessage.NORMAL_SEVERITY, - Messages.LOCALE_FORMAT_NOT_VALID_ID - ,null, LOCALE_FORMAT_NOT_VALID_ID); - return message; - } - - /** - * Customized localizable message for app config validation - * @author cbateman - * - */ - static class MyLocalizedMessage extends Message implements ILocalizedMessage - { - private final String _message; - private final int _errorCode; - - /** - * @param severity - * @param messageText - * @param targetObject - * @param errorCode - */ - public MyLocalizedMessage(int severity, String messageText, IResource targetObject, int errorCode) { - this(severity, messageText, (Object) targetObject, errorCode); - } - - /** - * @param severity - * @param messageText - * @param targetObject - * @param errorCode - */ - private MyLocalizedMessage(int severity, String messageText, Object targetObject, int errorCode) { - super(JSFCorePlugin.getDefault().getBundle().getSymbolicName(), severity, - messageText); - _message = messageText; - setTargetObject(targetObject); - _errorCode = errorCode; - } - - /** - * @return the localized message - */ - public String getLocalizedMessage() { - return _message; - } - - /** - * @see org.eclipse.wst.validation.internal.core.Message#getText() - */ - public String getText() { - return getLocalizedMessage(); - } - - /** - * @see org.eclipse.wst.validation.internal.core.Message#getText(java.lang.ClassLoader) - */ - public String getText(ClassLoader cl) { - return getLocalizedMessage(); - } - - /** - * @see org.eclipse.wst.validation.internal.core.Message#getText(java.util.Locale) - */ - public String getText(Locale l) { - return getLocalizedMessage(); - } - - public String getText(Locale l, ClassLoader cl) { - return getLocalizedMessage(); - } - - /** - * @return the error code related to this message - */ - public int getErrorCode() { - return _errorCode; - } - - - /** - * @param offset - * @return true if this message applies to document offset - */ - public boolean appliesTo(int offset) - { - return (offset >= getOffset() && offset < getOffset()+getLength()); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/EObjectValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/EObjectValidationVisitor.java deleted file mode 100644 index 619c74617..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/EObjectValidationVisitor.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -/** - * - * @author cbateman - */ -public abstract class EObjectValidationVisitor -{ - private EStructuralFeature _structuralFeature; - private Map _childFeatures; // == null; lazy initialized in validate - private final String _version; - - /** - * Used to indicate no child nodes - */ - protected final static EObjectValidationVisitor[] NO_CHILDREN = - new EObjectValidationVisitor[0]; - - /** - * @param version - * - */ - public EObjectValidationVisitor(String version) - { - _version = version; - } - - private EObjectValidationVisitor getVisitorForFeature(EStructuralFeature feature) - { - if (_childFeatures == null) - { - _childFeatures = new HashMap(); - - EObjectValidationVisitor[] children = getChildNodeValidators(); - - for (int i = 0; i < children.length; i++) - { - final EObjectValidationVisitor child = children[i]; - _childFeatures.put(child.getStructuralFeature(), child); - } - } - - return (EObjectValidationVisitor) _childFeatures.get(feature); - } - - /** - * @param structuralFeature - * @param version - */ - public EObjectValidationVisitor(EStructuralFeature structuralFeature, String version) - { - this(version); - _structuralFeature = structuralFeature; - } - - /** - * @param eObject - * @param messages - * @param file - */ - public final void validate(EObject eObject, List messages, IFile file) - { - doValidate(eObject, messages, file); - - List features = eObject.eClass().getEAllStructuralFeatures(); - - for (final Iterator it = features.iterator(); it.hasNext();) - { - final EStructuralFeature feature = (EStructuralFeature) it.next(); - final EObjectValidationVisitor visitor = - getVisitorForFeature(feature); - - if (visitor != null) - { - final Object obj = eObject.eGet(feature); - - if (obj instanceof List - && feature.isMany()) - { - for (final Iterator childIt = ((List)obj).iterator(); - childIt.hasNext();) - { - Object child = childIt.next(); - if (child instanceof EObject) - { - visitor.validate((EObject)child, messages, file); - } - } - } - else if (obj instanceof EObject) - { - visitor.validate((EObject)obj , messages, file); - } - } - } - } - - /** - * Do the validation for this visitor on this node. Add any Message's to - * the messages list - * - * @param eObject - * @param messages - * @param file - */ - protected abstract void doValidate(EObject eObject, List messages, IFile file); - - /** - * @return an array of visitors that validate children of the current node - */ - protected abstract EObjectValidationVisitor[] getChildNodeValidators(); - - /** - * @return the structural feature - */ - protected final EStructuralFeature getStructuralFeature() - { - return _structuralFeature; - } - - /** - * @return the version of the runtime - */ - protected final String getVersion() - { - return _version; - } - - /** - * @param messages - * @param message - * @param eObj - * @param file - */ - protected static void addMessageInfo(List messages, IMessage message, EObject eObj, IFile file) - { - if (message != null) - { - message.setOffset(AppConfigValidationUtil.getStartOffset(eObj)); - message.setLength(AppConfigValidationUtil.getLength(eObj)); - message.setTargetObject(file); - messages.add(message); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/FacesConfigValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/FacesConfigValidator.java deleted file mode 100644 index 53a63fd37..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/FacesConfigValidator.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.PhaseListenerType; - -/** - * Top-level validator for the faces-config model - * - * @author cbateman - * - */ -public class FacesConfigValidator extends EObjectValidationVisitor -{ - /** - * constructor - * @param version - */ - public FacesConfigValidator(String version) - { - super(version); - } - - protected EObjectValidationVisitor[] getChildNodeValidators() - { - return new EObjectValidationVisitor[] - { - new NavigationRuleValidator(getVersion()) - , new ApplicationValidationVisitor(getVersion()) - , new LifecycleValidationVisitor(getVersion()) - , new FactoryValidationVisitor(getVersion()) - , new ComponentValidatorVisitor(getVersion()) - , new ValidatorTypeValidationVisitor(getVersion()) - , new ConverterValidationVisitor(getVersion()) - , new ManagedBeanValidationVisitor(getVersion()) - , new RenderKitValidationVisitor(getVersion()) - }; - } - - protected void doValidate(EObject object, List messages, IFile file) - { - // nothing to do - } - - private static class LifecycleValidationVisitor extends EObjectValidationVisitor - { - LifecycleValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_Lifecycle(), - version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing to validate except in children - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] { - new PhaseListenerValidation(getVersion()) - }; - } - - private static class PhaseListenerValidation extends ClassNameEObjectValidationVisitor - { - PhaseListenerValidation(final String version) - { - super(FacesConfigPackage.eINSTANCE.getLifecycleType_PhaseListener(), - version); - } - protected String getFullyQualifiedName(EObject eobj) { - return ((PhaseListenerType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.event.PhaseListener"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - // no children - return NO_CHILDREN; - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/FactoryValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/FactoryValidationVisitor.java deleted file mode 100644 index 5b187d53a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/FactoryValidationVisitor.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.ApplicationFactoryType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesContextFactoryType; -import org.eclipse.jst.jsf.facesconfig.emf.LifecycleFactoryType; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitFactoryType; - -/** - * @author cbateman - * - */ -public class FactoryValidationVisitor extends EObjectValidationVisitor -{ - /** - * @param version - */ - public FactoryValidationVisitor(String version) { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_Factory() - ,version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing to do except vaildate children - } - - protected EObjectValidationVisitor[] getChildNodeValidators() - { - return new EObjectValidationVisitor[] - { - new ApplicationFactoryValidationVisitor(getVersion()) - , new FacesContextFactoryValidationVisitor(getVersion()) - , new LifecycleFactoryValidationVisitor(getVersion()) - , new RenderkitFactoryValidationVisitor(getVersion()) - }; - } - - private static class ApplicationFactoryValidationVisitor extends ClassNameEObjectValidationVisitor - { - ApplicationFactoryValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFactoryType_ApplicationFactory(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((ApplicationFactoryType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.application.ApplicationFactory"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - // none - return NO_CHILDREN; - } - - } - - private static class FacesContextFactoryValidationVisitor extends ClassNameEObjectValidationVisitor - { - FacesContextFactoryValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFactoryType_FacesContextFactory(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((FacesContextFactoryType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.context.FacesContextFactory"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - // none - return NO_CHILDREN; - } - - } - - private static class LifecycleFactoryValidationVisitor extends ClassNameEObjectValidationVisitor - { - LifecycleFactoryValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFactoryType_LifecycleFactory(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((LifecycleFactoryType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.lifecycle.LifecycleFactory"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - // none - return NO_CHILDREN; - } - - } - - private static class RenderkitFactoryValidationVisitor extends ClassNameEObjectValidationVisitor - { - RenderkitFactoryValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFactoryType_RenderKitFactory(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((RenderKitFactoryType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.render.RenderKitFactory"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - // none - return NO_CHILDREN; - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ILocalizedMessage.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ILocalizedMessage.java deleted file mode 100644 index f50207f6f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ILocalizedMessage.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -/** - * Used to expose internal message data to unit tests. Should not be used by clients - * @author cbateman - * - */ -public interface ILocalizedMessage { - /** - * @return the error code - */ - public int getErrorCode(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ManagedBeanValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ManagedBeanValidationVisitor.java deleted file mode 100644 index 19791d64d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ManagedBeanValidationVisitor.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntriesType; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -/** - * Managed bean validator - * - * @author cbateman - * - */ -public class ManagedBeanValidationVisitor extends EObjectValidationVisitor -{ - /** - * @param version - */ - public ManagedBeanValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_ManagedBean() - ,version); - } - - protected void doValidate(EObject object, List messages, IFile file) - { - final ManagedBeanType managedBean = (ManagedBeanType) object; - - // TODO: validate managedBeanName is a valid Java id -// final String managedBeanName = -// managedBean.getManagedBeanName().getTextContent(); - validateScope(managedBean.getManagedBeanScope(), messages, file); - validateClass(managedBean.getManagedBeanClass(), messages, file); - validateEntryTypes(managedBean, messages, file); - } - - private void validateScope(ManagedBeanScopeType scope, List messages, IFile file) - { - if (scope != null && scope.getTextContent() != null) - { - addMessageInfo(messages - , AppConfigValidationUtil.validateManagedBeanScope(scope) - , scope, file); - } - } - - private void validateClass(ManagedBeanClassType classType, List messages, IFile file) - { - if (classType != null) - { - String classTypeValue = classType.getTextContent(); - addMessageInfo(messages - , AppConfigValidationUtil.validateClassName - (classTypeValue == null ? "" : classTypeValue, - null, file.getProject()), classType, file); - } - } - - private void validateEntryTypes(ManagedBeanType managedBeanType, List messages, IFile file) - { - // TODO: do a bean look-up for targetName to verify that it a) matches the type - // and b) exists on the bean - if (managedBeanType.getManagedBeanName()!= null - && managedBeanType.getManagedBeanClass() != null) - { - final String propertyName = - managedBeanType.getManagedBeanName().getTextContent(); - final String propertyClass = - managedBeanType.getManagedBeanClass().getTextContent(); - - if (propertyName == null || propertyClass == null - || "".equals(propertyName.trim()) - || "".equals(propertyClass.trim())) - { - return; - } - - IMessage message = null; - EObject eObj = null; - if (managedBeanType.getMapEntries() != null) - { - eObj = managedBeanType.getMapEntries(); - message = - AppConfigValidationUtil - .validateMapEntries - (propertyName - , propertyClass - , (MapEntriesType) eObj - , file.getProject()); - } - else if (managedBeanType.getListEntries() != null) - { - eObj = managedBeanType.getListEntries(); - message = - AppConfigValidationUtil - .validateListEntries( - propertyName - , propertyClass - , (ListEntriesType) eObj - , file.getProject()); - } - addMessageInfo(messages, message, eObj, file); - } - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new ManagedPropertyValidationVisitor(getVersion()) - }; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ManagedPropertyValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ManagedPropertyValidationVisitor.java deleted file mode 100644 index 6c74b9b5d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ManagedPropertyValidationVisitor.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedPropertyType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntriesType; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -/** - * Validates managed bean properties - * - */ -public class ManagedPropertyValidationVisitor extends EObjectValidationVisitor -{ - /** - * @param version - */ - public ManagedPropertyValidationVisitor(String version) { - super(FacesConfigPackage.eINSTANCE.getManagedBeanType_ManagedProperty() - ,version); - } - - protected void doValidate(final EObject object, final List messages, final IFile file) - { - // TODO: do a bean look-up for propertyName to verify that it a) matches the type - // and b) exists on the bean - final ManagedPropertyType managedPropertyType = - (ManagedPropertyType) object; - - if (managedPropertyType.getPropertyName() == null - || managedPropertyType.getPropertyClass() == null) - { - // don't bother if the basics aren't correct - return; - } - - final String propertyName = - managedPropertyType.getPropertyName().getTextContent(); - final String propertyClass = - managedPropertyType.getPropertyClass().getTextContent(); - - if (propertyName == null || propertyClass == null - || "".equals(propertyName.trim()) - || "".equals(propertyClass.trim())) - { - return; - } - - IMessage message = null; - EObject eObj = null; - if (managedPropertyType.getMapEntries() != null) - { - eObj = managedPropertyType.getMapEntries(); - message = - AppConfigValidationUtil - .validateMapEntries - (propertyName - , propertyClass - , (MapEntriesType) eObj - , file.getProject()); - } - else if (managedPropertyType.getListEntries() != null) - { - eObj = managedPropertyType.getListEntries(); - message = - AppConfigValidationUtil - .validateListEntries( - propertyName - , propertyClass - , (ListEntriesType) eObj - , file.getProject()); - } - - addMessageInfo(messages, message, eObj, file); - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new PropertyNameValidationVisitor(FacesConfigPackage.eINSTANCE.getManagedPropertyType_PropertyName(), - FacesConfigPackage.eINSTANCE.getManagedBeanType_ManagedBeanClass(), getVersion()) - }; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java deleted file mode 100644 index fb62b62d3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/Messages.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import org.eclipse.osgi.util.NLS; - -class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.validation.internal.appconfig.messages"; //$NON-NLS-1$ - - - - - static { - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - /** - * see messages.properties - */ - public static String AppConfigValidationUtil_0; - - /** - * see messages.properties - */ - public static String EL_EXPR_MUST_BE_IN_HASH_BRACES_ID; - - /** - * see messages.properties - */ - public static String SYNTAX_ERROR_IN_EL_ID; - - /** - * see messages.properties - */ - public static String CANNOT_FIND_CLASS_NAME_ID; - - /** - * see messages.properties - */ - public static String FULLY_QUALIFIED_NAME_MUST_BE_A_CLASS_ID; - - /** - * see messages.properties - */ - public static String CLASS_MUST_BE_INSTANCE_OF_ID; - - /** - * see messages.properties - */ - public static String CLASS_MUST_BE_CONCRETE_ID; - - /** - * see messages.properties - */ - public static String API_DEPRECATED_AFTER_VERSION_ID; - - /** - * see messages.properties - */ - public static String BEAN_PROPERTY_NOT_FOUND_ID; - - /** - * see messages.properties - */ - public static String MUST_BE_A_VALID_JAVA_IDENT_ID; - - /** - * see messages.properties - */ - public static String BEAN_SCOPE_NOT_VALID_ID; - - /** - * see messages.properties - */ - public static String MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE_ID; - - /** - * see messages.properties - */ - public static String LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE_ID; - - /** - * see messages.properties - */ - public static String API_NOT_AVAILABLE_BEFORE_VERSION_ID; - - /** - * see messages.properties - */ - public static String APP_CONFIG_IS_NEWER_THAN_JSF_VERSION_ID; - - /** - * see messages.properties - */ - public static String APP_CONFIG_IS_OLDER_THAN_JSF_VERSION_ID; - - /** - * see messages.properties - */ - public static String LOCALE_FORMAT_NOT_VALID_ID; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NavigationCaseValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NavigationCaseValidationVisitor.java deleted file mode 100644 index 47a127118..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NavigationCaseValidationVisitor.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FromActionType; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -/** - * NavigationCase validation visitor. - * - * @author cbateman - * - */ -public class NavigationCaseValidationVisitor extends EObjectValidationVisitor -{ - /** - * @param version - * - */ - public NavigationCaseValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getNavigationRuleType_NavigationCase() - , version); - } - - protected void doValidate(EObject object, List messages, IFile file) - { - // nothing to do - } - - protected EObjectValidationVisitor[] getChildNodeValidators() - { - return new EObjectValidationVisitor[] - { - new FromActionValidationVisitor(getVersion()) - }; - } - - private static class FromActionValidationVisitor extends EObjectValidationVisitor - { - /** - * @param version - * - */ - public FromActionValidationVisitor(String version) { - super(FacesConfigPackage.eINSTANCE.getNavigationCaseType_FromAction(), - version); - } - - protected void doValidate(EObject object, List messages, IFile file) - { - if (object instanceof FromActionType) - { - final FromActionType actionType = (FromActionType) object; - IMessage message = AppConfigValidationUtil.validateELExpression - (actionType.getTextContent()); - addMessageInfo(messages, message, actionType, file); - } - } - - protected EObjectValidationVisitor[] getChildNodeValidators() - { - return NO_CHILDREN; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NavigationRuleValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NavigationRuleValidator.java deleted file mode 100644 index b1b6e1bc5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NavigationRuleValidator.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; - -/** - * Recursive validator for navigation-rule - * - * @author cbateman - * - */ -public class NavigationRuleValidator extends EObjectValidationVisitor -{ - /** - * Constructor - * @param version - */ - public NavigationRuleValidator(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_NavigationRule() - , version); - } - - protected void doValidate(EObject eobj, List messages, IFile file) - { - // nothing to do - } - - protected EObjectValidationVisitor[] getChildNodeValidators() - { - return new EObjectValidationVisitor[] - { - new NavigationCaseValidationVisitor(getVersion()) - }; - } -// private static class FromViewIdValidator extends ViewIdValidator -// { -// FromViewIdValidator() -// { -// super(Node.ELEMENT_NODE, "from-view-id"); -// } -// -// protected void doValidate(Node node, List messages, IFile file) -// { -// // only validate if a custom navigation handler is not set -// // since we can only validate against what the default navigation -// // handler will expect -// if (!hasCustomNavigationHandler(file)) -// { -// final String textContent = node.getTextContent(); -// final IProject project = file.getProject(); -// -// -// } -// } -// -// private boolean hasCustomNavigationHandler(IFile file) -// { -// JSFAppConfigManager configManager = -// JSFAppConfigManager.getInstance(file.getProject()); -// -// for (final Iterator appIt = configManager.getApplications().iterator(); appIt.hasNext();) -// { -// ApplicationType appType = (ApplicationType) appIt.next(); -// if (appType.getNavigationHandler().size() > 0) -// { -// return true; -// } -// } -// -// return false; -// } -// -// protected NodeValidationVisitor[] getChildNodeValidators() { -// return EMPTY_CHILDREN; -// } -// } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NodeValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NodeValidationVisitor.java deleted file mode 100644 index 49eacac63..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/NodeValidationVisitor.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -/** - * Visits an app config DOM tree and calls validators based on the - * configured validator tree - * - * @author cbateman - * - */ -public abstract class NodeValidationVisitor -{ - private final short _nodeType; - private final String _nodeName; - private final Map _attributeVisitors; - private final Map _elementVisitors; - - /** - * Used to indicate no child nodes - */ - protected final static NodeValidationVisitor[] EMPTY_CHILDREN = new NodeValidationVisitor[0]; - - /** - * @param nodeType - * @param nodeName - */ - public NodeValidationVisitor(short nodeType, String nodeName) - { - _nodeType = nodeType; - _nodeName = nodeName; - _attributeVisitors = new HashMap(); - _elementVisitors = new HashMap(); - - NodeValidationVisitor[] childVisitors = getChildNodeValidators(); - - for (int i = 0; i < childVisitors.length; i++) - { - final NodeValidationVisitor visitor = childVisitors[i]; - - switch(visitor.getNodeType()) - { - case Node.ATTRIBUTE_NODE: - _attributeVisitors.put(visitor.getNodeName(), visitor); - break; - - case Node.ELEMENT_NODE: - _elementVisitors.put(visitor.getNodeName(), visitor); - break; - } - } - } - - /** - * @param node - * @param messages - * @param file - */ - public final void validate(Node node, List messages, IFile file) - { - doValidate(node, messages, file); - - final NamedNodeMap attributes = node.getAttributes(); - - for (int i = 0; attributes != null && i < attributes.getLength(); i++) - { - final Node attr = attributes.item(i); - final NodeValidationVisitor visitor = - (NodeValidationVisitor) _attributeVisitors.get(attr.getNodeName()); - if (visitor != null) - { - visitor.validate(attr, messages, file); - } - } - - for (int i = 0; i < node.getChildNodes().getLength(); i++) - { - final Node child = node.getChildNodes().item(i); - final NodeValidationVisitor visitor = - (NodeValidationVisitor) _elementVisitors.get(child.getNodeName()); - if (visitor != null) - { - visitor.validate(child, messages, file); - } - } - } - - /** - * Do the validation for this visitor on this node. Add any Message's to - * the messages list - * - * @param node - * @param messages - * @param file - */ - protected abstract void doValidate(Node node, List messages, IFile file); - - /** - * @return an array of visitors that validate children of the current node - */ - protected abstract NodeValidationVisitor[] getChildNodeValidators(); - - /** - * @return the node type for this validator - */ - protected short getNodeType() - { - return _nodeType; - } - - /** - * @return the node name for this validator - */ - protected String getNodeName() - { - return _nodeName; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/PropertyNameValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/PropertyNameValidationVisitor.java deleted file mode 100644 index bce93013e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/PropertyNameValidationVisitor.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyNameType; - -/** - * Validate the validation property name - * - * @author cbateman - */ -class PropertyNameValidationVisitor extends EObjectValidationVisitor -{ - private final EStructuralFeature _parentClassNameFeature; - - /** - * @param feature - * @param parentClassNameFeature - * @param version - */ - public PropertyNameValidationVisitor(EStructuralFeature feature, - EStructuralFeature parentClassNameFeature, String version) - { - super(feature, version); - _parentClassNameFeature = parentClassNameFeature; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() - { - return PropertyValidationVisitor.NO_CHILDREN; - } - - protected void doValidate(EObject object, List messages, IFile file) - { - final String parentClassType = getParentClassType(object); - - if (parentClassType != null) - { - String typeSig = - PropertyValidationVisitor.validateProperty((PropertyNameType)object - , file.getProject(), parentClassType); - final String propertyName = - ((PropertyNameType)object).getTextContent(); - - if (typeSig == null) - { - PropertyValidationVisitor.addMessageInfo(messages, - DiagnosticFactory - .create_BEAN_PROPERTY_NOT_FOUND - (propertyName, parentClassType) - , object, file); - } - } - } - - private String getParentClassType(EObject object) - { - String parentClassType = null; - - // need to derive the parent's type - final EObject property = object.eContainer(); - if (property != null) - { - EObject owningObject = property.eContainer(); - - if (owningObject != null) - { - final EObject parentClassTypeObject = - (EObject) owningObject.eGet(_parentClassNameFeature); - - if (parentClassTypeObject != null) - { - final EStructuralFeature feature = - parentClassTypeObject.eClass() - .getEStructuralFeature("textContent"); - - if (feature != null) - { - parentClassType = (String) - parentClassTypeObject.eGet(feature); - } - } - } - } - - return parentClassType; - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/PropertyValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/PropertyValidationVisitor.java deleted file mode 100644 index be9f5ec4d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/PropertyValidationVisitor.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.common.util.JDTBeanIntrospector; -import org.eclipse.jst.jsf.common.util.JDTBeanProperty; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyNameType; - -/** - * Validates property's - * - */ -public class PropertyValidationVisitor extends EObjectValidationVisitor -{ - private final EStructuralFeature _parentClassName; - - /** - * @param feature - * @param parentClassName - * @param version - */ - public PropertyValidationVisitor(EStructuralFeature feature, EStructuralFeature parentClassName, String version) { - // this validator can be attached to numerous parents so it - // cannot hard-code its feature - super(feature,version); - _parentClassName = parentClassName; - } - - protected void doValidate(EObject object, List messages, IFile file) { - // validate the class type here because we need knowledge - // of the property name to do it - //TODO: -// final PropertyType property = (PropertyType) object; -// final String propertyClass = -// property.getPropertyClass().getTextContent(); -// final String propertySignature = -// validateProperty(property.getPropertyName() -// , file.getProject(), _parentClassType); -// -// if (propertySignature != null -// && Signature.) -// { -// Signature.create -// } - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new PropertyNameValidationVisitor(FacesConfigPackage.eINSTANCE.getPropertyType_PropertyName(), - _parentClassName, getVersion()) - }; - } - - static String validateProperty(PropertyNameType object, IProject project, String parentClassType) - { - String signatureBeanProperty = null; - try - { - IJavaProject javaProject = JavaCore.create(project); - IType type = javaProject.findType(parentClassType); - - if (type != null) - { - final JDTBeanIntrospector introspector = - new JDTBeanIntrospector(type); - - final Map properties = introspector.getProperties(); - - final String propertyName = object.getTextContent(); - if (properties.containsKey(propertyName)) - { - final JDTBeanProperty beanProperty = - (JDTBeanProperty) properties.get(propertyName); - signatureBeanProperty = - beanProperty.getTypeSignature(); - } - } - } - catch(JavaModelException jme) - { - JSFCorePlugin - .log(new Exception(jme), - "Problem validating on parent: "+parentClassType); - } - - return signatureBeanProperty; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/RenderKitValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/RenderKitValidationVisitor.java deleted file mode 100644 index bb81efa8a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/RenderKitValidationVisitor.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitClassType; - -/** - * Validates the renderkit - */ -public class RenderKitValidationVisitor extends EObjectValidationVisitor -{ - - /** - * @param version - */ - public RenderKitValidationVisitor(String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_RenderKit() - ,version); - } - - protected void doValidate(EObject object, List messages, IFile file) - { - // nothing to do - } - - protected EObjectValidationVisitor[] getChildNodeValidators() - { - return new EObjectValidationVisitor[] - { - new RenderKitClassValidationVisitor(getVersion()), - new RendererValidationVisitor(getVersion()) - }; - } - - private static class RenderKitClassValidationVisitor extends ClassNameEObjectValidationVisitor - { - /** - * @param version - */ - public RenderKitClassValidationVisitor(String version) - { - super(FacesConfigPackage.eINSTANCE.getRenderKitType_RenderKitClass() - , version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((RenderKitClassType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.render.RenderKit"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/RendererValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/RendererValidationVisitor.java deleted file mode 100644 index 7c5cfb52a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/RendererValidationVisitor.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.RendererClassType; - -/** - * Renderer validation - * - */ -public class RendererValidationVisitor extends EObjectValidationVisitor { - - /** - * @param version - */ - public RendererValidationVisitor(String version) - { - super(FacesConfigPackage.eINSTANCE.getRenderKitType_Renderer(), - version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing to do - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new RendererClassValidationVisitor(getVersion()) - , new AttributeValidationVisitor - (FacesConfigPackage.eINSTANCE.getRendererType_Attribute() - , getVersion()) - }; - } - - private static class RendererClassValidationVisitor extends ClassNameEObjectValidationVisitor - { - /** - * @param version - */ - public RendererClassValidationVisitor(String version) - { - super(FacesConfigPackage.eINSTANCE.getRendererType_RendererClass() - , version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((RendererClassType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.render.Renderer"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ValidatorTypeValidationVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ValidatorTypeValidationVisitor.java deleted file mode 100644 index 8068b0e29..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ValidatorTypeValidationVisitor.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorClassType; - -/** - * Validation visitor for the Validator faces config model sub-type - * @author cbateman - * - */ -public class ValidatorTypeValidationVisitor extends EObjectValidationVisitor { - - /** - * @param version - */ - public ValidatorTypeValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getFacesConfigType_Validator(), - version); - } - - protected void doValidate(EObject object, List messages, IFile file) { - // nothing in the tag to validate - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return new EObjectValidationVisitor[] - { - new ValidatorClassValidationVisitor(getVersion()), - new AttributeValidationVisitor(FacesConfigPackage.eINSTANCE.getValidatorType_Attribute(), getVersion()), - new PropertyValidationVisitor - (FacesConfigPackage.eINSTANCE.getValidatorType_Property() - ,FacesConfigPackage.eINSTANCE.getValidatorType_ValidatorClass() - ,getVersion()), - }; - } - - private static class ValidatorClassValidationVisitor extends ClassNameEObjectValidationVisitor - { - ValidatorClassValidationVisitor(final String version) - { - super(FacesConfigPackage.eINSTANCE.getValidatorType_ValidatorClass(), - version); - } - - protected String getFullyQualifiedName(EObject eobj) - { - return ((ValidatorClassType)eobj).getTextContent(); - } - - protected String getInstanceOf() { - return "javax.faces.validator.Validator"; - } - - protected EObjectValidationVisitor[] getChildNodeValidators() { - return NO_CHILDREN; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ViewIdValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ViewIdValidator.java deleted file mode 100644 index b925cff99..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/ViewIdValidator.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.appconfig; - - -/** - * @author cbateman - * - */ -public abstract class ViewIdValidator extends NodeValidationVisitor -{ - /** - * @param nodeType - * @param nodeName - */ - protected ViewIdValidator(final short nodeType, final String nodeName) - { - super(nodeType, nodeName); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties deleted file mode 100644 index 37da6845f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/appconfig/messages.properties +++ /dev/null @@ -1,27 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle 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: -# Oracle Corporation - initial API and implementation -############################################################################### -EL_EXPR_MUST_BE_IN_HASH_BRACES_ID=EL expression must be of the form #{expression} -SYNTAX_ERROR_IN_EL_ID=Syntax error in EL -CANNOT_FIND_CLASS_NAME_ID=Cannot find fully qualified class: {0} -FULLY_QUALIFIED_NAME_MUST_BE_A_CLASS_ID=Fully qualified name must be a class: {0} -CLASS_MUST_BE_INSTANCE_OF_ID=Class {0} must {1} the type {2} -CLASS_MUST_BE_CONCRETE_ID=Class {0} must be concrete (not abstract) -API_DEPRECATED_AFTER_VERSION_ID=API {0} is deprecated after JSF {1}. Use {2} instead. -BEAN_PROPERTY_NOT_FOUND_ID=Bean property {0} not found on parent class {1} -MUST_BE_A_VALID_JAVA_IDENT_ID={0} must be a valid Java identifier -BEAN_SCOPE_NOT_VALID_ID=Managed bean scope must be one of: request, session, application, none -MAP_ENTRIES_CAN_ONLY_BE_SET_ON_MAP_TYPE_ID=Map entries can only be set on objects of type Map. {0} is not an instance of type java.util.Map -LIST_ENTRIES_CAN_ONLY_BE_SET_ON_LIST_TYPE_ID=List entries can only be set on objects of type List. {0} is not an instance of type java.util.List -API_NOT_AVAILABLE_BEFORE_VERSION_ID=API {0} is not avaiable before JSF {1}. Use {2} instead. -APP_CONFIG_IS_NEWER_THAN_JSF_VERSION_ID=Faces 1.2 application configuration cannot be used in projects for Faces 1.1 or before -APP_CONFIG_IS_OLDER_THAN_JSF_VERSION_ID=Faces {0} application configuration being used in Faces {1} project. Not all Faces {1} features will be available" -LOCALE_FORMAT_NOT_VALID_ID=Locale format must be of the form lang_[_country[_variant]] like en or en_US or ja_JP_SJIS -AppConfigValidationUtil_0=extend diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ConstraintsFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ConstraintsFactory.java deleted file mode 100644 index 0df2966b4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ConstraintsFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsFactory.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints; - -import org.eclipse.emf.ecore.EFactory; - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage - * @generated - */ -public interface ConstraintsFactory extends EFactory { - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - ConstraintsFactory eINSTANCE = org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsFactoryImpl.init(); - - /** - * Returns a new object of class '<em>Tag Id</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Tag Id</em>'. - * @generated - */ - TagId createTagId(); - - /** - * Returns a new object of class '<em>Tag Set</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Tag Set</em>'. - * @generated - */ - TagSet createTagSet(); - - /** - * Returns a new object of class '<em>Contains Tag Constraint</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Contains Tag Constraint</em>'. - * @generated - */ - ContainsTagConstraint createContainsTagConstraint(); - - /** - * Returns the package supported by this factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the package supported by this factory. - * @generated - */ - ConstraintsPackage getConstraintsPackage(); - -} //ConstraintsFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ConstraintsPackage.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ConstraintsPackage.java deleted file mode 100644 index f21c6498c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ConstraintsPackage.java +++ /dev/null @@ -1,352 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsPackage.java,v 1.2 2007/04/16 17:50:08 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -/** - * <!-- begin-user-doc --> - * The <b>Package</b> for the model. - * It contains accessors for the meta objects to represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsFactory - * @model kind="package" - * @generated - */ -public interface ConstraintsPackage extends EPackage { - /** - * The package name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNAME = "constraints"; - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_URI = "http://org.eclipse.jst.jsf.core/constraints.ecore"; - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_PREFIX = "cnst"; - - /** - * The singleton instance of the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - ConstraintsPackage eINSTANCE = org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsPackageImpl.init(); - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.TagIdImpl <em>Tag Id</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.TagIdImpl - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsPackageImpl#getTagId() - * @generated - */ - int TAG_ID = 0; - - /** - * The feature id for the '<em><b>Uri</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TAG_ID__URI = 0; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TAG_ID__NAME = 1; - - /** - * The number of structural features of the '<em>Tag Id</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TAG_ID_FEATURE_COUNT = 2; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.TagSetImpl <em>Tag Set</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.TagSetImpl - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsPackageImpl#getTagSet() - * @generated - */ - int TAG_SET = 1; - - /** - * The feature id for the '<em><b>Tags</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TAG_SET__TAGS = 0; - - /** - * The number of structural features of the '<em>Tag Set</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TAG_SET_FEATURE_COUNT = 1; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.ContainsTagConstraintImpl <em>Contains Tag Constraint</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ContainsTagConstraintImpl - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsPackageImpl#getContainsTagConstraint() - * @generated - */ - int CONTAINS_TAG_CONSTRAINT = 2; - - /** - * The feature id for the '<em><b>Set Generator</b></em>' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int CONTAINS_TAG_CONSTRAINT__SET_GENERATOR = 0; - - /** - * The feature id for the '<em><b>Satisfies Set</b></em>' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int CONTAINS_TAG_CONSTRAINT__SATISFIES_SET = 1; - - /** - * The number of structural features of the '<em>Contains Tag Constraint</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int CONTAINS_TAG_CONSTRAINT_FEATURE_COUNT = 2; - - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId <em>Tag Id</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Tag Id</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.TagId - * @generated - */ - EClass getTagId(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId#getUri <em>Uri</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Uri</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.TagId#getUri() - * @see #getTagId() - * @generated - */ - EAttribute getTagId_Uri(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId#getName <em>Name</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Name</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.TagId#getName() - * @see #getTagId() - * @generated - */ - EAttribute getTagId_Name(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagSet <em>Tag Set</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Tag Set</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.TagSet - * @generated - */ - EClass getTagSet(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagSet#getTags <em>Tags</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference list '<em>Tags</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.TagSet#getTags() - * @see #getTagSet() - * @generated - */ - EReference getTagSet_Tags(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint <em>Contains Tag Constraint</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Contains Tag Constraint</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint - * @generated - */ - EClass getContainsTagConstraint(); - - /** - * Returns the meta object for the reference '{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSetGenerator <em>Set Generator</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference '<em>Set Generator</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSetGenerator() - * @see #getContainsTagConstraint() - * @generated - */ - EReference getContainsTagConstraint_SetGenerator(); - - /** - * Returns the meta object for the reference '{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSatisfiesSet <em>Satisfies Set</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference '<em>Satisfies Set</em>'. - * @see org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSatisfiesSet() - * @see #getContainsTagConstraint() - * @generated - */ - EReference getContainsTagConstraint_SatisfiesSet(); - - /** - * Returns the factory that creates the instances of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the factory that creates the instances of the model. - * @generated - */ - ConstraintsFactory getConstraintsFactory(); - - /** - * <!-- begin-user-doc --> - * Defines literals for the meta objects that represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @generated - */ - interface Literals { - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.TagIdImpl <em>Tag Id</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.TagIdImpl - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsPackageImpl#getTagId() - * @generated - */ - @SuppressWarnings("hiding") - EClass TAG_ID = eINSTANCE.getTagId(); - - /** - * The meta object literal for the '<em><b>Uri</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute TAG_ID__URI = eINSTANCE.getTagId_Uri(); - - /** - * The meta object literal for the '<em><b>Name</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EAttribute TAG_ID__NAME = eINSTANCE.getTagId_Name(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.TagSetImpl <em>Tag Set</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.TagSetImpl - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsPackageImpl#getTagSet() - * @generated - */ - @SuppressWarnings("hiding") - EClass TAG_SET = eINSTANCE.getTagSet(); - - /** - * The meta object literal for the '<em><b>Tags</b></em>' reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EReference TAG_SET__TAGS = eINSTANCE.getTagSet_Tags(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.ContainsTagConstraintImpl <em>Contains Tag Constraint</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ContainsTagConstraintImpl - * @see org.eclipse.jst.jsf.validation.internal.constraints.impl.ConstraintsPackageImpl#getContainsTagConstraint() - * @generated - */ - @SuppressWarnings("hiding") - EClass CONTAINS_TAG_CONSTRAINT = eINSTANCE.getContainsTagConstraint(); - - /** - * The meta object literal for the '<em><b>Set Generator</b></em>' reference feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EReference CONTAINS_TAG_CONSTRAINT__SET_GENERATOR = eINSTANCE.getContainsTagConstraint_SetGenerator(); - - /** - * The meta object literal for the '<em><b>Satisfies Set</b></em>' reference feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - EReference CONTAINS_TAG_CONSTRAINT__SATISFIES_SET = eINSTANCE.getContainsTagConstraint_SatisfiesSet(); - - } - -} //ConstraintsPackage diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ContainsTagConstraint.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ContainsTagConstraint.java deleted file mode 100644 index d91e5c064..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/ContainsTagConstraint.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ContainsTagConstraint.java,v 1.2 2007/04/16 19:53:29 itrimble Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Contains Tag Constraint</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSetGenerator <em>Set Generator</em>}</li> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSatisfiesSet <em>Satisfies Set</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getContainsTagConstraint() - * @model - * @generated - */ -public interface ContainsTagConstraint extends EObject { - /** - * Returns the value of the '<em><b>Set Generator</b></em>' reference. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Set Generator</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Set Generator</em>' reference. - * @see #setSetGenerator(SetGenerator) - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getContainsTagConstraint_SetGenerator() - * @model extendedMetaData="kind='element' name='set-generator'" - * @generated - */ - SetGenerator getSetGenerator(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSetGenerator <em>Set Generator</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Set Generator</em>' reference. - * @see #getSetGenerator() - * @generated - */ - void setSetGenerator(SetGenerator value); - - /** - * Returns the value of the '<em><b>Satisfies Set</b></em>' reference. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Satisfies Set</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Satisfies Set</em>' reference. - * @see #setSatisfiesSet(TagSet) - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getContainsTagConstraint_SatisfiesSet() - * @model extendedMetaData="kind='element' name='satisfies-set'" - * @generated - */ - TagSet getSatisfiesSet(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint#getSatisfiesSet <em>Satisfies Set</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Satisfies Set</em>' reference. - * @see #getSatisfiesSet() - * @generated - */ - void setSatisfiesSet(TagSet value); - -} // ContainsTagConstraint diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/TagId.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/TagId.java deleted file mode 100644 index 5c5ebb12b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/TagId.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TagId.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Tag Id</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId#getUri <em>Uri</em>}</li> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId#getName <em>Name</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getTagId() - * @model - * @generated - */ -public interface TagId extends EObject { - /** - * Returns the value of the '<em><b>Uri</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Uri</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Uri</em>' attribute. - * @see #setUri(String) - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getTagId_Uri() - * @model extendedMetaData="kind='element'" - * @generated - */ - String getUri(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId#getUri <em>Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Uri</em>' attribute. - * @see #getUri() - * @generated - */ - void setUri(String value); - - /** - * Returns the value of the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Name</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Name</em>' attribute. - * @see #setName(String) - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getTagId_Name() - * @model extendedMetaData="kind='element'" - * @generated - */ - String getName(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId#getName <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Name</em>' attribute. - * @see #getName() - * @generated - */ - void setName(String value); - -} // TagId diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/TagSet.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/TagSet.java deleted file mode 100644 index 5c60d5ddb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/TagSet.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TagSet.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Tag Set</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.TagSet#getTags <em>Tags</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getTagSet() - * @model - * @generated - */ -public interface TagSet extends EObject { - /** - * Returns the value of the '<em><b>Tags</b></em>' reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.validation.internal.constraints.TagId}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Tags</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Tags</em>' reference list. - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#getTagSet_Tags() - * @model type="org.eclipse.jst.jsf.validation.internal.constraints.TagId" - * @generated - */ - EList getTags(); - -} // TagSet diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ConstraintsFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ConstraintsFactoryImpl.java deleted file mode 100644 index f83091de0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ConstraintsFactoryImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsFactoryImpl.java,v 1.2 2007/03/22 23:56:16 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.impl.EFactoryImpl; - -import org.eclipse.emf.ecore.plugin.EcorePlugin; - -import org.eclipse.jst.jsf.validation.internal.constraints.*; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * <!-- end-user-doc --> - * @generated - */ -public class ConstraintsFactoryImpl extends EFactoryImpl implements ConstraintsFactory { - /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the constraints factory - * @generated - */ - public static ConstraintsFactory init() { - try { - ConstraintsFactory theConstraintsFactory = (ConstraintsFactory)EPackage.Registry.INSTANCE.getEFactory("http://org.eclipse.jst.jsf.core/constraints.ecore"); - if (theConstraintsFactory != null) { - return theConstraintsFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new ConstraintsFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ConstraintsFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param eClass - * @return the eobject for the class - * @generated - */ - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case ConstraintsPackage.TAG_ID: return createTagId(); - case ConstraintsPackage.TAG_SET: return createTagSet(); - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT: return createContainsTagConstraint(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new tag id - * @generated - */ - public TagId createTagId() { - TagIdImpl tagId = new TagIdImpl(); - return tagId; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new tag set - * @generated - */ - public TagSet createTagSet() { - TagSetImpl tagSet = new TagSetImpl(); - return tagSet; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new Contains Tag Constraint - * @generated - */ - public ContainsTagConstraint createContainsTagConstraint() { - ContainsTagConstraintImpl containsTagConstraint = new ContainsTagConstraintImpl(); - return containsTagConstraint; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the constraints package - * @generated - */ - public ConstraintsPackage getConstraintsPackage() { - return (ConstraintsPackage)getEPackage(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the package - * @deprecated - * @generated - */ - public static ConstraintsPackage getPackage() { - return ConstraintsPackage.eINSTANCE; - } - -} //ConstraintsFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ConstraintsPackageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ConstraintsPackageImpl.java deleted file mode 100644 index fc60ec767..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ConstraintsPackageImpl.java +++ /dev/null @@ -1,329 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsPackageImpl.java,v 1.3 2007/04/16 19:53:19 itrimble Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -import org.eclipse.emf.ecore.impl.EPackageImpl; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage; - -import org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsFactory; -import org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage; -import org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint; -import org.eclipse.jst.jsf.validation.internal.constraints.TagId; -import org.eclipse.jst.jsf.validation.internal.constraints.TagSet; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Package</b>. - * <!-- end-user-doc --> - * @generated - */ -public class ConstraintsPackageImpl extends EPackageImpl implements ConstraintsPackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass tagIdEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass tagSetEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass containsTagConstraintEClass = null; - - /** - * Creates an instance of the model <b>Package</b>, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - * <p>Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage#eNS_URI - * @see #init() - * @generated - */ - private ConstraintsPackageImpl() { - super(eNS_URI, ConstraintsFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this - * model, and for any others upon which it depends. Simple - * dependencies are satisfied by calling this method on all - * dependent packages before doing anything else. This method drives - * initialization for interdependent packages directly, in parallel - * with this package, itself. - * <p>Of this package and its interdependencies, all packages which - * have not yet been registered by their URI values are first created - * and registered. The packages are then initialized in two steps: - * meta-model objects for all of the packages are created before any - * are initialized, since one package's meta-model objects may refer to - * those of another. - * <p>Invocation of this method will not affect any packages that have - * already been initialized. - * <!-- begin-user-doc --> - * @return the initialized package - * <!-- end-user-doc --> - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static ConstraintsPackage init() { - if (isInited) return (ConstraintsPackage)EPackage.Registry.INSTANCE.getEPackage(ConstraintsPackage.eNS_URI); - - // Obtain or create and register package - ConstraintsPackageImpl theConstraintsPackage = (ConstraintsPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof ConstraintsPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new ConstraintsPackageImpl()); - - isInited = true; - - // Initialize simple dependencies - TraitTypesPackage.eINSTANCE.eClass(); - - // Create package meta-data objects - theConstraintsPackage.createPackageContents(); - - // Initialize created meta-data - theConstraintsPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theConstraintsPackage.freeze(); - - return theConstraintsPackage; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getTagId() { - return tagIdEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getTagId_Uri() { - return (EAttribute)tagIdEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getTagId_Name() { - return (EAttribute)tagIdEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getTagSet() { - return tagSetEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getTagSet_Tags() { - return (EReference)tagSetEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getContainsTagConstraint() { - return containsTagConstraintEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getContainsTagConstraint_SetGenerator() { - return (EReference)containsTagConstraintEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getContainsTagConstraint_SatisfiesSet() { - return (EReference)containsTagConstraintEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ConstraintsFactory getConstraintsFactory() { - return (ConstraintsFactory)getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - tagIdEClass = createEClass(TAG_ID); - createEAttribute(tagIdEClass, TAG_ID__URI); - createEAttribute(tagIdEClass, TAG_ID__NAME); - - tagSetEClass = createEClass(TAG_SET); - createEReference(tagSetEClass, TAG_SET__TAGS); - - containsTagConstraintEClass = createEClass(CONTAINS_TAG_CONSTRAINT); - createEReference(containsTagConstraintEClass, CONTAINS_TAG_CONSTRAINT__SET_GENERATOR); - createEReference(containsTagConstraintEClass, CONTAINS_TAG_CONSTRAINT__SATISFIES_SET); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Obtain other dependent packages - TraitTypesPackage theTraitTypesPackage = (TraitTypesPackage)EPackage.Registry.INSTANCE.getEPackage(TraitTypesPackage.eNS_URI); - - // Add supertypes to classes - - // Initialize classes and features; add operations and parameters - initEClass(tagIdEClass, TagId.class, "TagId", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getTagId_Uri(), ecorePackage.getEString(), "uri", null, 0, 1, TagId.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getTagId_Name(), ecorePackage.getEString(), "name", null, 0, 1, TagId.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(tagSetEClass, TagSet.class, "TagSet", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getTagSet_Tags(), this.getTagId(), null, "tags", null, 0, -1, TagSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(containsTagConstraintEClass, ContainsTagConstraint.class, "ContainsTagConstraint", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getContainsTagConstraint_SetGenerator(), theTraitTypesPackage.getSetGenerator(), null, "setGenerator", null, 0, 1, ContainsTagConstraint.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getContainsTagConstraint_SatisfiesSet(), this.getTagSet(), null, "satisfiesSet", null, 0, 1, ContainsTagConstraint.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - // Create resource - createResource(eNS_URI); - - // Create annotations - // http:///org/eclipse/emf/ecore/util/ExtendedMetaData - createExtendedMetaDataAnnotations(); - } - - /** - * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createExtendedMetaDataAnnotations() { - String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; - addAnnotation - (getTagId_Uri(), - source, - new String[] { - "kind", "element", - "name", "uri" - }); - addAnnotation - (getTagId_Name(), - source, - new String[] { - "kind", "element", - "name", "name" - }); - addAnnotation - (getTagSet_Tags(), - source, - new String[] { - "kind", "element", - "name", "tagId" - }); - addAnnotation - (getContainsTagConstraint_SetGenerator(), - source, - new String[] { - "kind", "element", - "name", "set-generator" - }); - addAnnotation - (getContainsTagConstraint_SatisfiesSet(), - source, - new String[] { - "kind", "element", - "name", "satisfies-set" - }); - } - -} //ConstraintsPackageImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ContainsTagConstraintImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ContainsTagConstraintImpl.java deleted file mode 100644 index d3fad7129..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/ContainsTagConstraintImpl.java +++ /dev/null @@ -1,220 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ContainsTagConstraintImpl.java,v 1.3 2007/04/16 19:53:19 itrimble Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator; - -import org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage; -import org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint; -import org.eclipse.jst.jsf.validation.internal.constraints.TagSet; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Contains Tag Constraint</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.ContainsTagConstraintImpl#getSetGenerator <em>Set Generator</em>}</li> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.ContainsTagConstraintImpl#getSatisfiesSet <em>Satisfies Set</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ContainsTagConstraintImpl extends EObjectImpl implements ContainsTagConstraint { - /** - * The cached value of the '{@link #getSetGenerator() <em>Set Generator</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSetGenerator() - * @generated - * @ordered - */ - protected SetGenerator setGenerator = null; - - /** - * The cached value of the '{@link #getSatisfiesSet() <em>Satisfies Set</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSatisfiesSet() - * @generated - * @ordered - */ - protected TagSet satisfiesSet = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ContainsTagConstraintImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ConstraintsPackage.Literals.CONTAINS_TAG_CONSTRAINT; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SetGenerator getSetGenerator() { - if (setGenerator != null && setGenerator.eIsProxy()) { - InternalEObject oldSetGenerator = (InternalEObject)setGenerator; - setGenerator = (SetGenerator)eResolveProxy(oldSetGenerator); - if (setGenerator != oldSetGenerator) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SET_GENERATOR, oldSetGenerator, setGenerator)); - } - } - return setGenerator; - } - - /** - * <!-- begin-user-doc --> - * @return the set generator - * <!-- end-user-doc --> - * @generated - */ - public SetGenerator basicGetSetGenerator() { - return setGenerator; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSetGenerator(SetGenerator newSetGenerator) { - SetGenerator oldSetGenerator = setGenerator; - setGenerator = newSetGenerator; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SET_GENERATOR, oldSetGenerator, setGenerator)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TagSet getSatisfiesSet() { - if (satisfiesSet != null && satisfiesSet.eIsProxy()) { - InternalEObject oldSatisfiesSet = (InternalEObject)satisfiesSet; - satisfiesSet = (TagSet)eResolveProxy(oldSatisfiesSet); - if (satisfiesSet != oldSatisfiesSet) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SATISFIES_SET, oldSatisfiesSet, satisfiesSet)); - } - } - return satisfiesSet; - } - - /** - * <!-- begin-user-doc --> - * @return the tag set that must be satisfied - * <!-- end-user-doc --> - * @generated - */ - public TagSet basicGetSatisfiesSet() { - return satisfiesSet; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSatisfiesSet(TagSet newSatisfiesSet) { - TagSet oldSatisfiesSet = satisfiesSet; - satisfiesSet = newSatisfiesSet; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SATISFIES_SET, oldSatisfiesSet, satisfiesSet)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SET_GENERATOR: - if (resolve) return getSetGenerator(); - return basicGetSetGenerator(); - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SATISFIES_SET: - if (resolve) return getSatisfiesSet(); - return basicGetSatisfiesSet(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SET_GENERATOR: - setSetGenerator((SetGenerator)newValue); - return; - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SATISFIES_SET: - setSatisfiesSet((TagSet)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SET_GENERATOR: - setSetGenerator((SetGenerator)null); - return; - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SATISFIES_SET: - setSatisfiesSet((TagSet)null); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SET_GENERATOR: - return setGenerator != null; - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT__SATISFIES_SET: - return satisfiesSet != null; - } - return super.eIsSet(featureID); - } - -} //ContainsTagConstraintImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/TagIdImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/TagIdImpl.java deleted file mode 100644 index a4f9985e2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/TagIdImpl.java +++ /dev/null @@ -1,215 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TagIdImpl.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage; -import org.eclipse.jst.jsf.validation.internal.constraints.TagId; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Tag Id</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.TagIdImpl#getUri <em>Uri</em>}</li> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.TagIdImpl#getName <em>Name</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class TagIdImpl extends EObjectImpl implements TagId { - /** - * The default value of the '{@link #getUri() <em>Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getUri() - * @generated - * @ordered - */ - protected static final String URI_EDEFAULT = null; - - /** - * The cached value of the '{@link #getUri() <em>Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getUri() - * @generated - * @ordered - */ - protected String uri = URI_EDEFAULT; - - /** - * The default value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TagIdImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ConstraintsPackage.Literals.TAG_ID; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getUri() { - return uri; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setUri(String newUri) { - String oldUri = uri; - uri = newUri; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ConstraintsPackage.TAG_ID__URI, oldUri, uri)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getName() { - return name; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setName(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ConstraintsPackage.TAG_ID__NAME, oldName, name)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ConstraintsPackage.TAG_ID__URI: - return getUri(); - case ConstraintsPackage.TAG_ID__NAME: - return getName(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ConstraintsPackage.TAG_ID__URI: - setUri((String)newValue); - return; - case ConstraintsPackage.TAG_ID__NAME: - setName((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case ConstraintsPackage.TAG_ID__URI: - setUri(URI_EDEFAULT); - return; - case ConstraintsPackage.TAG_ID__NAME: - setName(NAME_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case ConstraintsPackage.TAG_ID__URI: - return URI_EDEFAULT == null ? uri != null : !URI_EDEFAULT.equals(uri); - case ConstraintsPackage.TAG_ID__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (uri: "); - result.append(uri); - result.append(", name: "); - result.append(name); - result.append(')'); - return result.toString(); - } - -} //TagIdImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/TagSetImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/TagSetImpl.java deleted file mode 100644 index f3899144a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/impl/TagSetImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TagSetImpl.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.emf.ecore.util.EObjectResolvingEList; - -import org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage; -import org.eclipse.jst.jsf.validation.internal.constraints.TagId; -import org.eclipse.jst.jsf.validation.internal.constraints.TagSet; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Tag Set</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.validation.internal.constraints.impl.TagSetImpl#getTags <em>Tags</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class TagSetImpl extends EObjectImpl implements TagSet { - /** - * The cached value of the '{@link #getTags() <em>Tags</em>}' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getTags() - * @generated - * @ordered - */ - protected EList tags = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TagSetImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return ConstraintsPackage.Literals.TAG_SET; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getTags() { - if (tags == null) { - tags = new EObjectResolvingEList(TagId.class, this, ConstraintsPackage.TAG_SET__TAGS); - } - return tags; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ConstraintsPackage.TAG_SET__TAGS: - return getTags(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ConstraintsPackage.TAG_SET__TAGS: - getTags().clear(); - getTags().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case ConstraintsPackage.TAG_SET__TAGS: - getTags().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case ConstraintsPackage.TAG_SET__TAGS: - return tags != null && !tags.isEmpty(); - } - return super.eIsSet(featureID); - } - -} //TagSetImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsAdapterFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsAdapterFactory.java deleted file mode 100644 index ff1de0e99..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsAdapterFactory.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsAdapterFactory.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; - -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.jst.jsf.validation.internal.constraints.*; - -/** - * <!-- begin-user-doc --> - * The <b>Adapter Factory</b> for the model. - * It provides an adapter <code>createXXX</code> method for each class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage - * @generated - */ -public class ConstraintsAdapterFactory extends AdapterFactoryImpl { - /** - * The cached model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static ConstraintsPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ConstraintsAdapterFactory() { - if (modelPackage == null) { - modelPackage = ConstraintsPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> - * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. - * <!-- end-user-doc --> - * @return whether this factory is applicable for the type of the object. - * @generated - */ - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch the delegates to the <code>createXXX</code> methods. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ConstraintsSwitch modelSwitch = - new ConstraintsSwitch() { - public Object caseTagId(TagId object) { - return createTagIdAdapter(); - } - public Object caseTagSet(TagSet object) { - return createTagSetAdapter(); - } - public Object caseContainsTagConstraint(ContainsTagConstraint object) { - return createContainsTagConstraintAdapter(); - } - public Object defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the <code>target</code>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param target the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ - public Adapter createAdapter(Notifier target) { - return (Adapter)modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagId <em>Tag Id</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.validation.internal.constraints.TagId - * @generated - */ - public Adapter createTagIdAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.validation.internal.constraints.TagSet <em>Tag Set</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.validation.internal.constraints.TagSet - * @generated - */ - public Adapter createTagSetAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint <em>Contains Tag Constraint</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.validation.internal.constraints.ContainsTagConstraint - * @generated - */ - public Adapter createContainsTagConstraintAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * <!-- begin-user-doc --> - * This default implementation returns null. - * <!-- end-user-doc --> - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //ConstraintsAdapterFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsResourceFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsResourceFactoryImpl.java deleted file mode 100644 index e0da2ca89..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsResourceFactoryImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsResourceFactoryImpl.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * <!-- begin-user-doc --> - * The <b>Resource Factory</b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.util.ConstraintsResourceImpl - * @generated - */ -public class ConstraintsResourceFactoryImpl extends ResourceFactoryImpl { - /** - * Creates an instance of the resource factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ConstraintsResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Resource createResource(URI uri) { - XMLResource result = new ConstraintsResourceImpl(uri); - result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - - result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); - return result; - } - -} //ConstraintsResourceFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsResourceImpl.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsResourceImpl.java deleted file mode 100644 index c397df097..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsResourceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsResourceImpl.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; - -/** - * <!-- begin-user-doc --> - * The <b>Resource </b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.util.ConstraintsResourceFactoryImpl - * @generated - */ -public class ConstraintsResourceImpl extends XMLResourceImpl { - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param uri the URI of the new resource. - * @generated - */ - public ConstraintsResourceImpl(URI uri) { - super(uri); - } - -} //ConstraintsResourceImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsSwitch.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsSwitch.java deleted file mode 100644 index 9628616c4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsSwitch.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsSwitch.java,v 1.2 2007/04/09 02:40:07 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.jst.jsf.validation.internal.constraints.*; - -/** - * <!-- begin-user-doc --> - * The <b>Switch</b> for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the <code>caseXXX</code> method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage - * @generated - */ -public class ConstraintsSwitch { - /** - * The cached model package - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static ConstraintsPackage modelPackage; - - /** - * Creates an instance of the switch. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ConstraintsSwitch() { - if (modelPackage == null) { - modelPackage = ConstraintsPackage.eINSTANCE; - } - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - public Object doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param theEClass - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - List eSuperTypes = theEClass.getESuperTypes(); - return - eSuperTypes.isEmpty() ? - defaultCase(theEObject) : - doSwitch((EClass)eSuperTypes.get(0), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param classifierID - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case ConstraintsPackage.TAG_ID: { - TagId tagId = (TagId)theEObject; - Object result = caseTagId(tagId); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ConstraintsPackage.TAG_SET: { - TagSet tagSet = (TagSet)theEObject; - Object result = caseTagSet(tagSet); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ConstraintsPackage.CONTAINS_TAG_CONSTRAINT: { - ContainsTagConstraint containsTagConstraint = (ContainsTagConstraint)theEObject; - Object result = caseContainsTagConstraint(containsTagConstraint); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Tag Id</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Tag Id</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseTagId(TagId object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Tag Set</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Tag Set</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseTagSet(TagSet object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Contains Tag Constraint</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Contains Tag Constraint</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseContainsTagConstraint(ContainsTagConstraint object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>EObject</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public Object defaultCase(EObject object) { - return null; - } - -} //ConstraintsSwitch diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsXMLProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsXMLProcessor.java deleted file mode 100644 index 3d80420bb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/constraints/util/ConstraintsXMLProcessor.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ConstraintsXMLProcessor.java,v 1.1 2007/02/28 21:16:02 cbateman Exp $ - */ -package org.eclipse.jst.jsf.validation.internal.constraints.util; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.xmi.util.XMLProcessor; - -import org.eclipse.jst.jsf.validation.internal.constraints.ConstraintsPackage; - -/** - * This class contains helper methods to serialize and deserialize XML documents - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class ConstraintsXMLProcessor extends XMLProcessor { - /** - * Public constructor to instantiate the helper. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ConstraintsXMLProcessor() { - super((EPackage.Registry.INSTANCE)); - ConstraintsPackage.eINSTANCE.eClass(); - } - - /** - * Register for "*" and "xml" file extensions the ConstraintsResourceFactoryImpl factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Map getRegistrations() { - if (registrations == null) { - super.getRegistrations(); - registrations.put(XML_EXTENSION, new ConstraintsResourceFactoryImpl()); - registrations.put(STAR_EXTENSION, new ConstraintsResourceFactoryImpl()); - } - return registrations; - } - -} //ConstraintsXMLProcessor diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ASTSemanticValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ASTSemanticValidator.java deleted file mode 100644 index 2bb8348a2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ASTSemanticValidator.java +++ /dev/null @@ -1,638 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType; -import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.MethodType; -import org.eclipse.jst.jsf.common.internal.types.NullLiteralType; -import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType; -import org.eclipse.jst.jsf.common.internal.types.StringLiteralType; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.symbol.IInstanceSymbol; -import org.eclipse.jst.jsf.context.symbol.IPropertySymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.designtime.resolver.ISymbolContextResolver; -import org.eclipse.jst.jsf.designtime.resolver.StructuredDocumentSymbolResolverFactory; -import org.eclipse.jst.jsf.validation.internal.ELValidationPreferences; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.ValidationMessageFactory; -import org.eclipse.jst.jsf.validation.internal.el.operators.BinaryOperator; -import org.eclipse.jst.jsf.validation.internal.el.operators.BracketOperator; -import org.eclipse.jst.jsf.validation.internal.el.operators.DotOperator; -import org.eclipse.jst.jsf.validation.internal.el.operators.TernaryChoiceOperator; -import org.eclipse.jst.jsf.validation.internal.el.operators.UnaryOperator; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTAddExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTAndExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTChoiceExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTEqualityExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTFunctionInvocation; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTLiteral; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTMultiplyExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTOperatorExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTOrExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTRelationalExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTUnaryExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTValue; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTValuePrefix; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTValueSuffix; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserConstants; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserVisitor; -import org.eclipse.jst.jsp.core.internal.java.jspel.ParseException; -import org.eclipse.jst.jsp.core.internal.java.jspel.SimpleNode; -import org.eclipse.jst.jsp.core.internal.java.jspel.Token; -import org.eclipse.wst.validation.internal.core.Message; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidator; - - -class ASTSemanticValidator implements JSPELParserVisitor, IExpressionSemanticValidator -{ - private final IFile _targetFile; - private final ASTExpression _expr; - private final IStructuredDocumentContext _context; - private final ISymbolContextResolver _symbolResolver; - private final List<IMessage> _messages; - private final EvaluationTracker _tracker; - private final DiagnosticFactory _diagnosticFactory; - private final ELValidationPreferences _prefs; - private boolean _validatorHasBeenCalled; //=false - - ASTSemanticValidator(ASTExpression expr, IStructuredDocumentContext context, ELValidationPreferences prefs) - { - final IWorkspaceContextResolver resolver = - IStructuredDocumentContextResolverFactory. - INSTANCE.getWorkspaceContextResolver(context); - - if (resolver != null) - { - _targetFile = (IFile) resolver.getResource(); - } - else - { - _targetFile = null; - } - - _expr = expr; - _context = context; - _symbolResolver = StructuredDocumentSymbolResolverFactory.getInstance().getSymbolContextResolver(_context); - _messages = new ArrayList<IMessage>(); - _tracker = new EvaluationTracker(); - _diagnosticFactory = new DiagnosticFactory(); - _prefs = prefs; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.validation.internal.el.IExpressionSemanticValidator#validate() - */ - public void validate() - { - _expr.jjtAccept(this, _tracker); - _validatorHasBeenCalled = true; - } - - public Object visit(ASTAddExpression node, Object data) - { - performBinaryEvaluation(node, (EvaluationTracker)data); - return data; - } - - public Object visit(ASTAndExpression node, Object data) - { - performBinaryEvaluation(node, (EvaluationTracker)data); - return data; - } - - public Object visit(ASTChoiceExpression node, Object data) - { - if (node.jjtGetNumChildren() != 3) - { - throw new AssertionError("Binary operators should always have two sub-expressions"); - } - - // evaluate choice argument - node.jjtGetChild(0).jjtAccept(this, data); - final ValueType choiceArg = ((EvaluationTracker)data).getValueType(); - // evaluate when true argument - node.jjtGetChild(1).jjtAccept(this, data); - final ValueType whenTrueArg = ((EvaluationTracker)data).getValueType(); - //evaluate when false argument - node.jjtGetChild(2).jjtAccept(this, data); - final ValueType whenFalseArg = ((EvaluationTracker)data).getValueType(); - - - if (choiceArg != null && whenTrueArg != null && whenFalseArg != null) - { - final TernaryChoiceOperator operator = - new TernaryChoiceOperator(_diagnosticFactory); - - final Diagnostic diagnostic = - operator.validate(choiceArg/* whenTrueArg, whenFalseArg*/); - - if (diagnostic.getSeverity() != Diagnostic.OK) - { - final Token firstToken = node.getFirstToken(); - final int offset = _context.getDocumentPosition() + firstToken.beginColumn - 1; - final int length = node.getLastToken().endColumn - firstToken.beginColumn+1; - final Message message = - ValidationMessageFactory.createFromDiagnostic(diagnostic, - offset, length, _targetFile, _prefs); - _messages.add(message); - } - - ((EvaluationTracker)data).setType(operator.perform(choiceArg, whenTrueArg, whenFalseArg)); - } - else - { - ((EvaluationTracker)data).setType(null); - } - - return data; - } - - public Object visit(ASTEqualityExpression node, Object data) - { - performBinaryEvaluation(node, (EvaluationTracker)data); - return data; - } - - public Object visit(ASTExpression node, Object data) { - return node.childrenAccept(this, data); - } - - public Object visit(ASTFunctionInvocation node, Object data) - { - // when we see a function invocation, null the type - // we do not validate function invocations currently - Object retVal = node.childrenAccept(this, data); - ((EvaluationTracker)data).setType(null); - return retVal; - } - - public Object visit(ASTLiteral node, Object data) - { - // note, there is an implicit assumption here that literals - // are all terminals (leafs in the tree) - if (node.jjtGetNumChildren() > 0) - { - throw new AssertionError("Literals should be terminal"); - } - - LiteralType type = null; - - Token literalToken = node.getFirstToken(); - - switch (literalToken.kind) - { - case JSPELParserConstants.STRING_LITERAL: - type = new StringLiteralType(stripQuotes(literalToken.image)); - break; - - case JSPELParserConstants.INTEGER_LITERAL: - type = new IntegerLiteralType(Long.parseLong(literalToken.image)); - break; - - case JSPELParserConstants.FLOATING_POINT_LITERAL: - type = new FloatLiteralType(Double.parseDouble(literalToken.image)); - break; - - case JSPELParserConstants.FALSE: - type = BooleanLiteralType.FALSE; - break; - - case JSPELParserConstants.TRUE: - type = BooleanLiteralType.TRUE; - break; - - case JSPELParserConstants.NULL: - type = NullLiteralType.SINGLETON; - break; - - default: - JSFCorePlugin.log("Unknown EL literal: " +literalToken.toString(), new Throwable("This throwable simply used to mark a stack trace")); - } - - ((EvaluationTracker)data).setType(type); - return data; - } - - private String stripQuotes(String stringLiteral) - { - if (stringLiteral.startsWith("'") - || stringLiteral.startsWith("\"")) - - { - if (stringLiteral.length() > 2) - { - // take 'literal' -> literal - return stringLiteral.substring(1, stringLiteral.length()-1); - } - // if only two characters, then the empty string - return ""; - } - - return stringLiteral; - } - - public Object visit(ASTMultiplyExpression node, Object data) - { - performBinaryEvaluation(node, (EvaluationTracker)data); - return data; - } - - public Object visit(ASTOrExpression node, Object data) - { - performBinaryEvaluation(node, (EvaluationTracker)data); - return data; - } - - public Object visit(ASTRelationalExpression node, Object data) - { - performBinaryEvaluation(node, (EvaluationTracker)data); - return data; - } - - public Object visit(ASTUnaryExpression node, Object data) - { - // assertion here is that this expression decomposes: - // UnaryExpr -> Value - // UnaryExpr -> UnaryOp UnaryExpression - // since UnaryOp is a terminal (-,!,not,empty) node will - // always have exactly one child - node.childrenAccept(this, data); - final SignatureBasedType type = ((EvaluationTracker)data).getType(); - - if (type != null) - { - final Token firstToken = node.getFirstToken(); - if (UnaryOperator.isUnaryOperator(firstToken)) - { - if (type instanceof ValueType) - { - final UnaryOperator unaryOp = UnaryOperator.createUnaryOperator(firstToken, _diagnosticFactory); - final Diagnostic diagnostic = unaryOp.validate((ValueType)type); - - if (diagnostic.getSeverity() != Diagnostic.OK) - { - final int offset = _context.getDocumentPosition() + firstToken.beginColumn - 1; - final int length = node.getLastToken().endColumn - firstToken.beginColumn+1; - final Message message = - ValidationMessageFactory.createFromDiagnostic(diagnostic, offset, length, _targetFile,_prefs); - _messages.add(message); - } - - ((EvaluationTracker)data). - setType(unaryOp.performOperation ((ValueType)type)); - } - // cannot apply operations to method bindings - else - { - final int offset = _context.getDocumentPosition() + - firstToken.beginColumn - 1; - final int length = node.getLastToken().endColumn - - firstToken.beginColumn+1; - - _messages.add(ValidationMessageFactory. - createFromDiagnostic(_diagnosticFactory.create_CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING(), - offset, length, _targetFile,_prefs)); - } - } - } - - return data; - } - - public Object visit(ASTValue node, final Object data) { - ValueExpressionTracker tracker = new ValueExpressionTracker(); - - ((EvaluationTracker)data).setValueTracker(tracker); - - node.childrenAccept(this, data); - - SignatureBasedType type = ((EvaluationTracker)data).getType(); - - // now check the tracker. If the last property in the expression - // is non-null (i.e. the value has one or more suffices) then we - // to very the leaf node (i.e. 'z' in #{x.y.z}) is more than just - // an intermediate value used to get to other properties - if (type instanceof IObjectSymbolBasedValueType - && ((IObjectSymbolBasedValueType)type).getSymbol() instanceof IPropertySymbol - && ((IPropertySymbol)((IObjectSymbolBasedValueType)type).getSymbol()).isIntermediate()) - { - final int problemStartOffset = tracker.getCurPropertySymbolOffset(); - final int length = tracker.getCurPropertySymbolLength(); - _messages.add(ValidationMessageFactory.createFromDiagnostic( - _diagnosticFactory.create_MEMBER_NOT_FOUND( - ((IPropertySymbol)((IObjectSymbolBasedValueType)type).getSymbol()).getName() - , tracker.getRootSymbolName()) - , problemStartOffset, length, _targetFile, _prefs)); - } - - return data; - } - - public Object visit(ASTValuePrefix node, final Object data) - { - if (node.jjtGetNumChildren() == 0) - { - final Token token = node.getFirstToken(); - final String image = token.image; - - final ISymbol symbol = _symbolResolver.getVariable(image); - - if (symbol == null) - { - final int problemStartOffset = - _context.getDocumentPosition() + token.beginColumn - 1; - final int length = token.endColumn - token.beginColumn + 1; - - final Diagnostic diag = - _diagnosticFactory.create_VARIABLE_NOT_FOUND(image); - - if (diag.getSeverity() != Diagnostic.OK) - { - _messages.add( - ValidationMessageFactory.createFromDiagnostic(diag, - problemStartOffset, length, _targetFile, _prefs)); - } - } - else if (symbol instanceof IInstanceSymbol) - { - final IObjectSymbolBasedValueType symbolType = - IObjectSymbolBasedValueType.getInstance(symbol); - ((EvaluationTracker) data).setType(symbolType); - } - } - - return node.childrenAccept(this, data); - } - - public Object visit(final ASTValueSuffix node, final Object data) - { - final ValueExpressionTracker tracker = ((EvaluationTracker) data).getValueTracker(); - final SignatureBasedType type = ((EvaluationTracker) data).getType(); - - if (type instanceof IObjectSymbolBasedValueType) - { - final IObjectSymbolBasedValueType symbolType = - (IObjectSymbolBasedValueType) type; - final Token firstToken = node.getFirstToken(); - - if (node.jjtGetNumChildren() == 0 - && firstToken.kind == JSPELParserConstants.DOT) - { - final Token dotId = node.getLastToken(); - - final int startOffset = - _context.getDocumentPosition() + dotId.beginColumn - 1; - final int length = dotId.endColumn - dotId.beginColumn + 1; - - final DotOperator dotOp = new DotOperator(_diagnosticFactory, _targetFile); - - final StringLiteralType suffixLiteral = new StringLiteralType(dotId.image); - Diagnostic diag = - dotOp.validate(symbolType, - suffixLiteral); - - if (diag.getSeverity() != Diagnostic.OK) - { - _messages.add(ValidationMessageFactory.createFromDiagnostic( - diag, startOffset, length, _targetFile, _prefs)); - ((EvaluationTracker) data).setType(null); - } - else - { -// // if the base (value-a) is a map, then using the bracket value-a['y'] type -// // syntax is recommended. Note that we do this here instead of -// // DotOperator so that we don't tie the default property resolver -// // behaviour to that operator class. If someone changes the rules -// // of how the prop resolver interprets the base, then they may want to -// // write their own validator that doesn't do this -// if (symbolType.getSymbol().supportsCoercion(TypeConstants.TYPE_MAP)) -// { -// _messages.add(ValidationMessageFactory.createFromDiagnostic( -// DiagnosticFactory.create_BINARY_OP_DOT_WITH_VALUEA_MAP_SHOULD_USE_ARRAY -// (symbolType.getSymbol().getName(), dotId.image), -// startOffset, length, _targetFile)); -// } - - ((EvaluationTracker) data).setType(dotOp.performOperation(symbolType, - suffixLiteral)); - tracker.setCurMemberSymbol(startOffset, length); - } - - // we finished with the single dot suffix here - return data; - } - else if (firstToken.kind == JSPELParserConstants.LBRACKET) - { - final EvaluationTracker subExprTracker = new EvaluationTracker(); - node.childrenAccept(this, subExprTracker); - - final SignatureBasedType subExprType = subExprTracker.getType(); - - if (subExprType instanceof ValueType) - { - final Token lastToken = node.getLastToken(); - final int startOffset = - _context.getDocumentPosition() + firstToken.beginColumn - 1; - final int length = lastToken.endColumn - firstToken.beginColumn + 1; - - final BracketOperator bracketOperator = new BracketOperator(_diagnosticFactory, _targetFile); - - final Diagnostic diag = - bracketOperator.validate(symbolType, - (ValueType)subExprType); - - if (diag.getSeverity() != Diagnostic.OK) - { - _messages.add(ValidationMessageFactory.createFromDiagnostic( - diag, - startOffset, length, _targetFile, _prefs)); - ((EvaluationTracker) data).setType(null); - } - else - { - ((EvaluationTracker) data).setType(bracketOperator.performOperation(symbolType, - (ValueType)subExprType)); - tracker.setCurMemberSymbol(startOffset, length); - } - } - // we are finished with the bracketed suffix at this point. - return data; - } - } - - // don't bother to accept children, since if we haven't done - // something above, there's not much sensible we can do with it - // clear the type first though - ((EvaluationTracker) data).setType(null); - return data; //node.childrenAccept(this, data); - } - - public Object visit(SimpleNode node, Object data) { - return node.childrenAccept(this, data); - } - - /** - * Copies stored messages into the validation reporter - * @param validator - * @param reporter - */ - public void reportFindings(IValidator validator, IReporter reporter) - { - for (final Iterator<IMessage> it = _messages.iterator(); it.hasNext();) - { - IMessage message = it.next(); - - // don't report messages that have no severity. - if ((message.getSeverity() & IMessage.ALL_MESSAGES) != 0) - { - reporter.addMessage(validator, message); - } - } - } - - private void performBinaryEvaluation(ASTOperatorExpression node, EvaluationTracker tracker) - { - if (node.jjtGetNumChildren() < 2) - { - throw new AssertionError("Binary operators should always have at least two sub-expressions"); - } - else if (node.getOperatorTokens().size() != node.jjtGetNumChildren()-1) - { - throw new AssertionError("Binary operators should always have one operator token less than number of sub-expressions"); - } - - // evaluate left-most argument - node.jjtGetChild(0).jjtAccept(this, tracker); - - ValueType curType = getValueTypeForBinaryOperation(tracker.getType(), (SimpleNode) node.jjtGetChild(0)); - - for (int child = 1; child < node.jjtGetNumChildren(); child++) - { - // evaluate next argument running left-to-right - node.jjtGetChild(child).jjtAccept(this, tracker); - final ValueType secondType = - getValueTypeForBinaryOperation(tracker.getType(), (SimpleNode) node.jjtGetChild(child)); - - if (curType != null && secondType != null) - { - final BinaryOperator operator = - BinaryOperator.getBinaryOperator((Token)node.getOperatorTokens().get(child-1), _diagnosticFactory, _context); - - final Diagnostic diagnostic = operator.validate(curType, secondType); - - if (diagnostic.getSeverity() != Diagnostic.OK) - { - final Token firstToken = node.getFirstToken(); - final int offset = _context.getDocumentPosition() + firstToken.beginColumn - 1; - final int length = node.getLastToken().endColumn - firstToken.beginColumn+1; - final Message message = - ValidationMessageFactory.createFromDiagnostic - (diagnostic, offset, length, _targetFile, _prefs); - _messages.add(message); - } - - curType = operator.performOperation(curType, secondType); - } - } - - tracker.setType(curType); - } - - private ValueType getValueTypeForBinaryOperation(SignatureBasedType type, SimpleNode node) - { - if (type instanceof ValueType) - { - return (ValueType) type; - } - else if (type instanceof MethodType) - { - final int offset = _context.getDocumentPosition() + node.getFirstToken().beginColumn - 1; - final int length = node.getLastToken().endColumn - node.getFirstToken().beginColumn+1; - - _messages.add(ValidationMessageFactory.createFromDiagnostic - (_diagnosticFactory.create_CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING(), - offset, length, _targetFile, _prefs)); - } - - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.validation.internal.el.IExpressionSemanticValidator#getMessages() - */ - public List getMessages() - { - if (!_validatorHasBeenCalled) - { - throw new AssertionError("Should not call getMessages before validate has been called"); - } - return _messages; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.validation.internal.el.IExpressionSemanticValidator#getExpressionType() - */ - public SignatureBasedType getExpressionType() - { - return _tracker.getType(); - } - - /** - * @param args - * @throws IOException - * @throws ParseException - */ - public static void main(String[] args) throws IOException, ParseException - { - String elText = ""; - int nextCharacter; - - while(((nextCharacter = System.in.read()) != -1)) - { - char nextChar = (char) nextCharacter; - - if (nextChar == '\n') - { - JSPELParser parser = JSPELParser.createParser(elText); - ASTExpression expr = parser.Expression(); - expr.dump(""); - - elText = ""; - } - else - { - elText += nextChar; - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java deleted file mode 100644 index 055311a68..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java +++ /dev/null @@ -1,207 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jst.jsf.common.internal.types.CompositeType; -import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.validation.internal.ELValidationPreferences; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.ValidationMessageFactory; -import org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser; -import org.eclipse.jst.jsp.core.internal.java.jspel.ParseException; -import org.eclipse.jst.jsp.core.internal.java.jspel.Token; -import org.eclipse.jst.jsp.core.internal.java.jspel.TokenMgrError; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidator; - -/** - * Validates a single expression string - * - * @author cbateman - * - */ -public class ELExpressionValidator -{ - private final IStructuredDocumentContext _context; - private final String _elText; - private final IFile _file; - private final DiagnosticFactory _diagnosticFactory; - private final ELValidationPreferences _prefs; - - private final List<IMessage> _syntaxProblems; - private ASTSemanticValidator _semanticValidator; - - /** - * @param context - * @param elText - * @param file - * @param prefs - */ - public ELExpressionValidator(final IStructuredDocumentContext context, - final String elText, - final IFile file, - final ELValidationPreferences prefs) - { - _context = context; - _elText = elText; - _file = file; - _prefs = prefs; - _diagnosticFactory = new DiagnosticFactory(); - _syntaxProblems = new ArrayList<IMessage>(); - } - - /** - * Validates a single EL expression in an XML attribute value - * @return an ASTExpression for the node - */ - public ASTExpression validateXMLNode() - { - JSPELParser elParser = JSPELParser.createParser(_elText); - // = - try { - //final long startParsing = System.currentTimeMillis(); - final ASTExpression expr = elParser.Expression(); - //final long endParsing = System.currentTimeMillis(); - //final long startSemantics = System.currentTimeMillis(); - validateSemantics(expr, _context); - //final long endSemantics = System.currentTimeMillis(); - - - //System.out.println("Time to parse '"+elText+"' = "+(endParsing-startParsing)); - //System.out.println("Time to semantic checking '"+elText+"' = "+(endSemantics-startSemantics)); - - // if the parser bailed before parsing the whole - // expression, raise a warning that there is probably - // some syntatical issue - if (expr.getLastToken().endColumn < _elText.trim().length()-1) - { - int offset = _context.getDocumentPosition() + expr.getLastToken().endColumn; - int length = _elText.trim().length() - expr.getLastToken().endColumn; - - _syntaxProblems.add( - ValidationMessageFactory.createFromDiagnostic( - _diagnosticFactory.create_GENERAL_SYNTAX_ERROR(), - offset, length, _file, _prefs)); - } - - return expr; - } - catch (ParseException e) { - Token curTok = e.currentToken; - int offset = _context.getDocumentPosition() + curTok.beginColumn; - int length = curTok.endColumn - curTok.beginColumn + 1; - _syntaxProblems.add( - ValidationMessageFactory.createFromDiagnostic( - _diagnosticFactory.create_GENERAL_SYNTAX_ERROR(), - offset, length, _file, _prefs)); - return null; - } - catch (TokenMgrError te) { - final int offset = _context.getDocumentPosition(); - final int length = _elText.length(); - _syntaxProblems.add( - ValidationMessageFactory.createFromDiagnostic( - _diagnosticFactory.create_GENERAL_SYNTAX_ERROR(), - offset, length, _file, _prefs)); - return null; - } - } - - /** - * Report the results of this EL Expression validation to reportor - * using validator as a source - * - * @param validator - * @param reporter - */ - public void reportFindings(IValidator validator, IReporter reporter) - { - for (final Iterator<IMessage> it = _syntaxProblems.iterator(); it.hasNext();) - { - IMessage message = it.next(); - - // don't report messages that have no severity level - if ((message.getSeverity() & IMessage.ALL_MESSAGES) != 0) - { - reporter.addMessage(validator, message); - } - } - - if (_semanticValidator != null) - { - _semanticValidator.reportFindings(validator,reporter); - } - } - - /** - * @return the type of the expression or null if - * the type could not be evaluated - */ - public CompositeType getExpressionType() - { - if (_semanticValidator != null) - { - final SignatureBasedType type = - _semanticValidator.getExpressionType(); - - if (type != null) - { - return type.toCompositeType(); - } - } - - return null; - } - - /** - * @return an unmodifiable list containing all the detected syntax errors - * or an empty list if validate has not yet been called. - */ - public List getSyntaxProblems() - { - return Collections.unmodifiableList(_syntaxProblems); - } - - /** - * @return the EL semantic validator for this expression validitor or - * null if one has not yet been constructor. One will only be construct - * if validate is called and the expression does not have any syntax errors. - */ - public IExpressionSemanticValidator getSemanticValidator() - { - return _semanticValidator; - } - - /** - * Validates the context-specific data for one EL expressino - * - * @param expr - * @param file - * @param reporter - * @param context - */ - private void validateSemantics(ASTExpression expr,IStructuredDocumentContext context) - { - _semanticValidator = new ASTSemanticValidator(expr, context, _prefs); - _semanticValidator.validate(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/EvaluationTracker.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/EvaluationTracker.java deleted file mode 100644 index aec1b214d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/EvaluationTracker.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el; - -import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType; -import org.eclipse.jst.jsf.common.internal.types.ValueType; - -/** - * Used to track the evaulation of an EL expression AST - * - * @author cbateman - * - */ -class EvaluationTracker -{ - private ValueExpressionTracker _valueTracker; - private SignatureBasedType _type; - - /** - * @return the current value expression tracker or null if not set - */ - public ValueExpressionTracker getValueTracker() { - return _valueTracker; - } - - /** - * @param valueTracker - */ - public void setValueTracker(ValueExpressionTracker valueTracker) { - _valueTracker = valueTracker; - } - - /** - * @return the currently resolved type or null if not yet resolved - * or not able to resolve - */ - public SignatureBasedType getType() { - return _type; - } - - /** - * @param type - */ - public void setType(SignatureBasedType type) { - _type = type; - } - - /** - * @return if getType() is a ValueType, returns it otherwise null - */ - public ValueType getValueType() - { - if (_type instanceof ValueType) - { - return (ValueType) _type; - } - - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/IExpressionSemanticValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/IExpressionSemanticValidator.java deleted file mode 100644 index cf8d2d9b0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/IExpressionSemanticValidator.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.el; - -import java.util.List; - -import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType; - -/** - * Exposes certain parts of the ASTSemanticValidator without exposing the whole class - * Primarily this was done for JUnit testing - * - * @author cbateman - * - */ -public interface IExpressionSemanticValidator { - - /** - * Performs the semantic validatino - */ - public abstract void validate(); - - /** - * @return the list of generated message (may be empty if validate has not been called). - */ - public abstract List getMessages(); - - /** - * @return the value type of fully resolved expression - * or null if not resolved (or could not be resolved) - */ - public abstract SignatureBasedType getExpressionType(); - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/QuickFixAssistant.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/QuickFixAssistant.java deleted file mode 100644 index 89ff50f04..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/QuickFixAssistant.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el; - - -/** - * @author cbateman - * - */ -public class QuickFixAssistant //extends CorrectionAssistantProvider -{ -/* public IContentAssistant getCorrectionAssistant(ISourceViewer sourceViewer) { - IContentAssistant ca = null; - - if (sourceViewer != null) { - ContentAssistant assistant = new ContentAssistant(); - - if (sourceViewer != null) { - IContentAssistProcessor correctionProcessor = new CorrectionProcessorXML(sourceViewer); - assistant.setContentAssistProcessor(correctionProcessor, IJSPPartitions.JSP_DEFAULT_EL2); - } - ca = assistant; - } - - return ca; - - } - - private class CorrectionProcessorXML extends StructuredCorrectionProcessor { - /** - * quick assist processor - */ -/* protected IQuickAssistProcessor fQuickAssistProcessor; - /** - * quick fix processor - */ -/* protected IQuickFixProcessor fQuickFixProcessor; - - /** - * @param sourceViewer - */ -/* public CorrectionProcessorXML(ISourceViewer sourceViewer) { - super(sourceViewer); - } - - protected IQuickAssistProcessor getQuickAssistProcessor() { - if (fQuickAssistProcessor == null) - fQuickAssistProcessor = new IQuickAssistProcessor() - { - public boolean canAssist(StructuredTextViewer viewer, int offset) - { - return true; - } - - /** - * Collects proposals for assistant at the given offset. - */ -/* public ICompletionProposal[] getProposals(StructuredTextViewer viewer, int offset) throws CoreException - { - final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE.getContext(viewer, offset); - final ITextRegionContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE.getTextRegionResolver(context); - - if (resolver == null) - { - return new ICompletionProposal[0]; - } - - final String regionType = resolver.getRegionType(); - final List proposals = new ArrayList(); - - if (DOMJSPRegionContexts.JSP_VBL_CONTENT.equals(regionType)) - { - final String elText = resolver.getRegionText(); - final StringReader reader = new StringReader(elText); - final JSPELParser parser = new JSPELParser(reader); - - try - { - final ASTExpression expr = parser.Expression(); - final IExpressionSemanticValidator validator = new ASTSemanticValidator(expr, context); - validator.validate(); - -// for (final Iterator it = validator.getMessages().iterator(); it.hasNext();) -// { -// // TODO:MyLocalizedMessage message = (MyLocalizedMessage) it.next(); -// -// if (message.appliesTo(offset)) -// { - throw new UnsupportedOperationException("TODO:"); -// switch(message.getErrorCode()) -// { - //TODO: -// case Messages.ERROR_CODE_BEANNAME_NOT_FOUND: -// { -// final String beanName = -// (String) message.getAttribute("name"); -// proposals.add(new ELContentAssistProposal(beanName, ((IFile)message.getTargetObject()).getProject())); -// } -// break; -// } -// } -// } - } - catch (ParseException pe) - { - // left empty on purpose - } - } - - return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[0]); - } - }; - - return fQuickAssistProcessor; - } - - protected IQuickFixProcessor getQuickFixProcessor() { - if (fQuickFixProcessor == null) - { - // TODO: should use the approach where possible, but the Annotation doesn't pass - // enough info - fQuickFixProcessor = new QuickFixProcessorXML() - { - public boolean canFix(Annotation annnotation) - { - return true; - } - - public ICompletionProposal[] getProposals(Annotation annnotation) throws CoreException - { - return new ICompletionProposal[0]; - } - }; - } - - return fQuickFixProcessor; - } - }*/ -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ValueExpressionTracker.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ValueExpressionTracker.java deleted file mode 100644 index c5bf4bcc2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ValueExpressionTracker.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el; - - -class ValueExpressionTracker -{ - private String _rootSymbol; - - private int _curPropertySymbolOffset; - private int _curPropertySymbolLength; - - /** - * @return the root symbol or null if not set - */ - public String getRootSymbolName() { - return _rootSymbol; - } - - /** - * @param newName - */ - public void setRootSymbolName(String newName) - { - _rootSymbol = newName; - } - - /** - * @param offset - * @param length - */ - public void setCurMemberSymbol(int offset, int length) - { - _curPropertySymbolOffset = offset; - _curPropertySymbolLength = length; - } - - /** - * @return the offset of the current property symbol or 0 if no current property symbol - */ - public int getCurPropertySymbolOffset() - { - return _curPropertySymbolOffset; - } - - /** - * @return the length of the current property symbol or 0 if no current property symbol - */ - public int getCurPropertySymbolLength() - { - return _curPropertySymbolLength; - } - - /** - * @return the type of this value expression or null if it cannot be - * resolved - * @throws IllegalStateException if root symbol is not yet set - */ -// public SignatureBasedType resolveType() -// { -// if (!_isRootValid || _rootSymbol == null) -// { -// throw new IllegalStateException("Cannot resolve type without root symbol"); -// } -// -// // if there's been an error resolving the expression semantics, don't -// // bother trying to determine type -// if (_errorFlag) -// { -// return null; -// } -// -// if (_curMemberSymbol instanceof IMethodSymbol) -// { -// return new MethodType(_curMemberSymbol.getName(), -// ((IMethodSymbol)_curMemberSymbol).getSignature()); -// } -// -// IObjectSymbol objectSymbol = null; -// -// // no properties, so resolve root's type -// if (_curMemberSymbol == null) -// { -// objectSymbol = _rootSymbol; -// } -// else -// { -// objectSymbol = (IObjectSymbol) _curMemberSymbol; -// } -// -// final ITypeDescriptor typeDesc = objectSymbol.getTypeDescriptor(); -// int assignability = 0; -// assignability |= objectSymbol.isReadable() -// ? IAssignable.ASSIGNMENT_TYPE_RHS -// : 0; -// assignability |= objectSymbol.isWritable() -// ? IAssignable.ASSIGNMENT_TYPE_LHS -// : 0; -// final String typeDescString = typeDesc.getTypeSignature(); -// final String[] superTypes = (String[]) -// typeDesc.getSuperTypeSignatures().toArray(new String[0]); -// final String[] interfaceTypes = (String[]) -// typeDesc.getInterfaceTypeSignatures().toArray(new String[0]); -// -// return new ValueType(typeDescString, superTypes, interfaceTypes, -// assignability); -// } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/DiagnosticFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/DiagnosticFactory.java deleted file mode 100644 index 0cb7f568d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/DiagnosticFactory.java +++ /dev/null @@ -1,537 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation7 - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.diagnostics; - -import java.text.MessageFormat; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.validation.internal.ELValidationPreferences; -import org.eclipse.osgi.util.NLS; - -/** - * Factory for all operator diagnostics. Class should - * not be implemented, instantiated or sub-classed. - * - * @author cbateman - * - */ -public final class DiagnosticFactory -{ - - /** - * Problem id - */ - public final static int BINARY_OP_BOTH_OPERANDS_NULL_ID = 0; - /** - * Problem id - */ - public final static int BINARY_OP_POSSIBLE_DIVISION_BY_ZERO_ID = 1; - /** - * Problem id - */ - public final static int BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID = 2; - /** - * Problem id - */ - public final static int BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME_ID = 3; - /** - * Problem id - */ - public final static int BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME_ID = 4; - /** - * Problem id - */ - public final static int BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID = 5; - /** - * Problem id - */ - public final static int BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS_ID = 6; - /** - * Problem id - */ - public final static int BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME_ID = 7; - /** - * Problem id - */ - public final static int BINARY_OP_NO_AVAILABLE_TYPE_COERCION_ID = 8; - /** - * Problem id - */ - public final static int BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS_ID = 9; - /** - * Problem id - */ - public final static int UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID = 10; - /** - * Problem id - */ - public final static int UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE_ID = 11; - /** - * Problem id - */ - public final static int UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO_ID = 12; - /** - * Problem id - */ - public final static int UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID = 13; - /** - * Problem id - */ - public final static int UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID = 14; - /** - * Problem id - */ - public final static int TERNARY_OP_CHOICE_IS_ALWAYS_SAME_ID = 15; - /** - * Problem id - */ - public final static int TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID = 16; - /** - * Problem id - */ - public final static int UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED_ID = 17; - /** - * Problem id - */ - public final static int CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING_ID = 18; - /** - * Problem id - */ - public final static int MEMBER_NOT_FOUND_ID = 19; - /** - * Problem id - */ - public final static int VARIABLE_NOT_FOUND_ID = 20; - /** - * Problem id - */ - public final static int MISSING_CLOSING_EXPR_BRACKET_ID = 21; - /** - * Problem id - */ - public final static int GENERAL_SYNTAX_ERROR_ID = 22; - /** - * Problem id - */ - public final static int EMPTY_EL_EXPRESSION_ID = 23; - - /** - * - */ - public final static int BINARY_OP_DOT_WITH_VALUEB_NULL_ID = 24; - - /** - * Identifies a problem where we have x.y and x is a map. In this case - * the recommend syntax is x['y'] - */ - public final static int BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY_ID = 25; - - /** - * Indicates that a numeric array accessor is being used with a value - * which is either < 0 or may be greater than the assumed size of the array - */ - public final static int POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS_ID = 26; - - /** - * Identifies the problem where an expr like bean.enumProp == 'blah' - * but 'blah' does not match any of the possible enum constants, meaning - * that the operation will always resolve to a constant value (in this case false) - */ - public final static int BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME_ID = 27; - - /** - * Identifies a problem where two enum variables are compared but the enums are - * not compatible. i.e. bean.enum1 < bean.enum2. Enum.compareTo() may throw - * an exception in this case (CCE). - */ - public final static int BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE_ID = 28; - - /** - * Count of ids - */ - public final static int NUM_IDS = 29; - - /** - * @param operatorName - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_BOTH_OPERANDS_NULL(final String operatorName) - { - final String message = NLS.bind( - Messages.BINARY_OP_BOTH_OPERANDS_NULL, operatorName); - return create(BINARY_OP_BOTH_OPERANDS_NULL_ID, message); - } - - private static Diagnostic DIAGNOSTIC_POSSIBLE_DIV_BY_ZERO; - - /** - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO() - { - if (DIAGNOSTIC_POSSIBLE_DIV_BY_ZERO == null) - { - final String message = Messages.POSSIBLE_DIV_BY_ZERO; - DIAGNOSTIC_POSSIBLE_DIV_BY_ZERO = - create(BINARY_OP_POSSIBLE_DIVISION_BY_ZERO_ID, message); - } - return DIAGNOSTIC_POSSIBLE_DIV_BY_ZERO; - } - - /** - * @param operatorName - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(final String operatorName) - { - final String message = - NLS.bind(Messages.BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION, operatorName); - return create(BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID, message); - } - - /** - * @param operatorName - * @param value - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME(final String operatorName, final String value) - { - final String message = - NLS.bind(Messages.BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME,operatorName, value); - return create(BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME_ID, message); - } - - /** - * @param value - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME(final String value) - { - final String message = - NLS.bind(Messages.BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME, value); - return create(BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME_ID, message); - } - - /** - * @param whichArgument - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN(final String whichArgument) - { - final String message = - NLS.bind(Messages.BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN, whichArgument); - return create(BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID, message); - } - - /** - * @param shortCircuitValue - * @param operatorName - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS(boolean shortCircuitValue, String operatorName) - { - final String message = - NLS.bind(Messages.BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS, - Boolean.valueOf(shortCircuitValue), operatorName); - return create(BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS_ID, message); - } - - /** - * @param shortCircuitValue - * @param operatorName - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME(final boolean shortCircuitValue, final String operatorName) - { - final String message = - NLS.bind(Messages.BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME, - Boolean.valueOf(shortCircuitValue), operatorName); - - return create(BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME_ID, message); - } - - private static Diagnostic DIAGNOSTIC_NO_AVAILABLE_TYPE_COERCION; - - /** - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_NO_AVAILABLE_TYPE_COERCION() - { - if (DIAGNOSTIC_NO_AVAILABLE_TYPE_COERCION == null) - { - DIAGNOSTIC_NO_AVAILABLE_TYPE_COERCION = - create(BINARY_OP_NO_AVAILABLE_TYPE_COERCION_ID, - Messages.BINARY_OP_NO_AVAILABLE_TYPE_COERCION); - } - - return DIAGNOSTIC_NO_AVAILABLE_TYPE_COERCION; - } - - private static Diagnostic DIAGNOSTIC_COULD_NOT_COERCE_LITERALS; - - /** - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS() - { - if (DIAGNOSTIC_COULD_NOT_COERCE_LITERALS == null) - { - DIAGNOSTIC_COULD_NOT_COERCE_LITERALS = - create(BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS_ID, - Messages.BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS); - } - - return DIAGNOSTIC_COULD_NOT_COERCE_LITERALS; - } - - /** - * @param operatorName - * @param value - * @return a configured diagnostic - */ - public Diagnostic create_UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID(final String operatorName, final String value) - { - final String message = - NLS.bind(Messages.UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME, - operatorName, value); - return create(UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID, message); - } - - /** - * @return a configured diagnostic - */ - public Diagnostic create_UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE() - { - return create(UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE_ID, - Messages.UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE); - } - - /** - * @return a configured diagnostic - */ - public Diagnostic create_UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO() - { - return create(UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO_ID, - Messages.UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO); - } - - /** - * @param operatorName - * @return a configured diagnostic - */ - public Diagnostic create_UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(final String operatorName) - { - final String message = - NLS.bind(Messages.UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION, - operatorName); - return create(UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION_ID, message); - } - - /** - * @param operatorName - * @return a configured diagnostic - */ - public Diagnostic create_UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED(final String operatorName) - { - final String message = - NLS.bind(Messages.UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED, - operatorName); - return create(UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED_ID, message); - } - - /** - * @return a configured diagnostic - */ - public Diagnostic create_UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN() - { - return create(UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN_ID, - Messages.UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN); - } - - /** - * @param result - * @param whichSelected - * @return a configured diagnostic - */ - public Diagnostic create_TERNARY_OP_CHOICE_IS_ALWAYS_SAME(boolean result, String whichSelected) - { - final String message = - NLS.bind(Messages.TERNARY_OP_CHOICE_IS_ALWAYS_SAME, - Boolean.valueOf(result), whichSelected); - return create(TERNARY_OP_CHOICE_IS_ALWAYS_SAME_ID, message); - } - - /** - * @return a configured diagnostic - */ - public Diagnostic create_TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN() - { - return create(TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID, - Messages.TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID); - } - - /** - * Method bindings cannot participate in expressions involving operators - * Per JSP 1.1 spec section 5.2.1 - * - * @return a configured message - */ - public Diagnostic create_CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING() - { - return create(CANNOT_APPLY_OPERATOR_TO_METHOD_BINDING_ID, - Messages.CANNOT_APPLY_OPERATORS_TO_MB); - } - - /** - * @param curMemberSymbol - * @param owningMember - * @return a configured message - */ - public Diagnostic create_MEMBER_NOT_FOUND(String curMemberSymbol, String owningMember) - { - return create(MEMBER_NOT_FOUND_ID, - NLS.bind(Messages.VM_PROP_NAME_NOT_FOUND, curMemberSymbol, owningMember)); - } - - /** - * @param variableName - * @return a configured message - */ - public Diagnostic create_VARIABLE_NOT_FOUND(String variableName) - { - return create(VARIABLE_NOT_FOUND_ID - , NLS.bind(Messages.VM_ROOT_NAME_NOT_FOUND, variableName)); - } - - /** - * @return a configured message - */ - public Diagnostic create_MISSING_CLOSING_EXPR_BRACKET() - { - return create(MISSING_CLOSING_EXPR_BRACKET_ID - , Messages.MISSING_CLOSING_EXPR_BRACKET); - } - - /** - * @return a configured message - */ - public Diagnostic create_GENERAL_SYNTAX_ERROR() - { - return create(GENERAL_SYNTAX_ERROR_ID, Messages.GENERAL_SYNTAX_ERROR); - } - - /** - * @return a configured message - */ - public Diagnostic create_EMPTY_EL_EXPRESSION() - { - return create(EMPTY_EL_EXPRESSION_ID, Messages.EMPTY_EL_EXPRESSION); - } - - /** - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_DOT_WITH_VALUEB_NULL() - { - return create(BINARY_OP_DOT_WITH_VALUEB_NULL_ID - , Messages.BINARY_OP_DOT_WITH_VALUEB_NULL); - } - - /** - * @param valAName - * @param valueBName - * @return a configured diagnostic - */ - public Diagnostic create_BINARY_OP_DOT_WITH_VALUEA_MAP_SHOULD_USE_ARRAY(final String valAName, final String valueBName) - { - final Object[] formatArgs = new Object[] {valAName, valueBName}; - return create(BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY_ID, - MessageFormat.format(Messages.BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY,formatArgs)); - } - - /** - * @param value - * @return an array index out of bounds diagnostic - */ - public Diagnostic create_POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS(final Integer value) - { - final Object[] formatArgs = new Object[] {value}; - - return create(POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS_ID - , MessageFormat.format(Messages.POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS,formatArgs)); - } - - /** - * @param operatorName - * @param invariantResult - * @param enumName - * @param fieldName - * @return a diagnostic - */ - public Diagnostic create_BINARY_COMPARISON_WITH_ENUM_AND_CONST_ALWAYS_SAME(final String operatorName, final boolean invariantResult, final String enumName, final String fieldName) - { - return create(BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME_ID - , MessageFormat.format(Messages.BINARY_COMPARISON_WITH_ENUM_AND_CONST_ALWAYS_SAME - , new Object[] {operatorName - , Boolean.valueOf(invariantResult), enumName, fieldName})); - } - - /** - * @param operatorName - * @param invariantResult - * @param enumName1 - * @param enumName2 - * @return a diagnostic - */ - public Diagnostic create_BINARY_COMPARISON_WITH_TWO_ENUMS_ALWAYS_SAME(final String operatorName, final boolean invariantResult, final String enumName1, final String enumName2) - { - return create(BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME_ID - , MessageFormat.format(Messages.BINARY_COMPARISON_WITH_TWO_ENUMS_ALWAYS_SAME - , new Object[] {operatorName - , Boolean.valueOf(invariantResult), enumName1, enumName2})); - } - - /** - * @param operatorName - * @param invariantResult - * @param enumName - * @param nonEnum - * @return a diagnostic - */ - public Diagnostic create_BINARY_COMPARISON_WITH_ENUM_AND_UNCOERCABLE_NONCONST_ALWAYS_SAME(final String operatorName, final boolean invariantResult, final String enumName, final String nonEnum) - { - return create(BINARY_COMPARISON_WITH_ENUM_ALWAYS_SAME_ID - , MessageFormat.format(Messages.BINARY_COMPARISON_WITH_ENUM_AND_UNCOERCABLE_NONCONST_ALWAYS_SAME - , new Object[] {operatorName - , Boolean.valueOf(invariantResult), enumName, nonEnum})); - } - - /** - * @return a diagnostic - */ - public Diagnostic create_BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE() - { - return create(BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE_ID - , Messages.BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE); - } - - private BasicDiagnostic create(int diagnosticId, String message) - { - final int severity = ELValidationPreferences.getDefaultSeverity(diagnosticId); - return new BasicDiagnostic(severity, "" //$NON-NLS-1$ - , diagnosticId - , message - , null); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/IELLocalizedMessage.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/IELLocalizedMessage.java deleted file mode 100644 index 1d4b6a50b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/IELLocalizedMessage.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.el.diagnostics; - -/** - * Allows certain elements of the message to be made public without exposing - * the whole Message class - * - * @author cbateman - * - */ -public interface IELLocalizedMessage -{ - /** - * @return the unique error code for the message - */ - public int getErrorCode(); - - /** - * @return the absolute offset where the problem starts - */ - public int getOffset(); - - /** - * @return the number of characters starting from getOffset() - * where the mark stretches - */ - public int getLength(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/Messages.java deleted file mode 100644 index 7cd60aae0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/Messages.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.diagnostics; - -import org.eclipse.osgi.util.NLS; - -class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.validation.internal.el.diagnostics.messages"; //$NON-NLS-1$ - - - static { - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - /** - * see messages.properties - */ - public static String POSSIBLE_DIV_BY_ZERO; - /** - * see messages.properties - */ - public static String UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE; - /** - * see messages.properties - */ - public static String UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN; - /** - * see messages.properties - */ - public static String TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID; - /** - * see messages.properties - */ - public static String BINARY_OP_BOTH_OPERANDS_NULL; - /** - * see messages.properties - */ - public static String BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION; - /** - * see messages.properties - */ - public static String BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME; - /** - * see messages.properties - */ - public static String BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME; - /** - * see messages.properties - */ - public static String BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN; - /** - * see messages.properties - */ - public static String BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS; - /** - * see messages.properties - */ - public static String BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME; - /** - * see messages.properties - */ - public static String BINARY_OP_NO_AVAILABLE_TYPE_COERCION; - /** - * see messages.properties - */ - public static String BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS; - /** - * see messages.properties - */ - public static String UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME; - /** - * see messages.properties - */ - public static String UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO; - /** - * see messages.properties - */ - public static String UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION; - /** - * see messages.properties - */ - public static String UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED; - /** - * see messages.properties - */ - public static String TERNARY_OP_CHOICE_IS_ALWAYS_SAME; - /** - * see messages.properties - */ - public static String VM_PROP_NAME_NOT_FOUND; - /** - * see messages.properties - */ - public static String VM_ROOT_NAME_NOT_FOUND; - /** - * see messages.properties - */ - public static String CANNOT_APPLY_OPERATORS_TO_MB; - /** - * see messages.properties - */ - public static String MISSING_CLOSING_EXPR_BRACKET; - /** - * see messages.properties - */ - public static String GENERAL_SYNTAX_ERROR; - /** - * see messages.properties - */ - public static String EMPTY_EL_EXPRESSION; - /** - * see messages.properties - */ - public static String BINARY_OP_DOT_WITH_VALUEB_NULL; - /** - * see messages.properties - */ - public static String BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY; - - /** - * see messages.properties - */ - public static String POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS; - /** - * see messages.properties - */ - public static String BINARY_COMPARISON_WITH_ENUM_AND_CONST_ALWAYS_SAME; - /** - * see messages.properties - */ - public static String BINARY_COMPARISON_WITH_TWO_ENUMS_ALWAYS_SAME; - /** - * see messages.properties - */ - public static String BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE; - - /** - * see messages.properties - */ - public static String BINARY_COMPARISON_WITH_ENUM_AND_UNCOERCABLE_NONCONST_ALWAYS_SAME; - - private Messages() { - // do nothing; no external instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/MyLocalizedMessage.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/MyLocalizedMessage.java deleted file mode 100644 index 80da97d3f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/MyLocalizedMessage.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.diagnostics; - -import java.util.Locale; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.wst.validation.internal.core.Message; - -/** - * EL customized localizable validation message - * @author cbateman - * - */ -class MyLocalizedMessage extends Message implements IELLocalizedMessage -{ - private final String _message; - private final int _errorCode; - - /** - * @param severity - * @param messageText - * @param targetObject - * @param errorCode - */ - public MyLocalizedMessage(int severity, String messageText, IResource targetObject, int errorCode) { - this(severity, messageText, (Object) targetObject, errorCode); - } - - /** - * @param severity - * @param messageText - * @param targetObject - * @param errorCode - */ - private MyLocalizedMessage(int severity, String messageText, Object targetObject, int errorCode) { - super(JSFCorePlugin.getDefault().getBundle().getSymbolicName(), severity, - messageText); - _message = messageText; - setTargetObject(targetObject); - _errorCode = errorCode; - } - - /** - * @return the localized message - */ - public String getLocalizedMessage() { - return _message; - } - - /** - * @see org.eclipse.wst.validation.internal.core.Message#getText() - */ - public String getText() { - return getLocalizedMessage(); - } - - /** - * @see org.eclipse.wst.validation.internal.core.Message#getText(java.lang.ClassLoader) - */ - public String getText(ClassLoader cl) { - return getLocalizedMessage(); - } - - /** - * @see org.eclipse.wst.validation.internal.core.Message#getText(java.util.Locale) - */ - public String getText(Locale l) { - return getLocalizedMessage(); - } - - public String getText(Locale l, ClassLoader cl) { - return getLocalizedMessage(); - } - - /** - * @return the error code related to this message - */ - public int getErrorCode() { - return _errorCode; - } - - - /** - * @param offset - * @return true if this message applies to document offset - */ - public boolean appliesTo(int offset) - { - return (offset >= getOffset() && offset < getOffset()+getLength()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/ValidationMessageFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/ValidationMessageFactory.java deleted file mode 100644 index d13b5b455..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/ValidationMessageFactory.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.diagnostics; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.validation.internal.ELValidationPreferences; -import org.eclipse.wst.validation.internal.core.Message; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -/** - * Creates configured validation Message objects. - * - * @author cbateman - * - */ -public final class ValidationMessageFactory -{ - /** - * @param diagnostic - * @param offset - * @param length - * @param file - * @param prefs - * @return a configured message - */ - public static Message createFromDiagnostic(final Diagnostic diagnostic, int offset, int length, IFile file, ELValidationPreferences prefs) - { - final int severity = - prefs.getDiagnosticSeverity(diagnostic.getCode()); - - final Message message = - new MyLocalizedMessage( - convertSeverity(severity), - diagnostic.getMessage(), - file, - diagnostic.getCode()); - - message.setOffset(offset); - message.setLength(length); - - return message; - } - - /** - * @param diagnostic - * @return a Message severity equivilent to diagnostic.getSeverity() - */ - private static int convertSeverity(int severity) - { - switch (severity) - { - case Diagnostic.ERROR: - return IMessage.HIGH_SEVERITY; - case Diagnostic.WARNING: - return IMessage.NORMAL_SEVERITY; - case Diagnostic.INFO: - return IMessage.LOW_SEVERITY; - case Diagnostic.OK: - default: - // no bits set - return 0; - } - } - - private ValidationMessageFactory() - { - // no external instantiation - } -} - diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/messages.properties deleted file mode 100644 index 0116cb76c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/diagnostics/messages.properties +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle 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: -# Oracle Corporation - initial API and implementation -############################################################################### -GENERAL_SYNTAX_ERROR=Syntax error in EL -EMPTY_EL_EXPRESSION=Empty EL expression - -VM_ROOT_NAME_NOT_FOUND = {0} cannot be resolved -VM_PROP_NAME_NOT_FOUND = {0} cannot be resolved as a member of {1} -CANNOT_APPLY_OPERATORS_TO_MB=Cannot apply expression operators to method bindings -MISSING_CLOSING_EXPR_BRACKET=Missing closing bracket on expression - -POSSIBLE_DIV_BY_ZERO=Possible division by zero -UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE=This empty expression always evaluates to false. Only string, maps, arrays and collection have meaningful values for the empty operator -UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN=Not operator does not support type coercion. -TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN_ID=Could not coerce choice argument to boolean -BINARY_OP_BOTH_OPERANDS_NULL={0} with operand 'null' is always zero -BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION=Could not make numeric conversion for {0} operation -BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME=This {0} will always result a value of {1} -BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME=Comparisons with null always evaluates to {0} -BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN=Cannot coerce {0} argument to boolean -BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS=The first boolean argument is always {0}. The second argument will never be evaluated and the {1} will always evaluate to {0}. -BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME=The second boolean argument is always {0}. The {1} will always evaluate to {0} -BINARY_OP_NO_AVAILABLE_TYPE_COERCION=Cannot coerce arguments for this operator -BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS=Could not coerce literals to numbers -UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME=This {0} will always result a value of {1} -UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO=Unary minus applied to null is always zero -UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION=Could not make numeric conversion for {0} operation -UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED=Type coercion for {0} operator not guaranteed for possible runtime types: {1} -TERNARY_OP_CHOICE_IS_ALWAYS_SAME=Choice argument is always {0}. {1} argument is always returned -BINARY_OP_DOT_WITH_VALUEB_NULL=Applying the dot operator with null second argument always results in null -BINARY_OP_DOT_WITH_DOTTED_KEY_SHOULD_USE_ARRAY=Array syntax is preferred when accessing Map properties with keys containing dots (i.e. {0}[''{1}'']) -POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS=Possible array index out of bound on list/array access with value: {0} -BINARY_COMPARISON_WITH_ENUM_AND_CONST_ALWAYS_SAME=Comparison using {0} will always evaluate to {1}. Enumeration type {2} does not have a constant named {3} -BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE=Comparison of incompatible enumeration vales may cause a ClassCastException. -BINARY_COMPARISON_WITH_TWO_ENUMS_ALWAYS_SAME=Comparison using {0} will always evaulate to {1}. Enumeration type {2} is not equality comparable with {3} -BINARY_COMPARISON_WITH_ENUM_AND_UNCOERCABLE_NONCONST_ALWAYS_SAME=Comparison using {0} will always evaulate to {1}. Enumeration type {2} is not equality comparable with non-enumeration type {3}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AddArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AddArithmeticBinaryOperator.java deleted file mode 100644 index 56d1457d7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AddArithmeticBinaryOperator.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the arithmetic + operator in EL - * - * @author cbateman - * - */ -/*package*/ class AddArithmeticBinaryOperator extends NoDivArithmeticBinaryOperator { - - private static final String ADDITION = "addition"; - - AddArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) { - super(diagnosticFactory); - } - - protected Long doRealOperation(Long firstArg, Long secondArg) - { - return new Long(firstArg.longValue() + secondArg.longValue()); - } - - protected Double doRealOperation(Double firstArg, Double secondArg) { - return new Double(firstArg.doubleValue() + secondArg.doubleValue()); - } - - protected BigDecimal doRealOperation(BigDecimal firstArg, - BigDecimal secondArg) - { - return firstArg.add(secondArg); - } - - protected String getOperatorName() { - return ADDITION; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AndBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AndBinaryOperator.java deleted file mode 100644 index 2ce58ce6d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AndBinaryOperator.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - - -/** - * Encapsulates the 'and'/'&&' boolean-AND operator - * Based on JSP.2.3.6.1 - * - * @author cbateman - * - */ -/*package*/class AndBinaryOperator extends LogicalBinaryOperator -{ - - AndBinaryOperator(DiagnosticFactory diagnosticFactory) { - super(diagnosticFactory); - } - - protected boolean doRealOperation(Boolean firstArg, Boolean secondArg) - { - return (firstArg.booleanValue() && secondArg.booleanValue()); - } - - protected String readableOperatorName() - { - return "logical-AND"; - } - - protected boolean shortCircuitValue() { - // AND short-circuits on false - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ArithmeticBinaryOperator.java deleted file mode 100644 index 3f7000046..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ArithmeticBinaryOperator.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Super for all arithmetic binary operators -- +, -, *,/,% - * - * @author cbateman - * - */ -/*package*/ abstract class ArithmeticBinaryOperator extends BinaryOperator -{ - ArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) - { - super(diagnosticFactory); - } - - public abstract ValueType performOperation(ValueType firstArg, ValueType secondArg); - public abstract Diagnostic validate(ValueType firstArg, ValueType secondArg); - - /** - * @param firstArg - * @param secondArg - * @return the result of firstArg op secondArg - */ - protected abstract Long doRealOperation(Long firstArg, Long secondArg); - - /** - * @param firstArg - * @param secondArg - * @return the result of firstArg op secondArg - */ - protected abstract Double doRealOperation(Double firstArg, Double secondArg); - - /** - * @param firstArg - * @param secondArg - * @return the result of firstArg op secondArg - */ - protected abstract BigDecimal doRealOperation(BigDecimal firstArg, BigDecimal secondArg); - - /** - * @return human-readable name of the operator - */ - protected abstract String getOperatorName(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BinaryOperator.java deleted file mode 100644 index 58661da4e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BinaryOperator.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserConstants; -import org.eclipse.jst.jsp.core.internal.java.jspel.Token; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * Represents an abstract EL binary operator that always - * takes arguments and produces a single results - * - * @author cbateman - * - */ -public abstract class BinaryOperator -{ - /** - * the factory used to construct diagnostics - */ - protected final DiagnosticFactory _diagnosticFactory; - - /** - * @param operatorToken - * @param diagnosticFactory - * @param context -- the current EL document context; must not be null - * @return a binary operator based on the provided token - * @throws IllegalArgumentException if the token is not a recognized - * EL binary operator token or if context is null - */ - public static BinaryOperator getBinaryOperator(Token operatorToken, DiagnosticFactory diagnosticFactory, IStructuredDocumentContext context) - { - if (context == null) - { - throw new IllegalArgumentException("Context must not be null"); //$NON-NLS-1$ - } - final String facetVersion = determineJSFVersion(context); - - switch (operatorToken.kind) - { - case JSPELParserConstants.AND1: - case JSPELParserConstants.AND2: - return new AndBinaryOperator(diagnosticFactory); - - case JSPELParserConstants.OR1: - case JSPELParserConstants.OR2: - return new OrBinaryOperator(diagnosticFactory); - - case JSPELParserConstants.EQ1: - case JSPELParserConstants.EQ2: - return new EqualsBinaryRelationalOperator(diagnosticFactory,facetVersion); - - case JSPELParserConstants.NEQ1: - case JSPELParserConstants.NEQ2: - return new NotEqualsBinaryRelationalOperator(diagnosticFactory,facetVersion); - - case JSPELParserConstants.GT1: - case JSPELParserConstants.GT2: - return new GreaterThanRelationalBinaryOperator(diagnosticFactory,facetVersion); - - case JSPELParserConstants.GE1: - case JSPELParserConstants.GE2: - return new GreaterThanEqRelationalBinaryOperator(diagnosticFactory,facetVersion); - - case JSPELParserConstants.LT1: - case JSPELParserConstants.LT2: - return new LessThanRelationalBinaryOperator(diagnosticFactory,facetVersion); - - case JSPELParserConstants.LE1: - case JSPELParserConstants.LE2: - return new LessThanEqRelationalBinaryOperator(diagnosticFactory,facetVersion); - - case JSPELParserConstants.PLUS: - return new AddArithmeticBinaryOperator(diagnosticFactory); - - case JSPELParserConstants.MINUS: - return new SubtractArithmeticBinaryOperator(diagnosticFactory); - - case JSPELParserConstants.MULTIPLY: - return new MultiplyArithmeticBinaryOperator(diagnosticFactory); - - case JSPELParserConstants.DIVIDE1: - case JSPELParserConstants.DIVIDE2: - return new DivArithmeticBinaryOperator(diagnosticFactory); - - case JSPELParserConstants.MODULUS1: - case JSPELParserConstants.MODULUS2: - return new ModArithmeticBinaryOperator(diagnosticFactory); - } - - throw new IllegalArgumentException("Unknown binary operator: "+operatorToken.image); //$NON-NLS-1$ - } - - /** - * - * Constructor - */ - BinaryOperator(DiagnosticFactory diagnosticFactory) - { - /* no construction or sub-classing outside package*/ - _diagnosticFactory = diagnosticFactory; - } - - /** - * If both arguments are literals and the operation can be performed, then - * the return must be a new LiteralType transformed using this operator. - * - * If one or both of the arg is not a literal and the operaton can be performed, then - * the return is a new ValueType transformed per the rules of the operator - * - * If the operation cannot be performed on ValueType, return null - * - * @param firstArg - * @param secondArg - * @return a new value type after the operation is performed - */ - public abstract ValueType performOperation(ValueType firstArg, ValueType secondArg); - - - /** - * @param firstArg - * @param secondArg - * @return a Diagnostic interpreting whether it is valid to perform the - * operation on the two arguments - */ - public abstract Diagnostic validate(ValueType firstArg, ValueType secondArg); - - private static String determineJSFVersion(IStructuredDocumentContext context) - { - final IWorkspaceContextResolver wkResolver = - IStructuredDocumentContextResolverFactory. - INSTANCE.getWorkspaceContextResolver(context); - - IProject project = wkResolver.getProject(); - - IProjectFacetVersion projectVersion = JSFAppConfigUtils.getProjectFacet(project); - - if (projectVersion != null) - { - return projectVersion.getVersionString(); - } - - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BracketOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BracketOperator.java deleted file mode 100644 index 1ff10584c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BracketOperator.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType; -import org.eclipse.jst.jsf.designtime.el.AbstractDTPropertyResolver; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Handles the operator 'bracket' where bracket(expr-a, id-b) == 'expr-a[id-b]' in EL syntax - * - * @author cbateman - * - */ -public class BracketOperator extends MemberAccessorOperator -{ - private static final String OPERATOR_NAME_ARRAY_ACCESSOR = "array ('[]') accessor"; - - /** - * @param diagnosticFactory - * @param file - */ - public BracketOperator(final DiagnosticFactory diagnosticFactory, final IFile file) - { - super(file, diagnosticFactory); - } - - protected SignatureBasedType handlePerformObjectSymbolValue( - IObjectSymbolBasedValueType firstArg, ValueType secondArg) - { - // per JSP.2.3.4 step 5.2, if value-a is a list or array access - if (firstArg.isInstanceOf(TypeConstants.TYPE_LIST) - || Signature.getArrayCount(firstArg.getSignature()) > 0) - { - return handlePerformNumericPropertyAccessorBase(firstArg, secondArg); - } - - // per JSP.2.3.4 step 5, if value-a is a map or if it is not - // a list or array (and therefore a bean), treat it as named property accessed object - // if firstArg is a map then we must treat the access like a map.get(secondArg) - - // if we don't have a literal value with which to derive value-b, then - // we can't get a property - if (secondArg instanceof LiteralType) - { - return handlePerformNamedPropertyAccessorBase(firstArg, (LiteralType)secondArg); - } - - return null; - } - - protected Diagnostic validateObjectSymbolValue(IObjectSymbolBasedValueType firstArg, - ValueType secondArg) - { - // per JSP.2.3.4 step 5.2, if value-a is a list or array access - if (firstArg.isInstanceOf(TypeConstants.TYPE_LIST) - || firstArg.getSymbol().getTypeDescriptor().isArray()) - { - return validateNumericPropertyAccessorBase(firstArg, secondArg); - } - - // per JSP.2.3.4 step 5, if value-a is a map or if it is not - // a list or array (and therefore a bean), treat it as named property accessed object - // if firstArg is a map then we must treat the access like a map.get(secondArg) - if (secondArg instanceof LiteralType) - { - return validateNamedPropertyAccessorBase(firstArg, (LiteralType) secondArg); - } - // otherwise, there's nothing we can guarantee - return Diagnostic.OK_INSTANCE; - } - - private Diagnostic validateNumericPropertyAccessorBase(IObjectSymbolBasedValueType firstArg, - ValueType secondArg) - { - try - { - // secondArg must successfully coerce to integer - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - if (secondArg instanceof LiteralType) - { - // this will throw a TypeCoercionExceptino if it won't - // coerce - Integer integerValue = - (Integer) ((LiteralType)secondArg).coerceToNumber(Integer.class); - - if (integerValue.intValue() < 0) - { - return _diagnosticFactory.create_POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS(integerValue); - } - } - else - { - // if the argument is a non-literal string, we can't verify - // that the coercion to integer won't throw an exception - // at runtime - if (TypeCoercer.typeIsString(secondArg.getSignature())) - { - return _diagnosticFactory.create_UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED(OPERATOR_NAME_ARRAY_ACCESSOR); - } - } - - // TODO: attempt to detect ArrayIndexOutOfBoundsException - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException e) - { - return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(OPERATOR_NAME_ARRAY_ACCESSOR); - } - } - - private SignatureBasedType handlePerformNumericPropertyAccessorBase(IObjectSymbolBasedValueType firstArg, - ValueType secondArg) - { - AbstractDTPropertyResolver propResolver = getPropertyResolver(); - int index = 0; - if (secondArg instanceof LiteralType) - { - try { - index = ((LiteralType)secondArg).coerceToNumber(Integer.class).intValue(); - } catch (TypeCoercionException e) { - // suppress, just use index = 0 - // this maybe should be an assertion... - } - } - - final ISymbol symbol = - propResolver.getProperty(firstArg.getSymbol(), index); - - if (symbol instanceof IObjectSymbol) - { - return IObjectSymbolBasedValueType.getInstance(symbol); - } - - // if can't be resolved, return null - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DivArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DivArithmeticBinaryOperator.java deleted file mode 100644 index 34c63c4f2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DivArithmeticBinaryOperator.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents dividing EL binary operators: div and / (same operator) - * Based on JSP.2.3.5.2 - * - * @author cbateman - * - */ -/*package*/ class DivArithmeticBinaryOperator extends ArithmeticBinaryOperator -{ - - private static final String DIVISION = "division"; - - DivArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) { - super(diagnosticFactory); - // TODO Auto-generated constructor stub - } - - public ValueType performOperation(ValueType firstArg, ValueType secondArg) - { - // JSP.2.3.5.2, step one: if both null then always 0 - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - && TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return new IntegerLiteralType(0); - } - - final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.2, step 2: if one arg is BigInteger or BigDecimal - // then coerce to BigDecimal and do div - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - return performBigDecimal(firstArg, secondArg); - } - - return performDouble(firstArg, secondArg); - } - - public Diagnostic validate(ValueType firstArg, ValueType secondArg) { - // JSP.2.3.5.2, step one: if both null then always 0 - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - && TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return _diagnosticFactory.create_BINARY_OP_BOTH_OPERANDS_NULL(DIVISION); - } - - final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.2, step 2: if one arg is BigInteger or BigDecimal - // then coerce to BigDecimal and do div - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - return validateBigDecimal(firstArg, secondArg); - } - - return validateDouble(firstArg, secondArg); - } - - private ValueType performBigDecimal(ValueType firstArg, ValueType secondArg) - { - // since one or the other args must be either big decimal or big int, - // we don't have two literals, so it is sufficient to ensure that we can - // coerce both to numbers and check for div by zero and div of zero - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - // if we get to here, the result is always BigDecimal unless we have - // a div by zero - if (secondArg instanceof LiteralType) - { - final Number coercedValue = ((LiteralType)secondArg).coerceToNumber(BigDecimal.class); - if (((BigDecimal)coercedValue).equals(new BigDecimal(0))) - { - return null; - } - } - - return new ValueType(TypeConstants.TYPE_BIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS); - } - catch (TypeCoercionException ce) - { - return null; - } - } - - private ValueType performDouble(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - Number secondValue = null; - if (secondArg instanceof LiteralType) - { - secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class); - // if the second value is definitely 0, then return null since - // we have a div by zero - if (secondValue.doubleValue() == 0.0) - { - return null; - } - } - - Number firstValue = null; - - if (firstArg instanceof LiteralType) - { - firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class); - } - - if (firstValue != null && secondValue != null) - { - return new FloatLiteralType( - doRealOperation(new Double(firstValue.doubleValue()) - , new Double(secondValue.doubleValue())).doubleValue()); - } - - // if not both literals and could coerce, then the type is double - return new ValueType(Signature.SIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS); - } - catch (TypeCoercionException ce) - { - // could not coerce for the operation - return null; - } - } - - private Diagnostic validateBigDecimal(ValueType firstArg, ValueType secondArg) - { - // since one or the other args must be either big decimal or big int, - // we don't have two literals, so it is sufficient to ensure that we can - // coerce both to numbers and check for div by zero and div of zero - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - // if we get to here, the result is always BigDecimal unless we have - // a div by zero - if (secondArg instanceof LiteralType) - { - final Number coercedValue = ((LiteralType)secondArg).coerceToNumber(BigDecimal.class); - if (((BigDecimal)coercedValue).equals(new BigDecimal(0))) - { - return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO(); - } - } - - // everything's okay if we get here - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException ce) - { - return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(DIVISION); - } - } - - private Diagnostic validateDouble(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - Number secondValue = null; - if (secondArg instanceof LiteralType) - { - secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class); - // if the second value is definitely 0, then return null since - // we have a div by zero - if (secondValue.doubleValue() == 0.0) - { - return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO(); - } - } - - Number firstValue = null; - - if (firstArg instanceof LiteralType) - { - firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class); - } - - if (firstValue != null && secondValue != null) - { - String result - = Double.toString( - doRealOperation(new Double(firstValue.doubleValue()), - new Double(secondValue.doubleValue())).doubleValue()); - - return _diagnosticFactory.create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME(DIVISION, result); - } - - // if not both literals and could coerce, then the type is double - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException ce) - { - // could not coerce for the operation - return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(DIVISION); - } - } - - protected BigDecimal doRealOperation(BigDecimal firstArg, BigDecimal secondArg) { - // per JSP.2.3.5.2, step 2 - return firstArg.divide(secondArg, BigDecimal.ROUND_HALF_UP); - } - - protected Double doRealOperation(Double firstArg, Double secondArg) - { - return new Double(firstArg.doubleValue() / secondArg.doubleValue()); - } - - protected Long doRealOperation(Long firstArg, Long secondArg) { - return new Long(firstArg.longValue() / secondArg.longValue()); - } - - protected String getOperatorName() { - return DIVISION; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DotOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DotOperator.java deleted file mode 100644 index 644f51942..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DotOperator.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Handles the operator 'dot' where dot(expr-a, id-b) == 'expr-a.id-b' in EL syntax - * - * @author cbateman - * - */ -public class DotOperator extends MemberAccessorOperator -{ - /** - * @param diagnosticFactory - * @param file - */ - public DotOperator(final DiagnosticFactory diagnosticFactory, final IFile file) - { - super(file, diagnosticFactory); - } - - protected SignatureBasedType handlePerformObjectSymbolValue( - IObjectSymbolBasedValueType firstArg, ValueType secondArg) - { - // the dot operator (unlike the bracket) can only treat firstArg as - // a named property accessor object - // if we don't have a literal value with which to derive value-b, then - // we can't get a property - if (secondArg instanceof LiteralType) - { - return handlePerformNamedPropertyAccessorBase(firstArg, (LiteralType)secondArg); - } - return null; - } - - public Diagnostic validateObjectSymbolValue(IObjectSymbolBasedValueType firstArg, - ValueType secondArg) - { - if (secondArg instanceof LiteralType) - { - return validateNamedPropertyAccessorBase(firstArg, (LiteralType) secondArg); - } - - return Diagnostic.OK_INSTANCE; - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EmptyUnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EmptyUnaryOperator.java deleted file mode 100644 index 812d1cb00..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EmptyUnaryOperator.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType; -import org.eclipse.jst.jsf.common.internal.types.NullLiteralType; -import org.eclipse.jst.jsf.common.internal.types.StringLiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the EL unary operator '-' on a ValueType - * as described by JSP.2.3.7 - * - * @author cbateman - * - */ -/*package*/ class EmptyUnaryOperator extends UnaryOperator -{ - private static final String EMPTY = "empty"; - - EmptyUnaryOperator(DiagnosticFactory diagnosticFactory) - { - super(diagnosticFactory); - } - - public ValueType performOperation(ValueType type) - { - if (type instanceof StringLiteralType) - { - if ("".equals(((StringLiteralType)type).getLiteralValue())) - { - // if the string is empty, operator always returns true - return BooleanLiteralType.TRUE; - } - - // if the string is empty, operator always returns true - return BooleanLiteralType.FALSE; - } - - // empty(null) is always true - if (type instanceof NullLiteralType) - { - return BooleanLiteralType.TRUE; - } - - // if the type is not string, array, Map, or Collection - // then empty is always false - String testSig = type.getSignature(); - - if (!TypeConstants.TYPE_STRING.equals(testSig) - && !type.isInstanceOf(TypeConstants.TYPE_COLLECTION) - && !type.isInstanceOf(TypeConstants.TYPE_MAP) - && Signature.getTypeSignatureKind(testSig) != Signature.ARRAY_TYPE_SIGNATURE) - { - return BooleanLiteralType.FALSE; - } - - // otherwise, return a generic boolean type - return new ValueType(TypeConstants.TYPE_BOOLEAN, type.getAssignability()); - } - - public Diagnostic validate(ValueType type) - { - // empty always validates to false unless: - // the value is an empty string, array, map or collection - // one thing we do is see if the thing is a literal. If it is - // we can warn that the value could be folded - if (type instanceof StringLiteralType) - { - String condition; - - if ("".equals(((StringLiteralType)type).getLiteralValue())) - { - condition = "true"; - } - else - { - condition = "false"; - } - - return _diagnosticFactory. - create_UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID - (EMPTY,condition); - } - - // empty(null) is always true - if (type instanceof NullLiteralType) - { - return _diagnosticFactory. - create_UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID - (EMPTY,"true"); - } - - // if the type is not string, array, Map, or Collection warn that - // this may be always false - String testSig = type.getSignature(); - - if (!TypeConstants.TYPE_STRING.equals(testSig) - && !type.isInstanceOf(TypeConstants.TYPE_COLLECTION) - && !type.isInstanceOf(TypeConstants.TYPE_MAP) - && Signature.getTypeSignatureKind(testSig) != Signature.ARRAY_TYPE_SIGNATURE) - { - return _diagnosticFactory.create_UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE(); - } - - return Diagnostic.OK_INSTANCE; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualityRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualityRelationalBinaryOperator.java deleted file mode 100644 index cb150b6b6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualityRelationalBinaryOperator.java +++ /dev/null @@ -1,538 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.IType; -import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.StringLiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.common.util.TypeUtil; -import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * A relational binary operator for equality: "==" or "!=" - * - * @author cbateman - * - */ -/*package*/ abstract class EqualityRelationalBinaryOperator extends RelationalBinaryOperator -{ - EqualityRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) - { - super(diagnosticFactory, jsfVersion); - } - - /** - * @param firstArg - * @param secondArg - * @return the result of the operation - */ - protected abstract boolean doRealOperation(Boolean firstArg, Boolean secondArg); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.validation.internal.el.operators.BinaryOperator#performOperation(org.eclipse.jst.jsf.core.internal.types.ValueType, org.eclipse.jst.jsf.core.internal.types.ValueType) - */ - public ValueType performOperation(ValueType firstArg, ValueType secondArg) - { - // JSP.2.3.5.7 step 2 if either operand is null, then not equal - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - || TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return BooleanLiteralType.FALSE; - } - - String boxedFirstType = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - String boxedSecondType = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.7 step 3, if either is BigDecimal, promote both and compare - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, BigDecimal.class); - } - - // JSP.2.3.5.7, step 4 if either is a float or double, promote both to - // double and compare - if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, Double.class); - } - - // JSP.2.3.5.7, step 5 if either is a big integer, promote and compare - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, BigInteger.class); - } - - // JSP.2.3.5.7, step 6 if either is Long or smaller, coerce both to Long - if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, Long.class); - } - - // JSP.2.3.5.7, step 7 if either is a boolean, coerce to boolean - if (TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedSecondType)) - { - return handleBooleanComparison(firstArg, secondArg); - } - - // Unified EL 1.8.2, step 8 if either is a enum, then coerce both to enum - // NOTE: we handle the JSF 1.1 case also where enums are treated as non-coercable - // Object's - if (firstArg.isEnumType() || secondArg.isEnumType()) - { - return handleEnumComparison(firstArg, secondArg); - } - - // JSP.2.3.5.7, step 8 if either is a string, coerce to string and - // compare lexically - if (TypeConstants.TYPE_STRING.equals(boxedFirstType) - || TypeConstants.TYPE_STRING.equals(boxedSecondType)) - { - return handleStringComparison(firstArg, secondArg); - } - - // otherwise, an equal compare will be done A.equals(B). Since - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - private ValueType handleEnumComparison(ValueType firstArg, - ValueType secondArg) - { - assert firstArg.isEnumType() || secondArg.isEnumType(); - - // if the first is not an enum, then we have non-Enum == Enum case - if (!firstArg.isEnumType()) - { - return handleComparsionOfEnumAndNonEnum(firstArg, secondArg); - } - - // if the second is not an enum, then we have Enum == non-Enum case - if (!secondArg.isEnumType()) - { - return handleComparsionOfEnumAndNonEnum(secondArg, firstArg); - } - - // only other case is they are both enums. Check if they are directly - // comparable. - if (TypeUtil.canNeverBeEqual(firstArg.getSignature(), secondArg.getSignature())) - { - boolean result = doRealOperation("foo", "notFoo"); // just simulate the operation where the operands are not equal //$NON-NLS-1$ //$NON-NLS-2$ - - return BooleanLiteralType.valueOf(result); - } - - // otherwise, all we know is that it's a boolean - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - private ValueType handleComparsionOfEnumAndNonEnum(ValueType enumType, - ValueType nonEnumType) - { - // the only literal value that could have got us here is a - // StringLiteralValue since the others a filtered out before this is - // called - if (nonEnumType instanceof LiteralType) - { - assert nonEnumType instanceof StringLiteralType; - - Diagnostic result = validateIfEnumToStringComparison(((StringLiteralType)nonEnumType).getLiteralValue(), enumType); - - if (result != null) - { - // compare two things that aren't equal - return BooleanLiteralType.valueOf(doRealOperation("foo", "foo_")); //$NON-NLS-1$ //$NON-NLS-2$ - } - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - // if the arg is a String, then we can't prove anything before runtime - if (nonEnumType.isInstanceOf(TypeConstants.TYPE_STRING)) - { - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - // otherwise, we know it will result in a problem since one is an enum - // and the other isn't so simply do a comparison on two things that aren't equals - return BooleanLiteralType.valueOf(doRealOperation("foo", "foo_")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public Diagnostic validate(ValueType firstArg, ValueType secondArg) { - - // JSP.2.3.5.7 step 2 if either operand is null, then not equal - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - || TypeCoercer.typeIsNull(secondArg.getSignature())) - { - final boolean result = doRealOperation(new Integer(4), null); - return _diagnosticFactory.create_BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME(Boolean.toString(result)); - } - - final String boxedFirstType = - TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - final String boxedSecondType = - TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.7 step 3, if either is BigDecimal, promote both and compare - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, BigDecimal.class); - } - - // JSP.2.3.5.7, step 4 if either is a float or double, promote both to - // double and compare - if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, Double.class); - } - - // JSP.2.3.5.7, step 5 if either is a big integer, promote and compare - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, BigInteger.class); - } - - // JSP.2.3.5.7, step 6 if either is Long or smaller, coerce both to Long - if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, Long.class); - } - - // JSP.2.3.5.7, step 7 if either is a boolean, coerce to boolean - if (TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedSecondType)) - { - return validateBooleanComparison(firstArg, secondArg); - } - - // Unified EL 1.8.2, step 8 if either is a enum, then coerce both to enum - // NOTE: we handle the JSF 1.1 case also where enums are treated as non-coercable - // Object's - if (firstArg.isEnumType() || secondArg.isEnumType()) - { - return validateEnumComparison(firstArg, secondArg); - } - - // JSP.2.3.5.7, step 8 if either is a string, coerce to string and - // compare lexically - if (TypeConstants.TYPE_STRING.equals(boxedFirstType) - || TypeConstants.TYPE_STRING.equals(boxedSecondType)) - { - return validateStringComparison(firstArg, secondArg); - } - - // otherwise, an equal compare will be done A.equals(B). Since - return Diagnostic.OK_INSTANCE; - } - - - /** - * Both types are coerced to boolean before comparison - * - * @param firstArg - * @param secondArg - * @return the result of the comparison - */ - private ValueType handleBooleanComparison(ValueType firstArg, ValueType secondArg) - { - boolean canCoerceFirstArg = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - boolean canCoerceSecondArg = TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - if (! (canCoerceFirstArg && canCoerceSecondArg)) - { - return null; - } - - if (firstArg instanceof LiteralType && secondArg instanceof LiteralType) - { - try - { - Boolean firstValue = ((LiteralType)firstArg).coerceToBoolean(); - Boolean secondValue = ((LiteralType)secondArg).coerceToBoolean(); - - if (firstValue != null && secondValue != null) - { - boolean result = doRealOperation(firstValue, secondValue); - return result ? - BooleanLiteralType.TRUE : - BooleanLiteralType.FALSE; - } - } - catch (TypeCoercionException tce) - { - throw new AssertionError("should never get here; have already checked coercability above"); //$NON-NLS-1$ - } - } - - // otherwise, we have a valid comparison that results in boolean - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - private Diagnostic validateBooleanComparison(ValueType firstType, ValueType secondType) - { - boolean canCoerceFirstArg = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstType.getSignature())); - boolean canCoerceSecondArg = TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondType.getSignature())); - - if (!canCoerceFirstArg) - { - return _diagnosticFactory.create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN(Messages.getString("EqualityRelationalBinaryOperator.FirstArgument")); //$NON-NLS-1$ - } - - if (!canCoerceSecondArg) - { - return _diagnosticFactory.create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN(Messages.getString("EqualityRelationalBinaryOperator.SecondArgument")); //$NON-NLS-1$ - } - - if (firstType instanceof LiteralType && secondType instanceof LiteralType) - { - try - { - Boolean firstValue = ((LiteralType)firstType).coerceToBoolean(); - Boolean secondValue = ((LiteralType)secondType).coerceToBoolean(); - - if (firstValue != null && secondValue != null) - { - final boolean result = - doRealOperation(firstValue, secondValue); - return _diagnosticFactory. - create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME(getOperationName(), Boolean.toString(result)); - } - } - catch (TypeCoercionException tce) - { - throw new AssertionError("should never get here; have already checked coercability above"); //$NON-NLS-1$ - } - } - - // otherwise, we have a valid comparison - return Diagnostic.OK_INSTANCE; - } - - @Override - protected Diagnostic validateStringComparison(ValueType firstType, - ValueType secondType) - { - String firstValue = null; - - if (firstType instanceof LiteralType) - { - firstValue = ((LiteralType)firstType).getLiteralValue(); - } - - String secondValue = null; - if (secondType instanceof LiteralType) - { - secondValue = ((LiteralType)secondType).getLiteralValue(); - } - - if (firstValue != null) - { - Diagnostic result = validateIfEnumToStringComparison(firstValue, secondType); - - if (result != null) - { - return result; - } - } - - if (secondValue != null) - { - Diagnostic result = validateIfEnumToStringComparison(secondValue, firstType); - - if (result != null) - { - return result; - } - } - - // if it's a string to enum compare, do the default parent thing - return super.validateStringComparison(firstType, secondType); - } - - - @Override - protected ValueType handleStringComparison(ValueType firstType, - ValueType secondType) - { - String firstValue = null; - - if (firstType instanceof LiteralType) - { - firstValue = ((LiteralType)firstType).getLiteralValue(); - } - - String secondValue = null; - if (secondType instanceof LiteralType) - { - secondValue = ((LiteralType)secondType).getLiteralValue(); - } - - if (firstValue != null) - { - Diagnostic result = validateIfEnumToStringComparison(firstValue, secondType); - - if (result != null) - { - return handleIfEnumToNonMemberStringComparison(firstValue, secondType); - } - } - - if (secondValue != null) - { - Diagnostic result = validateIfEnumToStringComparison(secondValue, firstType); - - if (result != null) - { - return handleIfEnumToNonMemberStringComparison(secondValue, firstType); - } - } - - // otherwise, do the super thing - return super.handleStringComparison(firstType, secondType); - } - - private Diagnostic validateEnumComparison(final ValueType firstArg, final ValueType secondArg) - { - assert firstArg.isEnumType() || secondArg.isEnumType(); - - // if the first is not an enum, then we have non-Enum == Enum case - if (!firstArg.isEnumType()) - { - return validateComparsionOfEnumAndNonEnum(firstArg, secondArg); - } - - // if the second is not an enum, then we have Enum == non-Enum case - if (!secondArg.isEnumType()) - { - return validateComparsionOfEnumAndNonEnum(secondArg, firstArg); - } - - // only other case is they are both enums. Check if they are directly - // comparable. - if (TypeUtil.canNeverBeEqual(firstArg.getSignature(), secondArg.getSignature())) - { - return _diagnosticFactory. - create_BINARY_COMPARISON_WITH_TWO_ENUMS_ALWAYS_SAME - (getOperationName() - , doRealOperation("foo", "notFoo") // just simulate the operation where the operands are not equal //$NON-NLS-1$ //$NON-NLS-2$ - , TypeUtil.getFullyQualifiedName(firstArg.getSignature()) - , TypeUtil.getFullyQualifiedName(secondArg.getSignature())); - } - - // otherwise, it's all good - return Diagnostic.OK_INSTANCE; - } - - private Diagnostic validateComparsionOfEnumAndNonEnum(final ValueType nonEnumType, final ValueType enumType) - { - // the only literal value that could have got us here is a - // StringLiteralValue since the others a filtered out before this is - // called - if (nonEnumType instanceof LiteralType) - { - assert nonEnumType instanceof StringLiteralType; - - Diagnostic result = validateIfEnumToStringComparison(((StringLiteralType)nonEnumType).getLiteralValue(), enumType); - - if (result != null) - { - return result; - } - return Diagnostic.OK_INSTANCE; - } - - // if the arg is a String, then we can't prove anything before runtime - if (nonEnumType.isInstanceOf(TypeConstants.TYPE_STRING)) - { - return Diagnostic.OK_INSTANCE; - } - // otherwise, we know it will result in a problem since one is an enum - // and the other isn't - return _diagnosticFactory. - create_BINARY_COMPARISON_WITH_ENUM_AND_UNCOERCABLE_NONCONST_ALWAYS_SAME - (getOperationName() - , doRealOperation("foo", "notFoo") // just simulate the operation where the operands are not equal //$NON-NLS-1$ //$NON-NLS-2$ - , TypeUtil.getFullyQualifiedName(enumType.getSignature()) - , TypeUtil.getFullyQualifiedName(nonEnumType.getSignature())); - } - - private Diagnostic validateIfEnumToStringComparison(final String literalValue, final ValueType validateIfEnum) - { - if (validateIfEnum.isEnumType() - && validateIfEnum instanceof IObjectSymbolBasedValueType) - { - final IObjectSymbolBasedValueType symbolValueType = - (IObjectSymbolBasedValueType) validateIfEnum; - - IType type = symbolValueType.getSymbol().getTypeDescriptor().resolveType(symbolValueType.getSymbol().getTypeDescriptor().getTypeSignature()); - - if (type != null && !TypeUtil.isEnumMember(type, literalValue)) - { - return _diagnosticFactory. - create_BINARY_COMPARISON_WITH_ENUM_AND_CONST_ALWAYS_SAME - (getOperationName() - , doRealOperation(literalValue, literalValue+"_") // just simulate the operation where the operands are not equal //$NON-NLS-1$ - , TypeUtil.getFullyQualifiedName(validateIfEnum.getSignature()) - , literalValue); - } - } - - return null; - } - - private ValueType handleIfEnumToNonMemberStringComparison(final String literalValue, final ValueType enumValueType) - { - // we need to apply the real operation to literalValue and any string that !equals(literalValue) - // since it's not a member of the enum - return BooleanLiteralType.valueOf(doRealOperation(literalValue, literalValue+"_")); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualsBinaryRelationalOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualsBinaryRelationalOperator.java deleted file mode 100644 index 3fa99f472..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualsBinaryRelationalOperator.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the equals -- ==/eq EL binary operator - * - * @author cbateman - * - */ -/*package*/ class EqualsBinaryRelationalOperator extends - EqualityRelationalBinaryOperator -{ - - EqualsBinaryRelationalOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) { - super(diagnosticFactory, jsfVersion); - } - - /** - * @param firstArg - * @param secondArg - * @return the result of the operation - */ - protected boolean doRealOperation(Number firstArg, Number secondArg) - { - return firstArg.equals(secondArg); - } - - /** - * @param firstArg - * @param secondArg - * @return the result of the operation - */ - protected boolean doRealOperation(Boolean firstArg, Boolean secondArg) - { - return firstArg.equals(secondArg); - } - - /** - * @param firstArg - * @param secondArg - * @return the result of the operation - */ - protected boolean doRealOperation(String firstArg, String secondArg) - { - return firstArg.equals(secondArg); - } - - protected String getOperationName() - { - return Messages.getString("EqualsBinaryRelationalOperator.OperationName"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanEqRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanEqRelationalBinaryOperator.java deleted file mode 100644 index edab570f8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanEqRelationalBinaryOperator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Encapsulates the EL greater-than-eq operator -- ">="/ge - * - * @author cbateman - * - */ -/*package*/ class GreaterThanEqRelationalBinaryOperator extends - LtGtRelationalBinaryOperator -{ - GreaterThanEqRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) { - super(diagnosticFactory, jsfVersion); - } - - protected boolean doRealOperation(Number firstArg, Number secondArg) - { - return ((Comparable)firstArg).compareTo(secondArg) >= 0; - } - - protected boolean doRealOperation(String firstArg, String secondArg) - { - return firstArg.compareTo(secondArg) >= 0; - } - - protected String getOperationName() - { - return Messages.getString("GreaterThanEqRelationalBinaryOperator.OperationName"); //$NON-NLS-1$ - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanRelationalBinaryOperator.java deleted file mode 100644 index 78a62a7a6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanRelationalBinaryOperator.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the EL greater than operator -- ">"/gt - * @author cbateman - * - */ -/*package*/ class GreaterThanRelationalBinaryOperator extends - LtGtRelationalBinaryOperator { - - GreaterThanRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) - { - super(diagnosticFactory, jsfVersion); - } - - protected boolean doRealOperation(Number firstArg, Number secondArg) - { - return ((Comparable)firstArg).compareTo(secondArg) > 0; - } - - protected boolean doRealOperation(String firstArg, String secondArg) - { - return firstArg.compareTo(secondArg) > 0; - } - - protected String getOperationName() - { - return Messages.getString("GreaterThanRelationalBinaryOperator.OperationName"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanEqRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanEqRelationalBinaryOperator.java deleted file mode 100644 index 24dc5e2a5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanEqRelationalBinaryOperator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - - -/** - * Encapsulates the EL less-than-equal operator -- "<="/le - * - * @author cbateman - * - */ -/*package*/ class LessThanEqRelationalBinaryOperator extends - LtGtRelationalBinaryOperator -{ - LessThanEqRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) { - super(diagnosticFactory, jsfVersion); - } - - protected boolean doRealOperation(Number firstArg, Number secondArg) - { - return ((Comparable)firstArg).compareTo(secondArg) <= 0; - } - - protected boolean doRealOperation(String firstArg, String secondArg) - { - return firstArg.compareTo(secondArg) <= 0; - } - - protected String getOperationName() - { - return Messages.getString("LessThanEqRelationalBinaryOperator.OperationName"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanRelationalBinaryOperator.java deleted file mode 100644 index 7b8e7ea7b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanRelationalBinaryOperator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * The "<"/"lt" less-than EL operator - * - * @author cbateman - * - */ -/*package*/ class LessThanRelationalBinaryOperator extends - LtGtRelationalBinaryOperator -{ - LessThanRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) - { - super(diagnosticFactory, jsfVersion); - } - - protected boolean doRealOperation(Number firstArg, Number secondArg) - { - return ((Comparable)firstArg).compareTo(secondArg) < 0; - } - - protected boolean doRealOperation(String firstArg, String secondArg) - { - return firstArg.compareTo(secondArg) < 0; - } - - protected String getOperationName() - { - return Messages.getString("LessThanRelationalBinaryOperator.OperationName"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LogicalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LogicalBinaryOperator.java deleted file mode 100644 index 41b897fea..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LogicalBinaryOperator.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents a logical binary operator per JSP.2.3.6.1 (logical and/or) - * - * @author cbateman - * - */ -/*package*/abstract class LogicalBinaryOperator extends BinaryOperator -{ - LogicalBinaryOperator(DiagnosticFactory diagnosticFactory) { - super(diagnosticFactory); - } - - public ValueType performOperation(ValueType firstArg, ValueType secondArg) - { - final boolean canCoerceFirstArg = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - final boolean canCoerceSecondArg = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - // if can't perform, must return null - if (! (canCoerceFirstArg && canCoerceSecondArg)) - { - return null; - } - - Boolean firstArgResolvedValue = null; - - if (firstArg instanceof LiteralType) - { - try - { - firstArgResolvedValue = ((LiteralType)firstArg).coerceToBoolean(); - } - catch (TypeCoercionException tce) - { - // should never be throw due to already checking if can coerce - throw new AssertionError("coercion already checked; this should never be reached"); - } - } - - Boolean secondArgResolvedValue = null; - if (secondArg instanceof LiteralType) - { - try - { - secondArgResolvedValue = ((LiteralType)secondArg).coerceToBoolean(); - } - catch (TypeCoercionException tce) - { - // should never be throw due to already checking if can coerce - throw new AssertionError("coercion already checked; this should never be reached"); - } - } - - if (firstArgResolvedValue != null && secondArgResolvedValue != null) - { - boolean result = - doRealOperation(firstArgResolvedValue, secondArgResolvedValue); - - return result ? BooleanLiteralType.TRUE : BooleanLiteralType.FALSE; - - } - - // otherwise, just return a boolean - // result can only be an rvalue - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - public Diagnostic validate(ValueType firstArg, ValueType secondArg) - { - final boolean canCoerceFirstArg = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - final boolean canCoerceSecondArg = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - if (!canCoerceFirstArg) - { - return _diagnosticFactory. - create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN("first"); - //return new BasicDiagnostic(Diagnostic.ERROR, "", 0, "Cannot coerce first argument of "+readableOperatorName()+" to boolean", null); - } - - if (!canCoerceSecondArg) - { - return _diagnosticFactory. - create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN("first"); - - //return new BasicDiagnostic(Diagnostic.ERROR, "", 0, "Cannot coerce second argument of "+readableOperatorName()+" to boolean", null); - } - - if (firstArg instanceof LiteralType) - { - try - { - final Boolean boolValue = - ((LiteralType)firstArg).coerceToBoolean(); - - if (boolValue.booleanValue() == shortCircuitValue()) - { - return _diagnosticFactory. - create_BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS - (shortCircuitValue(), readableOperatorName()); - } - } - catch (TypeCoercionException tce) - { - // should never be throw due to already checking if can coerce - throw new AssertionError("coercion already checked; this should never be reached"); - } - } - - if (secondArg instanceof LiteralType) - { - try - { - final Boolean boolValue = - ((LiteralType)secondArg).coerceToBoolean(); - - if (boolValue.booleanValue() == shortCircuitValue()) - { - return _diagnosticFactory. - create_BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME - (shortCircuitValue(), readableOperatorName()); - } - } - catch (TypeCoercionException tce) - { - // should never be throw due to already checking if can coerce - throw new AssertionError("coercion already checked; this should never be reached"); - } - } - - // otherwise, nothing to report - return Diagnostic.OK_INSTANCE; - } - - /** - * @return a human readable name for the operator - */ - protected abstract String readableOperatorName(); - - /** - * @return the boolean value on which the operator short-circuits - */ - protected abstract boolean shortCircuitValue(); - - /** - * @param firstArg - * @param secondArg - * @return the result of performing the operator to two actual values - */ - protected abstract boolean doRealOperation(Boolean firstArg, Boolean secondArg); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LtGtRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LtGtRelationalBinaryOperator.java deleted file mode 100644 index e4695ac88..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LtGtRelationalBinaryOperator.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.common.util.TypeUtil; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Encapsulates the EL binary operators "<", ">", "<=", ">=" - * - * @author cbateman - * - */ -/*package*/ abstract class LtGtRelationalBinaryOperator extends RelationalBinaryOperator -{ - LtGtRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) - { - super(diagnosticFactory, jsfVersion); - } - - protected abstract boolean doRealOperation(Number firstArg, Number secondArg); - - protected abstract boolean doRealOperation(String firstArg, String secondArg); - - public ValueType performOperation(ValueType firstArg, ValueType secondArg) - { - // JSP.2.3.5.6 step 2 if either operand is null, then always false - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - || TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return BooleanLiteralType.FALSE; - } - - String boxedFirstType = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - String boxedSecondType = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.6 step 3, if either is BigDecimal, promote both and compare - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, BigDecimal.class); - } - - // JSP.2.3.5.6, step 4 if either is a float or double, promote both to - // double and compare - if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, Double.class); - } - - // JSP.2.3.5.6, step 5 if either is a big integer, promote and compare - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, BigInteger.class); - } - - // JSP.2.3.5.6, step 6 if either is Long or smaller, coerce both to Long - if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType)) - { - return handleNumericComparison(firstArg, secondArg, Long.class); - } - - // JSP.2.3.5.7, step 7 if either is a string, coerce to string and - // compare lexically - if (TypeConstants.TYPE_STRING.equals(boxedFirstType) - || TypeConstants.TYPE_STRING.equals(boxedSecondType)) - { - return handleStringComparison(firstArg, secondArg); - } - - // JSP.2.3.5.7, steps 8 and 9 -- if either one implements the - // Comparable interface, then as far as we can determine statically - // (compareTo may not work on the other arg, but who knows), - // we are good - if (firstArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE) - || secondArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE)) - { - if (checkIfIncompatibleEnums(firstArg, secondArg)) - { - // error: no point in validating further since expr will probably throw an exception - return null; - } - - return new ValueType(Signature.SIG_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - // JSP.2.3.5.6, step 10 -- otherwise, error - return null; - - } - - public Diagnostic validate(ValueType firstArg, ValueType secondArg) - { - // JSP.2.3.5.6 step 2 if either operand is null, then always false - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - || TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return _diagnosticFactory. - create_BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME(Messages.getString("LtGtRelationalBinaryOperator.ConstantName.False")); //$NON-NLS-1$ - } - - String boxedFirstType = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - String boxedSecondType = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.6 step 3, if either is BigDecimal, promote both and compare - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, BigDecimal.class); - } - - // JSP.2.3.5.6, step 4 if either is a float or double, promote both to - // double and compare - if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, Double.class); - } - - // JSP.2.3.5.6, step 5 if either is a big integer, promote and compare - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, BigInteger.class); - } - - // JSP.2.3.5.6, step 6 if either is Long or smaller, coerce both to Long - if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType) - || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType) - || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType)) - { - return validateNumericComparison(firstArg, secondArg, Long.class); - } - - // JSP.2.3.5.7, step 7 if either is a string, coerce to string and - // compare lexically - if (TypeConstants.TYPE_STRING.equals(boxedFirstType) - || TypeConstants.TYPE_STRING.equals(boxedSecondType)) - { - return validateStringComparison(firstArg, secondArg); - } - - // JSP.2.3.5.7, steps 8 and 9 -- if either one implements the - // Comparable interface, then as far as we can determine statically - // (compareTo may not work on the other arg, but who knows), - // we are good - if (firstArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE) - || secondArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE)) - { - Diagnostic diag = Diagnostic.OK_INSTANCE; - if(checkIfIncompatibleEnums(firstArg, secondArg)) - { - diag = _diagnosticFactory.create_BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE(); - } - return diag; - } - - // JSP.2.3.5.6, step 10 -- otherwise, error - return _diagnosticFactory.create_BINARY_OP_NO_AVAILABLE_TYPE_COERCION(); - } - - /** - * @param firstArg - * @param secondArg - * @return diagnostic if firstArg and secondArg are incompatible with each other - * for compareTo purpose or OK if not - */ - private boolean checkIfIncompatibleEnums(ValueType firstArg, - ValueType secondArg) - { - if (firstArg.isEnumType() - && secondArg.isEnumType() - && !TypeUtil.isEnumsCompareCompatible(firstArg.getSignature() - , secondArg.getSignature())) - { - return true; - } - - return false; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MemberAccessorOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MemberAccessorOperator.java deleted file mode 100644 index ef0272a2d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MemberAccessorOperator.java +++ /dev/null @@ -1,275 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.NullLiteralType; -import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.context.symbol.IMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IObjectSymbol; -import org.eclipse.jst.jsf.context.symbol.IPropertySymbol; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.internal.util.IMethodSymbolBasedType; -import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.designtime.DesignTimeApplicationManager; -import org.eclipse.jst.jsf.designtime.el.AbstractDTMethodResolver; -import org.eclipse.jst.jsf.designtime.el.AbstractDTPropertyResolver; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Super-class for all operators whose function is to access members of an - * EL object. i.e. the "." and "[]" operators - * - * @author cbateman - * - */ -public abstract class MemberAccessorOperator -{ - /** - * The source file for the EL expression in which this operator - * is being evaluated. - */ - protected final IFile _file; - - /** - * the common factory used to create diagnostics - */ - protected final DiagnosticFactory _diagnosticFactory; - - // TODO: need to reconcile with BinaryOperator? performOperation must return - // SignatureBasedType since it may return a method. This can't happen - // with other operators (besides eqiv []) - /** - * @param file - * @param diagnosticFactory - */ - protected MemberAccessorOperator(final IFile file, final DiagnosticFactory diagnosticFactory) - { - _file = file; - _diagnosticFactory = diagnosticFactory; - } - - /** - * @param firstArg - * @param secondArg - * @return the result of validating the dot operation with these arguments. - */ - public Diagnostic validate(ValueType firstArg, ValueType secondArg) - { - if (!(firstArg instanceof IObjectSymbolBasedValueType)) - { - throw new AssertionError("The first argument of the member operator must always be a symbol resolvable value type"); - } - - if (TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return _diagnosticFactory.create_BINARY_OP_DOT_WITH_VALUEB_NULL(); - } - - return validateObjectSymbolValue((IObjectSymbolBasedValueType) firstArg, secondArg); - } - - /** - * @param firstArg - * @param secondArg - * @return the diagnostic for member(firstArg, secondArg) - */ - protected abstract Diagnostic validateObjectSymbolValue(IObjectSymbolBasedValueType firstArg, ValueType secondArg); - - /** - * @param firstArg - * @param secondArg - * @return a validation of a named property accessible base (map or bean) given - * an a literal key argument - */ - protected Diagnostic validateNamedPropertyAccessorBase(IObjectSymbolBasedValueType firstArg - , LiteralType secondArg) - { - final IObjectSymbol curBaseSymbol = firstArg.getSymbol(); - - final ISymbol nextSymbol = getMemberSymbol(firstArg.getSymbol(), - secondArg.getLiteralValueRaw()); - - // if the x in x.y is an unconstrained map an it returns - // a java.lang.Object, then return null. We can't really say - // anything meaningful about such a property anyway. - // TODO: do we need to refine the type descriptor on such - // a property object to make this more precise? - if (curBaseSymbol.supportsCoercion(TypeConstants.TYPE_MAP) - && nextSymbol instanceof IPropertySymbol - && TypeConstants.TYPE_JAVAOBJECT.equals(((IPropertySymbol)nextSymbol).getTypeDescriptor().getTypeSignature())) - { - // if we get a symbol back that's a generic object coming from a map - // then stop validating; we can't tell anything for sure - return Diagnostic.OK_INSTANCE; - } - - if (nextSymbol == null) - { - return _diagnosticFactory.create_MEMBER_NOT_FOUND(secondArg.getLiteralValue() - ,firstArg.getSymbol().getName()); - } - - return Diagnostic.OK_INSTANCE; - } - - /** - * @param firstArg - * @param secondArg - * @return the resolved type for the operation or null if not computable - */ - public SignatureBasedType performOperation(ValueType firstArg, ValueType secondArg) - { - if (!(firstArg instanceof IObjectSymbolBasedValueType)) - { - return null; - } - - // per JSP.2.3.4, if value-b is null, then return null (not literal null) - if (TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return null; - } - - return handlePerformObjectSymbolValue((IObjectSymbolBasedValueType)firstArg, secondArg); - } - - /** - * @param firstArg -- represents value-a (expr-a after step 1) in JSP.2.3.4 - * @param secondArg -- represents value-b (expr-b after step 3) in JSP.2.3.4 - * @return the new ValueType for this operation or null - */ - protected abstract SignatureBasedType handlePerformObjectSymbolValue(IObjectSymbolBasedValueType firstArg - , ValueType secondArg); - - /** - * @param firstArg - * @param secondArg - * @return the resolved type for firstArg[secondArg] treating firstArg as a type - * that uses a named property accessor (i.e. a map or bean but not a list or array) - * or null if unresolved - */ - protected SignatureBasedType handlePerformNamedPropertyAccessorBase(IObjectSymbolBasedValueType firstArg - , LiteralType secondArg) - { - final ISymbol symbol = - getMemberSymbol(firstArg.getSymbol(), secondArg.getLiteralValueRaw()); - - if (symbol instanceof IPropertySymbol) - { - return new IObjectSymbolBasedValueType((IPropertySymbol)symbol); - } - else if (symbol instanceof IMethodSymbol) - { - return new IMethodSymbolBasedType((IMethodSymbol) symbol); - } - - // fall-through and return null - // per JSP2.3.4 steps 5 and 6, return null literal if map, null (error) otherwise - if (firstArg.isInstanceOf(TypeConstants.TYPE_MAP)) - { - return NullLiteralType.SINGLETON; - } - return null; - } - - /** - * @param symbol - * @param name - * @return the member symbol of 'symbol' corresponding to 'name' or - * null if there is no such member - */ - protected final ISymbol getMemberSymbol(final IObjectSymbol symbol, final Object name) - { - ISymbol memberSymbol = getPropertySymbol(symbol, name); - - if (memberSymbol != null) - { - return memberSymbol; - } - - memberSymbol = getMethodSymbol(symbol, name); - - // otherwise, see if it's a valid method - if (memberSymbol != null) - { - return memberSymbol; - } - - // if not a property or method, then not a valid member - return null; - } - - /** - * @param symbol - * @param name - * @return the property symbol called name relative to 'symbol' or null - * if one doesn't exist - */ - protected final ISymbol getPropertySymbol(final ISymbol symbol, final Object name) - { - AbstractDTPropertyResolver resolver = getPropertyResolver(); - - if (resolver != null) - { - return resolver.getProperty(symbol,name); - } - - JSFCorePlugin.log("Error acquiring property resolver", new Throwable()); - return null; - } - - /** - * @param symbol - * @param name - * @return the method symbol on 'symbol' corresponding to - * 'name' or null if no such member - */ - protected final IMethodSymbol getMethodSymbol(final IObjectSymbol symbol, final Object name) - { - AbstractDTMethodResolver resolver = getMethodResolver(); - - if (resolver != null) - { - return resolver.getMethod(symbol, name); - } - - JSFCorePlugin.log("Error acquiring property resolver", new Throwable()); - return null; - - } - - /** - * @return the property resolver for the current source file - */ - protected final AbstractDTPropertyResolver getPropertyResolver() - { - return - DesignTimeApplicationManager.getInstance(_file.getProject()) - .getPropertyResolver(); - } - - /** - * @return the method resolver for the current source file - */ - protected final AbstractDTMethodResolver getMethodResolver() - { - return - DesignTimeApplicationManager.getInstance(_file.getProject()) - .getMethodResolver(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/Messages.java deleted file mode 100644 index 99d0193ed..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/Messages.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -class Messages { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.validation.internal.el.operators.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - // no external instantiation - } - - /** - * @param key - * @return the string or !key! if not found - */ - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MinusUnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MinusUnaryOperator.java deleted file mode 100644 index 7dcdc3b8d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MinusUnaryOperator.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.StringLiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the EL unary operator '-' on a ValueType - * as described by JSP.2.3.5.4 - * - * - * @author cbateman - * - */ -/*package*/class MinusUnaryOperator extends UnaryOperator -{ - private static final String UNARY_MINUS = "unary minus"; - - MinusUnaryOperator(DiagnosticFactory diagnosticFactory) - { - super(diagnosticFactory); - } - - public Diagnostic validate(ValueType type) - { - // must coerce to numeric type - try - { - // if coerceTypeNumber doesn't throw an exception, then - // give the benefit of the doubt - final String coercedType = - TypeCoercer. - coerceToNumber(TypeTransformer. - transformBoxPrimitives(type.getSignature())); - - if (TypeCoercer.typeIsNull(coercedType)) - { - // null always coerces to 0L on this operator - return _diagnosticFactory. - create_UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO(); - } - - // JSP.2.3.5.4, step 2 if BigDecimal or BigInteger, then can't be - // literal and retains type - if (TypeConstants.TYPE_BIG_DOUBLE.equals(coercedType) - || TypeConstants.TYPE_BIG_INTEGER.equals(coercedType)) - { - return Diagnostic.OK_INSTANCE; - } - - // JSP.2.4.5.4, step 3: if String - // note, use uncoerced type, since type coercer will return null for strings - if (TypeCoercer.typeIsString(type.getSignature())) - { - // if it's a string and we have the value, we can determine for - // sure whether or not it's coercable to a number - // per JSP.2.3.5.4 step 3.1 - if (type instanceof StringLiteralType) - { - String literalValue = ((LiteralType)type).getLiteralValue(); - if (literalValue.indexOf('.') > -1 - || literalValue.indexOf('e') > -1 - || literalValue.indexOf('E') > -1) - { - // if it coerces to double, then it's a double - ((LiteralType)type).coerceToNumber(Double.class); - // this is okay, because an expression like #{-3.3} can't be folded - return Diagnostic.OK_INSTANCE; - } - // per JSP.2.3.5.4, step 3.2 try to coerce to long - // if it coerces to long, then it's a long - ((LiteralType)type).coerceToNumber(Long.class); - // this is okay, because an expression like #{-3} can't be folded - return Diagnostic.OK_INSTANCE; - } - // if non-literal string, warn that coercion to number is not - // guaranteed since Long.valueOf and Double.valueOf - // (unlike Boolean.valueOf) throw NumberFormatExceptions - return _diagnosticFactory.create_UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED(UNARY_MINUS); - } - - // JSP.2.3.5.4, step 4, for all numeric types, retain type, - // validate constant folding - // note that this return true for big int and decimal, so those cases - // must already have been handled. - if (TypeCoercer.typeIsNumeric(coercedType)) - { - // otherwise, we are fine - return Diagnostic.OK_INSTANCE; - } - - } - catch (TypeCoercionException tce) - { - // fallthrough to error below - } - // otherwise, error - return _diagnosticFactory.create_UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(UNARY_MINUS); - } - - /** - * Based on JSP.2.3.5.4 - * - * @param type - * @return type of type after a minus is applied or null if unknown - */ - public ValueType performOperation(ValueType type) - { - try - { - final String boxedType = - TypeTransformer.transformBoxPrimitives(type.getSignature()); - // check for valid type coercion - String coercedType = TypeCoercer.coerceToNumber(boxedType); - - if (TypeCoercer.typeIsNull(coercedType)) - { - // null always coerces to 0L on this operator - return new IntegerLiteralType(0L); - } - - // JSP.2.3.5.4, step 2 if BigDecimal or BigInteger, then can't be - // literal and retains type - if (TypeConstants.TYPE_BIG_DOUBLE.equals(coercedType)) - { - return new ValueType(TypeConstants.TYPE_BIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS); - } - else if (TypeConstants.TYPE_BIG_INTEGER.equals(coercedType)) - { - return new ValueType(TypeConstants.TYPE_BIG_INTEGER, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - if (TypeCoercer.typeIsString(type.getSignature())) - { - // if it's string and we have the value, we can determine for - // sure whether or not it's coercable to a number - // per JSP.2.3.5.4 step 3 - if (type instanceof StringLiteralType) - { - String literalValue = ((LiteralType)type).getLiteralValue(); - if (literalValue.indexOf('.') > -1 - || literalValue.indexOf('e') > -1 - || literalValue.indexOf('E') > -1) - { - // if it coerces to double, then it's a double - Number value = ((LiteralType)type).coerceToNumber(Double.class); - return new FloatLiteralType(-1 * value.doubleValue()); - } - - // if it coerces to long, then it's a long - Number value = ((LiteralType)type).coerceToNumber(Long.class); - return new IntegerLiteralType(-1 * value.longValue()); - } - - // otherwise, just return a long typed value - return new ValueType(Signature.SIG_LONG, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - // JSP.2.3.5.4 - // big integer and big decimal retain type - // all numeric types retain type - if (TypeCoercer.typeIsNumeric(boxedType)) - { - // integer and float literals are special because -1 or -1.0 - // is syntically minusOp(1) and minusOp(1.0) - if (type instanceof IntegerLiteralType) - { - return new IntegerLiteralType(-1 * ((IntegerLiteralType)type).coerceToNumber(Long.class).longValue()); - } - else if (type instanceof FloatLiteralType) - { - return new FloatLiteralType(-1 * ((FloatLiteralType)type).coerceToNumber(Double.class).doubleValue()); - } - return type; - } - - // all other cases, return null - // even is type represents a String, without it's value, we have - // no idea how to coerce it without it's value - // fall through and return null - } - catch (TypeCoercionException tce) - { - // do nothing, fall through and return null - } - - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ModArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ModArithmeticBinaryOperator.java deleted file mode 100644 index ed8e39470..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ModArithmeticBinaryOperator.java +++ /dev/null @@ -1,384 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the EL modulo operator: % or mod - * Based JSP.2.3.5.3 - * - * @author cbateman - * - */ -/*package*/ class ModArithmeticBinaryOperator extends ArithmeticBinaryOperator -{ - private static final String MODULO = "modulo"; - - ModArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) { - super(diagnosticFactory); - // TODO Auto-generated constructor stub - } - - public ValueType performOperation(ValueType firstArg, ValueType secondArg) - { - // JSP.2.3.5.3, step 1 if both null, then return zero - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - && TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return IntegerLiteralType.ZERO; - } - - final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.3, step 2, if either arg is BigDecimal, Float, Double - // or String (ignoring whether it is value coercable), then coerce - // to Double and do op - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg)) - { - // TODO: handle case where one is a literal or resolvable string value - // that containss ".", "e" or "E" - return performDouble(firstArg, secondArg); - } - - // JSP.2.3.5.3, step 3, if either arg is a BigInteger, coerce - // both to BigInteger - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - return performBigInteger(firstArg, secondArg); - } - - // JSP.2.3.5.3, step 4, otherwise try to perform as a Long op - return performLong(firstArg, secondArg); - } - - public Diagnostic validate(ValueType firstArg, ValueType secondArg) { - // JSP.2.3.5.3, step 1 if both null, then return zero - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - && TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return _diagnosticFactory.create_BINARY_OP_BOTH_OPERANDS_NULL(MODULO); - } - - final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.3, step 2, if either arg is BigDecimal, Float, Double - // or String (ignoring whether it is value coercable), then coerce - // to Double and do op - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg) - || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg)) - { - // TODO: handle case where one is a literal or resolvable string value - // that containss ".", "e" or "E" - return validateDouble(firstArg, secondArg); - } - - // JSP.2.3.5.3, step 3, if either arg is a BigInteger, coerce - // both to BigInteger - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - return validateBigInteger(firstArg, secondArg); - } - - // JSP.2.3.5.3, step 4, otherwise try to perform as a Long op - return validateLong(firstArg, secondArg); - } - - private ValueType performDouble(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - Number secondValue = null; - - if (secondArg instanceof LiteralType) - { - secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class); - - if (secondValue.doubleValue() == 0.0) - { - // division by zero - return null; - } - } - - Number firstValue = null; - - if (firstArg instanceof LiteralType) - { - firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class); - } - - if (firstValue != null && secondValue != null) - { - return new FloatLiteralType( - doRealOperation(new Double(firstValue.doubleValue()), - new Double(secondValue.doubleValue())).doubleValue()); - } - - // if we get to here, the coercion is valid, so a Double will be - // returned - return new ValueType(Signature.SIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS); - } - catch (TypeCoercionException tce) - { - // could not coerce, so null - return null; - } - } - - private ValueType performBigInteger(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - // check second arg for zero - if (secondArg instanceof LiteralType) - { - if (((LiteralType)secondArg).coerceToNumber(BigInteger.class).equals(BigInteger.ZERO)) - { - // division by zero - return null; - } - } - - // since one of the args is BigInteger, they are not both literals, - // so if we get to here, we have a successful mod of two - // big integers to one big integer - return new ValueType(TypeConstants.TYPE_BIG_INTEGER, IAssignable.ASSIGNMENT_TYPE_RHS); - } - catch (TypeCoercionException tce) - { - // no coercion - return null; - } - } - - private ValueType performLong(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - Number secondValue = null; - - if (secondArg instanceof LiteralType) - { - secondValue = ((LiteralType)secondArg).coerceToNumber(Long.class); - - if (secondValue.longValue() == 0) - { - // division by zero - return null; - } - } - - Number firstValue = null; - - if (firstArg instanceof LiteralType) - { - firstValue = ((LiteralType)firstArg).coerceToNumber(Long.class); - } - - if (firstValue != null && secondValue != null) - { - return new IntegerLiteralType( - doRealOperation(new Long(firstValue.longValue()), - new Long(secondValue.longValue())).longValue()); - } - - // if we get to here, the coercion is valid, so a Long will be - // returned - return new ValueType(Signature.SIG_LONG, IAssignable.ASSIGNMENT_TYPE_RHS); - } - catch (TypeCoercionException tce) - { - // could not coerce, so null - return null; - } - } - - private Diagnostic validateDouble(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - Number secondValue = null; - - if (secondArg instanceof LiteralType) - { - secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class); - - if (secondValue.doubleValue() == 0.0) - { - // division by zero - return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO(); - } - } - - Number firstValue = null; - - if (firstArg instanceof LiteralType) - { - firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class); - } - - if (firstValue != null && secondValue != null) - { - return _diagnosticFactory. - create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME - (MODULO, Double.toString( - firstValue.doubleValue()%secondValue.doubleValue())); - } - - // if we get to here, the coercion is valid, so a Double will be - // returned and everything is good - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException tce) - { - // could not coerce, so error - return _diagnosticFactory. - create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(MODULO); - } - } - - private Diagnostic validateBigInteger(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - // check second arg for zero - if (secondArg instanceof LiteralType) - { - if (((LiteralType)secondArg).coerceToNumber(BigInteger.class).equals(BigInteger.ZERO)) - { - // division by zero - return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO(); - } - } - - // since one of the args is BigInteger, they are not both literals, - // so if we get to here, we have a successful mod of two - // big integers to one big integer - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException tce) - { - // no coercion - return _diagnosticFactory. - create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(MODULO); - } - } - - private Diagnostic validateLong(ValueType firstArg, ValueType secondArg) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - Number secondValue = null; - - if (secondArg instanceof LiteralType) - { - secondValue = ((LiteralType)secondArg).coerceToNumber(Long.class); - - if (secondValue.longValue() == 0) - { - // division by zero - return _diagnosticFactory. - create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO(); - } - } - - Number firstValue = null; - - if (firstArg instanceof LiteralType) - { - firstValue = ((LiteralType)firstArg).coerceToNumber(Long.class); - } - - if (firstValue != null && secondValue != null) - { - return _diagnosticFactory. - create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME - (MODULO, Long.toString(firstValue.longValue()%secondValue.longValue())); - } - - // if we get to here, the coercion is valid, so a Long will be - // returned - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException tce) - { - // could not coerce, so error - return _diagnosticFactory. - create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(MODULO); - } - } - - protected Long doRealOperation(Long firstArg, Long secondArg) { - return new Long(firstArg.longValue() % secondArg.longValue()); - } - - protected Double doRealOperation(Double firstArg, Double secondArg) { - return new Double(firstArg.doubleValue() % secondArg.doubleValue()); - } - - protected BigDecimal doRealOperation(BigDecimal firstArg, - BigDecimal secondArg) { - return new BigDecimal(firstArg.doubleValue() % secondArg.doubleValue()); - } - - protected String getOperatorName() { - return MODULO; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MultiplyArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MultiplyArithmeticBinaryOperator.java deleted file mode 100644 index 01f8d9aa0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MultiplyArithmeticBinaryOperator.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the EL Multiply arithmetic binary operator "*" - * - * @author cbateman - * - */ -/*package*/ class MultiplyArithmeticBinaryOperator extends - NoDivArithmeticBinaryOperator -{ - private static final String MULTIPLICATION = "multiplication"; - - - MultiplyArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) - { - super(diagnosticFactory); - } - - protected Long doRealOperation(Long firstArg, Long secondArg) - { - return new Long(firstArg.longValue() * secondArg.longValue()); - } - - protected Double doRealOperation(Double firstArg, Double secondArg) - { - return new Double(firstArg.doubleValue() * secondArg.doubleValue()); - } - - protected BigDecimal doRealOperation(BigDecimal firstArg, - BigDecimal secondArg) - { - return firstArg.multiply(secondArg); - } - - protected String getOperatorName() { - return MULTIPLICATION; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NoDivArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NoDivArithmeticBinaryOperator.java deleted file mode 100644 index 5bdc163fc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NoDivArithmeticBinaryOperator.java +++ /dev/null @@ -1,300 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents non-dividing arithmetic EL operators: +,-,* - * Based on JSP.2.3.5.1 - * - * @author cbateman - * - */ -/*package*/ abstract class NoDivArithmeticBinaryOperator extends ArithmeticBinaryOperator -{ - NoDivArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) { - super(diagnosticFactory); - } - - protected abstract Long doRealOperation(Long firstArg, Long secondArg); - - protected abstract Double doRealOperation(Double firstArg, Double secondArg); - - public ValueType performOperation(ValueType firstArg, ValueType secondArg) - { - // JSP.2.3.5.1, step 1, if either arg is null, return (Long) 0 - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - && TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return new IntegerLiteralType(0); - } - - final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.1, step 2, if either arg is a BigDecimal, coerce to BigDecimal - // and apply - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg)) - { - return handleNumericArithmetic(firstArg, secondArg, BigDecimal.class); - } - - // JSP.2.3.5.1, step 3, if either arg is float or double or - // a String containing "., e or E", then coerce if the other is - // a big int, coerce up to BigDecimal, else to Double - // Note: we are ignoring strings we can't resolve to figure out - // if the contain "., e or E". Assume they always do - if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg) - ||TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg) - ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg) - ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg)) - { - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - ||TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - // if the other operand is BigInteger, treat as BigDecimal - return handleNumericArithmetic(firstArg, secondArg, BigDecimal.class); - } - - // otherwise as double - return handleNumericArithmetic(firstArg, secondArg, Double.class); - } - - // JSP.2.3.5.1, step 4, if one is a big integer, coerce to big integer - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - return handleNumericArithmetic(firstArg, secondArg, BigInteger.class); - } - - // JSP.2.3.5.1, step 5, otherwise, try to coerce to Long - return handleNumericArithmetic(firstArg, secondArg, Long.class); - } - - public Diagnostic validate(ValueType firstArg, ValueType secondArg) - { - // JSP.2.3.5.1, step 1, if either arg is null, return (Long) 0 - if (TypeCoercer.typeIsNull(firstArg.getSignature()) - && TypeCoercer.typeIsNull(secondArg.getSignature())) - { - return _diagnosticFactory.create_BINARY_OP_BOTH_OPERANDS_NULL(getOperatorName()); - } - - final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature()); - final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature()); - - // JSP.2.3.5.1, step 2, if either arg is a BigDecimal, coerce to BigDecimal - // and apply - if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg)) - { - return validateNumericArithmetic(firstArg, secondArg, BigDecimal.class); - } - - // JSP.2.3.5.1, step 3, if either arg is float or double or - // a String containing "., e or E", then coerce if the other is - // a big int, coerce up to BigDecimal, else to Double - // Note: we are ignoring strings we can't resolve to figure out - // if the contain "., e or E". Assume they always do - if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg) - ||TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg) - ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg) - ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg)) - { - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - ||TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - // if the other operand is BigInteger, treat as BigDecimal - return validateNumericArithmetic(firstArg, secondArg, BigDecimal.class); - } - - // otherwise as double - return validateNumericArithmetic(firstArg, secondArg, Double.class); - } - - // JSP.2.3.5.1, step 4, if one is a big integer, coerce to big integer - if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg) - || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg)) - { - return validateNumericArithmetic(firstArg, secondArg, BigInteger.class); - } - - // JSP.2.3.5.1, step 5, otherwise, try to coerce to Long - return validateNumericArithmetic(firstArg, secondArg, Long.class); - } - - /** - * @param firstArg - * @param secondArg - * @param numberType - * @return a value type based on the result of the arithmetic operation - */ - protected ValueType handleNumericArithmetic(ValueType firstArg, ValueType secondArg, Class numberType) - { - try - { -// final String coercedFirstArg = - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); -// final String coercedSecondArg = - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - if (firstArg instanceof LiteralType && secondArg instanceof LiteralType) - { - try - { - Number firstValue = - ((LiteralType)firstArg).coerceToNumber(numberType); - Number secondValue = - ((LiteralType)secondArg).coerceToNumber(numberType); - - LiteralType result = null; - - if (numberType == Double.class) - { - Double resultValue = - doRealOperation((Double)firstValue, - (Double) secondValue); - result = new FloatLiteralType(resultValue.doubleValue()); - } - else if (numberType == Long.class) - { - Long resultValue = - doRealOperation((Long) firstValue, (Long) secondValue); - result = new IntegerLiteralType(resultValue.longValue()); - } - else - { - throw new AssertionError("unsupport arithmetic upcast type"); - } - - return result; - } - catch (TypeCoercionException tce) - { - // could happen if two string literals passed - return null; - } - } - - // if we get to here, then we have two valid numeric arith - // types, but at least one is not a literal, so the best we can - // say is that the return will be the same asthe type of numeric - // coercion - if (numberType == BigDecimal.class) - { - return new ValueType(TypeConstants.TYPE_BIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS); - } - else if (numberType == Double.class) - { - return new ValueType(Signature.SIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS); - } - else if (numberType == BigInteger.class) - { - return new ValueType(TypeConstants.TYPE_BIG_INTEGER, IAssignable.ASSIGNMENT_TYPE_RHS); - } - else - { - return new ValueType(Signature.SIG_LONG, IAssignable.ASSIGNMENT_TYPE_RHS); - } - } - catch (TypeCoercionException tce) - { - // coercion to number failed, so no go - return null; - } - } - - /** - * @param firstArg - * @param secondArg - * @param numberType - * @return a diagnostic validating the arithmetic expr firstArg op secondArg - */ - protected Diagnostic validateNumericArithmetic(ValueType firstArg, ValueType secondArg, Class numberType) - { - try - { -// final String coercedFirstArg = - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); -// final String coercedSecondArg = - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - if (firstArg instanceof LiteralType && secondArg instanceof LiteralType) - { - try - { - Number firstValue = - ((LiteralType)firstArg).coerceToNumber(numberType); - Number secondValue = - ((LiteralType)secondArg).coerceToNumber(numberType); - - Number result = null; - - if (numberType == Double.class) - { - result = - doRealOperation((Double)firstValue, - (Double) secondValue); - } - else if (numberType == Long.class) - { - result = - doRealOperation((Long) firstValue, (Long) secondValue); - } - else - { - throw new AssertionError("unsupport arithmetic upcast type"); - } - - return _diagnosticFactory. - create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME - (getOperatorName(), result.toString()); - } - catch (TypeCoercionException tce) - { - // could happen when two strings are passed - return _diagnosticFactory. - create_BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS(); - } - } - - // if we get to here, then we have two valid numeric arith - // types, but at least one is not a literal - // everything should be ok - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException tce) - { - // coercion to number failed, so no go - return _diagnosticFactory. - create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(getOperatorName()); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotEqualsBinaryRelationalOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotEqualsBinaryRelationalOperator.java deleted file mode 100644 index 1d6245426..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotEqualsBinaryRelationalOperator.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the not equals -- "!="/ne EL binary operator - * @author cbateman - * - */ -/*package*/ class NotEqualsBinaryRelationalOperator extends - EqualityRelationalBinaryOperator { - - NotEqualsBinaryRelationalOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) - { - super(diagnosticFactory, jsfVersion); - } - - protected boolean doRealOperation(Number firstArg, Number secondArg) { - return !firstArg.equals(secondArg); - } - - protected boolean doRealOperation(Boolean firstArg, Boolean secondArg) { - return !firstArg.equals(secondArg); - } - - protected boolean doRealOperation(String firstArg, String secondArg) { - return !firstArg.equals(secondArg); - } - - protected String getOperationName() - { - return Messages.getString("NotEqualsBinaryRelationalOperator.OperationName"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotUnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotUnaryOperator.java deleted file mode 100644 index dd1d5db1a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotUnaryOperator.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents te EL unary operators "!" and "not" on a ValueType - * as described by JSP.2.3.6.2 - * - * @author cbateman - * - */ -/*package*/ class NotUnaryOperator extends UnaryOperator -{ - NotUnaryOperator(DiagnosticFactory diagnosticFactory) - { - super(diagnosticFactory); - } - - public Diagnostic validate(ValueType type) - { - boolean canCoerce = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(type.getSignature())); - - if (canCoerce) - { - // check for constant evaluation - if (type instanceof LiteralType) - { - try - { - Boolean coercedValue = ((LiteralType)type).coerceToBoolean(); - - // we are logically notting, so coerced is true, then false - // if false then true - return _diagnosticFactory.create_UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID( - "not" - , Boolean.valueOf(!coercedValue.booleanValue()).toString()); - - } - catch (TypeCoercionException tce) - { - throw new AssertionError("coerce should not throw exception"); - } - } - - return Diagnostic.OK_INSTANCE; - } - return _diagnosticFactory.create_UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN(); - } - - public ValueType performOperation(ValueType type) - { - boolean canCoerce = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(type.getSignature())); - - if (canCoerce) - { - if (type instanceof LiteralType) - { - try - { - Boolean coercedValue = ((LiteralType)type).coerceToBoolean(); - - // we are logically notting, so coerced is true, then false - // if false then true - return - coercedValue.booleanValue() ? - BooleanLiteralType.FALSE : - BooleanLiteralType.TRUE; - } - catch (TypeCoercionException tce) - { - throw new AssertionError("coerce should not throw exception"); - } - } - - return new ValueType(TypeConstants.TYPE_BOOLEAN, type.getAssignability()); - } - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/OrBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/OrBinaryOperator.java deleted file mode 100644 index 33bd4be7f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/OrBinaryOperator.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Encapsulates the 'and'/'&&' boolean-AND operator - * Based on JSP.2.3.6.1 - * - * @author cbateman - * - */ -/*package*/class OrBinaryOperator extends LogicalBinaryOperator -{ - OrBinaryOperator(DiagnosticFactory diagnosticFactory) - { - super(diagnosticFactory); - } - - protected boolean doRealOperation(Boolean firstArg, Boolean secondArg) - { - return (firstArg.booleanValue() || secondArg.booleanValue()); - } - - protected String readableOperatorName() - { - return "logical-OR"; - } - - protected boolean shortCircuitValue() - { - // OR short-circuits on true - return true; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/RelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/RelationalBinaryOperator.java deleted file mode 100644 index 924ec9854..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/RelationalBinaryOperator.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - - -/** - * Super-class of all relational binary ops - "==", "!=", "<", ">", "<=", ">=" - * @author cbateman - * - */ -/*package*/ abstract class RelationalBinaryOperator extends BinaryOperator -{ - private final String _jsfVersion; - - RelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, final String jsfVersion) - { - super(diagnosticFactory); - _jsfVersion = jsfVersion; - } - - /** - * @param firstArg - * @param secondArg - * @return the result of the operation - */ - protected abstract boolean doRealOperation(Number firstArg, Number secondArg); - - /** - * @param firstArg - * @param secondArg - * @return the result of the operation - */ - protected abstract boolean doRealOperation(String firstArg, String secondArg); - - /** - * @return the operation's user readable name - */ - protected abstract String getOperationName(); - - /** - * Performs a the operation, casting both args to BigDecimal first - * - * @param firstArg - * @param secondArg - * @param numberType - * @return the result of the comparison or null if indeterminate - */ - protected ValueType handleNumericComparison(ValueType firstArg, ValueType secondArg, Class numberType) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature())); - - Number firstValue = null; - if (firstArg instanceof LiteralType) - { - firstValue = ((LiteralType)firstArg).coerceToNumber(numberType); - } - - Number secondValue = null; - if (secondArg instanceof LiteralType) - { - secondValue = ((LiteralType)secondArg).coerceToNumber(numberType); - } - - if (firstValue != null && secondValue != null) - { - boolean result = doRealOperation(firstValue, secondValue); - - return result ? BooleanLiteralType.TRUE : BooleanLiteralType.FALSE; - } - - // if we get to here, we only know that both can be up cast to BigDecimal - // and compared. This will yield a boolean result - // this value cannot be lhs - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - catch (TypeCoercionException tce) - { - // no valid coercion, so return null - return null; - } - } - - /** - * @param firstType - * @param secondType - * @param numberType - * @return a diagnostic validating the relational comparison of firstType to secondType - */ - protected Diagnostic validateNumericComparison(ValueType firstType, ValueType secondType, Class numberType) - { - try - { - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstType.getSignature())); - TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondType.getSignature())); - - Number firstValue = null; - if (firstType instanceof LiteralType) - { - firstValue = ((LiteralType)firstType).coerceToNumber(numberType); - } - - Number secondValue = null; - if (secondType instanceof LiteralType) - { - secondValue = ((LiteralType)secondType).coerceToNumber(numberType); - } - - if (firstValue != null && secondValue != null) - { - boolean result = doRealOperation(firstValue, secondValue); - - return _diagnosticFactory. - create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME - (getOperationName(), Boolean.toString(result)); - } - - // if we get to here, we only know that both can be up cast to BigDecimal - // and compared. This condition is okay - return Diagnostic.OK_INSTANCE; - } - catch (TypeCoercionException tce) - { - // could not make numeric coercion for valid comparison - return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(getOperationName()); - } - } - - /** - * @param firstType - * @param secondType - * @return the result of the operation - */ - protected ValueType handleStringComparison(ValueType firstType, ValueType secondType) - { - String firstValue = null; - - if (firstType instanceof LiteralType) - { - firstValue = ((LiteralType)firstType).getLiteralValue(); - } - - String secondValue = null; - if (secondType instanceof LiteralType) - { - secondValue = ((LiteralType)secondType).getLiteralValue(); - } - - if (firstValue != null && secondValue != null) - { - boolean newValue = doRealOperation(firstValue, secondValue); - return newValue ? BooleanLiteralType.TRUE : BooleanLiteralType.FALSE; - } - - // if don't have all literals, just return boolean type - return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - /** - * @param firstType - * @param secondType - * @return a diagnostic validating the string comparison of firstType to secondType - */ - protected Diagnostic validateStringComparison(ValueType firstType, ValueType secondType) - { - String firstValue = null; - - if (firstType instanceof LiteralType) - { - firstValue = ((LiteralType)firstType).getLiteralValue(); - } - - String secondValue = null; - if (secondType instanceof LiteralType) - { - secondValue = ((LiteralType)secondType).getLiteralValue(); - } - - if (firstValue != null && secondValue != null) - { - boolean newValue = doRealOperation(firstValue, secondValue); - return _diagnosticFactory. - create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME - (getOperationName(), Boolean.toString(newValue)); - } - - // if don't have all literals, just return boolean type - return Diagnostic.OK_INSTANCE; - } - - - /** - * @return the current JSF version string - */ - protected final String getJsfVersion() { - return _jsfVersion; - } - - /** - * @return true if the JSF version for this operator is JSF 1.1 or 1.0 - */ - protected final boolean isPreJSF12() - { - return IJSFCoreConstants.JSF_VERSION_1_1.equals(_jsfVersion) - || IJSFCoreConstants.JSF_VERSION_1_0.equals(_jsfVersion); - } - - /** - * @return true if the JSF version for this operator is JSF 1.2 or later - */ - protected final boolean isJSF12OrLater() - { - return !isPreJSF12(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/SubtractArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/SubtractArithmeticBinaryOperator.java deleted file mode 100644 index bc1b97b0e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/SubtractArithmeticBinaryOperator.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import java.math.BigDecimal; - -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the EL arithmetic subtraction binary operator - * - * @author cbateman - * - */ -/*package*/ class SubtractArithmeticBinaryOperator extends - NoDivArithmeticBinaryOperator -{ - - private static final String SUBTRACTION = "subtraction"; - - SubtractArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) { - super(diagnosticFactory); - } - - protected Long doRealOperation(Long firstArg, Long secondArg) - { - return new Long(firstArg.longValue() - secondArg.longValue()); - } - - protected Double doRealOperation(Double firstArg, Double secondArg) - { - return new Double(firstArg.doubleValue() - secondArg.doubleValue()); - } - - protected BigDecimal doRealOperation(BigDecimal firstArg, - BigDecimal secondArg) - { - return firstArg.subtract(secondArg); - } - - protected String getOperatorName() - { - return SUBTRACTION; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/TernaryChoiceOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/TernaryChoiceOperator.java deleted file mode 100644 index c50d8ab44..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/TernaryChoiceOperator.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.IAssignable; -import org.eclipse.jst.jsf.common.internal.types.LiteralType; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercer; -import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException; -import org.eclipse.jst.jsf.common.internal.types.TypeTransformer; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; - -/** - * Represents the ternary choice op in EL: a ? b :c - * Based on JSP.2.3.8 - * - * @author cbateman - * - */ -public class TernaryChoiceOperator -{ - private final DiagnosticFactory _diagnosticFactory; - - - /** - * @param diagnosticFactory - */ - public TernaryChoiceOperator(DiagnosticFactory diagnosticFactory) - { - super(); - _diagnosticFactory = diagnosticFactory; - } - - /** - * @param choiceArg - * @param whenTrueArg - * @param whenFalseArg - * @return the result of the choice arguments or null if indeterminant - */ - public ValueType perform(ValueType choiceArg, ValueType whenTrueArg, ValueType whenFalseArg) - { - final boolean isChoiceBoolean = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(choiceArg.getSignature())); - - if (isChoiceBoolean) - { - if (choiceArg instanceof LiteralType) - { - try - { - Boolean result = ((LiteralType)choiceArg).coerceToBoolean(); - - if (result != null) - { - return result.booleanValue() ? whenTrueArg : whenFalseArg; - } - } - catch (TypeCoercionException tce) - { - return null; - } - } - - final String boxedWhenTrueArg = - TypeTransformer.transformBoxPrimitives(whenTrueArg.getSignature()); - - final String boxedWhenFalseArg = - TypeTransformer.transformBoxPrimitives(whenFalseArg.getSignature()); - // check if the two results are the same type - // TODO: could increase accuracy by appoximating type:i.e. if both - // are numeric etc. - if (boxedWhenTrueArg.equals(boxedWhenFalseArg)) - { - return new ValueType(whenTrueArg, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - // otherwise, we have no idea what the resulting type is - return null; - } - - // if choice is not boolean, then can't resolve - return null; - } - - /** - * @param choiceArg - * @return a diagnostic validating the choice expr with these arguments - */ - public Diagnostic validate(ValueType choiceArg) - { - final boolean isChoiceBoolean = - TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(choiceArg.getSignature())); - - if (isChoiceBoolean) - { - if (choiceArg instanceof LiteralType) - { - try - { - Boolean result = ((LiteralType)choiceArg).coerceToBoolean(); - - if (result != null) - { - String whichSelected = result.booleanValue() ? "first" : "second"; - return _diagnosticFactory. - create_TERNARY_OP_CHOICE_IS_ALWAYS_SAME - (result.booleanValue(), whichSelected); - } - } - catch (TypeCoercionException tce) - { - return _diagnosticFactory. - create_TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN(); - } - } - - // in both the case where the two arguments are the same and when - // they are different types, the best we can say is "OK", since - // we really don't know - return Diagnostic.OK_INSTANCE; - } - - // if choice is not boolean, then can't resolve - return _diagnosticFactory. - create_TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/UnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/UnaryOperator.java deleted file mode 100644 index d6a075999..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/UnaryOperator.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.validation.internal.el.operators; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.internal.types.ValueType; -import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory; -import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserConstants; -import org.eclipse.jst.jsp.core.internal.java.jspel.Token; - -/** - * Encapsulates an EL unary operator - * @author cbateman - * - */ -public abstract class UnaryOperator -{ - /** - * The common factory used to construct diagnostics - */ - protected final DiagnosticFactory _diagnosticFactory; - - /** - * @param token - * @return true if the token is a unary operator - */ - public static boolean isUnaryOperator(Token token) - { - return (token.kind == JSPELParserConstants.MINUS) - || (token.kind == JSPELParserConstants.NOT1) - || (token.kind == JSPELParserConstants.NOT2) - || (token.kind == JSPELParserConstants.EMPTY); - } - - /** - * @param token - * @param diagnosticFactory - * @return a new UnaryOperator instance matching token - */ - public static UnaryOperator createUnaryOperator(Token token, DiagnosticFactory diagnosticFactory) - { - if (!isUnaryOperator(token)) - { - throw new IllegalArgumentException("token must be a unary operator"); - } - - switch(token.kind) - { - case JSPELParserConstants.MINUS: - return new MinusUnaryOperator(diagnosticFactory); - - case JSPELParserConstants.NOT1: - case JSPELParserConstants.NOT2: - return new NotUnaryOperator(diagnosticFactory); - - case JSPELParserConstants.EMPTY: - return new EmptyUnaryOperator(diagnosticFactory); - } - - // should never get here because all four ops are covered - throw new AssertionError(); - } - - /** - * Constructor - */ - UnaryOperator(DiagnosticFactory diagnosticFactory) - { - /* no construction or sub-classing outside package*/ - _diagnosticFactory = diagnosticFactory; - } - - /** - * If ValueType is a literal and the operation can be performed, then - * the return must be a new LiteralType transformed using this operator. - * - * If ValueType is not a literal and the operaton can be performed, then - * the return is a new ValueType transformed per the rules of the operator - * (i.e. if it is a string type and the operator is "!", then the string - * must be coerced to a boolean and this is what will be returned) - * - * If the operation cannot be performed on ValueType, return null - * - * @param type - * @return a new value type after the operation is performed - */ - public abstract ValueType performOperation(ValueType type); - - - /** - * @param type - * @return a Diagnostic interpreting whether it is valid to perform the - * operation on this type - */ - public abstract Diagnostic validate(ValueType type); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/messages.properties deleted file mode 100644 index eb4014605..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/messages.properties +++ /dev/null @@ -1,9 +0,0 @@ -EqualityRelationalBinaryOperator.FirstArgument=first -EqualsBinaryRelationalOperator.OperationName=equals -EqualityRelationalBinaryOperator.SecondArgument=second -GreaterThanEqRelationalBinaryOperator.OperationName=greater than or equal to -GreaterThanRelationalBinaryOperator.OperationName=greater than -LessThanEqRelationalBinaryOperator.OperationName=less than or equal to -LessThanRelationalBinaryOperator.OperationName=less than -LtGtRelationalBinaryOperator.ConstantName.False=false -NotEqualsBinaryRelationalOperator.OperationName=not equals |