diff options
Diffstat (limited to 'plugins/org.eclipse.wst.common.frameworks/src/org/eclipse')
73 files changed, 0 insertions, 8422 deletions
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java deleted file mode 100644 index 00f877f66..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.AbstractOperation; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -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.core.runtime.jobs.ISchedulingRule; -import org.eclipse.wst.common.environment.IEnvironment; - -/** - * <p> - * Abstract implementation for an IDataModelOperation. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation - * - * @since 1.0 - */ -public abstract class AbstractDataModelOperation extends AbstractOperation implements IDataModelOperation { - - /** - * <p> - * Convenience IStatus.OK. - * </p> - */ - protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS; - - private String id; - private IEnvironment environment; - - /** - * <p> - * The IDataModel used by this IDataModelOperation - * </p> - */ - protected IDataModel model; - - /** - * <p> - * Default constructor. - * </p> - */ - public AbstractDataModelOperation() { - super(""); //$NON-NLS-1$ - this.id = getClass().getName(); - } - - /** - * <p> - * Constructor taking an IDataModel - * </p> - * - * @param model - * the IDataModel used to drive this operation - */ - public AbstractDataModelOperation(IDataModel model) { - super(""); //$NON-NLS-1$ // TODO add a label property to IDataModel??? - this.model = model; - this.id = getClass().getName(); - } - - /** - * <p> - * Default implementation of setID(). - * <p> - * - * @see IDataModelOperation#setID(String) - */ - public void setID(String id) { - this.id = id; - } - - /** - * <p> - * Default implementation of getID(). - * </p> - * - * @see IDataModelOperation#getID() - */ - public String getID() { - return id; - } - - /** - * <p> - * Default implementation of setDataModel() - * </p> - * - * @see IDataModelOperation#setDataModel(IDataModel) - */ - public void setDataModel(IDataModel model) { - this.model = model; - } - - /** - * <p> - * Default implementation of getDataModel() - * </p> - * - * @see IDataModelOperation#getDataModel() - */ - public IDataModel getDataModel() { - return model; - } - - /** - * <p> - * Default implementation of getSchedulingRule() returns - * <code>ResourcesPlugin.getWorkspace().getRoot()</code>. - * </p> - * - * @see IDataModelOperation#getSchedulingRule() - */ - public ISchedulingRule getSchedulingRule() { - return ResourcesPlugin.getWorkspace().getRoot(); - } - - /** - * <p> - * Default implementation of getOperationExecutionFlags() returns - * <code>IWorkspace.AVOID_UPDATE</code>. - * </p> - * - * @see IDataModelOperation#getOperationExecutionFlags() - */ - public int getOperationExecutionFlags() { - return IWorkspace.AVOID_UPDATE; - } - - /** - * <p> - * The framework will set the environment on this operation before it is executed. The operation - * can then use the environment to report status, log information, and access resources in an - * environment neutral way. - * </p> - * - * @param env - * the environment. - * - */ - public final void setEnvironment(IEnvironment env) { - environment = env; - } - - /** - * <p> - * An operation can call this method to get the environment that has been set by the operations - * framework. - * </p> - * - * @return returns an environment. - */ - public final IEnvironment getEnvironment() { - return environment; - } - - /** - * <p> - * Default empty implementation of redo. - * </p> - */ - @Override - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.OK_STATUS; - } - - /** - * <p> - * Default empty implementation of undo. - * </p> - */ - @Override - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return Status.OK_STATUS; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelProvider.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelProvider.java deleted file mode 100644 index 57f330252..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelProvider.java +++ /dev/null @@ -1,327 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IStatus; - -/** - * <p> - * A default implementation of <code>IDataModelProvider</code>. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider - * @since 1.0 - */ -public abstract class AbstractDataModelProvider implements IDataModelProvider { - - /** - * <p> - * The IDataModel for this provider. - * </p> - */ - protected IDataModel model = null; - - public Set getPropertyNames() { - return new HashSet(); - } - - /** - * <p> - * A default implementation of init(). Subclasses should override as necessary. - * </p> - * - * @see IDataModelProvider#init() - */ - public void init() { - } - - /** - * </p> - * An implemenation of setDataModel(). - * </p> - * - * @see IDataModelProvider#setDataModel(IDataModel) - */ - public final void setDataModel(IDataModel dataModel) { - this.model = dataModel; - } - - /** - * <p> - * An implemenation of getDataModel(). - * </p> - * - * @see IDataModelProvider#getDataModel() - */ - public final IDataModel getDataModel() { - return model; - } - - - /** - * </p> - * A default impleneation of propertySet(). Subclasses should override as necessary. - * </p> - * - * @param propertyName - * the name of the property that has been set - * @param propertyValue - * the value the property has been set - * - * @see IDataModelProvider#propertySet(String, Object) - */ - public boolean propertySet(String propertyName, Object propertyValue) { - return true; - } - - /** - * <p> - * A default implemenation of getDefaultProperty(). Subclasses should override as necessary. - * </p> - * - * @param propertyName - * the specified property - * - * @see IDataModelProvider#getDefaultProperty(String) - */ - public Object getDefaultProperty(String propertyName) { - if(ALLOW_EXTENSIONS.equals(propertyName)){ - return Boolean.TRUE; - } else if(RESTRICT_EXTENSIONS.equals(propertyName)){ - return Collections.EMPTY_LIST; - } - return null; - } - - /** - * <p> - * A default implemenation of isPropertyEnabled(). Subclasses should override as necessary. - * </p> - * - * @param propertyName - * the specified property - * @see IDataModelProvider#isPropertyEnabled(String) - */ - public boolean isPropertyEnabled(String propertyName) { - return true; - } - - /** - * <p> - * A default implemenation of validate(). Subclasses should override as necessary. - * </p> - * - * @param name - * the name of the property or nested IDataModel being validated. - * - * @see IDataModelProvider#validate(String) - */ - public IStatus validate(String name) { - return null; - } - - /** - * <p> - * A default implemenation of getPropertyDescriptor(). Subclasses should override as necessary. - * </p> - * - * @param propertyName - * the specified property - * @see IDataModelProvider#getPropertyDescriptor(String) - */ - public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) { - return null; - } - - /** - * <p> - * A default implemenation of getValidPropertyDescriptors(). Subclasses should override as - * necessary. - * </p> - * - * @param propertyName - * the specified property - * @see IDataModelProvider#getValidPropertyDescriptors(String) - */ - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - return null; - } - - /** - * <p> - * A default implemenation of getExtendedContext(). Subclasses should override as necessary. - * </p> - * - * @see IDataModelProvider#getExtendedContext() - */ - public List getExtendedContext() { - return null; - } - - /** - * <p> - * A default implemenation of getDefaultOperation(). Subclasses should override as necessary. - * </p> - * - * @see IDataModelProvider#getDefaultOperation() - */ - public IDataModelOperation getDefaultOperation() { - return null; - } - - /** - * <p> - * A default implemenation of getName(). Subclasses should override as necessary. - * </p> - * - * @see IDataModelProvider#getID() - */ - public String getID() { - return this.getClass().getName(); - } - - /** - * <p> - * A default implemenation of dispose(). Subclasses should override as necessary. - * </p> - * - * @see IDataModelProvider#dispose() - */ - public void dispose() { - } - - /** - * <p> - * Convenience method for getting a property from the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @return the property value - * - * @see IDataModel#getProperty(String) - */ - protected final Object getProperty(String propertyName) { - return model.getProperty(propertyName); - } - - /** - * <p> - * Convenience method for setting a property on the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @param propertyValue - * the property value - * - * @see IDataModel#setProperty(String, Object) - */ - protected final void setProperty(String propertyName, Object propertyValue) { - model.setProperty(propertyName, propertyValue); - } - - /** - * <p> - * Convenience method for getting a boolean property from the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @return the boolean value of the property - * - * @see IDataModel#getBooleanProperty(String) - */ - protected final boolean getBooleanProperty(String propertyName) { - return model.getBooleanProperty(propertyName); - } - - /** - * <p> - * Convenience method for setting a boolean property on the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @param propertyValue - * the boolean property value - * - * @see IDataModel#setBooleanProperty(String, boolean) - */ - protected final void setBooleanProperty(String propertyName, boolean propertyValue) { - model.setBooleanProperty(propertyName, propertyValue); - } - - /** - * <p> - * Convenience method for getting an int property from the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @return the int value of the property - * - * @see IDataModel#getIntProperty(String) - */ - protected final int getIntProperty(String propertyName) { - return model.getIntProperty(propertyName); - } - - /** - * <p> - * Convenience method for setting an int property on the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @param propertyValue - * the int property value - * - * @see IDataModel#setIntProperty(String, int) - */ - protected final void setIntProperty(String propertyName, int propertyValue) { - model.setIntProperty(propertyName, propertyValue); - } - - /** - * <p> - * Convenience method for getting a String property from the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @return the String value of the property - * - * @see IDataModel#getStringProperty(String) - */ - protected final String getStringProperty(String propertyName) { - return model.getStringProperty(propertyName); - } - - /** - * <p> - * Convenience method for checking if a property is set from the backing IDataModel. - * </p> - * - * @param propertyName - * the property name - * @return <code>true</code> if the property is set, <code>false</code> otherwise. - */ - protected final boolean isPropertySet(String propertyName) { - return model.isPropertySet(propertyName); - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelEvent.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelEvent.java deleted file mode 100644 index 402b0bc72..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelEvent.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -/** - * <p> - * This event is used to communicate property changes from IDataModels to their IDataModelListeners. - * </p> - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModel#addListener(IDataModelListener) - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelListener - * - * @since 1.0 - */ -public final class DataModelEvent { - - /** - * <p> - * A flag used to specify the property's value has changed. - * </p> - * - * @see IDataModel#getProperty(String) - * @see #getFlag() - */ - public static final int VALUE_CHG = 1; - - /** - * Internal. Clients should not use. - */ - static final int DEFAULT_CHG = 2; - - /** - * <p> - * A flag used to specify the property's enablment has changed. - * </p> - * - * @see IDataModel#isPropertyEnabled(String) - * @see #getFlag() - */ - public static final int ENABLE_CHG = 3; - - /** - * <p> - * A flag used to specify the property's valid values have changed. - * </p> - * - * @see IDataModel#getValidPropertyDescriptors(String) - * @see #getFlag() - */ - public static final int VALID_VALUES_CHG = 4; - - - private IDataModel dataModel; - private String propertyName; - private int flag; - - /** - * <p> - * Constructor for DataModelEvent. - * </p> - * - * @param dataModel - * the IDataModel whose property has changed - * @param propertyName - * the name of the changed property - * @param flag - * contains a flag specifiying the event type - */ - public DataModelEvent(IDataModel dataModel, String propertyName, int flag) { - this.dataModel = dataModel; - this.propertyName = propertyName; - this.flag = flag; - } - - /** - * <p> - * Returns the IDataModel whose property has changed. - * </p> - * - * @return the IDataModel whose property has changed. - */ - public IDataModel getDataModel() { - return dataModel; - } - - /** - * <p> - * Returns the name of the changed property. - * </p> - * - * @return the name of the changed property. - */ - public String getPropertyName() { - return propertyName; - } - - /** - * <p> - * Returns the flag indicating the event type. Valid types are: - * <ul> - * <li><code>PROPERTY_CHG</code></li> - * <li><code>VALID_VALUES_CHG</code></li> - * <li><code>ENABLE_CHG</code></li> - * </ul> - * </p> - * - * @return the flag indicating the event type. - */ - public int getFlag() { - return flag; - } - - /** - * <p> - * Convenience method to return the IDataModel's property. This is equavalent to: - * <code>getDataModel().getProperty(getPropertyName())</code>. - * </p> - * - * @return the dataModel's property. - * @see IDataModel#getProperty(String) - */ - public Object getProperty() { - return dataModel.getProperty(propertyName); - } - - /** - * <p> - * Convenience method to return the IDataModel property's enablement state. This is equavalent - * to: <code>getDataModel().isPropertyEnabled(getPropertyName())</code>. - * </p> - * - * @return the dataModel property's enablement state. - * @see IDataModel#isPropertyEnabled(String) - */ - public boolean isPropertyEnabled() { - return dataModel.isPropertyEnabled(propertyName); - } - - /** - * <p> - * Convenience method to return the IDataModel property's valid property descriptors. This is - * equavalent to: <code>getDataModel().getValidPropertyDescriptors(getPropertyName())</code>. - * </p> - * - * @return the dataModel property's valid property descriptors. - * @see IDataModel#getValidPropertyDescriptors(String) - */ - public DataModelPropertyDescriptor[] getValidPropertyDescriptors() { - return dataModel.getValidPropertyDescriptors(propertyName); - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelFactory.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelFactory.java deleted file mode 100644 index 3682a6d9b..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -import org.eclipse.wst.common.frameworks.internal.datamodel.DataModelExtensionReader; -import org.eclipse.wst.common.frameworks.internal.datamodel.DataModelImpl; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * <p> - * DataModelFactory is used to create IDataModel instances. - * </p> - * - * @since 1.0 - */ -public class DataModelFactory { - - private static DataModelExtensionReader reader; - - private DataModelFactory() { - } - - /** - * <p> - * Looks up the appropriate IDataModelProvider by the specified id and constructs a new - * IDataModel. If the IDataModelProvider is not found then a RuntimeException is logged and null - * is returned. - * </p> - * - * @param dataModelProviderID - * the id of the IDataModelProvider - * @return a new IDataModel - */ - public static IDataModel createDataModel(String dataModelProviderID) { - IDataModelProvider provider = loadProvider(dataModelProviderID); - if (provider == null) - return null; - return createDataModel(provider); - } - - private static IDataModelProvider loadProvider(String id) { - if (null == reader) { - reader = new DataModelExtensionReader(); - } - return reader.getProvider(id); - } - - /** - * <p> - * Looks up the appropriate dataModelProviderIDs by the specified dataModelProviderKindID. - * </p> - * - * @param dataModelProviderKindID - * the String id of the dataModelProviderKindID - * - * @return the array of valid dataModelProviderIDs or an empty array if there are none. - */ - public static String[] getDataModelProviderIDsForKind(String dataModelProviderKindID) { - String[] validProviderIDs = loadProviderForProviderKind(dataModelProviderKindID); - return null != validProviderIDs ? validProviderIDs : new String[0]; - } - - - private static String[] loadProviderForProviderKind(String providerKind) { - if (null == reader) { - reader = new DataModelExtensionReader(); - } - return reader.getProviderDescriptorsForProviderKind(providerKind); - } - - /** - * <p> - * Builds an {@link IDataModel} using the specified Class. This Class will - * normally be a sub interface of {@link IDataModelProperties}. If the - * Class it is an {@link IDataModelProperties}.class then this method will - * attempt to use the {@link IDataModelProperties#_provider_class} field to - * load the {@link IDataModelProvider} with which to back the - * {@link IDataModel}. If this fails, or if the Class is not an interface, - * then this method is equavalent to - * <code>createDataModel(aClass.getName())</code>. - * </p> - * - * @param aClass - * an {@link IDataModelProperties}.class or the class whose name - * is the id of the IDataModelProvider - * @return a new IDataModel - */ - public static IDataModel createDataModel(Class aClass) { - if(aClass.isInterface()){ - try{ - Class clazz = (Class)aClass.getField("_provider_class").get(null); //$NON-NLS-1$ - if(clazz != null){ - IDataModelProvider provider = (IDataModelProvider)clazz.newInstance(); - return createDataModel(provider); - } - } catch (NoSuchFieldException e) { - //ignore; the interface may not have defined the field and is relying on extensions. - } catch (IllegalArgumentException e) { - WTPCommonPlugin.logError(e); - } catch (SecurityException e) { - WTPCommonPlugin.logError(e); - } catch (IllegalAccessException e) { - WTPCommonPlugin.logError(e); - } catch (InstantiationException e) { - WTPCommonPlugin.logError(e); - } - } - return createDataModel(aClass.getName()); - } - - /** - * <p> - * Creates a new IDataModel using the the specified instance of an IDataModelProvider. - * </p> - * - * @param provider - * @return a new IDataModel - */ - public static IDataModel createDataModel(IDataModelProvider provider) { - if (null == provider) { - throw new NullPointerException(); - } - DataModelImpl dataModel = new DataModelImpl(provider); - return dataModel; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelPropertyDescriptor.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelPropertyDescriptor.java deleted file mode 100644 index dc757df4a..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/DataModelPropertyDescriptor.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -/** - * <p> - * A DataModelPropertyDescriptor provides a human readible description for an IDataModel - * propertyValue. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModel#getPropertyDescriptor(String) - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModel#getValidPropertyDescriptors(String) - * - * @since 1.0 - */ -public final class DataModelPropertyDescriptor { - - /** - * <p> - * A convenience method which returns an array of DataModelPropertyDescriptors. If - * <code>values</code> is <code>null</code> then a 0 length array is returned. Otherwise for - * each <code>values[i]</code> in the array, a new DataModelPropertyDescriptors is created - * using <code>new DataModelPropertyDescriptors(values[i]);</code>. - * </p> - * - * @param values - * the array of property values - * @return the constructed DataModelPropertyDescriptors array - */ - public static DataModelPropertyDescriptor[] createDescriptors(Object[] values) { - if (null == values) { - return new DataModelPropertyDescriptor[0]; - } - DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[values.length]; - for (int i = 0; i < descriptors.length; i++) { - descriptors[i] = new DataModelPropertyDescriptor(values[i]); - } - return descriptors; - } - - /** - * <p> - * A convenience method which returns an array of DataModelPropertyDescriptors. If - * <code>values</code> is <code>null</code> then a 0 length array is returned. Otherwise for - * each <code>values[i]</code> and <code>descriptions[i]</code> in the arrays, a new - * DataModelPropertyDescriptor is created using - * <code>new DataModelPropertyDescriptor(values[i], descriptions[i]);</code>. Both arrays - * must be the same length. - * </p> - * - * @param values - * the array of property values - * @param descriptions - * the array of property descriptions cooresponding the values array - * @return the constructed DataModelPropertyDescriptors array - */ - public static DataModelPropertyDescriptor[] createDescriptors(Object[] values, String[] descriptions) { - if (null == values) { - return new DataModelPropertyDescriptor[0]; - } - DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[values.length]; - for (int i = 0; i < descriptors.length; i++) { - descriptors[i] = new DataModelPropertyDescriptor(values[i], descriptions[i]); - } - return descriptors; - - } - - private Object propertyValue; - private String propertyDescription; - - /** - * <p> - * This is equavalent to calling <code>DataModelPropertyDescriptor(propertyValue, null)</code>. - * </p> - * - * @param propertyValue - * the propery value - */ - public DataModelPropertyDescriptor(Object propertyValue) { - this.propertyValue = propertyValue; - } - - /** - * <p> - * Creates a new DataModelPropertyDescriptor with the specified propertyValue and - * propertyDescription. - * </p> - * - * @param propertyValue - * the property value - * @param propertyDescription - * the human readible proeprty descriptionF - */ - public DataModelPropertyDescriptor(Object propertyValue, String propertyDescription) { - this.propertyValue = propertyValue; - this.propertyDescription = propertyDescription; - } - - /** - * <p> - * Returns the property value. - * </p> - * - * @return the property value - */ - public Object getPropertyValue() { - return propertyValue; - } - - /** - * <p> - * Returns a human readible property description. If a non null description has been specified, - * then it will be returned. Otherwise, the property value's <code>toString()</code> will be - * returned if it is not null. Otherwise the empty String (<code>""</code>) will be - * returned. <code>null</code> will never be returned. - * </p> - * - * @return the human readible property description, never <code>null</code> - */ - public String getPropertyDescription() { - if (null != propertyDescription) { - return propertyDescription; - } - String str = (null != propertyValue) ? propertyValue.toString() : null; - return (null != str) ? str : ""; //$NON-NLS-1$ - } - - @Override - public String toString(){ - return getPropertyDescription(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModel.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModel.java deleted file mode 100644 index fa31c67af..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModel.java +++ /dev/null @@ -1,747 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; - -/** - * <p> - * IDataModels are the core piece of a framework used to simplify data collection, operation - * execution, and Wizard generation. - * </p> - * <p> - * IDataModels are primarily an intelligent mechanism for managing data. Each IDataModel tracks - * specific Objects known as "properties". Each property may be set or get using its property name. - * A Collection of property names for an IDataModel instance may be retreived using - * <code>getAllProperties()</code>. In addition to getting/setting properties, IDataModels may - * also provide default values for unset properties, human readable descriptors for properties, - * enumerations of valid property values, validation for properties, and enablement for properties. - * </p> - * <p> - * IDataModels may also be nested (and unnested) recursively within another. When one IDataModel is - * nested within another, then client code may access all properties on the former through the - * latter. This is especially useful when the same IDataModel (tracking the same properties) may be - * used within the context of several different broader scenarios. Nesting may apply to any - * IDataModel, and may be abitraryly deep (even cylical if you dare). Nesting offers flexibility, - * especially for extension by 3rd party clients. - * </p> - * <p> - * Each IDataModel may also supply an IDataModelOperation (a subclass of - * org.eclipse.core.commands.operations.IUndoableOperation) for execution. When executed within the - * IDataModel framework all these operations are inherently and abitrarily extendable. - * </p> - * <p> - * Each IDataModel may also indirectly supply a DataModelWizard. This indirection is necessary to - * spilt UI dependencies from the core IDataModel framework. DataModelWizards are also inherently - * extendable. - * </p> - * <p> - * IDataModels are not meant to be instantiated directly, rather they are built from an - * IDataModelProvider. Clients wishing to define their own IDataModel must do so by implementing an - * IDataModelProvider. Clients wishing to utilize an IDataModel must create it using the - * DataModelFactory with the associated IDataModelProvider. - * </p> - * - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider - * @see org.eclipse.wst.common.frameworks.datamodel.DataModelFactory - * - * @since 1.0 - */ -public interface IDataModel { - - /** - * <p> - * Returns the unique ID which identifies this IDataModel instance. The same ID should be used - * by the default operation (if any) for clients to extend or instantiate directly, the - * DataModelWizard (if any) for clients to extend or instantiate directly. - * </p> - * <p> - * Note, this is not the same as a hashcode. Multiple IDataModel instances created with the same - * IDataModelProvider type will all have the same ID. - * </p> - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * - * @see IDataModelProvider#getID() - * - * @return the unique ID for this IDataModel - */ - public String getID(); - - /** - * <p> - * Returns the default operation to execute against this IDataModel. The returned operation is - * derived from the operation supplied by the backing IDataModelProvider. The returned type is - * IDataModelManagerOperation which adds additional functionality to the returned - * IDataModelOperation. - * </p> - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * - * @see IDataModelProvider#getDefaultOperation() - * - * @return the default operation - */ - public IDataModelOperation getDefaultOperation(); - - /** - * <p> - * This method only pertains to IDataModels for extedended operations. The returned extended - * context is used by the IDataModelOperation framework to determine whether a particular - * extended operation should execute. The returned list is should contain Objects adaptable to - * IProject. This IDataModel's function groups are looked up through the extension mechanism. If - * a function group is defined, it is first checked for enablement. Then each adapted IProject - * is inspected to verify it handles the function group. If all these conditions are met, then - * the extended operation associated with this IDataModel is executed; otherwise it is skipped. - * If no function group is defined, or no extended context is defined (i.e. this method returns - * an empty list, or the objects in the returned list are not adaptable to IProject) then the - * extended operation will execute (it will never be skipped). - * </p> - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * <p> - * This method should not be called by clients. - * </p> - * - * @return a List of Objects adaptable to IProject - * - * @see IDataModelProvider#getExtendedContext() - */ - public List getExtendedContext(); - - /** - * <p> - * Returns the property value for the specified propertyName. - * </p> - * <p> - * If the specified propertyName is not a property then a RuntimeException will be thrown. - * </p> - * <p> - * Before the property is returned, first the owning IDataModel must be located. If the - * specified propertyName is a base property {@link #isBaseProperty(String)}, then this - * IDataModel is the owner. Otherwise, a recursive search through the nested IDataModels is - * conducted to locate the owning IDataModel. If more than one nested IDataModel defines the - * property, then the first one located is considered the owning IDataModel. - * </p> - * <p> - * Once the owning IDataModel is found the property is checked to see if it is set - * {@link #isPropertySet(String)}. If the property is set, the set value is returned. If the - * property is not set, its default is returned {@link #getDefaultProperty(String)}. - * </p> - * <p> - * There are convenience methods for getting primitive <code>int</code> and - * <code>boolean</code> types as well as Strings. - * <ul> - * <li>{@link #getIntProperty(String)}</li> - * <li>{@link #getBooleanProperty(String)}</li> - * <li>{@link #getStringProperty(String)}</li> - * </ul> - * </p> - * - * @param propertyName - * the property name - * @return the property - * - * @see #setProperty(String, Object) - * @see #getBooleanProperty(String) - * @see #getIntProperty(String) - * @see #getStringProperty(String) - */ - public Object getProperty(String propertyName); - - /** - * <p> - * Returns the default property value for the specified propertyName. - * </p> - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * - * @see IDataModelProvider#getDefaultProperty(String) - */ - public Object getDefaultProperty(String propertyName); - - /** - * <p> - * A convenience method for getting ints. If the property is set then this method is equavalent - * to: - * </p> - * <p> - * <code>((Integer)getProperty(propertyName)).intValue();</code> - * </p> - * <p> - * <code>-1</code> is returned if a call to getProperty(propertyName) returns - * <code>null</code>. - * </p> - * - * @param propertyName - * the property name - * @return the int value of the property - * @see #setProperty(String, Object) - * @see #setIntProperty(String, int) - */ - public int getIntProperty(String propertyName); - - /** - * <p> - * A convenience method for getting booleans. If the property is set then this method is - * equavalent to: - * </p> - * <p> - * <code>((Boolean)getProperty(propertyName)).booleanValue();</code> - * </p> - * <p> - * <code>false</code> is returned if a call to getProperty(propertyName) returns - * <code>null</code>. - * </p> - * - * @param propertyName - * the property name - * @return the boolean value of the property - * @see #setProperty(String, Object) - * @see #setBooleanProperty(String, boolean) - */ - public boolean getBooleanProperty(String propertyName); - - /** - * <p> - * A convenience method for getting Strings. If the property is set then this method is - * equavalent to: - * </p> - * <p> - * <code>(String)getProperty(propertyName)</code> - * </p> - * <p> - * <code>""</code> is returned if a call to getProperty(propertyName) returns - * <code>null</code>. - * </p> - * - * @param propertyName - * @see #setProperty(String, Object) - */ - public String getStringProperty(String propertyName); - - /** - * <p> - * Sets the specified propertyName to the specified propertyValue. Subsequent calls to - * {@link #getProperty(String)} will return the same propertyValue. - * </p> - * <p> - * When a propertyValue other than <code>null</code> is set, then the property is considered - * "set" (see {@link #isPropertySet(String)}), conversly, a propertyValue of <code>null</code> - * is considered "unset". - * </p> - * <p> - * If the specified propertyName is not a property (see {@link #isProperty(String)}) then a - * RuntimeException will be thrown. - * </p> - * <p> - * There are convenience methods for setting primitive <code>int</code> and - * <code>boolean</code> types as well as Strings. - * <ul> - * <li>{@link #setIntProperty(String, int)}</li> - * <li>{@link #setBooleanProperty(String, boolean)}</li> - * <li>{@link #setStringProperty(String, String)}</li> - * </ul> - * </p> - * <p> - * An IDataModel implementor may define additional post set logic in - * {@link IDataModelProvider#propertySet(String, Object)}. - * </p> - * - * @param propertyName - * the name of the property to set - * @param propertyValue - * the value to set the property - * - * - * @see #getProperty(String) - * @see #isPropertySet(String) - * @see #isProperty(String) - * @see IDataModelProvider#propertySet(String, Object) - */ - public void setProperty(String propertyName, Object propertyValue); - - /** - * <p> - * A convenience method for setting ints. This method is equavalent to: - * <p> - * <code>setProperty(propertyName, new Integer(propertyValue));</code> - * </p> - * - * @param propertyName - * the name of the property - * @param propertyValue - * the <code>int</code> value of the property - * @see #setProperty(String, Object) - * @see #getIntProperty(String) - */ - public void setIntProperty(String propertyName, int propertyValue); - - /** - * <p> - * A convenience method for setting booleans. This method is equavalent to: - * <p> - * <code>setProperty(propertyName, (value) ? Boolean.TRUE : Boolean.FALSE);</code> - * </p> - * - * @param propertyName - * the name of the property - * @param propertyValue - * the <code>boolean</code> value of the property - * @see #setProperty(String, Object) - * @see #getBooleanProperty(String) - */ - public void setBooleanProperty(String propertyName, boolean propertyValue); - - /** - * <p> - * A convenience method for setting Strings. This method is equavalent to: - * <p> - * <code>setProperty(propertyName, propertyValue);</code> - * </p> - * - * @param propertyName - * the name of the property - * @param propertyValue - * the value of the property - * @see #setProperty(String, Object) - * @see #getStringProperty(String) - */ - public void setStringProperty(String propertyName, String propertyValue); - - /** - * <p> - * This method is used to nest the specified IDataModel within this IDataModel. The - * <code>nestedModelName</code> argument should be a unique String to identify this particular - * nested IDataModel. The same String is required when accessing the nested IDataModel using - * either {@link #getNestedModel(String)} or {@link #removeNestedModel(String)}. If the - * specified nested IDataModel has already been nested under this IDataModel or it is the same - * instance as this IDataModel, then calling this method will have no effect. - * </p> - * - * @param nestedModelName - * the name of the IDataModel to be nested - * @param dataModel - * the IDataModel to be nested - * @return <code>true</code> if the nesting was successful, <code>false</code> otherwise. - * - * @see #getNestedModel(String) - * @see #removeNestedModel(String) - */ - public boolean addNestedModel(String nestedModelName, IDataModel dataModel); - - /** - * <p> - * Remove the specified nestedModel. - * </p> - * - * @param nestedModelName - * the name of the nested IDataModel to remove. - * @return the IDataModel removed, or <code>null</code> if the nested model does not exist or - * if the specified name is null. - */ - public IDataModel removeNestedModel(String nestedModelName); - - /** - * <p> - * Returns <code>true</code> if a nested model exists (at the top level only) with the - * specified name and <code>false</code> otherwise. - * </p> - * - * @param nestedModelName - * the name of the nested IDataModel to check. - * @return Returns <code>true</code> if a nested model exists (at the top level only) with the - * specified name and <code>false</code> otherwise. - */ - public boolean isNestedModel(String nestedModelName); - - /** - * <p> - * Returns the nested IDataModel identified the by the specified name. A RuntimeException is - * thrown if there is no such nested IDataModel (i.e. isNestedModel() would return - * <code>false</code>). - * </p> - * - * @param nestedModelName - * the name of the nested IDataModel to get. - * @return the nested IDataModel - */ - public IDataModel getNestedModel(String nestedModelName); - - /** - * <p> - * Returns a Collection of all nested IDataModels, or an empty Collection if none exist. - * </p> - * - * @return a Collection of all nested IDataModels, or an empty Collection if none exist. - */ - public Collection getNestedModels(); - - /** - * <p> - * Returns a Collection of all nested IDataModels names, or an empty Collection if none exist. - * </p> - * - * @return a Collection of all nested IDataModels names, or an empty Collection if none exist. - */ - public Collection getNestedModelNames(); - - /** - * <p> - * Returns a Collection of all nesting (the inverse of nested) IDataModels, or an empty - * Collection if none exist. - * </p> - * - * @return a Collection of all nesting (the inverse of nested) IDataModels, or an empty - * Collection if none exist. - */ - public Collection getNestingModels(); - - /** - * <p> - * Returns a Collection of all base properties (not including nested properties), or an empty - * Collection if none exist. - * </p> - * - * @return a Collection of all base properties (not including nested properties), or an empty - * Collection if none exist. - */ - public Collection getBaseProperties(); - - /** - * <p> - * Returns a Collection of all properties of recursively nested IDataModels, or an empty - * Collection if none exist. - * </p> - * - * @return a Collection of all properties of recursively nested IDataModels, or an empty - * Collection if none exist. - */ - public Collection getNestedProperties(); - - /** - * <p> - * Returns a Collection of all properties (the union of getBaseProperties() and - * getNestedProperties()), or an empty Collection if none exist. - * </p> - * - * @return a Collection of all properties (the union of getBaseProperties() and - * getNestedProperties()), or an empty Collection if none exist. - */ - public Collection getAllProperties(); - - /** - * <p> - * Returns <code>true</code> if the specified propertyName is a valid propertyName for this - * root IDataModel only. Nested IDataModels are not checked, though it is possible for a nested - * IDataModel to contain the same property. - * </p> - * - * @param propertyName - * the property name to check - * @return <code>true</code> if this property is a base property, <code>false</code> - * otherwise. - * - * @see #isProperty(String) - * @see #isNestedProperty(String) - */ - public boolean isBaseProperty(String propertyName); - - /** - * <p> - * Returns <code>true</code> if the specified propertyName is a valid propertyName for this - * DataModel or any of its (recursively) nested IDataModels. - * </p> - * - * @param propertyName - * the property name to check - * @return <code>true</code> if this is a property, <code>false</code> otherwise. - * - * @see #isBaseProperty(String) - */ - public boolean isProperty(String propertyName); - - /** - * <p> - * Returns <code>true</code> if the specified propertyName is a valid propertyName for any of - * its (recursively) nested IDataModels. The root IDataModel is not checked, though it is - * possible for the root IDataModel to contain the same property. - * </p> - * - * @param propertyName - * the property name to check - * @return <code>true</code> if the property is nested, <code>false</code> otherwise. - * @see #isBaseProperty(String) - */ - public boolean isNestedProperty(String propertyName); - - /** - * <p> - * Returns <code>true</code> if the specified property has been set on the IDataModel. If it - * has not been set, then a call to get the same property will return the default value. - * </p> - * - * @param propertyName - * the property name to check - * @return <code>true</code> if the property is set, <code>false</code> otherwise. - */ - public boolean isPropertySet(String propertyName); - - /** - * <p> - * Returns <code>true</code> if the specified property is enabled and <code>false</code> - * otherwise. - * </p> - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * - * @see IDataModelProvider#isPropertyEnabled(String) - * - * @param propertyName - * the property name to check - * @return <code>true</code> if the specified property is enabled and <code>false</code> - * otherwise. - */ - public boolean isPropertyEnabled(String propertyName); - - /** - * <p> - * Returns <code>false</code> if the the IStatus returned by validateProperty(String) is ERROR - * and <code>true</code> otherwise. - * </p> - * - * @param propertyName - * the property name to check - * @return <code>false</code> if the the IStatus returned by validateProperty(String) is ERROR - * and <code>true</code> otherwise. - */ - public boolean isPropertyValid(String propertyName); - - /** - * <p> - * Returns an IStatus for the specified property. Retuns an IStatus.OK if the returned value is - * valid with respect itself, other properites, and broader context of the IDataModel. - * IStatus.ERROR is returned if the returned value is invalid. IStatus.WARNING may also be - * returned if the value is not optimal. - * </p> - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * - * @see IDataModelProvider#validate(String) - */ - public IStatus validateProperty(String propertyName); - - /** - * <p> - * Returns <code>false</code> if the IStatus returned by validate(true) is ERROR and - * <code>true</code> otherwise. - * </p> - * - * @return <code>false</code> if the IStatus returned by validate(true) is ERROR and - * <code>true</code> otherwise. - */ - public boolean isValid(); - - /** - * <p> - * Equavalent to calling <code>validate(true)</code>. - * </p> - * - * @return an IStatus - */ - public IStatus validate(); - - /** - * <p> - * Iterates over all base properties and nested models IDs and calls validate(String). This - * method returns when any call to validate(String) returns an IStatus error and - * stopAtFirstFailure is set to true. - * <p> - * - * @param stopAtFirstFailure - * whether validation should stop at the first failure - * @return an IStatus - */ - public IStatus validate(boolean stopAtFirstFailure); - - - - /** - * <p> - * Returns a DataModelPropertyDescriptor for the specified property. The - * <code>getPropertyValue()</code> method on the returned DataModelPropertyDescriptor will be - * the same value as returned by <code>getPropertyValue(propertyName)</code>. - * </p> - * <p> - * Following the example introduced in {@link #getValidPropertyDescriptors(String)}, suppose - * the <code>SHIRT_SIZE</code> property is currently set to 1. A call to this method would - * return a DataModelPropertyDescriptor whose <code>getPropertyValue()</code> returns - * <code>1</code> and whose <code>getPropertyDescription()</code> returns <code>small</code>. - * </p> - * <p> - * Also, note that even if a particular property is not confined to a finite set of values as - * defined by {@link #getValidPropertyDescriptors(String)}this method will always return a - * valid DataModelPropertyDescriptor. - * </p> - * - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * - * @param propertyName - * @return the DataModelPropertyDescriptor for the specified property - * - * @see #getValidPropertyDescriptors(String) - */ - public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName); - - /** - * <p> - * Returns a DataModelPropertyDescriptor array consisting of all valid - * DataModelPropertyDescriptors for the specified property. Each - * {@link DataModelPropertyDescriptor} contains a value and a human readible description for the - * value. The set of all values in the returned array are those values which are valid for the - * IDataModel. This value set only makes sense when valid property values conform to a well - * defined finite set. If no such value set exists for the property, then a 0 length array is - * returned. <code>null</code> is never returned. - * </p> - * <p> - * As an example, suppose there is a property called <code>SHIRT_SIZE</code> which is an - * <code>Integer</code> type. Also suppse that valid shirt sizes are only small, medium, or - * large. However, the actual values representing small, medium, and large are 1, 2, and 3 - * respectively. A call to <code>getValidPropertyDescriptors(SHIRT_SIZE)</code> would return a - * DataModelPropertyDescriptor array where the value, description pairs would be {(1, small), - * (2, medium), (3, large)}. - * </p> - * <p> - * An IDataModel implementor defines this in IDataModelProvider. - * </p> - * - * @param propertyName - * then name of the property to check - * @return the array of valid DataModelPropertyDescriptors - * @see #getPropertyDescriptor(String) - */ - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName); - - /** - * <p> - * Adds the specified IDataModelListener to listen for DataModelEvents. If the specified - * listener has already been added, calling this method will have no effect. - * </p> - * - * @param dataModelListener - * the new listener to add. - * - * @see #removeListener(IDataModelListener) - */ - public void addListener(IDataModelListener dataModelListener); - - /** - * <p> - * Remove the specified IDataModelListener. If the specified listener is not a registered - * listenr on this IDataModel, then calling this method will have no effect. - * </p> - * - * @param dataModelListener - * the listener to remove. - * @see #addListener(IDataModelListener) - */ - public void removeListener(IDataModelListener dataModelListener); - - /** - * <p> - * A constant used for notification. - * </p> - * - * @see DataModelEvent#VALUE_CHG - * @see #notifyPropertyChange(String, int) - */ - public static final int VALUE_CHG = DataModelEvent.VALUE_CHG; - /** - * <p> - * A constant used for notification. This contant is different from the others because it does - * not map to an event type on DataModelEvent. When notifying with this type, a check is first - * done to see whether the property is set. If the property is <empf>NOT</emph> set, then a - * <code>VALUE_CHG</code> is fired, otherwise nothing happens. - * </p> - * - * @see #notifyPropertyChange(String, int) - */ - public static final int DEFAULT_CHG = DataModelEvent.DEFAULT_CHG; - /** - * <p> - * A constant used for notification. - * </p> - * - * @see DataModelEvent#ENABLE_CHG - * @see #notifyPropertyChange(String, int) - */ - public static final int ENABLE_CHG = DataModelEvent.ENABLE_CHG; - /** - * <p> - * A constant used for notification. - * </p> - * - * @see DataModelEvent#VALID_VALUES_CHG - * @see #notifyPropertyChange(String, int) - */ - public static final int VALID_VALUES_CHG = DataModelEvent.VALID_VALUES_CHG; - - /** - * <p> - * Notify all listeners of a property change. <code>eventType</code> specifies the type of - * change. Acceptible values for eventType are <code>VALUE_CHG</code>, - * <code>DEFAULT_CHG</code>, <code>ENABLE_CHG</code>, <code>VALID_VALUES_CHG</code>. If - * the eventType is <code>DEFAULT_CHG</code> and the specified property is set, then this - * method will do nothing. - * </p> - * <p> - * Typically this method should only be invoked by an IDataModelProvider from its propertySet - * implementation. - * </p> - * - * @param propertyName - * the name of the property changing - * @param eventType - * the type of event to fire - * - * @see #VALUE_CHG - * @see #DEFAULT_CHG - * @see #ENABLE_CHG - * @see #VALID_VALUES_CHG - * @see DataModelEvent - */ - public void notifyPropertyChange(String propertyName, int eventType); - - /** - * <p> - * A typical dispose method used to clean up any resources not handled by general garbage - * collection. - * </p> - * - */ - public void dispose(); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelListener.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelListener.java deleted file mode 100644 index d50aa4a03..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelListener.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -/** - * <p> - * The interface required when listening for DataModelEvents from an IDataModel. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModel#addListener(IDataModelListener) - * @see org.eclipse.wst.common.frameworks.datamodel.DataModelEvent - * - * @since 1.0 - */ -public interface IDataModelListener { - - /** - * <p> - * Sent when DataModelEvents occur. - * </p> - * - * @param event - * the DataModelEvent - */ - public void propertyChanged(DataModelEvent event); -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java deleted file mode 100644 index de532a9ad..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.wst.common.environment.IEnvironment; - -/** - * <p> - * IDataModelOperation defines an IDataModel driven undoable operation. Every IDataModelOperation - * may be extended by third party clients using the extended operation framework. - * </p> - * - * <p> - * This interface is not intended to be implemented by clients. Clients should subclass - * {@link AbstractDataModelOperation}. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModel - * - * @since 1.0 - */ -public interface IDataModelOperation extends IUndoableOperation { - - /** - * <p> - * Sets the unique operation id. Typically, clients should not invoke this method. - * </p> - * - * @param id - * the unique operation id - */ - public void setID(String id); - - /** - * <p> - * Returns the unique operation id. - * </p> - * - * @return the unique operation id - */ - public String getID(); - - /** - * <p> - * Sets the IDataModel for this operation. - * </p> - * - * @param model - * the IDataModel used to run this operation - */ - public void setDataModel(IDataModel model); - - /** - * <p> - * Returns this operation's IDataModel. - * </p> - * - * @return this operation's IDataModel. - */ - public IDataModel getDataModel(); - - /** - * <p> - * Returns the ISchedulingRule used for executing this job using - * {@link org.eclipse.core.resources.IWorkspace#run(org.eclipse.core.resources.IWorkspaceRunnable, ISchedulingRule, int, org.eclipse.core.runtime.IProgressMonitor)}. - * If <code>null</code> is returned, then IWorkspace.getRoot() is used as the ISchedulingRule - * during execution. - * </p> - * - * @return the ISchedulingRule - * - * @see #getOperationExecutionFlags() - * @see org.eclipse.core.resources.IWorkspace#run(org.eclipse.core.resources.IWorkspaceRunnable, ISchedulingRule, int, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public ISchedulingRule getSchedulingRule(); - - /** - * <p> - * Returns the OperationExecutionFlags used for executing this Operation as a workspace job. - * {@link org.eclipse.core.resources.IWorkspace#run(org.eclipse.core.resources.IWorkspaceRunnable, ISchedulingRule, int, org.eclipse.core.runtime.IProgressMonitor)}. - * </p> - * - * @return the OperationExecutionFlags - * - * @see #getSchedulingRule() - * @seeorg.eclipse.core.resources.IWorkspace#run(org.eclipse.core.resources.IWorkspaceRunnable, ISchedulingRule, int, - * org.eclipse.core.runtime.IProgressMonitor) - */ - public int getOperationExecutionFlags(); - - /** - * <p> - * The framework will set the environment on this operation before it is executed. The operation - * can then use the environment to report status, log information, and access resources in an - * environment neutral way. - * <p> - * - * @param environment - * the IEnvironment to set. - */ - public void setEnvironment(IEnvironment environment); - - /** - * Returns the IEvironment set in {@link #setEnvironment(IEnvironment)}} - * - * @return the set IEnvironment - * - * @see #setEnvironment(IEnvironment) - */ - public IEnvironment getEnvironment(); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProperties.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProperties.java deleted file mode 100644 index f9be08e64..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProperties.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -/** - * <p> - * IDataModelProperties provides the base interface for all Data Model - * Properties interfaces. Sub interface classes (e.g. - * <code>some.company.IFooDataModelProperties.class</code>) should be used to - * create instances of IDataModels using the - * {@link DataModelFactory#createDataModel(Class)} method. In order for this - * mechanism to work, the backing {@link IDataModelProvider} class must be - * registerd to support the sub IDataModelProperties interface in one of two - * ways. This registration should be performed by the model developer. - * </p> - * <p> - * The first way to register the correct {@link IDataModelProvider} class is for - * the interface to define a public static Class _provider_class field - * which is set to the {@link IDataModelProvider} class, e.g. - * </p> - * <p> - * <code>public static final Class _provider_class = some.company.FooDataModelProvider.class</code> - * </p> - * The above mechanism is recommended whenever the {@link IDataModelProperties} and - * {@link IDataModelProvider} classes are both defined in the same plugin scope. - * A second mechanism using the DataModelProviderExtension extension point is - * available when the {@link IDataModelProvider} class is definend outside the - * {@link IDataModelProperties} plugin scope. - * - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider - * @see org.eclipse.wst.common.frameworks.datamodel.DataModelFactory - * - * @since 1.0 - */ -public interface IDataModelProperties { - - /** - * A boolean property defaults to Boolean.TRUE. If this is set to Boolean.FALSE no extended - * operations will be executed. - */ - public static final String ALLOW_EXTENSIONS = "IDataModelProperties.ALLOW_EXTENSIONS"; //$NON-NLS-1$ - - /** - * A List containing String objects, defautls to an empty List. If this list contains elements - * and ALLOW_EXTENSIONS is set to Boolean.TRUE, then only extended operations not identified in - * this list will be executed. These strings should either be the operation id or the fully - * qualified operation class name. - */ - public static final String RESTRICT_EXTENSIONS = "IDataModelProperties.RESTRICT_EXTENSIONS"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProvider.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProvider.java deleted file mode 100644 index c6abfd9a5..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelProvider.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.datamodel; - -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * IDataModelProviders are used by the DataMdoelFactory to construct IDataModels. - * - * <p> - * This interface is not intended to be implemented by clients. Clients should subclass - * {@link AbstractDataModelProvider}. - * </p> - * - * @since 1.0 - */ -public interface IDataModelProvider extends IDataModelProperties { - - public static IStatus OK_STATUS = new Status(IStatus.OK, "org.eclipse.wst.common.frameworks.internal", 0, "OK", null); //$NON-NLS-1$ //$NON-NLS-2$ - - public void setDataModel(IDataModel dataModel); - - /** - * <p> - * Returns the backing IDataModel for this provider. - * </p> - * - * @return the backing IDataModel - */ - public IDataModel getDataModel(); - - /** - * <p> - * Returns a list of property names for which this provider is responsible. This method is - * called only once during initialization. - * </p> - * - * @return the array of valid property names. - */ - public Set getPropertyNames(); - - /** - * <p> - * Providers should perform additional initialization here. - * </p> - */ - public void init(); - - /** - * <p> - * This is where the provider should define how default properties should be computed. - * </p> - * - * @param propertyName - * the specified property - * @return the default property value - */ - public Object getDefaultProperty(String propertyName); - - - /** - * <p> - * This is where the provider should define how property enablements are computed. - * </p> - * - * @param propertyName - * the specified property - * @return <code>true</code> if the property is enabled, <code>false</code> otherwise. - */ - public boolean isPropertyEnabled(String propertyName); - - /** - * IDataModelProviders should perform property validation here. All calls to - * IDataModel.validateProperty(String) are routed to the appropriate IDatModelProvider. When - * IDataModel.validate() or IDataModel.validate(boolean) are called to validate the entire - * IDataModel, any nested model names are also passed through to the IDataModelProvider for a - * chance to validate the nested IDataModel in an appropriate manner. - * - * @param name - * @return an IStatus - */ - public IStatus validate(String name); - - /** - * <p> - * This is a special callback hook for the IDataModel provider to be notified of a setProperty() - * call invoked on the backing IDataModel. This method is called after the actual value has been - * stored by the IDataModel but before any general notifications are fired to its listeners. - * Thus this IDataModelProvider may react to updates apropriately by setting other properties, - * notifying default changes, notifying valid value changes, etc. - * </p> - * - * @param propertyName - * @param propertyValue - * @return <code>true</code> to fire a VALUE_CHG DataModelEvent. - */ - public boolean propertySet(String propertyName, Object propertyValue); - - public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName); - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName); - - public List getExtendedContext(); - - public IDataModelOperation getDefaultOperation(); - - public String getID(); - - public void dispose(); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/package.xml b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/package.xml deleted file mode 100644 index 855e7a4b4..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/package.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../../" /> - <title>Component creation and Referenced Component api overview</title> - </head> - - <body> - <abstract> - This package includes API for Data Model Provider framework for builing executable - and undoable operations using data models, their providers and provider interfaces that - contain the properties used by the providers to set and retrieve these propertiese. - </abstract> - - <a href="#top">top</a> - </body> -</html> -
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/properties/package.xml b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/properties/package.xml deleted file mode 100644 index caaf7741b..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/properties/package.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../../../" /> - <title>Component creation and Referenced Component api overview</title> - </head> - - <body> - <abstract> - This package includes API that defines the propeties that can be set on a flexible - project datamodel to drive the the wizard and operations. - </abstract> - - <a href="#top">top</a> - </body> -</html> -
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/AbstractRegistryDescriptor.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/AbstractRegistryDescriptor.java deleted file mode 100644 index d4069c502..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/AbstractRegistryDescriptor.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 12, 2004 - * - */ -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.common.frameworks.internal.enablement.FunctionGroupRegistry; -import org.eclipse.wst.common.frameworks.internal.enablement.IEnablementIdentifier; -import org.eclipse.wst.common.frameworks.internal.enablement.IEnablementManager; -import org.eclipse.wst.common.frameworks.internal.enablement.Identifiable; - - -/** - * @author schacher - * - * Common superclass for enablement-aware (e.g., using function groups or activiities) extension - * points. - */ -public abstract class AbstractRegistryDescriptor extends ConfigurationElementWrapper implements Identifiable { - - protected Integer priority; - - public AbstractRegistryDescriptor(IConfigurationElement anElement) { - super(anElement); - } - - public IEnablementIdentifier getEnablementIdentifier(IProject project) { - return IEnablementManager.INSTANCE.getIdentifier(getID(), project); - } - - public abstract String getID(); - - public int getPriority() { - if (priority == null) - priority = new Integer(FunctionGroupRegistry.getInstance().getFunctionPriority(getID())); - return priority.intValue(); - } - - public boolean isEnabled(IProject p) { - IEnablementIdentifier id = getEnablementIdentifier(p); - return id.isEnabled(); - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/AdaptabilityUtility.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/AdaptabilityUtility.java deleted file mode 100644 index 9e8a19d3a..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/AdaptabilityUtility.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; - -/** - * @author mdelder - * - */ -public class AdaptabilityUtility { - - - public static Object getAdapter(Object element, Class adapter) { - if (element == null) - return null; - else if (element instanceof IAdaptable) - return ((IAdaptable) element).getAdapter(adapter); - else - return Platform.getAdapterManager().getAdapter(element, adapter); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ConfigurationElementWrapper.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ConfigurationElementWrapper.java deleted file mode 100644 index 1f3572a96..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ConfigurationElementWrapper.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 20, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; - -/** - * @author schacher - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class ConfigurationElementWrapper { - - protected IConfigurationElement element; - - /** - * - */ - public ConfigurationElementWrapper(IConfigurationElement element) { - super(); - this.element = element; - } - - - - /** - * @return Returns the element. - */ - protected IConfigurationElement getElement() { - return element; - } - - /** - * Return the plugin id of the configuration element - * - * @return - */ - public String getPluginId() { - String pluginId = null; - - if (element != null) { - IExtension extension = element.getDeclaringExtension(); - - if (extension != null) { - pluginId = extension.getNamespace(); - // TODO jsholl is this correct??? - } - } - - return pluginId; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/DoNotUseMeThisWillBeDeletedPost15.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/DoNotUseMeThisWillBeDeletedPost15.java deleted file mode 100644 index 607332147..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/DoNotUseMeThisWillBeDeletedPost15.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -/** - * Other things to delete: - * - * The wtpuiAction extension point and schema in org.eclipse.wst.common.frameworks.ui - */ - - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface/method/field - * - * @deprecated - * - */ - -/** - * This interface is being used to track code slated for removal. Any class or interface - * implementing or extending this interface respectively should not be used. All such classes and - * interfaces have been deprecated and are no longer supported and will be deleted post WTP 1.5. - * - * Any method or field with javadoc referencing this interface should not be used and will be - * deleted post WTP 1.5 - * - * @deprecated - */ -public interface DoNotUseMeThisWillBeDeletedPost15 { -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ExceptionHelper.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ExceptionHelper.java deleted file mode 100644 index 517d65be8..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ExceptionHelper.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -import java.util.ArrayList; -import java.util.List; - -/** - * Utility class to factor common code for implementers of IArchiveWrappedException - */ -public class ExceptionHelper { - /** - * Utility class; cannot be instantiated - */ - private ExceptionHelper() { - super(); - } - - /** - * Return the messages from - * - * @exception and - * all nested exceptions, in order from outermost to innermost - */ - public static java.lang.String[] getAllMessages(IWrappedException exception) { - List messages = new ArrayList(4); - messages.add(exception.getMessage()); - Exception nested = exception.getNestedException(); - while (nested != null) { - messages.add(nested.getMessage()); - if (nested instanceof IWrappedException) - nested = ((IWrappedException) nested).getNestedException(); - else - nested = null; - } - return (String[]) messages.toArray(new String[messages.size()]); - } - - /** - * Return the messages from - * - * @exception and - * all nested exceptions, in order from outermost to innermost, concatenated as - * one - */ - public static String getConcatenatedMessages(IWrappedException exception) { - String[] messages = getAllMessages(exception); - StringBuffer sb = new StringBuffer(256); - for (int i = 0; i < messages.length; i++) { - sb.append(messages[i]); - if (i < messages.length - 1) - sb.append('\n'); - } - return sb.toString(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/HashUtil.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/HashUtil.java deleted file mode 100644 index f2da27a17..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/HashUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -public class HashUtil { - - public static int SEED = 11; - private static int MULTI = 31; - - public static int hash(int seed, int i){ - return seed * MULTI + i; - } - - public static int hash(int seed, Object obj){ - return hash(seed, null != obj ? obj.hashCode() : SEED); - } - - public static int hash(int seed, boolean b){ - return hash(seed, b ? 1 : SEED); - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ISaveHandler.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ISaveHandler.java deleted file mode 100644 index f67ce31d6..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ISaveHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * Defines the API for coping with attempts to overwrite read-only files or save failures - */ -public interface ISaveHandler { - public void access(); - - public void handleSaveFailed(SaveFailedException ex, IProgressMonitor monitor); - - public void release(); - - public boolean shouldContinueAndMakeFileEditable(IFile aFile); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ISimpleValidateEditContext.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ISimpleValidateEditContext.java deleted file mode 100644 index 5b21d8e36..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/ISimpleValidateEditContext.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IStatus; - -public interface ISimpleValidateEditContext { - - public static final String CLASS_KEY = "ISimpleValidateEditContext"; //$NON-NLS-1$ - - public IStatus validateEdit(IFile [] files); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/IWrappedException.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/IWrappedException.java deleted file mode 100644 index 7b3f3ae74..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/IWrappedException.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -/** - * Common interface for ArchiveRuntime and ArchiveWrapped exceptions, which can contain nested - * exceptions - */ -public interface IWrappedException { - /** - * Return the messages from this and all nested exceptions, in order from outermost to innermost - */ - public String[] getAllMessages(); - - /** - * Return the messages from this and all nested exceptions, in order from outermost to - * innermost, concatenated as one - */ - public String getConcatenatedMessages(); - - public Exception getInnerMostNestedException(); - - public String getMessage(); - - public java.lang.Exception getNestedException(); - - public void printStackTrace(); - - public void printStackTrace(java.io.PrintStream s); - - public void printStackTrace(java.io.PrintWriter s); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/Messages.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/Messages.java deleted file mode 100644 index d8756a943..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/Messages.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Nov 21, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * @author DABERG - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public abstract class Messages { - //Resource bundle. - protected ResourceBundle resourceBundle; - - /** - * The constructor. - */ - public Messages() { - initializeBundle(); - } - - protected abstract void initializeBundle(); - - /** - * Returns the string from the resource bundle, or 'key' if not found. - */ - protected String doGetResourceString(String key) { - try { - return (resourceBundle != null ? resourceBundle.getString(key) : key); - } catch (MissingResourceException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - protected String doGetResourceString(String key, Object[] args) { - String pattern = doGetResourceString(key); - if (pattern != null) - return MessageFormat.format(pattern, args); - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveFailedException.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveFailedException.java deleted file mode 100644 index 776350958..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveFailedException.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -/** - * Runtime exception that could get thrown during save of an edit model; clients should use - * {@link #getConcatenatedMessages}to get all the messages of this and all nested exceptions to - * report the failure. - */ -public class SaveFailedException extends WrappedRuntimeException { - /** - * Comment for <code>serialVersionUID</code> - */ - private static final long serialVersionUID = -4640018901910731240L; - - /** - * SaveFailedException constructor comment. - */ - public SaveFailedException() { - super(); - } - - /** - * SaveFailedException constructor comment. - * - * @param e - * java.lang.Exception - */ - public SaveFailedException(Exception e) { - super(e); - } - - /** - * SaveFailedException constructor comment. - * - * @param s - * java.lang.String - */ - public SaveFailedException(String s) { - super(s); - } - - /** - * SaveFailedException constructor comment. - * - * @param s - * java.lang.String - * @param e - * java.lang.Exception - */ - public SaveFailedException(String s, Exception e) { - super(s, e); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveHandlerHeadless.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveHandlerHeadless.java deleted file mode 100644 index 2ae150ff3..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveHandlerHeadless.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.IWFTWrappedException; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * Insert the type's description here. Creation date: (10/19/2001 11:40:59 AM) - * - * @author: Administrator - */ -public class SaveHandlerHeadless implements ISaveHandler { - /** - * HeadlessSaveHandler constructor comment. - */ - public SaveHandlerHeadless() { - super(); - } - - /** - * access method comment. - */ - public void access() { - } - - /** - * handleSaveFailed method comment. - */ - public void handleSaveFailed(SaveFailedException ex, org.eclipse.core.runtime.IProgressMonitor monitor) { - throw ex; - } - - public static boolean isFailedWriteFileFailure(IWFTWrappedException ex) { - Exception nested = ex.getInnerMostNestedException(); - if (nested == null) - return false; - - return isFailedWriteFileFailure(nested); - } - - public static boolean isFailedWriteFileFailure(Exception ex) { - if (ex instanceof IWFTWrappedException) - return isFailedWriteFileFailure((IWFTWrappedException) ex); - else if (ex instanceof CoreException) - return isFailedWriteFileFailure((CoreException) ex); - return false; - } - - public static boolean isFailedWriteFileFailure(CoreException ex) { - org.eclipse.core.runtime.IStatus status = ex.getStatus(); - if (status == null) - return false; - Throwable nested = status.getException(); - if (nested instanceof CoreException) - return isFailedWriteFileFailure((CoreException) nested); - return status.getCode() == org.eclipse.core.resources.IResourceStatus.FAILED_WRITE_LOCAL; - } - - /** - * release method comment. - */ - public void release() { - } - - /** - * shouldContinueAndMakeFileEditable method comment. - */ - public boolean shouldContinueAndMakeFileEditable(org.eclipse.core.resources.IFile aFile) { - if (aFile == null) - return false; - String error = WTPResourceHandler.getString("Unable_to_save_read-only_f_ERROR_", new Object[]{aFile.getFullPath()}); //$NON-NLS-1$ = "Unable to save read-only file: " - WTPCommonPlugin.logError(error); - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveHandlerRegister.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveHandlerRegister.java deleted file mode 100644 index 7aaef0069..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SaveHandlerRegister.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.wst.common.core.util.UIContextDetermination; - -/** - * A registry for the default ISaveHandler to use when saving edit models - */ -public class SaveHandlerRegister { - private static ISaveHandler saveHandler; - - /** - * This is a utility class and should not be instantiated - */ - protected SaveHandlerRegister() { - super(); - } - - public static ISaveHandler getSaveHandler() { - if (saveHandler == null) - saveHandler = (ISaveHandler) UIContextDetermination.createInstance("saveHandler"); //$NON-NLS-1$ - return saveHandler; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEdit.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEdit.java deleted file mode 100644 index f8d6acb62..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEdit.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.core.util.UIContextDetermination; - -public class SimpleValidateEdit { - - /** - * @param files must contain only {@link IFile}s - * @return - */ - public static boolean validateEdit(List files){ - if(files == null || files.size() == 0){ - return true; - } - return validateEdit( (IFile [])files.toArray(new IFile[files.size()])); - } - - public static boolean validateEdit(IFile[] files) { - if(files == null || files.length == 0){ - return true; - } - ISimpleValidateEditContext validator = (ISimpleValidateEditContext) UIContextDetermination.createInstance(ISimpleValidateEditContext.CLASS_KEY); - if (validator != null) { - IStatus status = validator.validateEdit(files); - if (status != null) - return status.isOK(); - } - return true; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEditContextHeadless.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEditContextHeadless.java deleted file mode 100644 index eb8fe6562..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEditContextHeadless.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -public class SimpleValidateEditContextHeadless implements ISimpleValidateEditContext { - - public IStatus validateEdit(IFile[] files) { - final List filesList = new ArrayList(); - for(int i=0;i<files.length; i++){ - if(files[i].exists() && files[i].isReadOnly()){ - filesList.add(files[i]); - } - } - if(filesList.size() > 0){ - IFile [] filesToValidate = (IFile [])filesList.toArray(new IFile[filesList.size()]); - return validateEditImpl(filesToValidate); - } - return IDataModelProvider.OK_STATUS; - } - - protected IStatus validateEditImpl(IFile[] filesToValidate) { - return ResourcesPlugin.getWorkspace().validateEdit(filesToValidate, null); - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPPlugin.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPPlugin.java deleted file mode 100644 index 7f798bae3..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPPlugin.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal; - -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WorkbenchUtil; -import org.osgi.framework.BundleContext; - -public abstract class WTPPlugin extends Plugin { - protected static WTPPlugin instance = null; - public ResourceBundle resourceBundle; - - /** - * @param descriptor - */ - public WTPPlugin() { - super(); - instance = this; - } - - public static boolean isPlatformCaseSensitive() { - return Platform.OS_MACOSX.equals(Platform.getOS()) ? false : new - java.io.File("a").compareTo(new java.io.File("A")) != 0; //$NON-NLS-1$//$NON-NLS-2$ - } - - public abstract String getPluginID(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugin#startup() - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - WorkbenchUtil.setWorkbenchIsRunning(true); - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPProjectUtilities.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPProjectUtilities.java deleted file mode 100644 index ab74ed322..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPProjectUtilities.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Nov 4, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -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.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - - -/** - * @author jsholl - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class WTPProjectUtilities { - - /** - * Adds a old nauture to a project, FIRST, this is used to make project backward compatible - */ - public static void addOldNatureToProject(IProject proj, String natureId) throws CoreException { - IProjectDescription description = proj.getDescription(); - String[] prevNatures = description.getNatureIds(); - - //check if the old nature does not exist - boolean addNature = true; - for (int i = 0; i < prevNatures.length; i++) { - String nature = prevNatures[i]; - if (nature.equals(natureId)) { - addNature = false; - break; - } - } - if (addNature) { - String[] newNatures = new String[prevNatures.length + 1]; - System.arraycopy(prevNatures, 0, newNatures, 1, prevNatures.length); - newNatures[0] = natureId; - description.setNatureIds(newNatures); - proj.setDescription(description, IResource.AVOID_NATURE_CONFIG, null); - } - } - - /** - * Adds a nature in the project in the index specified - */ - public static void addOldNatureToProject(IProject proj, String natureId, int index) throws CoreException { - IProjectDescription description = proj.getDescription(); - String[] prevNatures = description.getNatureIds(); - - //check if the old nature does not exist - boolean addNature = true; - for (int i = 0; i < prevNatures.length; i++) { - String nature = prevNatures[i]; - if (nature.equals(natureId)) { - addNature = false; - break; - } - } - if (addNature) { - String[] newNatures = new String[prevNatures.length + 1]; - System.arraycopy(prevNatures, 0, newNatures, 0, index); - - newNatures[index] = natureId; - System.arraycopy(prevNatures, index, newNatures, index + 1, prevNatures.length - index); - description.setNatureIds(newNatures); - proj.setDescription(description, IResource.AVOID_NATURE_CONFIG, null); - } - } - - /** - * Adds a nauture to a project, FIRST - */ - public static void addNatureToProject(IProject proj, String natureId) throws CoreException { - IProjectDescription description = proj.getDescription(); - String[] prevNatures = description.getNatureIds(); - String[] newNatures = new String[prevNatures.length + 1]; - System.arraycopy(prevNatures, 0, newNatures, 1, prevNatures.length); - newNatures[0] = natureId; - description.setNatureIds(newNatures); - proj.setDescription(description, null); - } - - /** - * Adds a nature to a project, LAST - */ - public static void addNatureToProjectLast(IProject proj, String natureId) throws CoreException { - IProjectDescription description = proj.getDescription(); - String[] prevNatures = description.getNatureIds(); - String[] newNatures = new String[prevNatures.length + 1]; - System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); - newNatures[prevNatures.length] = natureId; - description.setNatureIds(newNatures); - proj.setDescription(description, null); - } - - /** - * remove a nature from the project - */ - public static void removeNatureFromProject(IProject project, String natureId) throws CoreException { - IProjectDescription description = project.getDescription(); - String[] prevNatures = description.getNatureIds(); - int size = prevNatures.length; - int newsize = 0; - String[] newNatures = new String[size]; - boolean matchfound = false; - for (int i = 0; i < size; i++) { - if (prevNatures[i].equals(natureId)) { - matchfound = true; - continue; - } - newNatures[newsize++] = prevNatures[i]; - } - if (!matchfound) - throw new CoreException(new Status(IStatus.ERROR, WTPCommonPlugin.PLUGIN_ID, 0, "The nature id " + natureId + " does not exist on the project " + project.getName(), null)); //$NON-NLS-1$ //$NON-NLS-2$ - String[] temp = newNatures; - newNatures = new String[newsize]; - System.arraycopy(temp, 0, newNatures, 0, newsize); - description.setNatureIds(newNatures); - if (ResourcesPlugin.getWorkspace().getNatureDescriptor(natureId) == null) { - // The nature does not exist, so do not attempt to de-configure it while removing it. - project.setDescription(description, IResource.AVOID_NATURE_CONFIG | IResource.KEEP_HISTORY, null); - } else { - project.setDescription(description, null); - } - } - - public static IProject getProject(Object object) { - IProject result = null; - - if (object instanceof IProject) - result = (IProject) object; - else if (object instanceof IResource) - result = ((IResource) object).getProject(); - else if (object instanceof IAdaptable) - result = (IProject) ((IAdaptable) object).getAdapter(IProject.class); - - return result; - } - - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPResourceHandler.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPResourceHandler.java deleted file mode 100644 index 6d82d6612..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WTPResourceHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * @author Administrator - * - * - */ -public class WTPResourceHandler { - - private static ResourceBundle fgResourceBundle; - - /** - * Returns the resource bundle used by all classes in this Project - */ - public static ResourceBundle getResourceBundle() { - try { - return ResourceBundle.getBundle("wtp_common"); //$NON-NLS-1$ - } catch (MissingResourceException e) { - // does nothing - this method will return null and - // getString(String) will return the key - // it was called with - } - return null; - } - - public static String getString(String key) { - if (fgResourceBundle == null) { - fgResourceBundle = getResourceBundle(); - } - - if (fgResourceBundle != null) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!"; //$NON-NLS-2$//$NON-NLS-1$ - } - } - return "!" + key + "!"; //$NON-NLS-2$//$NON-NLS-1$ - } - - public static String getString(String key, Object[] args) { - - try { - return MessageFormat.format(getString(key), args); - } catch (IllegalArgumentException e) { - return getString(key); - } - - } - - public static String getString(String key, Object[] args, int x) { - - return getString(key); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedException.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedException.java deleted file mode 100644 index 3c182d147..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedException.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -public class WrappedException extends java.lang.reflect.InvocationTargetException { - /** - * Comment for <code>serialVersionUID</code> - */ - private static final long serialVersionUID = -9221925581603648538L; - - /** - * WFTWrappedException constructor comment. - */ - protected WrappedException() { - super(); - } - - /** - * WFTWrappedException constructor comment. - * - * @param target - * java.lang.Throwable - */ - public WrappedException(Throwable target) { - super(target); - } - - /** - * WFTWrappedException constructor comment. - * - * @param target - * java.lang.Throwable - * @param s - * java.lang.String - */ - public WrappedException(Throwable target, String s) { - super(target, s); - } - - /** - * Print out a stack trace to the system err. - */ - @Override - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Prints the exception to System.err. If we have a nested exception, print its stack. - */ - @Override - public void printStackTrace(java.io.PrintStream s) { - if (getTargetException() != null) { - s.println(this); - s.println("Stack trace of nested exception:"); //$NON-NLS-1$ - getTargetException().printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - /** - * Prints the exception to System.err. If we have a nested exception, print its stack. - */ - @Override - public void printStackTrace(java.io.PrintWriter s) { - if (getTargetException() != null) { - s.println(this); - s.println("Stack trace of nested exception:"); //$NON-NLS-1$ - getTargetException().printStackTrace(s); - } else { - super.printStackTrace(s); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedRuntimeException.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedRuntimeException.java deleted file mode 100644 index 7e9895fd9..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/WrappedRuntimeException.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal; - -public class WrappedRuntimeException extends RuntimeException implements IWrappedException { - /** - * Comment for <code>serialVersionUID</code> - */ - private static final long serialVersionUID = 2684637746275620101L; - /** The exception which necessitated this runtime exception, if one exists */ - protected Exception nestedException; - - public WrappedRuntimeException() { - super(); - } - - public WrappedRuntimeException(Exception e) { - super(); - setNestedException(e); - } - - public WrappedRuntimeException(String s) { - super(s); - } - - public WrappedRuntimeException(String s, Exception e) { - super(s); - setNestedException(e); - } - - /** - * Return the messages from this and all nested exceptions, in order from outermost to innermost - */ - public java.lang.String[] getAllMessages() { - return ExceptionHelper.getAllMessages(this); - } - - /** - * Return the messages from this and all nested exceptions, in order from outermost to - * innermost, concatenated as one - */ - public java.lang.String getConcatenatedMessages() { - return ExceptionHelper.getConcatenatedMessages(this); - } - - /** - * getInnerMostNestedException method comment. - */ - public java.lang.Exception getInnerMostNestedException() { - Exception n = getNestedException(); - if (n == null) - return this; - else if (n instanceof IWrappedException) - return ((IWrappedException) n).getInnerMostNestedException(); - else - return n; - } - - /** - * @return java.lang.Exception - */ - public java.lang.Exception getNestedException() { - return nestedException; - } - - /** - * Added to provide compatibility for the Java 1.4.2 addition of - * <code>Throwable.getCause()</code>. - * @return The nested exception held by the receiver. - */ - @Override - public java.lang.Throwable getCause() { - return getNestedException(); - } - - /** - * Print out a stack trace to the system err. - */ - @Override - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Prints the exception to System.err. If we have a nested exception, print its stack. - */ - @Override - public void printStackTrace(java.io.PrintStream s) { - if (nestedException != null) { - s.println(this); - s.println("Stack trace of nested exception:"); //$NON-NLS-1$ - nestedException.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - /** - * Prints the exception to System.err. If we have a nested exception, print its stack. - */ - @Override - public void printStackTrace(java.io.PrintWriter s) { - if (nestedException != null) { - s.println(this); - s.println("Stack trace of nested exception:"); //$NON-NLS-1$ - nestedException.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - /** - * @param newNestedException - * java.lang.Exception - */ - public void setNestedException(java.lang.Exception newNestedException) { - nestedException = newNestedException; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/activities/WTPActivityBridge.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/activities/WTPActivityBridge.java deleted file mode 100644 index 6c7fa23ed..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/activities/WTPActivityBridge.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on May 4, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.activities; - -import java.util.Collections; -import java.util.Set; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * @author jsholl - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Generation - Code and Comments - */ -public class WTPActivityBridge { - private static final String PLUGIN_ID = "org.eclipse.wst.common.frameworks"; //$NON-NLS-1$ - private static final String EXTENSION_POINT = "WTPActivityBridgeHelper"; //$NON-NLS-1$ - private static final String LISTENER_CLASS = "class"; //$NON-NLS-1$ - - private static WTPActivityBridge INSTANCE = null; - private WTPActivityBridgeHelper[] listeners; - - public static WTPActivityBridge getInstance() { - if (null == INSTANCE) { - INSTANCE = new WTPActivityBridge(); - } - return INSTANCE; - } - - private WTPActivityBridge() { - loadExtensionPoints(); - } - - public void enableActivity(String activityID, boolean enabled) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].enableActivity(activityID, enabled); - } - } - - public Set getEnabledActivityIds() { - if(listeners.length > 0){ - return listeners[0].getEnabledActivityIds(); - } - return Collections.EMPTY_SET; - } - - public void setEnabledActivityIds(Set activityIDs) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].setEnabledActivityIds(activityIDs); - } - } - - public Set getActivityIDsFromContribution(String localID, String pluginID) { - if(listeners.length > 0) { - return listeners[0].getActivityIDsFromContribution(localID, pluginID); - } - return Collections.EMPTY_SET; - } - - private void loadExtensionPoints() { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, EXTENSION_POINT); - if (point == null) - return; - IConfigurationElement[] elements = point.getConfigurationElements(); - listeners = new WTPActivityBridgeHelper[elements.length]; - for (int i = 0; i < elements.length; i++) { - if (null == elements[i].getAttribute(LISTENER_CLASS)) { - logError(elements[i], "No " + LISTENER_CLASS + " defined."); //$NON-NLS-1$ //$NON-NLS-2$ - } - try { - listeners[i] = (WTPActivityBridgeHelper) elements[i].createExecutableExtension(LISTENER_CLASS); - } catch (CoreException e) { - logError(elements[i], "Error loading " + LISTENER_CLASS + ":" + elements[i].getAttribute(LISTENER_CLASS)); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); - } - } - } - - public static void logError(IConfigurationElement element, String text) { - IExtension extension = element.getDeclaringExtension(); - StringBuffer buf = new StringBuffer(); - buf.append("Plugin " + extension.getNamespace() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ - buf.append("\n" + text); //$NON-NLS-1$ - WTPCommonPlugin.logError(buf.toString()); - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/activities/WTPActivityBridgeHelper.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/activities/WTPActivityBridgeHelper.java deleted file mode 100644 index 4378df1df..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/activities/WTPActivityBridgeHelper.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on May 4, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.activities; - -import java.util.Set; - -/** - * @author jsholl - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Generation - Code and Comments - */ -public interface WTPActivityBridgeHelper { - - public void enableActivity(String activityID, boolean enabled); - - public Set getEnabledActivityIds(); - - public void setEnabledActivityIds(Set activityIDs); - - public Set getActivityIDsFromContribution(String localID, String pluginID); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelExtensionReader.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelExtensionReader.java deleted file mode 100644 index 5b1fe15b9..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelExtensionReader.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.common.core.util.RegistryReader; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class DataModelExtensionReader extends RegistryReader { - - private static final String EXTENSION = "DataModelProviderExtension"; //$NON-NLS-1$ - - private static final String PROVIDER_ELEMENT = "DataModelProvider"; //$NON-NLS-1$ - private static final String DEFINES_TYPE_ELEMENT = "ProviderDefinesType"; //$NON-NLS-1$ - private static final String IMPLEMENTS_TYPE_ELEMENT = "ProviderImplementsType"; //$NON-NLS-1$ - - private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ - private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ - private static final String ATTRIBUTE_PROVIDER_TYPE = "providerType"; //$NON-NLS-1$ - private static final String ATTRIBUTE_PROVIDER_ID = "providerID"; //$NON-NLS-1$ -// private static final String ATTRIBUTE_FG = "functionGroupID"; //$NON-NLS-1$ - - private HashMap providerExtensions; - private HashMap definesExtensions; - private HashMap implementsExtensions; - - private boolean hasInitialized = false; - - public DataModelExtensionReader() { - super(WTPCommonPlugin.PLUGIN_ID, EXTENSION); - } - - @Override - public boolean readElement(IConfigurationElement element) { - if (element.getName().equals(PROVIDER_ELEMENT)) { - String id = element.getAttribute(ATTRIBUTE_ID); - if (null == id || id.trim().length() == 0) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + PROVIDER_ELEMENT + " is missing " + ATTRIBUTE_ID)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - String className = element.getAttribute(ATTRIBUTE_CLASS); - if (null == className || className.trim().length() == 0) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + PROVIDER_ELEMENT + " is missing " + ATTRIBUTE_CLASS)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - addProviderExtension(id, element); - } else if (element.getName().equals(DEFINES_TYPE_ELEMENT)) { - String type = element.getAttribute(ATTRIBUTE_PROVIDER_TYPE); - if (null == type || type.trim().length() == 0) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + DEFINES_TYPE_ELEMENT + " is missing " + ATTRIBUTE_PROVIDER_TYPE)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - String id = element.getAttribute(ATTRIBUTE_PROVIDER_ID); - if (null == id || id.trim().length() == 0) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + DEFINES_TYPE_ELEMENT + " is missing " + ATTRIBUTE_PROVIDER_ID)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - addDefinesExtension(type, id); - } else if (element.getName().equals(IMPLEMENTS_TYPE_ELEMENT)) { - String type = element.getAttribute(ATTRIBUTE_PROVIDER_TYPE); - if (null == type || type.trim().length() == 0) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + DEFINES_TYPE_ELEMENT + " is missing " + ATTRIBUTE_PROVIDER_TYPE)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - String id = element.getAttribute(ATTRIBUTE_PROVIDER_ID); - if (null == id || id.trim().length() == 0) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + DEFINES_TYPE_ELEMENT + " is missing " + ATTRIBUTE_PROVIDER_ID)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - addImplementsExtension(type, id); - } - return true; - } - - private void addProviderExtension(String id, IConfigurationElement element) { - if (providerExtensions.containsKey(id)) { - WTPCommonPlugin.logError(new RuntimeException("Duplicate " + PROVIDER_ELEMENT + " " + ATTRIBUTE_ID + " " + id)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - providerExtensions.put(id, element); - } - - private void addDefinesExtension(String type, String id) { - if (definesExtensions.containsKey(type)) { - WTPCommonPlugin.logError(new RuntimeException("Duplicate " + PROVIDER_ELEMENT + " " + ATTRIBUTE_PROVIDER_TYPE + " " + type)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - definesExtensions.put(type, id); - } - - private void addImplementsExtension(String type, String id) { - List cache; - if (implementsExtensions.containsKey(type)) - cache = (List) implementsExtensions.get(type); - else - cache = new ArrayList(); - cache.add(id); - implementsExtensions.put(type, cache); - } - - protected IConfigurationElement getProviderExtension(String id) { - readRegistryIfNecessary(); - IConfigurationElement element = (IConfigurationElement) providerExtensions.get(id); - if (null == element) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + PROVIDER_ELEMENT + " not found for " + ATTRIBUTE_ID + ": " + id)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - return element; - } - - protected String getDefinesExtension(String providerType) { - readRegistryIfNecessary(); - String element = (String) definesExtensions.get(providerType); - if (null == element) { - WTPCommonPlugin.logError(new RuntimeException("Extension:" + EXTENSION + " Element:" + DEFINES_TYPE_ELEMENT + " not found for " + ATTRIBUTE_PROVIDER_TYPE + ": " + providerType)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - return element; - } - - public String[] getProviderDescriptorsForProviderKind(String providerType) { - readRegistryIfNecessary(); - List providerList = new ArrayList(); - providerList.add(getDefinesExtension(providerType)); - if (implementsExtensions.containsKey(providerType)) { - List implementsIds = (List) implementsExtensions.get(providerType); - if (implementsIds != null && !implementsIds.isEmpty()) { - providerList.addAll(implementsIds); - } - } - String[] providerArray = new String[providerList.size()]; - for (int i = 0; i < providerArray.length; i++) { - providerArray[i] = (String) providerList.get(i); - } - return providerArray; - } - - private void readRegistryIfNecessary() { - if (!hasInitialized) { - providerExtensions = new HashMap(); - definesExtensions = new HashMap(); - implementsExtensions = new HashMap(); - readRegistry(); - hasInitialized = true; - } - } - - public IDataModelProvider getProvider(String id) { - IDataModelProvider provider = null; - IConfigurationElement element = getProviderExtension(id); - if (element == null) - return null; - try { - provider = (IDataModelProvider) element.createExecutableExtension(ATTRIBUTE_CLASS); - } catch (CoreException e) { - WTPCommonPlugin.logError(e); - } - return provider; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelImpl.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelImpl.java deleted file mode 100644 index 434e312eb..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelImpl.java +++ /dev/null @@ -1,471 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -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.MultiStatus; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; - -public final class DataModelImpl implements IDataModel, IDataModelListener { - - private static final String PROPERTY_NOT_LOCATED_ = WTPResourceHandler.getString("20"); //$NON-NLS-1$ - private static final String NESTED_MODEL_NOT_LOCATED = WTPResourceHandler.getString("21"); //$NON-NLS-1$ - - private static final DataModelPropertyDescriptor[] NO_DESCRIPTORS = new DataModelPropertyDescriptor[0]; - - private Collection basePropertyNames; - private Collection allPropertyNames; - private Collection nestedPropertyNames; // lazily initialzed when nested models added - private Map propertyValues = new Hashtable(); - private Map nestedModels; - private Set nestingModels; - private List listeners; - - private IDataModelProvider provider; - - public DataModelImpl(IDataModelProvider dataModelProvider) { - init(dataModelProvider); - } - - private void init(IDataModelProvider dataModelProvider) { - this.provider = dataModelProvider; - dataModelProvider.setDataModel(this); - Collection propertyNames = dataModelProvider.getPropertyNames(); - HashSet properties = new HashSet(); - properties.addAll(propertyNames); - - properties.add(IDataModelProperties.ALLOW_EXTENSIONS); - properties.add(IDataModelProperties.RESTRICT_EXTENSIONS); - basePropertyNames = Collections.unmodifiableCollection(properties); - allPropertyNames = new HashSet(); - allPropertyNames.addAll(basePropertyNames); - dataModelProvider.init(); - } - - public boolean isBaseProperty(String propertyName) { - return basePropertyNames.contains(propertyName); - } - - public Collection getBaseProperties() { - return Collections.unmodifiableCollection(basePropertyNames); - } - - public boolean isProperty(String propertyName) { - return allPropertyNames.contains(propertyName); - } - - public Collection getAllProperties() { - return Collections.unmodifiableCollection(allPropertyNames); - } - - public boolean isNestedProperty(String propertyName) { - return null != nestedPropertyNames && nestedPropertyNames.contains(propertyName); - } - - public Collection getNestedProperties() { - return Collections.unmodifiableCollection(nestedPropertyNames); - } - - private void checkValidPropertyName(String propertyName) { - if (!isProperty(propertyName)) { - throw new RuntimeException(PROPERTY_NOT_LOCATED_ + propertyName); - } - } - - private DataModelImpl getOwningDataModel(String propertyName) { - checkValidPropertyName(propertyName); - return searchNestedModels(propertyName); - } - - private DataModelImpl searchNestedModels(String propertyName) { - if (isBaseProperty(propertyName)) { - return this; - } else if (nestedModels != null) { - DataModelImpl dataModel = null; - Object[] keys = nestedModels.keySet().toArray(); - for (int i = 0; i < keys.length; i++) { - dataModel = (DataModelImpl) nestedModels.get(keys[i]); - if (dataModel.isProperty(propertyName)) { - return dataModel.searchNestedModels(propertyName); - } - } - } - throw new RuntimeException(PROPERTY_NOT_LOCATED_ + propertyName); - } - - public Object getProperty(String propertyName) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - if (dataModel.propertyValues.containsKey(propertyName)) { - return dataModel.propertyValues.get(propertyName); - } - return dataModel.provider.getDefaultProperty(propertyName); - } - - public Object getDefaultProperty(String propertyName) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - return dataModel.provider.getDefaultProperty(propertyName); - } - - public int getIntProperty(String propertyName) { - Object prop = getProperty(propertyName); - if (prop == null) - return -1; - return ((Integer) prop).intValue(); - } - - public boolean getBooleanProperty(String propertyName) { - Object prop = getProperty(propertyName); - if (prop == null) - return false; - return ((Boolean) prop).booleanValue(); - } - - public String getStringProperty(String propertyName) { - Object prop = getProperty(propertyName); - if (prop == null) - return ""; //$NON-NLS-1$ - return (String) prop; - } - - public boolean isPropertySet(String propertyName) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - return dataModel.propertyValues.containsKey(propertyName); - } - - public boolean isPropertyEnabled(String propertyName) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - return dataModel.provider.isPropertyEnabled(propertyName); - } - - - public void setProperty(String propertyName, Object propertyValue) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - dataModel.internalSetProperty(propertyName, propertyValue); - } - - private void internalSetProperty(String propertyName, Object propertyValue) { - Object oldValue = propertyValues.get(propertyName); - if (valueChanged(propertyValue, oldValue)) { - if (null != propertyValue) - propertyValues.put(propertyName, propertyValue); - else if (propertyValues.containsKey(propertyName)) - propertyValues.remove(propertyName); - if (provider.propertySet(propertyName, propertyValue)) { - notifyPropertyChange(propertyName, DataModelEvent.VALUE_CHG); - } - } - } - - private boolean valueChanged(Object o1, Object o2) { - return o1 != o2 && ((o1 != null && !o1.equals(o2)) || !o2.equals(o1)); - } - - public void setIntProperty(String propertyName, int value) { - setProperty(propertyName, new Integer(value)); - } - - public void setBooleanProperty(String propertyName, boolean value) { - setProperty(propertyName, (value) ? Boolean.TRUE : Boolean.FALSE); - } - - public void setStringProperty(String propertyName, String value) { - setProperty(propertyName, value); - } - - public boolean addNestedModel(String modelName, IDataModel dataModel) { - if (this == dataModel) { - return false; - } - if (null == nestedModels) { - nestedModels = new Hashtable(); - nestedPropertyNames = new HashSet(); - } - DataModelImpl nestedDataModel = (DataModelImpl) dataModel; - if (null == nestedDataModel.nestingModels) { - nestedDataModel.nestingModels = new HashSet(); - } - if (nestedDataModel.nestingModels.contains(this)) { - return false; - } - nestedDataModel.nestingModels.add(this); - - nestedModels.put(modelName, nestedDataModel); - - addNestedProperties(nestedDataModel.allPropertyNames); - nestedDataModel.addListener(this); - return true; - } - - private void addNestedProperties(Collection nestedProperties) { - boolean propertiesAdded = allPropertyNames.addAll(nestedProperties); - propertiesAdded = nestedPropertyNames.addAll(nestedProperties) || propertiesAdded; - // Pass the new properties up the nesting chain - if (propertiesAdded && nestingModels != null) { - Iterator iterator = nestingModels.iterator(); - while (iterator.hasNext()) { - ((DataModelImpl) iterator.next()).addNestedProperties(nestedProperties); - } - } - } - - public Collection getNestedModels() { - return nestedModels != null ? Collections.unmodifiableCollection(nestedModels.values()) : Collections.EMPTY_SET; - } - - public Collection getNestedModelNames() { - return nestedModels != null ? Collections.unmodifiableCollection(nestedModels.keySet()) : Collections.EMPTY_SET; - } - - public Collection getNestingModels() { - return nestingModels != null ? Collections.unmodifiableCollection(nestingModels) : Collections.EMPTY_SET; - } - - public IDataModel removeNestedModel(String modelName) { - if (!isNestedModel(modelName)) { - return null; - } - DataModelImpl model = (DataModelImpl) nestedModels.remove(modelName); - model.nestingModels.remove(this); - removeNestedProperties(model.allPropertyNames); - model.removeListener(this); - if (nestedModels.isEmpty()) { - nestedModels = null; - } - return model; - } - - private void removeNestedProperties(Collection nestedProperties) { - Iterator iterator = nestedProperties.iterator(); - String property = null; - boolean keepProperty = false; - Set nestedPropertiesToRemove = null; - while (iterator.hasNext()) { - keepProperty = false; - property = (String) iterator.next(); - if (basePropertyNames.contains(property)) { - keepProperty = true; - } - if (!keepProperty && nestedModels != null) { - Iterator nestedModelsIterator = nestedModels.values().iterator(); - while (!keepProperty && nestedModelsIterator.hasNext()) { - DataModelImpl nestedModel = (DataModelImpl) nestedModelsIterator.next(); - if (nestedModel.isProperty(property)) { - keepProperty = true; - } - } - } - if (!keepProperty) { - if (null == nestedPropertiesToRemove) { - nestedPropertiesToRemove = new HashSet(); - } - nestedPropertiesToRemove.add(property); - } - } - - if (null != nestedPropertiesToRemove) { - allPropertyNames.removeAll(nestedPropertiesToRemove); - nestedPropertyNames.removeAll(nestedPropertiesToRemove); - if (nestingModels != null) { - Iterator nestingModelsIterator = nestingModels.iterator(); - while (nestingModelsIterator.hasNext()) { - ((DataModelImpl) nestingModelsIterator.next()).removeNestedProperties(nestedPropertiesToRemove); - } - } - } - } - - public boolean isNestedModel(String modelName) { - return modelName != null && null != nestedModels && nestedModels.containsKey(modelName); - } - - public IDataModel getNestedModel(String modelName) { - IDataModel dataModel = (null != nestedModels && null != modelName) ? (IDataModel) nestedModels.get(modelName) : null; - if (null == dataModel) { - throw new RuntimeException(NESTED_MODEL_NOT_LOCATED + modelName); - } - return dataModel; - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - DataModelPropertyDescriptor[] descriptors = dataModel.provider.getValidPropertyDescriptors(propertyName); - return descriptors == null ? NO_DESCRIPTORS : descriptors; - } - - public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - DataModelPropertyDescriptor descriptor = dataModel.provider.getPropertyDescriptor(propertyName); - return descriptor == null ? new DataModelPropertyDescriptor(getProperty(propertyName)) : descriptor; - } - - public void notifyPropertyChange(final String propertyName, final int flag) { - int innerFlag = flag; - if (innerFlag == DEFAULT_CHG) { - if (isPropertySet(propertyName)) { - return; - } - innerFlag = VALUE_CHG; - } - notifyListeners(new DataModelEvent(this, propertyName, innerFlag)); - } - - private void notifyListeners(DataModelEvent event) { - if (listeners != null && !listeners.isEmpty()) { - IDataModelListener listener; - for (int i = 0; i < listeners.size(); i++) { - listener = (IDataModelListener) listeners.get(i); - if (listener != event.getDataModel()) { - listener.propertyChanged(event); - } - } - } - } - - public void propertyChanged(DataModelEvent event) { - notifyListeners(event); - } - - public IStatus validate() { - return validate(true); - } - - public IStatus validate(boolean stopOnFirstFailure) { - IStatus status = null; - IStatus propStatus; - String propName; - Iterator it; - for (int i = 0; i < 2; i++) { - switch (i) { - case 0 : - it = basePropertyNames.iterator(); - break; - case 1 : - default : - it = getNestedModelNames().iterator(); - } - while (it.hasNext()) { - propName = (String) it.next(); - propStatus = provider.validate(propName); - if (propStatus != null) { - if (status == null || status.isOK()) { - status = propStatus; - } else { - if (status.isMultiStatus()) { - ((MultiStatus) status).merge(propStatus); - } else { - MultiStatus multi = new MultiStatus("org.eclipse.wst.common.frameworks.internal", 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$ - multi.merge(status); - multi.merge(propStatus); - status = multi; - } - } - if (stopOnFirstFailure && !status.isOK() && status.getSeverity() == IStatus.ERROR) - return status; - } - } - } - - if (status == null) - return IDataModelProvider.OK_STATUS; - return status; - } - - public void addListener(IDataModelListener listener) { - if (listener != null) { - if (listeners == null) { - listeners = new ArrayList(); - listeners.add(listener); - } else if (!listeners.contains(listener)) - listeners.add(listener); - } - } - - public void removeListener(IDataModelListener listener) { - if (listeners != null && listener != null) - listeners.remove(listener); - } - - /** - * Return true if the model doesn't have any errors. - * - * @return boolean - */ - public boolean isValid() { - return validate(true).getSeverity() != IStatus.ERROR; - } - - public boolean isPropertyValid(String propertyName) { - return validateProperty(propertyName).getSeverity() != IStatus.ERROR; - } - - public IStatus validateProperty(String propertyName) { - DataModelImpl dataModel = getOwningDataModel(propertyName); - IStatus status = dataModel.provider.validate(propertyName); - return status == null ? IDataModelProvider.OK_STATUS : status; - } - - public List getExtendedContext() { - List extendedContext = provider.getExtendedContext(); - return extendedContext == null ? Collections.EMPTY_LIST : extendedContext; - } - - public void dispose() { - provider.dispose(); - } - - public IDataModelOperation getRawOperation() { - IDataModelOperation providerOp = provider.getDefaultOperation(); - if (null == providerOp) { - providerOp = new AbstractDataModelOperation(this) { - @Override - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return OK_STATUS; - } - }; - } - return providerOp; - } - - public IDataModelOperation getDefaultOperation() { - return new DataModelPausibleOperationImpl(getRawOperation()); - } - - @Override - public String toString() { - return "IDataModel, provider=" + provider.toString(); //$NON-NLS-1$ - } - - public String getID() { - String id = provider.getID(); - return null != id ? id : ""; //$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelPausibleOperationEventImpl.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelPausibleOperationEventImpl.java deleted file mode 100644 index a8c8ad522..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelPausibleOperationEventImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class DataModelPausibleOperationEventImpl implements IDataModelPausibleOperationEvent { - - private IDataModelOperation operation; - private int operationType; - private int executionType; - - public DataModelPausibleOperationEventImpl(IDataModelOperation operation, int operationType, int executionType) { - this.operation = operation; - this.operationType = operationType; - this.executionType = executionType; - } - - public IDataModelOperation getOperation() { - return operation; - } - - public int getOperationType() { - return operationType; - } - - public int getExecutionType() { - return executionType; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelPausibleOperationImpl.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelPausibleOperationImpl.java deleted file mode 100644 index 31d078afb..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/DataModelPausibleOperationImpl.java +++ /dev/null @@ -1,597 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; -import java.util.Stack; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; -import org.eclipse.wst.common.frameworks.internal.AdaptabilityUtility; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; -import org.eclipse.wst.common.frameworks.internal.enablement.IEnablementManager; -import org.eclipse.wst.common.frameworks.internal.operations.ComposedExtendedOperationHolder; -import org.eclipse.wst.common.frameworks.internal.operations.OperationStatus; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class DataModelPausibleOperationImpl extends WrappedOperation implements IDataModelPausibleOperation { - - // Stack of StackEntries to be executed - protected Stack operationStackToExecute = null; - - // Stack of StackEntries already executed - protected Stack undoStack = null; - protected Stack redoStack = null; - - protected OperationStackEntry rootStackEntry = null; - - protected List operationListeners; - - protected int executionState = NOT_STARTED; - - public DataModelPausibleOperationImpl(IDataModelOperation rootOperation) { - super(rootOperation); - } - - public void addOperationListener(IDataModelPausibleOperationListener operationListener) { - if (null == operationListeners) { - operationListeners = new ArrayList(); - } - operationListeners.add(operationListener); - } - - public void removeOperationListener(IDataModelPausibleOperationListener operationListener) { - if (null != operationListeners) { - operationListeners.remove(operationListener); - } - } - - public int getExecutionState() { - return executionState; - } - - protected static final int EXECUTE_IMPL = 0; - protected static final int UNDO_IMPL = 1; - protected static final int REDO_IMPL = 2; - protected static final int ROLLBACK_IMPL = 3; - protected static final int RESUME_IMPL = 4; - - private static Hashtable threadToExtendedOpControl = new Hashtable(); - - protected IStatus cacheThreadAndContinue(IProgressMonitor monitor, IAdaptable info, int runType) throws ExecutionException { - final Thread currentThread = Thread.currentThread(); - final boolean isTopLevelOperation = !threadToExtendedOpControl.containsKey(currentThread); - try { - if (isTopLevelOperation) { - threadToExtendedOpControl.put(currentThread, this); - } - switch (runType) { - case EXECUTE_IMPL : - return executeImpl(monitor, info); - case UNDO_IMPL : - return undoImpl(monitor, info); - case REDO_IMPL : - return redoImpl(monitor, info); - case ROLLBACK_IMPL : - return rollBackImpl(monitor, info); - case RESUME_IMPL : - return resumeImpl(monitor, info); - } - } finally { - if (isTopLevelOperation) { - threadToExtendedOpControl.remove(currentThread); - } - } - throw new RuntimeException(); - } - - public IStatus resume(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return cacheThreadAndContinue(monitor, info, RESUME_IMPL); - } - - protected IStatus resumeImpl(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - switch (executionState) { - case NOT_STARTED : - return executeImpl(monitor, info); - case PAUSED_EXECUTE : - case COMPLETE_ROLLBACK : - return doExecute(monitor, info); - case PAUSED_UNDO : - return doUndo(monitor, info); - case PAUSED_REDO : - return redoImpl(monitor, info); - } - throw new RuntimeException(); - } - - @Override - public boolean canRedo() { - return (COMPLETE_UNDO == executionState) && super.canRedo(); - } - - @Override - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return cacheThreadAndContinue(monitor, info, REDO_IMPL); - } - - protected IStatus redoImpl(IProgressMonitor monitor, IAdaptable info) { - return doRedo(monitor, info); - } - - protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) { - try { - executionState = RUNNING_REDO; - OperationStatus returnStatus = null; - int shouldContinue = IDataModelPausibleOperationListener.CONTINUE; - while (IDataModelPausibleOperationListener.CONTINUE == shouldContinue && !redoStack.isEmpty()) { - OperationStackEntry stackEntry = (OperationStackEntry) redoStack.peek(); - IDataModelOperation operation = stackEntry.getOperation(); - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(operation, IDataModelPausibleOperationEvent.MAIN_STARTING, IDataModelPausibleOperationEvent.REDO); - shouldContinue = notifyOperationListeners(event); - if (IDataModelPausibleOperationListener.PAUSE == shouldContinue) { - continue; - } - undoStack.push(redoStack.pop()); - returnStatus = runOperation(operation, monitor, info, IDataModelPausibleOperationEvent.REDO, returnStatus); - event = new DataModelPausibleOperationEventImpl(operation, IDataModelPausibleOperationEvent.MAIN_FINISHED, IDataModelPausibleOperationEvent.REDO); - shouldContinue = notifyOperationListeners(event); - - } - return returnStatus == null ? Status.OK_STATUS : returnStatus; - } finally { - executionState = redoStack.isEmpty() ? COMPLETE_REDO : PAUSED_REDO; - } - } - - @Override - public boolean canUndo() { - return (executionState == COMPLETE_EXECUTE || executionState == COMPLETE_REDO) && super.canUndo(); - } - - @Override - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return cacheThreadAndContinue(monitor, info, UNDO_IMPL); - } - - protected IStatus undoImpl(IProgressMonitor monitor, IAdaptable info) { - redoStack = new Stack(); - return doUndo(monitor, info); - } - - protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) { - try { - executionState = RUNNING_UNDO; - OperationStatus returnStatus = null; - int shouldContinue = IDataModelPausibleOperationListener.CONTINUE; - while (IDataModelPausibleOperationListener.CONTINUE == shouldContinue && !undoStack.isEmpty()) { - OperationStackEntry stackEntry = (OperationStackEntry) undoStack.peek(); - IDataModelOperation operation = stackEntry.getOperation(); - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(operation, IDataModelPausibleOperationEvent.MAIN_STARTING, IDataModelPausibleOperationEvent.UNDO); - shouldContinue = notifyOperationListeners(event); - if (IDataModelPausibleOperationListener.PAUSE == shouldContinue) { - continue; - } - redoStack.push(undoStack.pop()); - returnStatus = runOperation(operation, monitor, info, IDataModelPausibleOperationEvent.UNDO, returnStatus); - event = new DataModelPausibleOperationEventImpl(operation, IDataModelPausibleOperationEvent.MAIN_FINISHED, IDataModelPausibleOperationEvent.UNDO); - shouldContinue = notifyOperationListeners(event); - - } - return returnStatus == null ? Status.OK_STATUS : returnStatus; - } finally { - executionState = undoStack.isEmpty() ? COMPLETE_UNDO : PAUSED_UNDO; - } - } - - @Override - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return cacheThreadAndContinue(monitor, info, EXECUTE_IMPL); - } - - protected IStatus executeImpl(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - executionState = RUNNING_EXECUTE; - undoStack = new Stack(); - operationStackToExecute = new Stack(); - rootStackEntry = new OperationStackEntry(null, rootOperation); - operationStackToExecute.push(rootStackEntry); - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(rootOperation, IDataModelPausibleOperationEvent.NODE_STARTING, IDataModelPausibleOperationEvent.EXECUTE); - if (IDataModelPausibleOperationListener.CONTINUE == notifyOperationListeners(event)) { - return doExecute(monitor, info); - } - return Status.OK_STATUS; - } finally { - executionState = operationStackToExecute.isEmpty() ? COMPLETE_EXECUTE : PAUSED_EXECUTE; - } - } - - protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - OperationStatus returnStatus = null; - int shouldContinue = IDataModelPausibleOperationListener.CONTINUE; - while (IDataModelPausibleOperationListener.CONTINUE == shouldContinue && !operationStackToExecute.isEmpty()) { - OperationStackEntry stackEntry = (OperationStackEntry) operationStackToExecute.peek(); - OperationStackEntry preStackEntry = stackEntry.getNextPreOperation(); - if (null != preStackEntry) { - operationStackToExecute.push(preStackEntry); - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(preStackEntry.getOperation(), IDataModelPausibleOperationEvent.NODE_STARTING, IDataModelPausibleOperationEvent.EXECUTE); - shouldContinue = notifyOperationListeners(event); - continue; - } - IDataModelOperation stackEntryOperation = stackEntry.getOperationForExecution(); - if (null != stackEntryOperation) { - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(stackEntryOperation, IDataModelPausibleOperationEvent.MAIN_STARTING, IDataModelPausibleOperationEvent.EXECUTE); - shouldContinue = notifyOperationListeners(event); - if (IDataModelPausibleOperationListener.PAUSE == shouldContinue) { - continue; - } - returnStatus = runOperation(stackEntryOperation, monitor, info, IDataModelPausibleOperationEvent.EXECUTE, returnStatus); - undoStack.push(stackEntry); - event = new DataModelPausibleOperationEventImpl(stackEntryOperation, IDataModelPausibleOperationEvent.MAIN_FINISHED, IDataModelPausibleOperationEvent.EXECUTE); - shouldContinue = notifyOperationListeners(event); - if (IDataModelPausibleOperationListener.PAUSE == shouldContinue) { - continue; - } - } - OperationStackEntry postStackEntry = stackEntry.getNextPostOperation(); - if (null != postStackEntry) { - operationStackToExecute.push(postStackEntry); - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(postStackEntry.getOperation(), IDataModelPausibleOperationEvent.NODE_STARTING, IDataModelPausibleOperationEvent.EXECUTE); - shouldContinue = notifyOperationListeners(event); - continue; - } - operationStackToExecute.pop(); - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(stackEntry.getOperation(), IDataModelPausibleOperationEvent.NODE_FINISHED, IDataModelPausibleOperationEvent.EXECUTE); - shouldContinue = notifyOperationListeners(event); - } - return returnStatus == null ? Status.OK_STATUS : returnStatus; - } finally { - executionState = operationStackToExecute.isEmpty() ? COMPLETE_EXECUTE : PAUSED_EXECUTE; - } - } - - public IStatus rollBack(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return cacheThreadAndContinue(monitor, info, ROLLBACK_IMPL); - } - - protected IStatus rollBackImpl(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if (PAUSED_EXECUTE == executionState || PAUSED_ROLLBACK == executionState) { - try { - executionState = RUNNING_ROLLBACK; - OperationStatus returnStatus = null; - int shouldContinue = IDataModelPausibleOperationListener.CONTINUE; - while (IDataModelPausibleOperationListener.CONTINUE == shouldContinue && !undoStack.isEmpty()) { - OperationStackEntry stackEntry = (OperationStackEntry) undoStack.peek(); - IDataModelOperation operation = stackEntry.getOperation(); - DataModelPausibleOperationEventImpl event = new DataModelPausibleOperationEventImpl(operation, IDataModelPausibleOperationEvent.MAIN_STARTING, IDataModelPausibleOperationEvent.ROLLBACK); - shouldContinue = notifyOperationListeners(event); - if (IDataModelPausibleOperationListener.PAUSE == shouldContinue) { - continue; - } - undoStack.pop(); - OperationStackEntry executionTopStackEntry = stackEntry.rollBackOneOperation(); - if (operationStackToExecute.contains(executionTopStackEntry)) { - while (operationStackToExecute.peek() != executionTopStackEntry) { - operationStackToExecute.pop(); - } - } else { - Stack parentStack = new Stack(); - parentStack.push(executionTopStackEntry); - OperationStackEntry entry = executionTopStackEntry.parent; - while (!operationStackToExecute.contains(entry)) { - parentStack.push(entry); - entry = entry.parent; - } - while (operationStackToExecute.peek() != entry) { - operationStackToExecute.pop(); - } - while (!parentStack.isEmpty()) { - operationStackToExecute.push(parentStack.pop()); - } - } - returnStatus = runOperation(operation, monitor, info, IDataModelPausibleOperationEvent.UNDO, returnStatus); - event = new DataModelPausibleOperationEventImpl(operation, IDataModelPausibleOperationEvent.MAIN_FINISHED, IDataModelPausibleOperationEvent.ROLLBACK); - shouldContinue = notifyOperationListeners(event); - } - return returnStatus == null ? Status.OK_STATUS : returnStatus; - } finally { - executionState = undoStack.isEmpty() ? COMPLETE_ROLLBACK : PAUSED_ROLLBACK; - } - } - throw new RuntimeException(); - } - - private int notifyOperationListeners(DataModelPausibleOperationEventImpl event) { - if (null != operationListeners) { - IDataModelPausibleOperationListener listener = null; - for (int i = 0; i < operationListeners.size(); i++) { - listener = (IDataModelPausibleOperationListener) operationListeners.get(i); - if (IDataModelPausibleOperationListener.PAUSE == listener.notify(event)) { - return IDataModelPausibleOperationListener.PAUSE; - } - } - } - return IDataModelPausibleOperationListener.CONTINUE; - } - - protected OperationStatus addStatus(OperationStatus returnStatus, IStatus status) { - OperationStatus innerReturnStatus = returnStatus; - if (innerReturnStatus == null) { - innerReturnStatus = new OperationStatus(status.getMessage(), status.getException()); - innerReturnStatus.setSeverity(status.getSeverity()); - innerReturnStatus.add(status); - } else { - innerReturnStatus.add(status); - } - return innerReturnStatus; - } - - private OperationStatus addExtendedStatus(OperationStatus returnStatus, IStatus aStatus) { - OperationStatus innerReturnStatus = returnStatus; - if (innerReturnStatus == null) { - innerReturnStatus = new OperationStatus(new IStatus[]{WTPCommonPlugin.OK_STATUS}); - } - innerReturnStatus.addExtendedStatus(aStatus); - return innerReturnStatus; - } - - private OperationStatus runOperation(final IDataModelOperation operation, final IProgressMonitor monitor, final IAdaptable info, final int executionType, OperationStatus returnStatus) { - OperationStatus innerReturnStatus = returnStatus; - if (rootOperation == operation) { - IStatus status = runOperation(operation, monitor, info, IDataModelPausibleOperationEvent.EXECUTE); - if (!status.isOK()) { - innerReturnStatus = addStatus(innerReturnStatus, status); - } - } else { - try { - IStatus status = runOperation(operation, monitor, info, IDataModelPausibleOperationEvent.EXECUTE); - if (!status.isOK()) { - innerReturnStatus = addExtendedStatus(innerReturnStatus, status); - } - } catch (Exception e) { - IStatus status = new Status(IStatus.ERROR, WTPCommonPlugin.PLUGIN_ID, 0, WTPResourceHandler.getString("25", new Object[]{operation.getClass().getName()}), e); //$NON-NLS-1$ - innerReturnStatus = addExtendedStatus(innerReturnStatus, status); - } - } - return innerReturnStatus; - } - - private IStatus runOperation(final IDataModelOperation operation, final IProgressMonitor monitor, final IAdaptable info, final int executionType) { - IWorkspaceRunnableWithStatus workspaceRunnable = new IWorkspaceRunnableWithStatus(info) { - @Override - public void run(IProgressMonitor pm) throws CoreException { - try { - switch (executionType) { - case IDataModelPausibleOperationEvent.EXECUTE : - this.setStatus(operation.execute(pm, info)); - break; - case IDataModelPausibleOperationEvent.UNDO : - this.setStatus(operation.undo(pm, info)); - break; - case IDataModelPausibleOperationEvent.REDO : - this.setStatus(operation.redo(pm, info)); - break; - } - if (null == this.getStatus()) { - this.setStatus(Status.OK_STATUS); - } - } catch (Exception e) { - this.setStatus(new Status(IStatus.ERROR, WTPCommonPlugin.PLUGIN_ID, 0, WTPResourceHandler.getString("25", new Object[]{operation.getClass().getName()}), e)); //$NON-NLS-1$ - WTPCommonPlugin.logError(e); - } - } - }; - - ISchedulingRule rule = operation.getSchedulingRule(); - if (null == rule) { - rule = ResourcesPlugin.getWorkspace().getRoot(); - } - - try { - ResourcesPlugin.getWorkspace().run(workspaceRunnable, rule, operation.getOperationExecutionFlags(), monitor); - } catch (CoreException e) { - workspaceRunnable.setStatus(new Status(IStatus.ERROR, WTPCommonPlugin.PLUGIN_ID, 0, WTPResourceHandler.getString("25", new Object[]{operation.getClass().getName()}), e)); //$NON-NLS-1$ - } - return workspaceRunnable.getStatus(); - } - - protected class OperationStackEntry { - - private IDataModelOperation operation; - private IDataModelOperation operationForExecution; - - private boolean extendedOpsInitialized = false; - - private ComposedExtendedOperationHolder extOpHolder = null; - - private int preOpIndex = 0; - private int postOpIndex = 0; - - private OperationStackEntry[] preOpStackEntries = null; - private OperationStackEntry[] postOpStackEntries = null; - - public OperationStackEntry parent = null; - - public OperationStackEntry(OperationStackEntry parent, IDataModelOperation operation) { - this.parent = parent; - this.operation = operation; - this.operationForExecution = operation; - } - - public OperationStackEntry rollBackOneOperation() { - postOpIndex = 0; - operationForExecution = operation; - if (preOpIndex == 0 && parent != null) { - return parent.rollBackExtended(this); - } - return this; - } - - private OperationStackEntry rollBackExtended(OperationStackEntry extendedEntry) { - while (postOpIndex > 0) { - int index = --postOpIndex; - if (postOpStackEntries[index] == extendedEntry) { - postOpStackEntries[index] = null; - return this; - } - } - while (preOpIndex > 0) { - int index = --preOpIndex; - if (preOpStackEntries[index] == extendedEntry) { - preOpStackEntries[index] = null; - if (index != 0) { - return this; - } - } - } - if (null != parent) { - return parent.rollBackExtended(this); - } - return this; - } - - public OperationStackEntry getNextPreOperation() { - if (!extendedOpsInitialized) { - initExtendedOps(); - } - if (extOpHolder == null) { - return null; - } - List ops = extOpHolder.getPreOps(); - if (ops == null || ops.size() <= preOpIndex) { - return null; - } - - while (preOpIndex < ops.size()) { - int index = preOpIndex++; - IDataModelOperation op = (IDataModelOperation) ops.get(index); - if (shouldExecuteExtended(op.getID())) { - op.setDataModel(getDataModel()); - op.setEnvironment(getEnvironment()); - preOpStackEntries[index] = new OperationStackEntry(this, op); - return preOpStackEntries[index]; - } - } - return null; - } - - @Override - public String toString() { - return getOperationID(); - } - - public String getOperationID() { - return operation.getID(); - } - - public IDataModelOperation getOperation() { - return operation; - } - - public boolean executed() { - return null != operationForExecution; - } - - /** - * The root operation is only returned once; this way it is known whether it has been - * executed yet or not. - * - * @return - */ - public IDataModelOperation getOperationForExecution() { - try { - return operationForExecution; - } finally { - operationForExecution = null; - } - } - - public OperationStackEntry getNextPostOperation() { - if (!extendedOpsInitialized) { - initExtendedOps(); - } - if (extOpHolder == null) { - return null; - } - List ops = extOpHolder.getPostOps(); - if (ops == null || ops.size() <= postOpIndex) { - return null; - } - - while (postOpIndex < ops.size()) { - int index = postOpIndex++; - IDataModelOperation op = (IDataModelOperation) ops.get(index); - if (shouldExecuteExtended(op.getID())) { - op.setDataModel(getDataModel()); - op.setEnvironment(getEnvironment()); - postOpStackEntries[index] = new OperationStackEntry(this, op); - return postOpStackEntries[index]; - } - } - return null; - - } - - private void initExtendedOps() { - if (shouldExecuteExtended(operation.getID())) { - extOpHolder = ComposedExtendedOperationHolder.createExtendedOperationHolder(operation.getID()); - if (null != extOpHolder) { - if (extOpHolder.hasPreOps()) { - preOpStackEntries = new OperationStackEntry[extOpHolder.getPreOps().size()]; - } - if (extOpHolder.hasPostOps()) { - postOpStackEntries = new OperationStackEntry[extOpHolder.getPostOps().size()]; - } - } - } - extendedOpsInitialized = true; - } - } - - protected boolean shouldExecuteExtended(String operationID) { - // Check the top most level operation first - DataModelPausibleOperationImpl threadRootOperation = (DataModelPausibleOperationImpl) threadToExtendedOpControl.get(Thread.currentThread()); - if (threadRootOperation != this && threadRootOperation.getDataModel() != getDataModel() && !threadRootOperation.shouldExecuteExtended(operationID)) { - return false; - } - // No extended operations are being executed - boolean allowExtensions = getDataModel().getBooleanProperty(IDataModelProperties.ALLOW_EXTENSIONS); - if (!allowExtensions) { - return false; - } - // This specific operation should not be executed - List restrictedExtensions = (List) getDataModel().getProperty(IDataModelProperties.RESTRICT_EXTENSIONS); - if (restrictedExtensions.contains(operationID)) { - return false; - } - // This specific function group should not be executed - List extendedContext = getDataModel().getExtendedContext(); - for (int contextCount = 0; contextCount < extendedContext.size(); contextCount++) { - IProject project = (IProject) AdaptabilityUtility.getAdapter(extendedContext.get(contextCount), IProject.class); - if (null != project && !IEnablementManager.INSTANCE.getIdentifier(operationID, project).isEnabled()) { - return false; - } - } - return true; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperation.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperation.java deleted file mode 100644 index e5d94a744..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperation.java +++ /dev/null @@ -1,318 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -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.wst.common.frameworks.datamodel.IDataModelOperation; - -/** - * <p> - * IDataModelManagerOperation is an IDataModelOperation returned from - * {@linkorg.eclipse.wst.common.frameworks.datamodel.IDataModel#getDefaultOperation()}. This Operation wraps the IDataModelOperation returned - * from the IDatModelProvider backing the IDataModel that created it. - * </p> - * <p> - * This operation supports pre and post operation execution. Pre and post operations are - * IDataModelOperations registered through the OperationExtension extension point which are executed - * before and after the primary operation. - * </p> - * <p> - * <b>Example 1</b> <br> - * Suppose an IDataModelProvider returns IDataModelOperation X as its default operation, and this - * IDataModelManagerOperation is wrapping X. Also suppose operation A is registered as a pre - * operation to X and operation B is registered as a post operation to X. When this - * IDataModelManagerOperation is executed the following operations will be executed in this order: - * A, X, B which may be thought as a preorder execution of the following tree: - * </p> - * - * <pre> - * X - * / \ - * A B - * - * execution = A.execute(), X.execute(), B.execute() - * undo = B.undo(), X.undo(), A.undo() - * redo = A.redo(), X.redo(), B.redo() - * </pre> - * - * <p> - * <b>Example 2</b> <br> - * If A had a pre operation C and post operation D, and B had a pre operation E and post operation F - * then the tree would look like: - * </p> - * - * <pre> - * X - * / \ - * / \ - * A B - * / \ / \ - * C D E F - * - * execution = C.execute(), A.execute(), D.execute(), X.execute(), E.execute(), B.execute(), F.execute() - * undo = F.undo(), B.undo(), E.undo(), X.undo(), D.undo(), A.undo(), C.undo() - * redo = C.redo(), A.redo(), D.redo(), X.redo(), E.redo(), B.redo(), F.redo() - * </pre> - * - * </p> - * <b>Example 3</b> <br> - * If there is more than one pre operation or post operation for a particular operation, then there - * is no defined ordering of those pre and post operation with respect to each other, other than - * that it will be consistent. For example suppose operation X had only two pre operations, A and B, - * and two post operations, C and D. The execution tree would be one of the following: - * </p> - * - * <pre> - * X X X X - * / \ / \ / \ / \ - * AB CD BA CD AB DC BA DC - * - * exec = ABXCD exec = BAXCD exec = ABXDC exec = BAXDC - * undo = DCXBA undo = DCXAB undo = CDXBA undo = CDXAB - * redo = ABXCD redo = BAXCD redo = ABXDC redo = BAXDC - * </pre> - * - * <p> - * During execution, rollback, undo, and redo, {@link IDataModelPausibleOperationEvent}s are fired to all - * registered {@link IDataModelPausibleOperationListener}s giving each of them an opportunity to pause the - * operation by returning {@link IDataModelPausibleOperationListener#PAUSE}. - * {@link IDataModelPausibleOperationEvent} has more details on when these events are fired. - * </p> - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @seeorg.eclipse.wst.common.frameworks.datamodel.IDataModel#getDefaultOperation() - * - * @since 1.5 - */ -public interface IDataModelPausibleOperation extends IDataModelOperation { - - /** - * <p> - * The exeuction state when the operation never been executed. When the operation is in this - * state it may only be executed. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(IProgressMonitor, IAdaptable) - */ - public static final int NOT_STARTED = 0; - /** - * <p> - * The exeuction state while the operation is executing. When the operation is in this state it - * may only be paused by an {@link IDataModelPausibleOperationListener}. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(IProgressMonitor, IAdaptable) - * @see IDataModelPausibleOperationListener - */ - public static final int RUNNING_EXECUTE = 1; - /** - * <p> - * The exeuction state while the operation is rolling back. When the operation is in this state - * it may only be paused by an {@link IDataModelPausibleOperationListener}. - * </p> - * - * @see #rollBack(IProgressMonitor, IAdaptable) - * @see IDataModelPausibleOperationListener - */ - public static final int RUNNING_ROLLBACK = 2; - /** - * <p> - * The exeuction state while the operation is redoing. When the operation is in this state it - * may only be paused by an {@link IDataModelPausibleOperationListener}. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(IProgressMonitor, IAdaptable) - * @see IDataModelPausibleOperationListener - */ - public static final int RUNNING_UNDO = 3; - /** - * <p> - * The exeuction state while the operaiton is redoing. When the operation is in this state it - * may only be paused by an {@link IDataModelPausibleOperationListener}. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(IProgressMonitor, IAdaptable) - * @see IDataModelPausibleOperationListener - */ - public static final int RUNNING_REDO = 4; - /** - * <p> - * The exeuction state when the operation has been paused while it was executing. When the - * operation is in this state it may either be resumed to continue execution or rolled back to - * undo the partial execution. - * </p> - * - * @see #resume(IProgressMonitor, IAdaptable) - * @see #rollBack(IProgressMonitor, IAdaptable) - */ - public static final int PAUSED_EXECUTE = 5; - /** - * <p> - * The exeuction state when the operation has been paused while it was rolling back. When the - * operation is in this state it may either be resumed to continue rolling back or executed - * which continue the foward execution from the point where the rollback was paused - * </p> - * - * @see #resume(IProgressMonitor, IAdaptable) - * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(IProgressMonitor, IAdaptable) - */ - public static final int PAUSED_ROLLBACK = 6; - /** - * <p> - * The exeuction state when the operation has been paused while it was undoing. When the - * operation is in this state it may be only be resumed to continue undoing. - * </p> - * - * @see #resume(IProgressMonitor, IAdaptable) - */ - public static final int PAUSED_UNDO = 7; - /** - * <p> - * The exeuction state when the operation has been paused while it was redoing. When the - * operation is in this state it may only be resumed to continue redoing. - * </p> - * - * @see #resume(IProgressMonitor, IAdaptable) - */ - public static final int PAUSED_REDO = 8; - /** - * <p> - * The exeuction state when the operation finished execution. When the operation is in this - * state it may only be undone. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(IProgressMonitor, IAdaptable) - */ - public static final int COMPLETE_EXECUTE = 9; - /** - * <p> - * The exeuction state when the operation finished rolling back. When the operation is in this - * state it may only be executed. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(IProgressMonitor, IAdaptable) - */ - public static final int COMPLETE_ROLLBACK = 10; - /** - * <p> - * The exeuction state when the operation finished undoing. When the operation is in this state - * it may only be redone. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(IProgressMonitor, IAdaptable) - */ - public static final int COMPLETE_UNDO = 11; - /** - * <p> - * The exeuction state when the operation finished redoing. When the operation is in this state - * it may only be udone. - * </p> - * - * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(IProgressMonitor, IAdaptable) - */ - public static final int COMPLETE_REDO = 12; - - - /** - * <p> - * Returns the current execution state of the operation. Returns one of: - * <ul> - * <li>{@link #NOT_STARTED}</li> - * <li>{@link #RUNNING_EXECUTE}</li> - * <li>{@link #RUNNING_ROLLBACK}</li> - * <li>{@link #RUNNING_UNDO}</li> - * <li>{@link #RUNNING_REDO}</li> - * <li>{@link #PAUSED_EXECUTE}</li> - * <li>{@link #PAUSED_ROLLBACK}</li> - * <li>{@link #PAUSED_UNDO}</li> - * <li>{@link #PAUSED_REDO}</li> - * <li>{@link #COMPLETE_EXECUTE}</li> - * <li>{@link #COMPLETE_ROLLBACK}</li> - * <li>{@link #COMPLETE_UNDO}</li> - * <li>{@link #COMPLETE_REDO}</li> - * </ul> - * <p> - * - * @return The current execution state. - */ - public int getExecutionState(); - - /** - * <p> - * Resumes execution if the operation is curently paused. An operation is paused if - * {@link #getExecutionState()} returns any of {@link #PAUSED_EXECUTE}, - * {@link #PAUSED_ROLLBACK}, {@link #PAUSED_UNDO}, or {@link #PAUSED_REDO}. - * </p> - * - * @param monitor - * the progress monitor (or <code>null</code>) to use for reporting progress to - * the user. - * @param info - * the IAdaptable (or <code>null</code>) provided by the caller in order to supply - * UI information for prompting the user if necessary. When this parameter is not - * <code>null</code>, it should minimally contain an adapter for the - * org.eclipse.swt.widgets.Shell.class. - * - * @return the IStatus of the resume. The status severity should be set to <code>OK</code> if - * the operation was successful, and <code>ERROR</code> if it was not. Any other - * status is assumed to represent an incompletion of the resume. - */ - public IStatus resume(IProgressMonitor monitor, IAdaptable info) throws ExecutionException; - - /** - * <p> - * Rolls back the partial execution if the operation is currently in - * {@link #getExecutionState()} returns eiter {@link #PAUSED_EXECUTE} or - * {@link #PAUSED_ROLLBACK}. - * </p> - * - * @param monitor - * the progress monitor (or <code>null</code>) to use for reporting progress to - * the user. - * @param info - * the IAdaptable (or <code>null</code>) provided by the caller in order to supply - * UI information for prompting the user if necessary. When this parameter is not - * <code>null</code>, it should minimally contain an adapter for the - * org.eclipse.swt.widgets.Shell.class. - * - * @return the IStatus of the resume. The status severity should be set to <code>OK</code> if - * the operation was successful, and <code>ERROR</code> if it was not. Any other - * status is assumed to represent an incompletion of the resume. - * - */ - public IStatus rollBack(IProgressMonitor monitor, IAdaptable info) throws ExecutionException; - - /** - * <p> - * Adds an operation listener to listen for operation events. - * </p> - * - * @param operationListener - * the IOperationListener to add. - */ - public void addOperationListener(IDataModelPausibleOperationListener operationListener); - - /** - * <p> - * Removes the specified IOperationLinstener. - * <p> - * - * @param operationListener - * The IOperatoinListener to remove. - */ - public void removeOperationListener(IDataModelPausibleOperationListener operationListener); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperationEvent.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperationEvent.java deleted file mode 100644 index 8b678080b..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperationEvent.java +++ /dev/null @@ -1,253 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -/** - * <p> - * These events are fired to {@link IDataModelPausibleOperationListener}s from {@link IDataModelPausibleOperation}s during execution, rollback, undo, - * and redo. - * </p> - * - * <p> - * <b>Example 2</b> from {@link IDataModelPausibleOperation}<br> - * <pre> - * X - * / \ - * / \ - * A B - * / \ / \ - * C D E F - * </pre> - * In the example above, the events will be fired in the following order during an execution: - * <table border=1> - * <tr><th>operation</th><th>operation type</th><th>execution type</th></tr> - * <tr><td>X</td><td>NODE_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>A</td><td>NODE_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>C</td><td>NODE_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>C</td><td>MAIN_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>C</td><td>MAIN_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>C</td><td>NODE_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>A</td><td>MAIN_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>A</td><td>MAIN_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>D</td><td>NODE_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>D</td><td>MAIN_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>D</td><td>MAIN_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>D</td><td>NODE_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>A</td><td>NODE_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>X</td><td>MAIN_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>X</td><td>MAIN_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>B</td><td>NODE_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>E</td><td>NODE_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>E</td><td>MAIN_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>E</td><td>MAIN_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>E</td><td>NODE_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>B</td><td>MAIN_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>B</td><td>MAIN_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>F</td><td>NODE_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>F</td><td>MAIN_STARTING</td><td>EXECUTE</td></tr> - * <tr><td>F</td><td>MAIN_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>F</td><td>NODE_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>B</td><td>NODE_FINISHED</td><td>EXECUTE</td></tr> - * <tr><td>X</td><td>NODE_FINISHED</td><td>EXECUTE</td></tr> - * </table> - * </p> - * <p> - * <b>Example 2</b> from {@link IDataModelPausibleOperation}<br> - * <pre> - * X - * / \ - * / \ - * A B - * / \ / \ - * C D E F - * </pre> - * In the example above, the events will be fired in the following order during a rollback: - * <table border=1> - * <tr><th>operation</th><th>operation type</th><th>execution type</th></tr> - * <tr><td>F</td><td>MAIN_STARTING</td><td>ROLLBACK</td></tr> - * <tr><td>F</td><td>MAIN_FINISHED</td><td>ROLLBACK</td></tr> - * <tr><td>B</td><td>MAIN_STARTING</td><td>ROLLBACK</td></tr> - * <tr><td>B</td><td>MAIN_FINISHED</td><td>ROLLBACK</td></tr> - * <tr><td>E</td><td>MAIN_STARTING</td><td>ROLLBACK</td></tr> - * <tr><td>E</td><td>MAIN_FINISHED</td><td>ROLLBACK</td></tr> - * <tr><td>X</td><td>MAIN_STARTING</td><td>ROLLBACK</td></tr> - * <tr><td>X</td><td>MAIN_FINISHED</td><td>ROLLBACK</td></tr> - * <tr><td>D</td><td>MAIN_STARTING</td><td>ROLLBACK</td></tr> - * <tr><td>D</td><td>MAIN_FINISHED</td><td>ROLLBACK</td></tr> - * <tr><td>A</td><td>MAIN_STARTING</td><td>ROLLBACK</td></tr> - * <tr><td>A</td><td>MAIN_FINISHED</td><td>ROLLBACK</td></tr> - * <tr><td>C</td><td>MAIN_STARTING</td><td>ROLLBACK</td></tr> - * <tr><td>C</td><td>MAIN_FINISHED</td><td>ROLLBACK</td></tr> - * </table> - * </p> - * <p> - * <b>Example 2</b> from {@link IDataModelPausibleOperation}<br> - * <pre> - * X - * / \ - * / \ - * A B - * / \ / \ - * C D E F - * </pre> - * In the example above, the events will be fired in the following order during an undo: - * <table border=1> - * <tr><th>operation</th><th>operation type</th><th>execution type</th></tr> - * <tr><td>F</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>F</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>B</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>B</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>E</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>E</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>X</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>X</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>D</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>D</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>A</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>A</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>C</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>C</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * </table> - * </p> - * <p> - * <b>Example 2</b> from {@link IDataModelPausibleOperation}<br> - * <pre> - * X - * / \ - * / \ - * A B - * / \ / \ - * C D E F - * </pre> - * In the example above, the events will be fired in the following order during a redo: - * <table border=1> - * <tr><th>operation</th><th>operation type</th><th>execution type</th></tr> - * <tr><td>C</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>C</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>A</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>A</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>D</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>D</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>X</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>X</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>E</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>E</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>B</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>B</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * <tr><td>F</td><td>MAIN_STARTING</td><td>UNDO</td></tr> - * <tr><td>F</td><td>MAIN_FINISHED</td><td>UNDO</td></tr> - * </table> - * </p> - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @since 1.5 - */ -public interface IDataModelPausibleOperationEvent { - - /** - * <p> - * The operation type set when an operation execution traversal is about to start within the - * tree of operations handled by the owning {@link IDataModelPausibleOperation}. This operation - * type is only set when the execution type is set to {@link #EXECUTE}. Using the example - * above, events with this operation type will be fired according to an in order traversal of - * the tree; i.e. XACDBEF - * </p> - */ - public static final int NODE_STARTING = 1; - /** - * <p> - * The operation type set when an operation execution traversal finishes within the tree of - * operations handled by the owning {@link IDataModelPausibleOperation}. This operation type is - * only set when the execution type is set to {@link #EXECUTE}. Using the example above, events - * with this operation type will be fired according to a post order traversal of the tree; i.e. - * CDAEFBX - * </p> - */ - public static final int NODE_FINISHED = 2; - /** - * <p> - * The operation type set right before an operation is going to do its work. This operation type - * may be used with all exection types. Using the example above, events with this operiton type - * will be fired according to the following tree traversal: CADXBEF - * <p> - */ - public static final int MAIN_STARTING = 3; - /** - * <p> - * The operation type set immediatly after an operation finshed doing its work. This operation - * type may be used with all exection types. Using the example above, events with this operiton - * type will be fired according to the following tree traversal: CADXBEF - * <p> - */ - public static final int MAIN_FINISHED = 4; - - /** - * <p> - * The execution type set when during execution. - * </p> - */ - public static final int EXECUTE = 0; - /** - * <p> - * The execution type set when during rollback. - * </p> - */ - public static final int ROLLBACK = 1; - /** - * <p> - * The execution type set when during undo. - * </p> - */ - public static final int UNDO = 2; - /** - * <p> - * The execution type set when during redo. - * </p> - */ - public static final int REDO = 3; - - /** - * <p> - * Returns the operation in question. This operation will be one of the operations within the - * tree of operations handled by the owning {@link IDataModelPausibleOperation}. - * </p> - * - * @return the operation. - */ - public IDataModelOperation getOperation(); - - /** - * <p> - * Returns the type of operation with respect to the {@link IDataModelPausibleOperation} - * executing it. This will be one of {@link #NODE_STARTING}, {@link #NODE_FINISHED}, - * {@link #MAIN_STARTING}, or {@link #MAIN_FINISHED}. - * </p> - * - * @return one of {@link #NODE_STARTING}, {@link #NODE_FINISHED}, {@link #MAIN_STARTING}, or - * {@link #MAIN_FINISHED}. - */ - public int getOperationType(); - - /** - * <p> - * Returns the type of execution the operation is about to begin. This will be one of - * {@link #EXECUTE}, {@link #ROLLBACK}, {@link #UNDO}, or {@link #REDO}. - * </p> - * - * @return one of {@link #EXECUTE}, {@link #ROLLBACK}, {@link #UNDO}, or {@link #REDO}. - */ - public int getExecutionType(); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperationListener.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperationListener.java deleted file mode 100644 index 865f4723f..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IDataModelPausibleOperationListener.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -/** - * <p> - * Used to listen for {@link IDataModelPausibleOperationEvent}s fired from {@link IDataModelPausibleOperation}s. - * </p> - * - * @since 1.5 - */ -public interface IDataModelPausibleOperationListener { - - /** - * <p> - * Clients should return this constant from {@link #notify(IDataModelPausibleOperationEvent)} to specify that - * execution should continue. - * </p> - */ - public static final int CONTINUE = 0; - - /** - * <p> - * Clients should return this constant from {@link #notify(IDataModelPausibleOperationEvent)} to specify that - * execution should pause. - * </p> - */ - public static final int PAUSE = 1; - - - /** - * <p> - * Listener interface by {@link IDataModelPausibleOperation} for operation execution - * notification. Prior to starting any operation's execution, notifications will be sent which - * allow clients to pause an operation's execution. Implementers should return {@link #CONTINUE} - * to allow the operation's execution to continue or {@link #PAUSE} to pause execution. If - * {@link #PAUSE} is returned, then the entire operation stack will be paused until it is - * resumed. The responsiblity for resuming a paused operation lies on the client that paused it. - * </p> - * - * @param event - * The operation event - * - * @return return CONTINUE to continue, or PAUSE to pause. - * - * @see IDataModelPausibleOperation#addOperationListener(IDataModelPausibleOperationListener) - * @see IDataModelPausibleOperation#resume(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.core.runtime.IAdaptable) - */ - public int notify(IDataModelPausibleOperationEvent event); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IWorkspaceRunnableWithStatus.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IWorkspaceRunnableWithStatus.java deleted file mode 100644 index 2214bd00a..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/IWorkspaceRunnableWithStatus.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; - -public class IWorkspaceRunnableWithStatus implements IWorkspaceRunnable { - private IAdaptable info; - private IStatus status; - -public IWorkspaceRunnableWithStatus(IAdaptable info) { - super(); - this.info = info; - } -public IAdaptable getInfo() { - // TODO Auto-generated method stub - return info; -} -public void setStatus(IStatus aStatus) { - status = aStatus; -} - -public void run(IProgressMonitor monitor) throws CoreException { - - } -public IStatus getStatus() { - return status; -} - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/WrappedOperation.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/WrappedOperation.java deleted file mode 100644 index 7e35853b9..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/WrappedOperation.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.datamodel; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.IUndoContext; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class WrappedOperation implements IDataModelOperation { - - protected IDataModelOperation rootOperation; - - public WrappedOperation(IDataModelOperation rootOperation) { - this.rootOperation = rootOperation; - if (null == rootOperation) { - throw new NullPointerException(); - } - } - - public boolean canExecute() { - return rootOperation.canExecute(); - } - - public boolean canRedo() { - return rootOperation.canRedo(); - } - - public boolean canUndo() { - return rootOperation.canUndo(); - } - - public void setID(String id) { - rootOperation.setID(id); - } - - public String getID() { - return rootOperation.getID(); - } - - public void setDataModel(IDataModel model) { - rootOperation.setDataModel(model); - } - - public IDataModel getDataModel() { - return rootOperation.getDataModel(); - } - - public void setEnvironment(IEnvironment environment) { - rootOperation.setEnvironment(environment); - } - - public IEnvironment getEnvironment() { - return rootOperation.getEnvironment(); - } - - public ISchedulingRule getSchedulingRule() { - return rootOperation.getSchedulingRule(); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return rootOperation.execute(monitor, info); - } - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return rootOperation.undo(monitor, info); - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return rootOperation.redo(monitor, info); - } - - public int getOperationExecutionFlags() { - return rootOperation.getOperationExecutionFlags(); - } - - public String getLabel() { - return rootOperation.getLabel(); - } - - public IUndoContext[] getContexts() { - return rootOperation.getContexts(); - } - - public boolean hasContext(IUndoContext context) { - return rootOperation.hasContext(context); - } - - public void addContext(IUndoContext context) { - rootOperation.addContext(context); - } - - public void removeContext(IUndoContext context) { - rootOperation.removeContext(context); - } - - public void dispose() { - rootOperation.dispose(); - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/AbstractIdentifiable.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/AbstractIdentifiable.java deleted file mode 100644 index f7d143ecd..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/AbstractIdentifiable.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - -public class AbstractIdentifiable implements Identifiable { - - protected String id; - - public AbstractIdentifiable(String id) { - this.id = id; - } - - public String getID() { - return id; - } - - public int getLoadOrder() { - return 0; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/AscendingGroupComparator.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/AscendingGroupComparator.java deleted file mode 100644 index 39afa0c2f..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/AscendingGroupComparator.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 2, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.Comparator; - -/** - * @author blancett - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class AscendingGroupComparator implements Comparator { - private static AscendingGroupComparator singleton; - - public int compare(Object o1, Object o2) { - if (o2 == null && o1 != null) - return -1; - if (o1 == null && o2 != null) - return 1; - if (o1 == null && o2 == null) - return 0; - - FunctionGroup group1 = (FunctionGroup) o1; - FunctionGroup group2 = (FunctionGroup) o2; - - if (group1.getPriority() > group2.getPriority()) - return 1; - if (group1.getPriority() == group2.getPriority()) - return 0; - if (group1.getPriority() < group2.getPriority()) - return -1; - return 0; - } - - public static Comparator singleton() { - if (singleton == null) - singleton = new AscendingGroupComparator(); - return singleton; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/DataModelEnablementFactory.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/DataModelEnablementFactory.java deleted file mode 100644 index 9de12539a..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/DataModelEnablementFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class DataModelEnablementFactory { - /** - * Looks up the appropriate IDataModelProvider by the specified providerKind String and a - * context of the containing Project. The method gets an array of DataModelProviderDescriptor - * from the base DataModelFactory then filters out Providers based on function group enablement. - * Finally the Provider with the highest priority is returned. If the IDataModelProvider is not - * found then a RuntimeException is logged and null is returned. - * - * @param providerKind - * the String id of the provider kind - * @param curProject - * the containing IProject - * - * @return a new IDataModel - */ - public static IDataModel createDataModel(String providerKind, IProject curProject) { - String[] providerIDs = DataModelFactory.getDataModelProviderIDsForKind(providerKind); - if (providerIDs == null || providerIDs.length == 0) - return null; - String topProvider = getHighestPriorityEnabledProviderDesc(providerIDs, curProject); - if (topProvider == null) - return null; - return DataModelFactory.createDataModel(topProvider); - } - - private static String getHighestPriorityEnabledProviderDesc(String[] providerIDs, IProject curProject) { - String defaultID = providerIDs[0]; - IEnablementIdentifier enablementIdentifier; - Identifiable tempIdentifiable; - Identifiable topPriorityIdentifiable = null; - - for (int i = 1; i < providerIDs.length; i++) { - tempIdentifiable = new AbstractIdentifiable(providerIDs[i]); - enablementIdentifier = EnablementManager.INSTANCE.getIdentifier(tempIdentifiable.getID(), curProject); - if (enablementIdentifier.isEnabled()) { - if (topPriorityIdentifiable == null) - topPriorityIdentifiable = tempIdentifiable; - else if (IdentifiableComparator.instance.compare(tempIdentifiable, topPriorityIdentifiable) == IdentifiableComparator.GREATER_THAN) - topPriorityIdentifiable = tempIdentifiable; - } - } - if (topPriorityIdentifiable == null) - return defaultID; - return topPriorityIdentifiable.getID(); - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/DescendingGroupComparator.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/DescendingGroupComparator.java deleted file mode 100644 index 07208566d..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/DescendingGroupComparator.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 2, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.Comparator; - -/** - * @author blancett - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class DescendingGroupComparator implements Comparator { - - private static DescendingGroupComparator singleton; - - public int compare(Object o1, Object o2) { - if (o1 == null && o2 != null) - return -1; - if (o2 == null && o1 != null) - return 1; - if (o1 == null && o2 == null) - return 0; - - FunctionGroup group1 = (FunctionGroup) o1; - FunctionGroup group2 = (FunctionGroup) o2; - - if (group1.getPriority() > group2.getPriority()) - return -1; - if (group1.getPriority() == group2.getPriority()) - return 0; - if (group1.getPriority() < group2.getPriority()) - return 1; - return 0; - - } - - public static Comparator singleton() { - if (singleton == null) - singleton = new DescendingGroupComparator(); - return singleton; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifier.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifier.java deleted file mode 100644 index 7147a3ee6..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifier.java +++ /dev/null @@ -1,236 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 10, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -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; - - -/** - * @author schacher - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class EnablementIdentifier implements IEnablementIdentifier { - - private final static int HASH_FACTOR = 89; - - private final static int HASH_INITIAL = EnablementIdentifier.class.getName().hashCode(); - - private final static Set strongReferences = new HashSet(); - - private Set functionGroupIds; - - private transient String[] functionGroupIdsAsArray; - - private boolean enabled; - - private transient int hashCode; - - private transient boolean hashCodeComputed; - - private String id; - - private List identifierListeners; - - private transient String string; - - private IProject project; - - protected EnablementIdentifier(String id) { - this(id, null); - } - - protected EnablementIdentifier(String id, IProject project) { - if (id == null) - throw new NullPointerException(); - this.id = id; - this.project = project; - } - - public void addIdentifierListener(IEnablementIdentifierListener identifierListener) { - if (identifierListener == null) - throw new NullPointerException(); - - if (identifierListeners == null) - identifierListeners = new ArrayList(); - - if (!identifierListeners.contains(identifierListener)) - identifierListeners.add(identifierListener); - - strongReferences.add(this); - } - - public int compareTo(Object object) { - EnablementIdentifier castedObject = (EnablementIdentifier) object; - return Util.compare(id, castedObject.id); - - } - - @Override - public boolean equals(Object object) { - if (!(object instanceof EnablementIdentifier)) - return false; - - EnablementIdentifier castedObject = (EnablementIdentifier) object; - boolean equals = Util.equals(id, castedObject.id); - return equals; - } - - protected void fireIdentifierChanged(EnablementIdentifierEvent functionIdentifierEvent) { - if (functionIdentifierEvent == null) - throw new NullPointerException(); - - if (identifierListeners != null) { - synchronized (identifierListeners) { - for (int i = 0; i < identifierListeners.size(); i++) - ((IEnablementIdentifierListener) identifierListeners.get(i)).identifierChanged(functionIdentifierEvent); - } - } - } - - public Set getFunctionGroupIds() { - return functionGroupIds; - } - - public String getId() { - return id; - } - - @Override - public int hashCode() { - if (!hashCodeComputed) { - hashCode = HASH_INITIAL; - hashCode = hashCode * HASH_FACTOR + Util.hashCode(id); - hashCodeComputed = true; - } - - return hashCode; - } - - public boolean isEnabled() { - return enabled; - } - - public void removeIdentifierListener(IEnablementIdentifierListener identifierListener) { - if (identifierListener == null) - throw new NullPointerException(); - - if (identifierListeners != null) - identifierListeners.remove(identifierListener); - - if (identifierListeners.isEmpty()) - strongReferences.remove(this); - } - - protected boolean setFunctionGroupIds(Set functionGroupIds) { - Set safeFunctionGroupIds = Util.safeCopy(functionGroupIds, String.class); - - if (!Util.equals(safeFunctionGroupIds, this.functionGroupIds)) { - this.functionGroupIds = safeFunctionGroupIds; - this.functionGroupIdsAsArray = (String[]) this.functionGroupIds.toArray(new String[this.functionGroupIds.size()]); - - hashCodeComputed = false; - hashCode = 0; - string = null; - return true; - } - - return false; - } - - protected boolean setEnabled(boolean enabled) { - if (enabled != this.enabled) { - this.enabled = enabled; - hashCodeComputed = false; - hashCode = 0; - string = null; - return true; - } - - return false; - } - - /** - * Recompute the enabled state and return whether the state changed - */ - protected boolean resetEnabled() { - return setEnabled(getNewEnabled()); - } - - protected boolean getNewEnabled() { - if (project == null) - return true; - if (functionGroupIdsAsArray.length == 0) - return true; - for (int i = 0; i < functionGroupIdsAsArray.length; i++) { - FunctionGroup group = FunctionGroupRegistry.getInstance().getGroupByID(functionGroupIdsAsArray[i]); - if (group != null && group.isEnabled(project)) - return true; - } - return false; - } - - @Override - public String toString() { - if (string == null) { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append('['); - stringBuffer.append(functionGroupIds); - stringBuffer.append(','); - stringBuffer.append(enabled); - stringBuffer.append(','); - stringBuffer.append(id); - stringBuffer.append(']'); - string = stringBuffer.toString(); - } - - return string; - } - - /** - * The associated Project may be null - * - * @return Returns the project. - */ - public IProject getProject() { - return project; - } - - public String getPrimaryFunctionGroupId() { - int selectedPriority = Integer.MAX_VALUE; - int priority = 0; - String selectedFunctionGroupId = null; - String functionGroupId = null; - for (Iterator iterator = getFunctionGroupIds().iterator(); iterator.hasNext();) { - functionGroupId = iterator.next().toString(); - priority = FunctionGroupRegistry.getInstance().getGroupPriority(functionGroupId); - if (priority < selectedPriority) - selectedFunctionGroupId = functionGroupId; - if (priority == 0) - return selectedFunctionGroupId; - } - return selectedFunctionGroupId; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifierEvent.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifierEvent.java deleted file mode 100644 index 5e077b78e..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementIdentifierEvent.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 10, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - - - -/** - * @author schacher - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class EnablementIdentifierEvent { - - private boolean functionGroupIdsChanged; - private boolean enabledChanged; - private IEnablementIdentifier identifier; - - public EnablementIdentifierEvent(IEnablementIdentifier identifier, boolean functionGroupIdsChanged, boolean enabledChanged) { - if (identifier == null) - throw new NullPointerException(); - - this.identifier = identifier; - this.functionGroupIdsChanged = functionGroupIdsChanged; - this.enabledChanged = enabledChanged; - } - - /** - * Returns the instance of the interface that changed. - * - * @return the instance of the interface that changed. Guaranteed not to be <code>null</code>. - */ - public IEnablementIdentifier getIdentifier() { - return identifier; - } - - /** - * Returns whether or not the functionGroupIds property changed. - * - * @return true, iff the functionGroupIds property changed. - */ - public boolean hasFunctionGroupIdsChanged() { - return functionGroupIdsChanged; - } - - /** - * Returns whether or not the enabled property changed. - * - * @return true, iff the enabled property changed. - */ - public boolean hasEnabledChanged() { - return enabledChanged; - } - - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "EnablementIdentifierEvent [identifier=" + identifier.toString() + ", functionGroupIdsChanged=" + hasFunctionGroupIdsChanged() + ", enabledChanged=" + hasEnabledChanged() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementManager.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementManager.java deleted file mode 100644 index 5a21de801..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/EnablementManager.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 3, 2004 - * - * To change the template for this generated file go to Window - Preferences - - * Java - Code Generation - Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.WeakHashMap; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * @author mdelder - */ -public class EnablementManager implements IEnablementManager { - - public static final IEnablementManager INSTANCE = new EnablementManager(); - - private static Map identifiersByProject = new WeakHashMap(); - - public EnablementManager() { - } - - /** - * Returns a Map in which the keys are ids and the values are the identifiers - * - * @param project - * @return - */ - protected Map getIdentifiersById(IProject project) { - Map aMap = (Map) identifiersByProject.get(project); - if (aMap == null) { - aMap = new WeakHashMap(); - identifiersByProject.put(project, aMap); - } - return aMap; - } - - public IEnablementIdentifier getIdentifier(String identifierId, IProject project) { - if (identifierId == null){ - throw new NullPointerException(); - } - IProject innerProject = project; - if (innerProject != null && !innerProject.isAccessible()){ - innerProject = null; - } - - EnablementIdentifier identifier = null; - boolean identifierRequiresUpdate = false; - synchronized(this) { - Map identifiersById = getIdentifiersById(innerProject); - identifier = (EnablementIdentifier) identifiersById.get(identifierId); - if(identifier == null){ - identifierRequiresUpdate = true; - identifier = createIdentifier(identifierId, innerProject); - identifiersById.put(identifierId, identifier); - } - } - - synchronized (identifier){ - if(identifierRequiresUpdate){ - updateIdentifier(identifier); - } - return identifier; - } - } - - protected EnablementIdentifier createIdentifier(String identifierId, IProject project) { - return new EnablementIdentifier(identifierId, project); - } - - private EnablementIdentifierEvent updateIdentifier(EnablementIdentifier identifier) { - String id = identifier.getId(); - Set functionGroupIds = new HashSet(); - - List groups = FunctionGroupRegistry.getInstance().getKnownGroups(); - for (Iterator iterator = groups.iterator(); iterator.hasNext();) { - FunctionGroup group = (FunctionGroup) iterator.next(); - - if (group == null) - throw new IllegalStateException(); - if (group.isMatch(id)) - functionGroupIds.add(group.getGroupID()); - } - - boolean functionGroupsChanged = identifier.setFunctionGroupIds(functionGroupIds); - boolean enabledChanged = identifier.resetEnabled(); - - if (functionGroupsChanged || enabledChanged) - return new EnablementIdentifierEvent(identifier, functionGroupsChanged, enabledChanged); - return null; - } - - /** - * Notify all identifier listeners that the state of a project has changed that affects the - * enablement of a group for a project. This method is fail safe, in that if one listener throws - * an exception while being notified, it will not stop the notification of other listeners. - * - * @param evt - * @throws CoreException - * if exceptions were caught notifying any of the listeners. Check the status of the - * core exception for the nested exceptions. - */ - public final void notifyFunctionGroupChanged(String groupID, IProject project) throws CoreException { - - Map identifiers = getIdentifiersById(project); - - if (identifiers == null) - return; - - EnablementIdentifier identifier = null; - Iterator iter = identifiers.values().iterator(); - IStatus errorStatus = null; - IStatus nextStatus = null; - - while (iter.hasNext()) { - identifier = (EnablementIdentifier) iter.next(); - - EnablementIdentifierEvent evt = updateIdentifier(identifier); - try { - if (evt != null) - identifier.fireIdentifierChanged(evt); - } catch (Exception ex) { - //Defer the exception so others can handle it. - nextStatus = WTPCommonPlugin.createErrorStatus(WTPCommonMessages.INTERNAL_ERROR, ex); - WTPCommonPlugin.logError(ex); - if (errorStatus == null) - errorStatus = nextStatus; - else if (errorStatus.isMultiStatus()) - ((MultiStatus) errorStatus).add(nextStatus); - else { - IStatus[] children = {errorStatus, nextStatus}; - errorStatus = new MultiStatus(errorStatus.getPlugin(), errorStatus.getCode(), children, WTPCommonMessages.INTERNAL_ERROR, null); - } - } - - } - if (errorStatus != null) - throw new CoreException(errorStatus); - - } - - /** - * Utility method for clients to dispose of listeners - * - * @param enablementIdentifiers - * @param listener - */ - public void removeEnablementIdentifierListener(Collection enablementIdentifiers, IEnablementIdentifierListener listener) { - Iterator iter = enablementIdentifiers.iterator(); - while (iter.hasNext()) { - IEnablementIdentifier identifier = (IEnablementIdentifier) iter.next(); - identifier.removeIdentifierListener(listener); - } - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroup.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroup.java deleted file mode 100644 index c470bbcf4..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroup.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - - -/** - * @author mdelder/blancett - */ -public class FunctionGroup implements Comparable { - - public static final String GROUP_NAME_ATTR = "name"; //$NON-NLS-1$ - public static final String GROUP_DESC_ATTR = "description"; //$NON-NLS-1$ - public static final String GROUP_ENABLED_BY_DEFAULT_ATTR = "enabledByDefault"; //$NON-NLS-1$ - public static final String GROUP_PRIORITY_ATTR = "priority"; //$NON-NLS-1$ - public static final String GROUP_INTIALIZER_CLASS_ATTR = "initializerClassName"; //$NON-NLS-1$ - private static final int NEGATIVE_PRIORITY = -1; - - private String groupID; - private String name; - private String description; - private String intializerClassName; - private String declaringExtension; - private int priority = NEGATIVE_PRIORITY; - private IConfigurationElement element; - private IGroupInitializer groupInterface; - private Set functionGroupPatternBindings; -// private transient FunctionGroupPatternBinding[] functionGroupPatternBindingsAsArray; - private boolean errorReported = false; - - public FunctionGroup(String groupID, IConfigurationElement element) { - this.groupID = groupID; - this.element = element; - } - - public String getDescription() { - if (description == null) - description = element.getAttribute(GROUP_DESC_ATTR); - return description; - } - - String getInitalizerClassName() { - if (intializerClassName == null) - intializerClassName = element.getAttribute(GROUP_INTIALIZER_CLASS_ATTR); - return intializerClassName; - } - - public String getName() { - if (name == null) - name = element.getAttribute(GROUP_NAME_ATTR); - return name; - } - - private String getDeclaringExtensionName() { - if (declaringExtension == null) { - if (element.getDeclaringExtension() == null) - return ""; //$NON-NLS-1$ - declaringExtension = element.getDeclaringExtension().toString(); - } - return declaringExtension; - } - - public String getGroupID() { - return groupID; - } - - IGroupInitializer getInitializerClass() { - if (groupInterface == null) - try { - groupInterface = (IGroupInitializer) element.createExecutableExtension(GROUP_INTIALIZER_CLASS_ATTR); - } catch (CoreException e) { - WTPCommonPlugin.logError(WTPResourceHandler.getString("29", new Object[]{GROUP_INTIALIZER_CLASS_ATTR, getInitalizerClassName(), getDeclaringExtensionName()}) + "\r\n"); //$NON-NLS-1$//$NON-NLS-2$ - WTPCommonPlugin.logError(e); - } - return groupInterface; - } - - @Override - public String toString() { - return "\"" + getName() + "\" (" + getGroupID() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - public int getPriority() { - if (priority == NEGATIVE_PRIORITY) - priority = Integer.parseInt(element.getAttribute(GROUP_PRIORITY_ATTR)); - return priority; - } - - public boolean isEnabled(IProject project) { - if (getInitializerClass() != null) - return getInitializerClass().isGroupEnabled(project); - return false; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - public int compareTo(Object o) { - if (this.equals(o)) - return 0; - else if (!(o instanceof FunctionGroup)) - return 1; - - FunctionGroup group = (FunctionGroup) o; - if (getPriority() == group.getPriority()) - return getGroupID().compareTo(group.getGroupID()); - - else if (getPriority() < group.getPriority()) - return -1; - else - return 1; - } - - public boolean isMatch(String string) { - if (functionGroupPatternBindings == null) { - if (!errorReported) { - WTPCommonPlugin.logError(WTPResourceHandler.getString("30", new Object[]{getGroupID()})); //$NON-NLS-1$ - errorReported = true; - } - return false; - } - for (Iterator iterator = functionGroupPatternBindings.iterator(); iterator.hasNext();) { - FunctionGroupPatternBinding functionGroupPatternBinding = (FunctionGroupPatternBinding) iterator.next(); - - if (functionGroupPatternBinding.getPattern().matcher(string).matches()) - return true; - } - - return false; - } - - boolean setFunctionGroupPatternBindings(Set functionGroupPatternBindings) { - Set safeFunctionGroupPatternBindings = Util.safeCopy(functionGroupPatternBindings, FunctionGroupPatternBinding.class); - - if (!Util.equals(safeFunctionGroupPatternBindings, this.functionGroupPatternBindings)) { - this.functionGroupPatternBindings = safeFunctionGroupPatternBindings; - return true; - } - - return false; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupPatternBinding.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupPatternBinding.java deleted file mode 100644 index 464bcc5e9..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupPatternBinding.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 10, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.regex.Pattern; - - -/** - * @author schacher - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class FunctionGroupPatternBinding { - - private final static int HASH_FACTOR = 89; - private final static int HASH_INITIAL = FunctionGroupPatternBinding.class.getName().hashCode(); - private String functionGroupId; - private transient int hashCode; - private transient boolean hashCodeComputed; - private Pattern pattern; - private transient String string; - - /** - * - */ - public FunctionGroupPatternBinding(String functionGroupId, Pattern pattern) { - if (pattern == null) - throw new NullPointerException(); - - this.functionGroupId = functionGroupId; - this.pattern = pattern; - } - - public int compareTo(Object object) { - FunctionGroupPatternBinding castedObject = (FunctionGroupPatternBinding) object; - int compareTo = Util.compare(functionGroupId, castedObject.functionGroupId); - - if (compareTo == 0) - compareTo = Util.compare(pattern.pattern(), castedObject.pattern.pattern()); - - return compareTo; - } - - @Override - public boolean equals(Object object) { - if (!(object instanceof FunctionGroupPatternBinding)) - return false; - - FunctionGroupPatternBinding castedObject = (FunctionGroupPatternBinding) object; - boolean equals = true; - equals &= Util.equals(functionGroupId, castedObject.functionGroupId); - equals &= Util.equals(pattern, castedObject.pattern); - return equals; - } - - public String getActivityId() { - return functionGroupId; - } - - public Pattern getPattern() { - return pattern; - } - - @Override - public int hashCode() { - if (!hashCodeComputed) { - hashCode = HASH_INITIAL; - hashCode = hashCode * HASH_FACTOR + Util.hashCode(functionGroupId); - hashCode = hashCode * HASH_FACTOR + Util.hashCode(pattern); - hashCodeComputed = true; - } - - return hashCode; - } - - @Override - public String toString() { - if (string == null) { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append('[').append(functionGroupId).append(",pattern=\"").append(pattern.pattern()).append("\"]"); //$NON-NLS-1$ //$NON-NLS-2$ - string = stringBuffer.toString(); - } - - return string; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupRegistry.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupRegistry.java deleted file mode 100644 index ce55ca9a7..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/FunctionGroupRegistry.java +++ /dev/null @@ -1,254 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; -import java.util.regex.Pattern; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.common.core.util.RegistryReader; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * The FunctionGroupRegistry will consume Configuration elements conforming to the FunctionGroup - * Extension Point schema. - */ -public class FunctionGroupRegistry extends RegistryReader { - - private static FunctionGroupRegistry INSTANCE = null; - - public static final String GROUP_ELEMENT = "functionGroup"; //$NON-NLS-1$ - public static final String GROUP_ID_ATTR = "functionGroupID"; //$NON-NLS-1$ - public static final String FUNCTION_GROUP_PATTERN_BINDING_ELMT = "functionGroupPatternBinding"; //$NON-NLS-1$ - public static final String PATTERN_ATTR = "pattern"; //$NON-NLS-1$ - - private Map groupMapById; - private List knownGroups; - private Map patternBindingsByGroupId; - - private FunctionGroupRegistry() { - super(WTPCommonPlugin.PLUGIN_ID, WTPCommonPlugin.GROUP_REGISTRY_EXTENSION_POINT); - patternBindingsByGroupId = new HashMap(); - - } - - public static FunctionGroupRegistry getInstance() { - if (INSTANCE == null) { - INSTANCE = new FunctionGroupRegistry(); - INSTANCE.readRegistry(); - } - return INSTANCE; - } - - /* - * (non-Javadoc) Read all the elements first, then set the pattern bindings on the function - * groups - */ - @Override - public void readRegistry() { - super.readRegistry(); - setPatternBindings(); - } - - private void setPatternBindings() { - Iterator iter = patternBindingsByGroupId.entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Entry) iter.next(); - String groupId = (String) entry.getKey(); - Set value = (Set) entry.getValue(); - FunctionGroup aGroup = getGroupByID(groupId); - if (aGroup != null) - aGroup.setFunctionGroupPatternBindings(value); - } - - } - - @Override - public boolean readElement(IConfigurationElement element) { - if (element.getName().equals(GROUP_ELEMENT)) { - readGroup(element); - return true; - } else if (element.getName().equals(FUNCTION_GROUP_PATTERN_BINDING_ELMT)) { - readPatternBinding(element); - return true; - } - return false; - } - - /** - * @param element - */ - private void readPatternBinding(IConfigurationElement element) { - String groupID = element.getAttribute(GROUP_ID_ATTR); - String pattern = element.getAttribute(PATTERN_ATTR); - if (!isNullOrEmpty(groupID) && !isNullOrEmpty(pattern)) { - Pattern aPattern = Pattern.compile(pattern); - FunctionGroupPatternBinding binding = new FunctionGroupPatternBinding(groupID, aPattern); - addPatternBinding(groupID, binding); - } - - } - - /** - * @param binding - */ - private void addPatternBinding(String groupID, FunctionGroupPatternBinding binding) { - Set bindings = (Set) patternBindingsByGroupId.get(groupID); - if (bindings == null) { - bindings = new HashSet(); - patternBindingsByGroupId.put(groupID, bindings); - } - bindings.add(binding); - } - - private boolean isNullOrEmpty(String aString) { - return aString == null || aString.length() == 0; - } - - private void readGroup(IConfigurationElement element) { - String groupID = element.getAttribute(GROUP_ID_ATTR); - if (!isNullOrEmpty(groupID)) { - FunctionGroup group = new FunctionGroup(groupID, element); - getGroupMapById().put(groupID, group); - getKnownGroups().add(group); - } - } - - private List getAscendingSortedGroups(IProject project) { - Comparator ascendingGrpComparator = AscendingGroupComparator.singleton(); - List groupList = getKnownGroups(project); - Collections.sort(groupList, ascendingGrpComparator); - return groupList; - } - - private List getDescendingSortedGroups(IProject project) { - Comparator descendingGrpComparator = DescendingGroupComparator.singleton(); - List groupList = getKnownGroups(project); - Collections.sort(groupList, descendingGrpComparator); - return groupList; - } - - public List getKnownGroups(IProject project) { - ArrayList groupByProjectList = new ArrayList(getKnownGroups().size()); - List groupList = getKnownGroups(); - for (int i = 0; i < groupList.size(); i++) { - FunctionGroup group = (FunctionGroup) groupList.get(i); - if (group.isEnabled(project)) - groupByProjectList.add(group); - } - return groupByProjectList; - } - - public List getAscendingPriorityGroupNames(IProject project) { - List sortedGroup = getAscendingSortedGroups(project); - return getGroupListNames(sortedGroup, new ArrayList(sortedGroup.size())); - - } - - public List getDescendingPriorityGroupNames(IProject project) { - List sortedGroup = getDescendingSortedGroups(project); - return getGroupListNames(sortedGroup, new ArrayList(sortedGroup.size())); - } - - private List getGroupListNames(List sortedGroup, List sortedGroupNames) { - for (int i = 0; i < sortedGroup.size(); i++) { - FunctionGroup grp = (FunctionGroup) sortedGroup.get(i); - sortedGroupNames.add(grp.getGroupID()); - } - return sortedGroupNames; - } - - public Iterator getGroupIDs() { - return getGroupMapById().keySet().iterator(); - } - - public FunctionGroup getGroupByID(String groupID) { - return (FunctionGroup) getGroupMapById().get(groupID); - } - - public boolean isGroupEnabled(IProject project, String groupID) { - FunctionGroup group = getGroupByID(groupID); - if (group != null) - return group.isEnabled(project); - return false; - } - - public List getKnownGroups() { - if (knownGroups == null) - knownGroups = new ArrayList(); - return knownGroups; - } - - /** - * @return Returns the groupMapById. - */ - protected Map getGroupMapById() { - if (groupMapById == null) - groupMapById = new HashMap(); - return groupMapById; - } - - /** - * Check the priority of the two groups referenced by - * - * @groupID1 and - * @groupID2 - * - * @param groupID1 - * @param groupID2 - * @return 0 if the two groups are equal, 1 if - * @groupID1 has a higher precedence, otherwise -1 - */ - public int compare(String groupID1, String groupID2) { - FunctionGroup group1 = getGroupByID(groupID1); - FunctionGroup group2 = getGroupByID(groupID2); - if (group1 == null) { - WTPCommonPlugin.logError(new IllegalArgumentException(WTPResourceHandler.getString("28", new Object[]{groupID1}))); //$NON-NLS-1$ - return -1; - } - if (group2 == null) { - WTPCommonPlugin.logError(new IllegalArgumentException(WTPResourceHandler.getString("28", new Object[]{groupID2}))); //$NON-NLS-1$ - return 1; - } - - return group1.compareTo(group2); - } - - public int getGroupPriority(String grpId) { - FunctionGroup group = getGroupByID(grpId); - return (group != null) ? group.getPriority() : -1; - } - - public int getFunctionPriority(String enablementID) { - int priority = Integer.MAX_VALUE; - Iterator iter = getKnownGroups().iterator(); - while (iter.hasNext()) { - FunctionGroup group = (FunctionGroup) iter.next(); - if (group.isMatch(enablementID)) - priority = Math.min(priority, group.getPriority()); - } - return priority; - - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementIdentifier.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementIdentifier.java deleted file mode 100644 index d73d81280..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementIdentifier.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 10, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.Set; - -/** - * @author schacher - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public interface IEnablementIdentifier { - - - /** - * Registers an instance of <code>IIdentifierListener</code> to listen for changes to - * properties of this instance. - * - * @param identifierListener - * the instance to register. Must not be <code>null</code>. If an attempt is made - * to register an instance which is already registered with this instance, no - * operation is performed. - */ - void addIdentifierListener(IEnablementIdentifierListener identifierListener); - - /** - * Returns the set of function group ids that this instance matches. - * <p> - * Notification is sent to all registered listeners if this property changes. - * </p> - * - * @return the set of activity ids that this instance matches. This set may be empty, but is - * guaranteed not to be <code>null</code>. If this set is not empty, it is guaranteed - * to only contain instances of <code>String</code>. - */ - Set getFunctionGroupIds(); - - /** - * Returns the identifier of this instance. - * - * @return the identifier of this instance. Guaranteed not to be <code>null</code>. - */ - String getId(); - - /** - * Returns whether or not this instance is enabled. - * <p> - * Notification is sent to all registered listeners if this property changes. - * </p> - * - * @return true, iff this instance is enabled. - */ - boolean isEnabled(); - - /** - * Unregisters an instance of <code>IEnablementIdentifierListener</code> listening for changes - * to properties of this instance. - * - * @param identifierListener - * the instance to unregister. Must not be <code>null</code>. If an attempt is - * made to unregister an instance which is not already registered with this instance, - * no operation is performed. - */ - void removeIdentifierListener(IEnablementIdentifierListener identifierListener); - - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementIdentifierListener.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementIdentifierListener.java deleted file mode 100644 index 90cf938e3..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementIdentifierListener.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 10, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -/** - * @author schacher - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public interface IEnablementIdentifierListener { - /** - * Notifies that one or more properties of an instance of <code>IIdentifier</code> have - * changed. Specific details are described in the <code>IdentifierEvent</code>. - * - * @param identifierEvent - * the identifier event. Guaranteed not to be <code>null</code>. - */ - void identifierChanged(EnablementIdentifierEvent identifierEvent); -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementManager.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementManager.java deleted file mode 100644 index ab6fcdcbc..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IEnablementManager.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.Collection; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.common.core.util.UIContextDetermination; - -public interface IEnablementManager { - String INTERNAL_ENABLEMENT_DETERMINATION_ID = "org.eclipse.wst.common.frameworks.internal.EnablementDetermination"; //$NON-NLS-1$ - - IEnablementManager INSTANCE = (IEnablementManager) UIContextDetermination.createInstance(INTERNAL_ENABLEMENT_DETERMINATION_ID); - - IEnablementIdentifier getIdentifier(String identifierId, IProject project); - - /** - * Notify all identifier listeners that the state of a project has changed that affects the - * enablement of a group for a project. This method is fail safe, in that if one listener throws - * an exception while being notified, it will not stop the notification of other listeners. - * - * @param evt - * @throws CoreException - * if exceptions were caught notifying any of the listeners. Check the status of the - * core exception for the nested exceptions. - */ - void notifyFunctionGroupChanged(String groupID, IProject project) throws CoreException; - - /** - * Utility method for clients to dispose of listeners - * - * @param enablementIdentifiers - * @param listener - */ - void removeEnablementIdentifierListener(Collection enablementIdentifiers, IEnablementIdentifierListener listener); - - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IGroupInitializer.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IGroupInitializer.java deleted file mode 100644 index c1cdc9c4b..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IGroupInitializer.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 2, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import org.eclipse.core.resources.IProject; - -/** - * @author blancett - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public interface IGroupInitializer { - - public boolean isGroupEnabled(IProject project); - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/Identifiable.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/Identifiable.java deleted file mode 100644 index bd364b984..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/Identifiable.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - - -/** - * @author mdelder - * - */ -public interface Identifiable { - - /** - * return id that uniquely identifies this instance of an extension point. It is up to each - * individual extension point provider to decide what that might be (e.g., "editorID", "pageID", - * etc. - */ - String getID(); - - /** - * - * @return the order the Identifiable element was loaded - */ - int getLoadOrder(); -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IdentifiableComparator.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IdentifiableComparator.java deleted file mode 100644 index b6d9a6130..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/IdentifiableComparator.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - - -/** - * @author mdelder - * - */ -public class IdentifiableComparator implements java.util.Comparator { - - protected static final int GREATER_THAN = 1; - - protected static final int LESS_THAN = -1; - - protected static final int EQUAL = 0; - - protected static final IdentifiableComparator instance = new IdentifiableComparator(); - - private static final int DEFAULT_PRIORITY = Integer.MAX_VALUE; - - public static IdentifiableComparator getInstance() { - return instance; - } - - /* - * (non-Javadoc) - * - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - public int compare(Object o1, Object o2) { - Identifiable lvalue = null; - Identifiable rvalue = null; - if (o1 instanceof Identifiable) - lvalue = (Identifiable) o1; - if (o2 instanceof Identifiable) - rvalue = (Identifiable) o2; - - if (rvalue == null) - return GREATER_THAN; - if (lvalue == null) - return LESS_THAN; - - if ((lvalue.getID() == null && rvalue.getID() == null) || (getPriority(lvalue) == getPriority(rvalue))) - return compareLoadOrder(lvalue, rvalue); - /* R - L implies 0 is the highest priority */ - return getPriority(lvalue) - getPriority(rvalue); - } - - /* - * (non-Javadoc) - * - * @see java.util.Comparator#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return obj instanceof IdentifiableComparator; - } - @Override - public int hashCode() { - return super.hashCode(); - } - - private int compareLoadOrder(Identifiable lvalue, Identifiable rvalue) { - /* R - L implies 0 is the highest priority */ - return lvalue.getLoadOrder() - rvalue.getLoadOrder(); - } - - public int getPriority(Identifiable identifiable) { - if (identifiable.getID() != null && identifiable.getID().length() > 0) - return FunctionGroupRegistry.getInstance().getFunctionPriority(identifiable.getID()); - return DEFAULT_PRIORITY; - } - - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/Util.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/Util.java deleted file mode 100644 index 2c49776d2..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement/Util.java +++ /dev/null @@ -1,354 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.enablement; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Set; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; - -/* - * Rename this class to EnablementsUtil - */ - -public final class Util { - public final static SortedMap EMPTY_SORTED_MAP = Collections.unmodifiableSortedMap(new TreeMap()); - public final static SortedSet EMPTY_SORTED_SET = Collections.unmodifiableSortedSet(new TreeSet()); - public final static String ZERO_LENGTH_STRING = ""; //$NON-NLS-1$ - - public static void assertInstance(Object object, Class c) { - assertInstance(object, c, false); - } - - public static void assertInstance(Object object, Class c, boolean allowNull) { - if (object == null && allowNull) - return; - - if (object == null || c == null) - throw new NullPointerException(); - else if (!c.isInstance(object)) - throw new IllegalArgumentException(); - } - - public static int compare(boolean left, boolean right) { - return left == false ? (right == true ? -1 : 0) : 1; - } - - public static int compare(Comparable left, Comparable right) { - if (left == null && right == null) - return 0; - else if (left == null) - return -1; - else if (right == null) - return 1; - else - return left.compareTo(right); - } - - public static int compare(Comparable[] left, Comparable[] right) { - if (left == null && right == null) - return 0; - else if (left == null) - return -1; - else if (right == null) - return 1; - else { - int l = left.length; - int r = right.length; - - if (l != r) - return l - r; - for (int i = 0; i < l; i++) { - int compareTo = compare(left[i], right[i]); - - if (compareTo != 0) - return compareTo; - } - return 0; - } - } - - public static int compare(int left, int right) { - return left - right; - } - - public static int compare(List left, List right) { - if (left == null && right == null) - return 0; - else if (left == null) - return -1; - else if (right == null) - return 1; - else { - int l = left.size(); - int r = right.size(); - - if (l != r) - return l - r; - for (int i = 0; i < l; i++) { - int compareTo = compare((Comparable) left.get(i), (Comparable) right.get(i)); - - if (compareTo != 0) - return compareTo; - } - return 0; - } - } - - public static void diff(Map left, Map right, Set leftOnly, Set different, Set rightOnly) { - if (left == null || right == null || leftOnly == null || different == null || rightOnly == null) - throw new NullPointerException(); - - Iterator iterator = left.keySet().iterator(); - - while (iterator.hasNext()) { - Object key = iterator.next(); - - if (!right.containsKey(key)) - leftOnly.add(key); - else if (!Util.equals(left.get(key), right.get(key))) - different.add(key); - } - - iterator = right.keySet().iterator(); - - while (iterator.hasNext()) { - Object key = iterator.next(); - - if (!left.containsKey(key)) - rightOnly.add(key); - } - } - - public static void diff(Set left, Set right, Set leftOnly, Set rightOnly) { - if (left == null || right == null || leftOnly == null || rightOnly == null) - throw new NullPointerException(); - - Iterator iterator = left.iterator(); - - while (iterator.hasNext()) { - Object object = iterator.next(); - - if (!right.contains(object)) - leftOnly.add(object); - } - - iterator = right.iterator(); - - while (iterator.hasNext()) { - Object object = iterator.next(); - - if (!left.contains(object)) - rightOnly.add(object); - } - } - - public static boolean endsWith(List left, List right, boolean equals) { - if (left == null || right == null) - return false; - int l = left.size(); - int r = right.size(); - if (r > l || !equals && r == l) - return false; - - for (int i = 0; i < r; i++) - if (!equals(left.get(l - i - 1), right.get(r - i - 1))) - return false; - return true; - } - - public static boolean endsWith(Object[] left, Object[] right, boolean equals) { - if (left == null || right == null) - return false; - int l = left.length; - int r = right.length; - if (r > l || !equals && r == l) - return false; - for (int i = 0; i < r; i++) - if (!equals(left[l - i - 1], right[r - i - 1])) - return false; - return true; - } - - public static boolean equals(boolean left, boolean right) { - return left == right; - } - - public static boolean equals(int left, int right) { - return left == right; - } - - public static boolean equals(Object left, Object right) { - return left == null ? right == null : left.equals(right); - } - - public static int hashCode(boolean b) { - return b ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode(); - } - - public static int hashCode(int i) { - return i; - } - - public static int hashCode(Object object) { - return object != null ? object.hashCode() : 0; - } - - public static List safeCopy(List list, Class c) { - return safeCopy(list, c, false); - } - - public static List safeCopy(List list, Class c, boolean allowNullElements) { - if (list == null || c == null) - throw new NullPointerException(); - - List safeList = Collections.unmodifiableList(new ArrayList(list)); - Iterator iterator = safeList.iterator(); - - while (iterator.hasNext()) - assertInstance(iterator.next(), c, allowNullElements); - - return safeList; - } - - public static Map safeCopy(Map map, Class keyClass, Class valueClass) { - return safeCopy(map, keyClass, valueClass, false, false); - } - - public static Map safeCopy(Map map, Class keyClass, Class valueClass, boolean allowNullKeys, boolean allowNullValues) { - if (map == null || keyClass == null || valueClass == null) - throw new NullPointerException(); - - Map safeMap = Collections.unmodifiableMap(new HashMap(map)); - Iterator iterator = safeMap.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - assertInstance(entry.getKey(), keyClass, allowNullKeys); - assertInstance(entry.getValue(), valueClass, allowNullValues); - } - - return safeMap; - } - - public static Set safeCopy(Set set, Class c) { - return safeCopy(set, c, false); - } - - public static Set safeCopy(Set set, Class c, boolean allowNullElements) { - if (set == null || c == null) - throw new NullPointerException(); - - Set safeSet = Collections.unmodifiableSet(new HashSet(set)); - Iterator iterator = safeSet.iterator(); - - while (iterator.hasNext()) - assertInstance(iterator.next(), c, allowNullElements); - - return safeSet; - } - - public static SortedMap safeCopy(SortedMap sortedMap, Class keyClass, Class valueClass) { - return safeCopy(sortedMap, keyClass, valueClass, false, false); - } - - public static SortedMap safeCopy(SortedMap sortedMap, Class keyClass, Class valueClass, boolean allowNullKeys, boolean allowNullValues) { - if (sortedMap == null || keyClass == null || valueClass == null) - throw new NullPointerException(); - - SortedMap safeSortedMap = Collections.unmodifiableSortedMap(new TreeMap(sortedMap)); - Iterator iterator = safeSortedMap.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - assertInstance(entry.getKey(), keyClass, allowNullKeys); - assertInstance(entry.getValue(), valueClass, allowNullValues); - } - - return safeSortedMap; - } - - public static SortedSet safeCopy(SortedSet sortedSet, Class c) { - return safeCopy(sortedSet, c, false); - } - - public static SortedSet safeCopy(SortedSet sortedSet, Class c, boolean allowNullElements) { - if (sortedSet == null || c == null) - throw new NullPointerException(); - - SortedSet safeSortedSet = Collections.unmodifiableSortedSet(new TreeSet(sortedSet)); - Iterator iterator = safeSortedSet.iterator(); - - while (iterator.hasNext()) - assertInstance(iterator.next(), c, allowNullElements); - - return safeSortedSet; - } - - public static boolean startsWith(List left, List right, boolean equals) { - if (left == null || right == null) - return false; - int l = left.size(); - int r = right.size(); - if (r > l || !equals && r == l) - return false; - for (int i = 0; i < r; i++) - if (!equals(left.get(i), right.get(i))) - return false; - return true; - } - - public static boolean startsWith(Object[] left, Object[] right, boolean equals) { - if (left == null || right == null) - return false; - int l = left.length; - int r = right.length; - if (r > l || !equals && r == l) - return false; - - for (int i = 0; i < r; i++) - if (!equals(left[i], right[i])) - return false; - return true; - } - - public static String translateString(ResourceBundle resourceBundle, String key) { - return Util.translateString(resourceBundle, key, key, true, true); - } - - public static String translateString(ResourceBundle resourceBundle, String key, String string, boolean signal, boolean trim) { - if (resourceBundle != null && key != null) - try { - final String translatedString = resourceBundle.getString(key); - - if (translatedString != null) - return trim ? translatedString.trim() : translatedString; - } catch (MissingResourceException eMissingResource) { - if (signal) - System.err.println(eMissingResource); - } - - return trim ? string.trim() : string; - } - - private Util() { - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ComposedExtendedOperationHolder.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ComposedExtendedOperationHolder.java deleted file mode 100644 index b1676d231..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ComposedExtendedOperationHolder.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.operations; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.common.frameworks.internal.enablement.EnablementManager; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class ComposedExtendedOperationHolder { - - private ArrayList preOps = null; - private ArrayList postOps = null; - - protected ComposedExtendedOperationHolder() { - super(); - } - - public static ComposedExtendedOperationHolder createExtendedOperationHolder(String operationID) { - Collection extensions = (Collection) OperationExtensionReader.getExtensionPoints().get(operationID); - if (extensions == null) { - return null; - } - - ComposedExtendedOperationHolder extOperationHolder = new ComposedExtendedOperationHolder(); - Object preOp = null; - Object postOp = null; - OperationExtension currentExt = null; - for (Iterator iterator = extensions.iterator(); iterator.hasNext();) { - currentExt = (OperationExtension) iterator.next(); - if (EnablementManager.INSTANCE.getIdentifier(currentExt.getExtensionId(), null).isEnabled()) { - try { - preOp = currentExt.getPreOperation(); - if (preOp != null) { - extOperationHolder.addPreOperation(preOp); - } - } catch (CoreException e) { - WTPCommonPlugin.logError(e); - } - try { - postOp = currentExt.getPostOperation(); - if (postOp != null) { - extOperationHolder.addPostOperation(postOp); - } - } catch (CoreException e) { - WTPCommonPlugin.logError(e); - } - } - } - return extOperationHolder; - } - - protected void addPreOperation(Object preOperation) { - if (preOps == null) { - preOps = new ArrayList(); - } - preOps.add(preOperation); - } - - protected void addPostOperation(Object postOperation) { - if (postOps == null) { - postOps = new ArrayList(); - } - postOps.add(postOperation); - } - - public boolean hasPreOps() { - return preOps != null; - } - - public boolean hasPostOps() { - return postOps != null; - } - - public ArrayList getPostOps() { - return postOps; - } - - public ArrayList getPreOps() { - return preOps; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IHeadlessRunnableWithProgress.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IHeadlessRunnableWithProgress.java deleted file mode 100644 index 35db85cd8..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IHeadlessRunnableWithProgress.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * Simialar to org.eclipse.jface.operation.IRunnableWithProgress, however without UI dependencies. - * - * This class is EXPERIMENTAL and is subject to substantial changes. - */ -public interface IHeadlessRunnableWithProgress { - /** - * Runs this operation without forcing a UI dependency. - * - * @param monitor - * the progress monitor to use to display progress and receive requests for - * cancelation - * @exception InvocationTargetException - * if the run method must propagate a checked exception, it should wrap it inside - * an <code>InvocationTargetException</code>; runtime exceptions are - * automatically wrapped in an <code>InvocationTargetException</code> by the - * calling context - * @exception InterruptedException - * if the operation detects a request to cancel, using - * <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing - * <code>InterruptedException</code> - * - * @see IRunnableWithProgress - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException; -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IOperationHandler.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IOperationHandler.java deleted file mode 100644 index 633e4c10c..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IOperationHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.frameworks.internal.operations; - -/** - * Passed to complex methods that may require reporting of messages, or interactions from the user; - * Defined as an interface because the actions may run in headless environments - */ -public interface IOperationHandler { - int YES = 0; - int YES_TO_ALL = 1; - int NO = 2; - int CANCEL = 3; - - /** - * A decision needs to made as to whether an action/operation can continue - */ - public boolean canContinue(String message); - - /** - * A decision needs to made as to whether an action/operation can continue. <code>items</code> - * is an array of details that accompany the <code>message</code>. - */ - public boolean canContinue(String message, String[] items); - - /** - * A decision needs to made as to whether an action/operation can continue. The boolean array - * will return two booleans. The first indicates their response to the original question and the - * second indicates if they selected the apply to all check box. - * - * Return the return code for the dialog. 0 = Yes, 1 = Yes to all, 2 = No - */ - int canContinueWithAllCheck(String message); - - int canContinueWithAllCheckAllowCancel(String message); - - /** - * An error has occurred - */ - public void error(String message); - - /** - * An informational message needs to be presented - */ - public void inform(String message); - - public Object getContext(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IProjectCreationPropertiesNew.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IProjectCreationPropertiesNew.java deleted file mode 100644 index 8b36cd7f6..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/IProjectCreationPropertiesNew.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.operations; - -public interface IProjectCreationPropertiesNew { - - /** - * A required dataModel propertyName for a <code>java.lang.String</code> type. This is used to - * specify the project name. - */ - public static final String PROJECT_NAME = "IProjectCreationPropertiesNew.PROJECT_NAME"; //$NON-NLS-1$ - - /** - * A Boolean property used for determining how the PROJECT_LOCATION is computed. If this - * property is true then the PROJECT_LOCATION is null. Otherwise the PROJECT_LOCATION is the - * value of USER_DEFINED_LOCATION. - */ - public static final String USE_DEFAULT_LOCATION = "IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION"; //$NON-NLS-1$ - - /** - * A String property used in conjuction with USE_DEFAULT_LOCATION to override the - * DEFAULT_LOCATION. - */ - public static final String USER_DEFINED_LOCATION = "IProjectCreationPropertiesNew.USER_DEFINED_LOCATION"; //$NON-NLS-1$ - - /** - * A String property used in conjunction with {@link #USE_DEFAULT_LOCATION} and - * {@link #PROJECT_NAME} to overrid the {@link #PROJECT_LOCATION}. - * - * If {@link #USE_DEFAULT_LOCATION} is <code>false</code> and this property is set, then the - * {@link #PROJECT_LOCATION} is defined by {@link #USER_DEFINED_BASE_LOCATION}/{@link #PROJECT_NAME}. - */ - public static final String USER_DEFINED_BASE_LOCATION = "IProjectCreationPropertiesNew.USER_DEFINED_BASE_LOCATION"; //$NON-NLS-1$ - - /** - * An unsettable property which specified the default location for a newly created project. The - * value is computed by appending the project name to the workspace location. - */ - public static final String DEFAULT_LOCATION = "IProjectCreationPropertiesNew.DEFAULT_LOCATION"; //$NON-NLS-1$ - - /** - * An unsettable property used to specify the project location. If USE_DEFAULT_LOCATION this - * property evaluates to USER_DEFINED_LOCATION; otherwise it i <code>null</code>. - */ - public static final String PROJECT_LOCATION = "IProjectCreationPropertiesNew.PROJECT_LOCATION"; //$NON-NLS-1$ - - /** - * An optional dataModel propertyName for a <code>java.lang.String[]</code> type. This is a - * list of all natures to add to the project. There is no default value. - */ - public static final String PROJECT_NATURES = "IProjectCreationPropertiesNew.PROJECT_NATURES"; //$NON-NLS-1$ - - /** - * IProject. An non settable property. This is a conveniece for constructiong getting the - * IProject - */ - public static final String PROJECT = "IProjectCreationPropertiesNew.PROJECT"; //$NON-NLS-1$ - - /** - * IProjectDescription. An non settable property. This is a conveniece for constructiong a - * project description. - */ - public static final String PROJECT_DESCRIPTION = "IProjectCreationPropertiesNew.PROJECT_DESCRIPTION"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationExtension.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationExtension.java deleted file mode 100644 index 2fcd16eec..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationExtension.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.operations; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; - -public class OperationExtension { - - protected String opID = null; - - protected IConfigurationElement baseElement = null; - - protected String preOperationClass = null; - - protected String postOperationClass = null; - - protected String extensionId; - - public OperationExtension(IConfigurationElement element, String id, String preOp, String postOp) { - super(); - baseElement = element; - setUpExtension(id, preOp, postOp); - } - - private void setUpExtension(String id, String preOp, String postOp) { - opID = id; - preOperationClass = preOp; - postOperationClass = postOp; - this.extensionId = baseElement.getDeclaringExtension().getUniqueIdentifier(); - if (this.extensionId == null) - this.extensionId = baseElement.getDeclaringExtension().getNamespace(); - } - - public String getOpID() { - return opID; - } - - public String getPostOperationClass() { - return postOperationClass; - } - - public String getPreOperationClass() { - return preOperationClass; - } - - public Object getPostOperation() throws CoreException { - if (postOperationClass == null) - return null; - return baseElement.createExecutableExtension(OperationExtensionReader.ATT_POST_OP); - } - - public Object getPreOperation() throws CoreException { - if (preOperationClass == null) - return null; - return baseElement.createExecutableExtension(OperationExtensionReader.ATT_PRE_OP); - } - - /** - * @return Returns the extensionId. - */ - public String getExtensionId() { - return extensionId; - } - - public IConfigurationElement getBaseElement() { - return baseElement; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationExtensionReader.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationExtensionReader.java deleted file mode 100644 index 32280376a..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationExtensionReader.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.operations; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.common.core.util.RegistryReader; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class OperationExtensionReader extends RegistryReader { - protected static HashMap opExtensions = null; - - public static final String ELEMENT_J2EEOPEXT = "operationExtension"; //$NON-NLS-1$ - public static final String ATT_ID = "id"; //$NON-NLS-1$ - public static final String ATT_PRE_OP = "preOperationClass"; //$NON-NLS-1$ - public static final String ATT_POST_OP = "postOperationClass"; //$NON-NLS-1$ - - public OperationExtensionReader() { - super(WTPCommonPlugin.PLUGIN_ID, "OperationExtension"); //$NON-NLS-1$ - } - - /** - * readElement() - parse and deal with an extension like: <operationExtension - * preOperationClass="com.ibm.etools....PreDeleteOperation" - * postOperationClass="com.ibm.etools....PostDeleteOperation"> </operationExtension> - */ - - @Override - public boolean readElement(IConfigurationElement element) { - if (!element.getName().equals(ELEMENT_J2EEOPEXT)) - return false; - String id = element.getAttribute(ATT_ID); - String preOp = element.getAttribute(ATT_PRE_OP); - String postOp = element.getAttribute(ATT_POST_OP); - OperationExtension extension = new OperationExtension(element, id, preOp, postOp); - addExtensionPoint(extension); - return true; - } - - /** - * Sets the extension point. - * - * @param extensions - * The extensions to set - */ - private static void addExtensionPoint(OperationExtension newExtension) { - Collection temp = null; - Object holder = opExtensions.get(newExtension.getOpID()); - if (holder == null) { - temp = new ArrayList(); - temp.add(newExtension); - opExtensions.put(newExtension.getOpID(), temp); - } else { - temp = (Collection) holder; - temp.add(newExtension); - } - } - - public static HashMap getExtensionPoints() { - if(opExtensions == null){ - opExtensions = new HashMap(); - OperationExtensionReader opExtensionReader = new OperationExtensionReader(); - opExtensionReader.readRegistry(); - } - return opExtensions; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationStatus.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationStatus.java deleted file mode 100644 index 22bf0f316..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/OperationStatus.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.operations; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class OperationStatus extends MultiStatus { - - public OperationStatus(String message, Throwable e) { - super(WTPCommonPlugin.PLUGIN_ID, 0, new IStatus[]{}, message, e); - } - - public OperationStatus(IStatus[] children) { - this(WTPCommonPlugin.PLUGIN_ID, 0, children, "", null); //$NON-NLS-1$ - } - - public OperationStatus(String pluginId, int code, IStatus[] children, String message, Throwable exception) { - super(pluginId, code, children, message, exception); - } - - public void addExtendedStatus(IStatus status) { - int oldSeverity = getSeverity(); - super.add(status); - if (oldSeverity != IStatus.ERROR && getSeverity() == IStatus.ERROR) { - setSeverity(IStatus.WARNING); - } - } - - /** - * Overridden to expose as public instead of protected - */ - @Override - public void setCode(int code) { - super.setCode(code); - } - - /** - * Overridden to expose as public instead of protected - */ - @Override - public void setException(Throwable exception) { - super.setException(exception); - } - - /** - * Overridden to expose as public instead of protected - */ - @Override - public void setMessage(String message) { - super.setMessage(message); - } - - /** - * Overridden to expose as public instead of protected - */ - @Override - public void setSeverity(int severity) { - super.setSeverity(severity); - } - - @Override - public void add(IStatus status) { - int newSev = status.getSeverity(); - if (newSev > getSeverity()) { - setMessage(status.getMessage()); - setException(status.getException()); - } - super.add(status); - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationDataModelProviderNew.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationDataModelProviderNew.java deleted file mode 100644 index 8796f6830..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationDataModelProviderNew.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.operations; - -import java.io.File; -import java.util.Set; - -import org.eclipse.core.internal.resources.Resource; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -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.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class ProjectCreationDataModelProviderNew extends AbstractDataModelProvider implements IProjectCreationPropertiesNew { - - @Override - public IDataModelOperation getDefaultOperation() { - return new ProjectCreationOperationNew(model); - } - - @Override - public void init() { - super.init(); - } - - @Override - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(PROJECT); - propertyNames.add(PROJECT_NAME); - propertyNames.add(PROJECT_LOCATION); - propertyNames.add(USE_DEFAULT_LOCATION); - propertyNames.add(DEFAULT_LOCATION); - propertyNames.add(USER_DEFINED_LOCATION); - propertyNames.add(USER_DEFINED_BASE_LOCATION); - propertyNames.add(PROJECT_NATURES); - propertyNames.add(PROJECT_DESCRIPTION); - return propertyNames; - } - - @Override - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(PROJECT_LOCATION)) { - if (getBooleanProperty(USE_DEFAULT_LOCATION)) { - return null; - } else if (isPropertySet(USER_DEFINED_BASE_LOCATION)) { - return getStringProperty(USER_DEFINED_BASE_LOCATION) + File.separator + getStringProperty(PROJECT_NAME); - } - return getProperty(USER_DEFINED_LOCATION); - } else if (DEFAULT_LOCATION.equals(propertyName)) { - return getDefaultLocation(); - } else if (USE_DEFAULT_LOCATION.equals(propertyName)) { - return Boolean.TRUE; - } else if (USER_DEFINED_LOCATION.equals(propertyName) || USER_DEFINED_BASE_LOCATION.equals(propertyName)) { - return ""; //$NON-NLS-1$ - } else if (propertyName.equals(PROJECT_DESCRIPTION)) - return getProjectDescription(); - return super.getDefaultProperty(propertyName); - } - - private String getDefaultLocation() { - IPath path = ResourcesPlugin.getWorkspace().getRoot().getLocation(); - String projectName = (String) getProperty(PROJECT_NAME); - if (projectName != null) - path = path.append(projectName); - return path.toOSString(); - } - - @Override - public boolean propertySet(String propertyName, Object propertyValue) { - if (propertyName.equals(PROJECT_LOCATION) || propertyName.equals(DEFAULT_LOCATION) || propertyName.equals(PROJECT_DESCRIPTION)) { - throw new RuntimeException(); - } else if (propertyName.equals(PROJECT_NAME)) { - IStatus stat = model.validateProperty(PROJECT_NAME); - if (stat != OK_STATUS) - return true; - model.setProperty(PROJECT, getProject()); - model.notifyPropertyChange(DEFAULT_LOCATION, IDataModel.VALUE_CHG); - if (getBooleanProperty(USE_DEFAULT_LOCATION) || isPropertySet(USER_DEFINED_BASE_LOCATION)) { - model.notifyPropertyChange(PROJECT_LOCATION, IDataModel.VALUE_CHG); - } - } else if (propertyName.equals(USE_DEFAULT_LOCATION)) { - model.notifyPropertyChange(PROJECT_LOCATION, IDataModel.VALUE_CHG); - } else if ((propertyName.equals(USER_DEFINED_LOCATION) || propertyName.equals(USER_DEFINED_BASE_LOCATION)) && !getBooleanProperty(USE_DEFAULT_LOCATION)) { - model.notifyPropertyChange(PROJECT_LOCATION, IDataModel.VALUE_CHG); - } - return true; - } - - private IProjectDescription getProjectDescription() { - String projectName = (String) getProperty(PROJECT_NAME); - IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName); - String projectLocation = (String) getProperty(PROJECT_LOCATION); - if (projectLocation != null) - desc.setLocation(new Path(projectLocation)); - else - desc.setLocation(null); - return desc; - } - - protected IProject getProject() { - String projectName = (String) getProperty(PROJECT_NAME); - return (null != projectName && projectName.length() > 0) ? ResourcesPlugin.getWorkspace().getRoot().getProject(projectName) : null; - } - - @Override - public IStatus validate(String propertyName) { - if (propertyName.equals(PROJECT_NAME)) { - String name = model.getStringProperty(PROJECT_NAME); - IStatus status = validateName(name); - if (!status.isOK()) - return status; - } - if (propertyName.equals(PROJECT_LOCATION)) { - IStatus status = validateLocation(); - if (!status.isOK()) - return status; - } - if (propertyName.equals(PROJECT_LOCATION) || propertyName.equals(PROJECT_NAME)) { - String projectName = getStringProperty(PROJECT_NAME); - - String projectLoc = ""; //$NON-NLS-1$ - if (getBooleanProperty(USE_DEFAULT_LOCATION)) { - projectLoc = getDefaultLocation(); - } else { - projectLoc = getStringProperty(PROJECT_LOCATION); - } - return validateExisting(projectName, projectLoc); - } - return OK_STATUS; - } - - /** - * @param projectName - * @param projectLoc - * @todo Generated comment - */ - public static IStatus validateExisting(String projectName, String projectLoc) { - if (projectName != null && !projectName.equals("")) {//$NON-NLS-1$ - File file = new File(projectLoc); - if (file.exists()) { - if (file.isDirectory()) { - File dotProject = new File(file, ".project");//$NON-NLS-1$ - if (dotProject.exists()) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_EXISTS_AT_LOCATION_ERROR, new Object[]{file.toString()})); - } - } - } - } - return OK_STATUS; - } - - public static IProject getProjectHandleFromProjectName(String projectName) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IStatus status = workspace.validateName(projectName, IResource.PROJECT); - return (null != projectName && projectName.length() > 0 && status.isOK()) ? ResourcesPlugin.getWorkspace().getRoot().getProject(projectName) : null; - } - - public static IStatus validateProjectName(String projectName) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IStatus status = workspace.validateName(projectName, IResource.PROJECT); - if (!status.isOK()) - return status; - if (projectName.endsWith(" ")) //$NON-NLS-1$ - return WTPCommonPlugin.createErrorStatus(WTPResourceHandler.getString("41")); //$NON-NLS-1$ - //special FRAGMENT_SEPARATOR char in org.eclipse.emf.common.util.URI - if (projectName.indexOf('#') != -1) - return WTPCommonPlugin.createErrorStatus(WTPResourceHandler.getString("8")); //$NON-NLS-1$ - return OK_STATUS; - } - - public static IStatus validateName(String name) { - IStatus status = validateProjectName(name); - if (!status.isOK()) - return status; - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); - if (project.exists()) { - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_EXISTS_SAMENAME_ERROR, new Object[]{name})); - } - if (!WTPPlugin.isPlatformCaseSensitive()) { - // now look for a matching case variant in the tree - IResource variant = ((Resource) project).findExistingResourceVariant(project.getFullPath()); - if (variant != null) { - return WTPCommonPlugin.createErrorStatus(WTPResourceHandler.getString("42")); //$NON-NLS-1$ - } - } - return OK_STATUS; - } - - - private IStatus validateLocation() { - String loc = (String) getProperty(PROJECT_LOCATION); - if (null != loc) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IPath path = new Path(loc); - return workspace.validateProjectLocation(getProject(), path); - } - return OK_STATUS; - } -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationOperationNew.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationOperationNew.java deleted file mode 100644 index a1ba7bb11..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/ProjectCreationOperationNew.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 27, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.operations; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class ProjectCreationOperationNew extends AbstractDataModelOperation implements IProjectCreationPropertiesNew { - - public ProjectCreationOperationNew(IDataModel dataModel) { - super(dataModel); - } - - @Override - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - IProgressMonitor subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN); - IProjectDescription desc = (IProjectDescription) model.getProperty(PROJECT_DESCRIPTION); - IProject project = (IProject) model.getProperty(PROJECT); - if (!project.exists()) { - project.create(desc, subMonitor); - } - if (monitor.isCanceled()) - throw new OperationCanceledException(); - subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN); - - project.open(subMonitor); - - String[] natureIds = (String[]) model.getProperty(PROJECT_NATURES); - if (null != natureIds) { - desc = project.getDescription(); - desc.setNatureIds(natureIds); - project.setDescription(desc, monitor); - } - } catch (CoreException e) { - WTPCommonPlugin.logError(e); - } finally { - monitor.done(); - } - if (monitor.isCanceled()) - throw new OperationCanceledException(); - return OK_STATUS; - } - - @Override - public boolean canUndo() { - return false; - } - - @Override - public boolean canRedo() { - return false; - } - -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/package.html b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/package.html deleted file mode 100644 index 65a58f55d..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/package.html +++ /dev/null @@ -1,33 +0,0 @@ -<html> -<head> -<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -<link rel="stylesheet" href="../../../../../..//apistyles.css" type="text/css"> -<title>wtp operation api overview</title> -</head> -<body> -<p>The WTP Operation API allows clients to do...everything!</p> -<table width="500"> -<tr> -<td> -<p>Under Construction.</p> -</td> -</tr> -</table> -<table cellpadding="10" cellspacing="10"> -<tr> -<td> -<p> -<img src="escape_out_to_source_folder level/overview/your_image.jpg"></p> -</td> -</tr> -<tr> -<td> -<p> -<i>Figure 1: Image description</i> -</p> -</td> -</tr> -</table> -</body> -</html> diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/package.xml b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/package.xml deleted file mode 100644 index 9d050d496..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/operations/package.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../../" /> - <title>wtp operation api overview</title> - </head> - - <body> - <abstract>The WTP Operation API allows clients to do...everything!</abstract> - - <!-- formatting handled by XSLT Transformation --> - <p>Under Construction.</p> - <img src="escape_out_to_source_folder level/overview/your_image.jpg" caption ="Image description" /> - </body> -</html> -
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java deleted file mode 100644 index 8fade808b..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Nov 5, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.common.frameworks.internal.plugin; - -/** - * @author DABERG - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class WTPCommonMessages { - public static final String PROJECT_EXISTS_ERROR = "1"; //$NON-NLS-1$ - public static final String PROJECT_NOT_EAR = "2"; //$NON-NLS-1$ - public static final String INCOMPATABLE_J2EE_VERSIONS = "3"; //$NON-NLS-1$ - public static final String SAME_MODULE_AND_EAR_NAME = "4"; //$NON-NLS-1$ - public static final String ARCHIVE_FILE_NAME_EMPTY_ERROR = "5"; //$NON-NLS-1$ - public static final String FILE_DOES_NOT_EXIST_ERROR = "6"; //$NON-NLS-1$ - public static final String INTERNAL_ERROR = "7"; //$NON-NLS-1$ - public static final String PROJECT_NAME_INVALID = "8"; //$NON-NLS-1$ - public static final String DESTINATION_ARCHIVE_SHOULD_END_WITH = "9"; //$NON-NLS-1$ - public static final String DESTINATION_INVALID = "10"; //$NON-NLS-1$ - public static final String IS_READ_ONLY = "11"; //$NON-NLS-1$ - public static final String RESOURCE_EXISTS_ERROR = "12"; //$NON-NLS-1$ - public static final String PROJECT_NOT_EXISTS_ERROR = "13"; //$NON-NLS-1$ - public static final String SPEC_LEVEL_NOT_FOUND = "14"; //$NON-NLS-1$ - public static final String PROJECT_NAME_EMPTY = "15"; //$NON-NLS-1$ - public static final String PROJECT_ClOSED = "31"; //$NON-NLS-1$ - public static final String PROJECT_EXISTS_AT_LOCATION_ERROR = "32"; //$NON-NLS-1$ - public static final String ERR_EMPTY_MODULE_NAME = "34"; //$NON-NLS-1$ - public static final String ERR_INVALID_CHARS = "35"; //$NON-NLS-1$ - public static final String DUPLICATE_COMPONENT_NAME="36";//$NON-NLS-1$ - public static final String MODULE_NOT_SUPPORTED="37";//$NON-NLS-1$ - - public static final String MODULE_EXISTS_ERROR = "38"; //$NON-NLS-1$ - public static final String SOURCEFOLDER_EMPTY = "39"; //$NON-NLS-1$ - public static final String WEBCONTENTFOLDER_EMPTY = "40"; //$NON-NLS-1$ - public static final String PROJECT_EXISTS_SAMENAME_ERROR = "43"; //$NON-NLS-1$ - public static final String RUNTIME_NONE = "44"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonPlugin.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonPlugin.java deleted file mode 100644 index e3fc87dfa..000000000 --- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonPlugin.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.frameworks.internal.plugin; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; -import org.eclipse.core.runtime.Platform; -import java.lang.Throwable; -import org.eclipse.core.runtime.CoreException; - -public class WTPCommonPlugin extends WTPPlugin { - - public static final String PLUGIN_ID = "org.eclipse.wst.common.frameworks"; //$NON-NLS-1$ - public static final String GROUP_REGISTRY_EXTENSION_POINT = "functionGroup"; //$NON-NLS-1$ - public static final IStatus OK_STATUS = new Status(IStatus.OK, PLUGIN_ID, 0, "OK", null); //$NON-NLS-1$ - - // The shared instance. - private static WTPCommonPlugin plugin; - - public WTPCommonPlugin() { - super(); - plugin = this; - try { - resourceBundle = ResourceBundle.getBundle("wtp_common"); //$NON-NLS-1$ - } catch (MissingResourceException x) { - resourceBundle = null; - } - } - - public static WTPCommonPlugin getDefault() { - return plugin; - } - - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - /** - * @param string - * @return - */ - public static IStatus createErrorStatus(String message) { - return createErrorStatus(message, null); - } - - /** - * @param string - * @return - */ - public static IStatus createWarningStatus(String message) { - return createWarningStatus(message, null); - } - - /** - * @param string - * @return - */ - public static IStatus createCancelStatus(String message) { - return createCancelStatus(message, null); - } - - /** - * @param string - * @return - */ - public static IStatus createWarningStatus(String message, Throwable exception) { - return new Status(IStatus.WARNING, PLUGIN_ID, -1, message, exception); - } - - /** - * @param string - * @return - */ - public static IStatus createErrorStatus(String message, Throwable exception) { - return new Status(IStatus.ERROR, PLUGIN_ID, -1, message, exception); - } - - /** - * @param string - * @return - */ - public static IStatus createCancelStatus(String message, Throwable exception) { - return new Status(IStatus.CANCEL, PLUGIN_ID, -1, message, exception); - } - - /** - * Returns the string from the plugin's resource bundle, or 'key' if not found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = WTPCommonPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null ? bundle.getString(key) : key); - } catch (MissingResourceException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - public static String getResourceString(String key, Object[] args) { - String pattern = getResourceString(key); - if (pattern != null) - return MessageFormat.format(pattern, args); - return null; - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.WTPPlugin#getPluginID() - */ - @Override - public String getPluginID() { - return PLUGIN_ID; - } - - public static IStatus createStatus(int severity, String message, Throwable exception) { - return new Status(severity, PLUGIN_ID, message, exception); - } - - public static IStatus createStatus(int severity, String message) { - return createStatus(severity, message, null); - } - - public static void logError(Throwable exception) { - Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception)); - } - - public static void logError(CoreException exception) { - Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() ); - } - - public static void logError(String message) { - Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, message)); - } -} |